public ProjectSetManagerToolWindowViewModel(IServiceProvider serviceProvider) { Dispatcher.CurrentDispatcher.VerifyAccess(); m_serviceProvider = serviceProvider; m_repository = (IProjectSetRepository)m_serviceProvider.RequireService <SProjectSetRepository>(); m_interactionService = (IInteractionService)m_serviceProvider.RequireService <SInteractionService>(); if (m_repository != null) { m_repositoryViewModel = new ProjectSetRepositoryViewModel(m_repository); m_collectionView = new ListCollectionView(m_repositoryViewModel.ProjectSets); //m_collectionView = CollectionViewSource.GetDefaultView(m_repository.ProjectSets); m_collectionView.SortDescriptions.Clear(); m_collectionView.SortDescriptions.Add(new SortDescription("Name", ListSortDirection.Ascending)); } OleMenuCommandService mcs = m_serviceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService; if (null != mcs) { mcs.AddCommand(new OleMenuCommand(OnDeleteProfile, null, OnQuerySelectedItemCommandStatus, GetCommandID(PkgCmdIDList.cmdidDeleteProfile))); mcs.AddCommand(new OleMenuCommand(OnAddProfile, null, OnQueryGlobalCommandStatus, GetCommandID(PkgCmdIDList.cmdidAddProfile))); mcs.AddCommand(new OleMenuCommand(OnEditProfile, null, OnQuerySelectedItemCommandStatus, GetCommandID(PkgCmdIDList.cmdidEditProfile))); mcs.AddCommand(new OleMenuCommand(OnLoadProfile, null, OnQuerySelectedItemCommandStatus, GetCommandID(PkgCmdIDList.cmdidLoadSelectedProfile))); mcs.AddCommand(new OleMenuCommand(OnUnloadProfile, null, OnQuerySelectedItemCommandStatus, GetCommandID(PkgCmdIDList.cmdidUnloadSelectedProfile))); mcs.AddCommand(new OleMenuCommand(OnLoadExProfile, null, OnQuerySelectedItemCommandStatus, GetCommandID(PkgCmdIDList.cmdidLoadExSelectedProfile))); mcs.AddCommand(new OleMenuCommand(OnUnloadExProfile, null, OnQuerySelectedItemCommandStatus, GetCommandID(PkgCmdIDList.cmdidUnloadExSelectedProfile))); } m_loadCommand = new DelegateCommand(() => OnLoadProfile(this, EventArgs.Empty), CanExecuteSelectedItemCommand); m_loadExCommand = new DelegateCommand(() => OnLoadExProfile(this, EventArgs.Empty), CanExecuteSelectedItemCommand); m_unloadCommand = new DelegateCommand(() => OnUnloadProfile(this, EventArgs.Empty), CanExecuteSelectedItemCommand); m_unloadExCommand = new DelegateCommand(() => OnUnloadExProfile(this, EventArgs.Empty), CanExecuteSelectedItemCommand); m_addCommand = new DelegateCommand(() => OnAddProfile(this, EventArgs.Empty)); m_editCommand = new DelegateCommand(() => OnEditProfile(this, EventArgs.Empty), CanExecuteSelectedItemCommand); m_deleteCommand = new DelegateCommand(() => OnDeleteProfile(this, EventArgs.Empty), CanExecuteSelectedItemCommand); }
public ProjectSetRepositoryViewModel(IProjectSetRepository repository) { m_repository = repository; m_projects = ViewModelCollection <ProjectSetSummaryViewModel, ProjectSet> .Create(m_repository.ProjectSets, ps => new ProjectSetSummaryViewModel(ps)); }