コード例 #1
0
        public DirectoryNodeViewModel(IEventAggregator events, IDirectoryTreeViewModel rootModel, IEntryModel curDirModel,
                                      IDirectoryNodeViewModel parentModel)
            : base(curDirModel)
        {
            _events    = events;
            _rootModel = rootModel;

            Entries = new EntriesHelper <IDirectoryNodeViewModel>(loadEntriesTask)
            {
                ClearBeforeLoad = true
            };
            Selection = new TreeSelector <IDirectoryNodeViewModel, IEntryModel>(curDirModel, this,
                                                                                parentModel == null ? rootModel.Selection : parentModel.Selection, Entries);
            Selection.PropertyChanged += (o, e) =>
            {
                if (e.PropertyName == "IsSelected")
                {
                    IsSelected = Selection.IsSelected;
                }
            };
            DropHelper = new DirectoryNodeDropHelper(curDirModel, Entries, Selection)
            {
                DisplayName = curDirModel.Label
            };
        }
コード例 #2
0
        public DirectoryTreeViewModel(IWindowManager windowManager, IEventAggregator events)
        {
            _events = events;

            if (events != null)
            {
                events.Subscribe(this);
            }

            Entries = new EntriesHelper <IDirectoryNodeViewModel>();
            var selection = new TreeRootSelector <IDirectoryNodeViewModel, IEntryModel>(Entries)
            {
                Comparers = new[] { PathComparer.LocalDefault }
            };

            selection.SelectionChanged += (o, e) =>
            {
                BroadcastDirectoryChanged(EntryViewModel.FromEntryModel(selection.SelectedValue));
            };
            Selection = selection;

            Commands = new DirectoryTreeCommandManager(this, windowManager, events);

            DragHelper = new DirectoryTreeDragHelper(Entries, Selection);
        }
コード例 #3
0
        public TreeNodeViewModel(string value, string header, TreeViewModel root, TreeNodeViewModel parentNode)
        {
            if (root == null || value == null)
            {
                throw new ArgumentException();
            }
            _path   = value;
            _root   = root;
            _parent = parentNode;
            _header = header;


            Entries = new EntriesHelper <TreeNodeViewModel>((ct) => Task.Run(() =>
            {
                return((IEnumerable <TreeNodeViewModel>) new List <TreeNodeViewModel>(
                           from i in Enumerable.Range(1, 9)
                           select new TreeNodeViewModel(
                               (Path + "\\Sub" + i.ToString()).TrimStart('\\'),
                               "Sub" + i.ToString(),
                               _root, this)
                           ));
            }));

            Selection = new TreeSelector <TreeNodeViewModel, string>(value, this,
                                                                     parentNode == null ? root.Selection : parentNode.Selection, Entries);
        }
コード例 #4
0
        public RegistryTreeViewModel(RegistryCommand registryCommand)
        {
            Entries   = new EntriesHelper <SubKeyNodeViewModel>();
            Selection = new TreeRootSelector <SubKeyNodeViewModel, AdvancedRegistrySubKey>(Entries)
            {
                Comparers = new[] { new RegistryPathComparer() }
            };

            var hiveEntries = new List <RegistryHive>
            {
                RegistryHive.ClassesRoot,
                RegistryHive.CurrentUser,
                RegistryHive.LocalMachine,
                RegistryHive.Users,
                RegistryHive.CurrentConfig
            };

            Entries.SetEntries(UpdateMode.Replace,
                               hiveEntries.ToDictionary(x => x, y => y.ToReadableString()).Select(
                                   x =>
                                   new SubKeyNodeViewModel(this,
                                                           new AdvancedRegistrySubKey
            {
                IsEmpty      = false,
                Name         = x.Value,
                Path         = x.Value,
                RegistryHive = x.Key,
                RelativePath = ""
            }, null, registryCommand)).ToArray());
        }
コード例 #5
0
 public DirectoryTreeViewModel(IFileSystem fileSystem, Func <IWindowService> getWindow)
 {
     _fileSystem = fileSystem;
     _getWindow  = getWindow;
     Entries     = new EntriesHelper <DirectoryNodeViewModel>();
     Selection   = new TreeRootSelector <DirectoryNodeViewModel, IFileExplorerEntry>(Entries)
     {
         Comparers = new[] { new FileExplorerPathComparer() }
     };
 }
