using System.Windows.Controls;
using System.Windows.Input;
using NexusShell.Models;
using NexusShell.ViewModels;

namespace NexusShell.Views;

public partial class NexusFilesView
{
    public NexusFilesView()
    {
        InitializeComponent();
    }

    private void FileList_OnMouseDoubleClick(object sender, MouseButtonEventArgs e)
    {
        if (sender is not ListBox listBox)
        {
            return;
        }

        if (listBox.SelectedItem is FileSystemItem item &&
            DataContext is NexusFilesViewModel viewModel &&
            viewModel.OpenItemCommand.CanExecute(item))
        {
            viewModel.OpenItemCommand.Execute(item);
        }
    }
}
