Ejemplo n.º 1
0
        public FileBrowserViewModel()
        {
            var Model = new FileBrowserManagers();

            ComboBoxItems = Model.GetComboBoxItems;
            SelectedDrive = comboBoxItems.First();
            Linq          = Model.GetLinq;
            ListItems     = Model.GetListItems;

            this.Selected = (sender, e) => {
                ListItems = Item.GetItems(new DirectoryInfo(((sender as ComboBox).SelectedItem as DriveInfo).Name));
                var drive = (sender as ComboBox).SelectedItem as DriveInfo;
                TextNearComboBox    = $"{AdapterNumber.ToAdaptNumber(drive.TotalFreeSpace / 1024 / 1024)}Mбайт из {AdapterNumber.ToAdaptNumber(drive.TotalSize / 1024 / 1024)}Mбайт";
                Linq                = drive.Name;
                GetCurrentDirectory = new Item(new DirectoryInfo(drive.Name));
            };
            this.DoubleClick = (sender, e) => {
                if ((sender as ListView).SelectedItem == null)
                {
                    return;
                }
                var selected = ((sender as ListView).SelectedItem as Item);
                try
                {
                    if (selected.info is DirectoryInfo)
                    {
                        GetCurrentDirectory = selected;
                        UpdateListsItems();
                    }
                    else
                    {
                        var a = new System.Diagnostics.Process();
                        a.StartInfo.FileName        = selected.info.FullName;
                        a.StartInfo.UseShellExecute = true;
                        a.Start();
                    }
                }
                catch (Exception ex)
                {
                    TotalCommander.ViewModel.MainWindowViewModel.Alert.Call(ex.Message, Colors.Red);
                }
            };

            AllFileBrowserViewModel.Add(this);

            GetSelectionItems = new List <Item>();
        }
Ejemplo n.º 2
0
 public void Dispose()
 {
     AllFileBrowserViewModel.Remove(this);
 }