Exemplo n.º 1
0
        internal ProjectExplorerViewModel(ObservableCollection <ProjectViewModel> projects,
                                          ProjectViewModelSelectionService selectionService,
                                          ProjectService projectService,
                                          ProjectFileService projectFileService,
                                          IErrorInfoService errorInfoService,
                                          OptionService optionService,
                                          OleMenuCommandService oleMenuCommandService,
                                          IWaitIndicator waitIndicator,
                                          TextBlockBuilderService textBlockBuilderService,
                                          SearchContextFactory searchContextFactory)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            _projects           = projects ?? throw new ArgumentNullException(nameof(projects));
            _selectionService   = selectionService ?? throw new ArgumentNullException(nameof(selectionService));
            _projectService     = projectService ?? throw new ArgumentNullException(nameof(projectService));
            _projectFileService = projectFileService ?? throw new ArgumentNullException(nameof(projectFileService));

            _errorInfoService        = errorInfoService;
            _optionService           = optionService;
            _oleMenuCommandService   = oleMenuCommandService;
            _waitIndicator           = waitIndicator;
            _textBlockBuilderService = textBlockBuilderService;
            _searchContextFactory    = searchContextFactory;

            _commands = new List <Command> {
                { RefreshCommand = new RefreshCommand(this) },
                { CancelRefreshCommand = new CancelRefreshCommand(this) },
                { OpenInFileExplorerCommand = new OpenInFileExplorerCommand(this) },
                { AddProjectCommand = new AddProjectCommand(this) },
                { RemoveProjectCommand = new RemoveProjectCommand(this) },
                { UnloadProjectCommand = new UnloadProjectCommand(this) },
                { LoadProjectCommand = new LoadProjectCommand(this) },
                { SettingsCommand = new SettingsCommand(this) },
                { ExceuteDefaultCommand = new ExceuteDefaultCommand(this) },
            };

            // View
            _projectsView = (ListCollectionView)CollectionViewSource.GetDefaultView(_projects);
            // Sortierung
            _projectsView.CustomSort    = new ProjectViewModelComparer();
            _projectsView.IsLiveSorting = true;
            _projectsView.LiveSortingProperties.Add(nameof(ProjectViewModel.Status));
            _projectsView.LiveSortingProperties.Add(nameof(ProjectViewModel.PatternMatch));
            // Filter
            _projectsView.IsLiveFiltering = true;
            _projectsView.LiveFilteringProperties.Add(nameof(ProjectViewModel.Visible));
            _projectsView.Filter = vm => (vm as ProjectViewModel)?.Visible == true;

            WireEvents();
            RegisterCommands();
            UpdateCommands();

            if (_projectService.IsSolutionOpen)
            {
                RefreshCommand.Execute();
            }
        }
Exemplo n.º 2
0
 public ProjectExplorerToolWindowServices(ProjectExplorerPackage package, OleMenuCommandService oleMenuCommandService, ProjectExplorerViewModelProvider viewModelProvider, IVsWindowSearchHostFactory windowSearchHostFactory, OptionService optionService, IWaitIndicator waitIndicator)
 {
     Package = package;
     OleMenuCommandService   = oleMenuCommandService;
     ViewModelProvider       = viewModelProvider;
     WindowSearchHostFactory = windowSearchHostFactory;
     OptionService           = optionService;
     WaitIndicator           = waitIndicator;
 }