コード例 #6
0
        public CommandViewModel(ICommandModel commandModel, IParameterDicConverter parameterDicConverter, ICommandViewModel parentCommandViewModel = null)
        {
            CommandModel            = commandModel;
            _parentCommandViewModel = parentCommandViewModel;
            _parameterDicConverter  = parameterDicConverter;

            if (CommandModel != null)
            {
                if (CommandModel is IRoutedCommandModel && (CommandModel as IRoutedCommandModel).RoutedCommand != null)
                {
                    CommandBinding = ScriptCommandBinding.ForRoutedUICommand((CommandModel as IRoutedCommandModel).RoutedCommand);
                }
                else
                {
                    CommandBinding = ScriptCommandBinding.FromScriptCommand(
                        ApplicationCommands.NotACommand, commandModel, cm => cm.Command,
                        parameterDicConverter, /*ParameterDicConverters.ConvertUIParameter, */ ScriptBindingScope.Local);
                }
            }

            CommandModel.PropertyChanged += (o, e) =>
            {
                switch (e.PropertyName)
                {
                case "IsChecked":
                case "Symbol":
                case "HeaderIconExtractor":
                    RefreshIcon();
                    break;

                case "SubCommands":
                    SubCommands.LoadAsync(UpdateMode.Replace, true);
                    RefreshIcon();
                    break;

                case "IsEnabled":
                case "IsVisibleOnMenu":
                case "IsVisibleOnToolbar":
                    NotifyOfPropertyChange(() => IsVisibleOnMenu);
                    NotifyOfPropertyChange(() => IsVisibleOnToolbar);
                    break;
                }
            };

            RefreshIcon();

            if (commandModel is IDirectoryCommandModel)
            {
                IDirectoryCommandModel directoryModel = CommandModel as IDirectoryCommandModel;
                SubCommands = new EntriesHelper <ICommandViewModel>(
                    (cts) => Task.Run <IEnumerable <ICommandViewModel> >(
                        () => directoryModel.SubCommands.Select(c => (ICommandViewModel) new CommandViewModel(c, parameterDicConverter, this))));
                SubCommands.LoadAsync(UpdateMode.Replace, false);
            }
        }
コード例 #7
0
        public BreadcrumbItemViewModel(IEventAggregator events, IBreadcrumbViewModel rootModel,
                                       IEntryModel curDirModel, IBreadcrumbItemViewModel parentModel)
            : base(curDirModel)
        {
            _events    = events;
            _rootModel = rootModel;

            Entries   = new EntriesHelper <IBreadcrumbItemViewModel>(loadEntriesTask);
            Selection = new TreeSelector <IBreadcrumbItemViewModel, IEntryModel>(curDirModel, this,
                                                                                 parentModel == null ? rootModel.Selection : parentModel.Selection, Entries);
        }
コード例 #8
0
        public TreeViewModel()
        {
            //Submodel is TreeNodeViewModel,
            Entries = new EntriesHelper <TreeNodeViewModel>();
            //Value is based on string
            Selection = new TreeRootSelector <TreeNodeViewModel, string>(Entries)
            {
                Comparers = new[] { this }
            };

            Entries.SetEntries(UpdateMode.Update, new TreeNodeViewModel("", "Root", this, null));
        }
コード例 #9
0
        public void Initialize(FileExplorerViewModel fileExplorerViewModel)
        {
            _fileExplorerViewModel = fileExplorerViewModel;

            Entries   = new EntriesHelper <DirectoryViewModel>();
            Selection = new TreeRootSelector <DirectoryViewModel, FileExplorerEntry>(Entries)
            {
                Comparers = new[]
                { _fileExplorerPathComparer = new FileExplorerPathComparer(fileExplorerViewModel.FileSystem) }
            };

            Selection.AsRoot().SelectionChanged += OnSelectionChanged;
            _fileExplorerViewModel.PathChanged += FileExplorerViewModelOnPathChanged;
        }
コード例 #10
0
        public RegistryTreeViewModel(ITargetedRestClient restClient, IShellStatusBar statusBar)
        {
            _restClient = restClient;
            _statusBar  = statusBar;
            Entries     = new EntriesHelper <RegistryKeyViewModel>();
            Selection   = new TreeRootSelector <RegistryKeyViewModel, IntegratedRegistryKey>(Entries)
            {
                Comparers = new[] { new RegistryPathComparer() }
            };

            Entries.SetEntries(new[]
            {
                RegistryHive.ClassesRoot, RegistryHive.CurrentUser, RegistryHive.LocalMachine, RegistryHive.Users, RegistryHive.CurrentUser
            }.Select(CreateHiveViewModel));
        }
コード例 #11
0
        public DirectoryViewModel(DirectoryTreeViewModel rootViewModel, DirectoryViewModel parentViewModel,
                                  DirectoryEntry directoryEntry, IFileSystem fileSystem, IUiTools uiTools) : this(directoryEntry, fileSystem,
                                                                                                                  uiTools, true)
        {
            _rootViewModel = rootViewModel;
            Parent         = parentViewModel;

            Entries   = new EntriesHelper <DirectoryViewModel>(LoadEntriesAsync);
            Selection = new TreeSelector <DirectoryViewModel, FileExplorerEntry>(Source, this,
                                                                                 parentViewModel?.Selection ?? rootViewModel.Selection, Entries);

            if (!directoryEntry.HasSubFolder)
            {
                Entries.SetEntries(ImmutableList <DirectoryViewModel> .Empty);
            }
        }
