Example #1
0
 public static IDisposable ProjectsRoot(ProjectExplorerViewModel model)
 {
     ThreadHelper.ThrowIfNotOnUIThread();
     return(new StateSaver <string>(
                value: model._optionService.ProjectsRoot,
                getter: () => model._optionService.ProjectsRoot,
                setter: value => model._optionService.ProjectsRoot = value));
 }
Example #2
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();
            }
        }
Example #3
0
        protected void Unadvise()
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            if (_cookie != 0)
            {
                _vsSolution?.UnadviseSolutionEvents(_cookie);
            }
        }
Example #4
0
        public void Dispose()
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            if (_updateSolutionEventsCookieEx != VSCOOKIE_NIL)
            {
                ((IVsSolutionBuildManager)_solutionBuildManager).UnadviseUpdateSolutionEvents(_updateSolutionEventsCookieEx);
                _updateSolutionEventsCookieEx = VSCOOKIE_NIL;
            }
        }
        protected override void OnSaveOptions(string key, Stream stream)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            if (OptionService.OptionKey == key)
            {
                _services.OptionService?.SaveOptions(stream);
            }

            base.OnSaveOptions(key, stream);
        }
        protected override void OnLoadOptions(string key, Stream stream)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            // TODO Wenn der Explorer geƶffnet wurde, nachdem eine Solution geladen wurde, haben wir noch keinen OptionService...
            if (OptionService.OptionKey == key)
            {
                _services.OptionService?.LoadOptions(stream);
            }

            base.OnLoadOptions(key, stream);
        }
Example #7
0
        protected void Advise(IServiceProvider serviceProvider)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            if (serviceProvider == null)
            {
                throw new ArgumentNullException(nameof(serviceProvider));
            }

            _vsSolution = serviceProvider.GetService <SVsSolution, IVsSolution>();
            if (_vsSolution != null)
            {
                var hr = _vsSolution.AdviseSolutionEvents(this, out _cookie);
                ErrorHandler.ThrowOnFailure(hr);
            }
        }
 public static TInterface GetGlobalService <TService, TInterface>() where TInterface : class
 {
     ThreadHelper.ThrowIfNotOnUIThread();
     return(ServiceProvider.GlobalProvider.GetService <TService, TInterface>());
 }