コード例 #12
0
        public SubKeyNodeViewModel(RegistryTreeViewModel rootTreeViewModel, AdvancedRegistrySubKey currentEntry,
                                   SubKeyNodeViewModel parentViewModel, RegistryCommand registryCommand)
        {
            _rootTreeViewModel = rootTreeViewModel;
            _registryCommand   = registryCommand;
            Parent             = parentViewModel;
            Value          = currentEntry;
            IsRegistryHive = string.IsNullOrEmpty(Value.RelativePath);

            Entries   = new EntriesHelper <SubKeyNodeViewModel>(LoadSubEntries);
            Selection = new TreeSelector <SubKeyNodeViewModel, AdvancedRegistrySubKey>(Value, this,
                                                                                       parentViewModel == null ? rootTreeViewModel.Selection : parentViewModel.Selection, Entries);

            if (Value.IsEmpty)
            {
                Entries.SetEntries(UpdateMode.Update);
            }
        }
コード例 #13
0
        public DirectoryNodeViewModel(DirectoryTreeViewModel rootTreeViewModel, PackedDirectoryEntry currentEntry,
                                      DirectoryNodeViewModel parentModel, IFileSystem fileSystem, Func <IWindowService> getWindow) : this(currentEntry, fileSystem)
        {
            _rootModel = rootTreeViewModel;
            _getWindow = getWindow;

            Parent    = parentModel;
            Entries   = new EntriesHelper <DirectoryNodeViewModel>(LoadEntriesTask);
            Selection = new TreeSelector <DirectoryNodeViewModel, IFileExplorerEntry>(Value, this,
                                                                                      parentModel == null ? rootTreeViewModel.Selection : parentModel.Selection, Entries);

            _isNodeViewModel = true;

            if (!Value.HasSubFolder)
            {
                Entries.SetEntries(UpdateMode.Update);
            }
        }
コード例 #14
0
        public RegistryKeyViewModel(RegistryTreeViewModel rootTreeViewModel, IntegratedRegistryKey registryKey, ITargetedRestClient restClient,
                                    IShellStatusBar statusBar, RegistryKeyViewModel parentViewModel)
        {
            RegistryKey        = registryKey;
            _rootTreeViewModel = rootTreeViewModel;
            _restClient        = restClient;
            _statusBar         = statusBar;
            Parent             = parentViewModel;

            Entries   = new EntriesHelper <RegistryKeyViewModel>(LoadSubKeys);
            Selection = new TreeSelector <RegistryKeyViewModel, IntegratedRegistryKey>(registryKey, this,
                                                                                       parentViewModel == null ? rootTreeViewModel.Selection : parentViewModel.Selection, Entries);

            if (!registryKey.HasSubKeys)
            {
                Entries.SetEntries(Enumerable.Empty <RegistryKeyViewModel>());
            }
        }
コード例 #15
0
        public BreadcrumbViewModel(IEventAggregator events)
        {
            _events = events;

            if (events != null)
            {
                events.Subscribe(this);
            }

            Entries = new EntriesHelper <IBreadcrumbItemViewModel>();
            var selection = new TreeRootSelector <IBreadcrumbItemViewModel, IEntryModel>(Entries)
            {
                Comparers = new[] { PathComparer.LocalDefault }
            };

            selection.SelectionChanged += (o, e) =>
            {
                BroadcastDirectoryChanged(EntryViewModel.FromEntryModel(selection.SelectedValue));
            };
            Selection = selection;
            Commands  = new BreadcrumbCommandManager(this, events);
        }
コード例 #16
0
        public FileListViewModel(IWindowManager windowManager, IEventAggregator events, ISidebarViewModel sidebar = null)
        {
            Events = events;
            var entryHelper = new EntriesHelper <IEntryViewModel>(loadEntriesTask)
            {
                ClearBeforeLoad = false
            };

            ProcessedEntries = new EntriesProcessor <IEntryViewModel>(entryHelper, evm => evm.EntryModel);
            Columns          = new ColumnsHelper(ProcessedEntries,
                                                 (col, direction) =>
                                                 new EntryViewModelComparer(
                                                     col.Comparer != null ? col.Comparer : CurrentDirectory.Profile.GetComparer(col),
                                                     direction)
                                                 );
            Selection  = new ListSelector <IEntryViewModel, IEntryModel>(entryHelper);
            DropHelper = new FileListDropHelper(this);
            DragHelper = new FileListDragHelper(this);

            Selection.SelectionChanged += (o, e) =>
            { events.PublishOnUIThread(new SelectionChangedEvent(this, Selection.SelectedItems)); };

            if (events != null)
            {
                events.Subscribe(this);
            }

            Sidebar = sidebar ?? new SidebarViewModel(events);
            Sidebar.PropertyChanged += (o, e) =>
            {
                if (e.PropertyName == "IsVisible")
                {
                    NotifyOfPropertyChange(() => ShowSidebar);
                }
            };
            Commands = new FileListCommandManager(this, windowManager, events, Selection, Sidebar.Commands);
        }