/// <summary> /// The populate possible parameter types. /// </summary> private void PopulatePossibleParameterTypes() { this.PossibleParameterType.Clear(); var containerRdl = this.Container as ReferenceDataLibrary; if (containerRdl == null) { return; } var allParameterTypes = containerRdl.ParameterType.ToList(); var allParameterTypesFromChainedRdl = containerRdl.GetRequiredRdls().SelectMany(rdl => rdl.ParameterType); allParameterTypes.AddRange(allParameterTypesFromChainedRdl); if (this.filterStringService == null) { this.filterStringService = ServiceLocator.Current.GetInstance <IFilterStringService>(); } if (!this.filterStringService.ShowDeprecatedThings) { allParameterTypes = allParameterTypes.Where(pt => !pt.IsDeprecated).ToList(); } this.PossibleParameterType.AddRange(this.ParameterType.OrderBy(c => c.ShortName)); this.PossibleParameterType.AddRange(allParameterTypes.Except(this.ParameterType).OrderBy(c => c.ShortName)); }
/// <summary> /// Initializes a new instance of the <see cref="MatrixViewModel" /> class /// </summary> /// <param name="session">The current session</param> /// <param name="iteration">The current iteration</param> /// <param name="settings">The module settings</param> public MatrixViewModel(ISession session, Iteration iteration, RelationshipMatrixPluginSettings settings) { this.filterStringService = ServiceLocator.Current.GetInstance <IFilterStringService>(); this.IsDeprecatedDisplayed = this.filterStringService.ShowDeprecatedThings; this.Disposables = new List <IDisposable>(); this.Records = new ReactiveList <IDictionary <string, MatrixCellViewModel> >(); this.Columns = new ReactiveList <ColumnDefinition>(); this.session = session; this.iteration = iteration; this.CreateSourceYToSourceXLink = ReactiveCommand.CreateAsyncTask( this.WhenAnyValue(x => x.CanCreateSourceYToSourceX), x => this.CreateRelationship(RelationshipDirectionKind.RowThingToColumnThing), RxApp.MainThreadScheduler); this.CreateSourceXToSourceYLink = ReactiveCommand.CreateAsyncTask( this.WhenAnyValue(x => x.CanCreateSourceXToSourceY), x => this.CreateRelationship(RelationshipDirectionKind.ColumnThingToRowThing), RxApp.MainThreadScheduler); this.DeleteSourceYToSourceXLink = ReactiveCommand.CreateAsyncTask( this.WhenAnyValue(x => x.CanDelete), x => this.DeleteRelationship(RelationshipDirectionKind.RowThingToColumnThing), RxApp.MainThreadScheduler); this.DeleteSourceXToSourceYLink = ReactiveCommand.CreateAsyncTask( this.WhenAnyValue(x => x.CanDelete), x => this.DeleteRelationship(RelationshipDirectionKind.ColumnThingToRowThing), RxApp.MainThreadScheduler); this.DeleteAllRelationships = ReactiveCommand.CreateAsyncTask( this.WhenAnyValue(x => x.CanDelete), x => this.DeleteRelationship(RelationshipDirectionKind.BiDirectional), RxApp.MainThreadScheduler); this.ProcessCellCommand = ReactiveCommand.CreateAsyncTask(x => this.ProcessCellCommandExecute((List <object>)x), RxApp.MainThreadScheduler); this.ProcessAltCellCommand = ReactiveCommand.CreateAsyncTask(x => this.ProcessAltCellCommandExecute((List <object>)x), RxApp.MainThreadScheduler); this.ProcessAltControlCellCommand = ReactiveCommand.CreateAsyncTask( x => this.ProcessAltControlCellCommandExecute((List <object>)x), RxApp.MainThreadScheduler); this.ToggleColumnHighlightCommand = ReactiveCommand.CreateAsyncTask( x => this.ToggleColumnHighlightCommandExecute(x as GridColumn), RxApp.MainThreadScheduler); this.MouseDownCommand = ReactiveCommand.Create(); this.MouseDownCommand.Subscribe(x => this.MouseDownCommandExecute((MatrixAddress)x)); this.SubscribeCommandExceptions(); this.WhenAnyValue(x => x.SelectedCell).Subscribe(_ => this.ComputeCommandCanExecute()); }
/// <summary> /// Toggles showing only the the favorite items. /// </summary> private void ExecuteToggleShowFavoriteCommand() { if (this.filterStringService == null) { this.filterStringService = ServiceLocator.Current.GetInstance <IFilterStringService>(); } this.filterStringService.RefreshFavoriteBrowser(this); }
public PanelNavigationService( [ImportMany] IEnumerable <IPanelView> panelViewKinds, [ImportMany] IEnumerable <IPanelViewModel> panelViewModelKinds, [ImportMany] IEnumerable <Lazy <IPanelViewModel, INameMetaData> > panelViewModelDecorated, DockLayoutViewModel dockLayoutViewModel, IFilterStringService filterStringService) { var sw = new Stopwatch(); sw.Start(); logger.Debug("Instantiating the PanelNavigationService"); this.dockLayoutViewModel = dockLayoutViewModel; this.filterStringService = filterStringService; this.dockLayoutViewModel.DockPanelViewModels.ItemsRemoved.Subscribe(CleanUpPanelsAndSendCloseEvent); this.PanelViewKinds = new Dictionary <string, IPanelView>(); // TODO T2428 : PanelViewModelKinds seems to be always empty and is used only one time in the Open(Thing thing, ISession session) method. We should probably refactor this part of the code. this.PanelViewModelKinds = new Dictionary <string, IPanelViewModel>(); this.AddInViewModelViewPairs = new Dictionary <IPanelViewModel, IPanelView>(); this.PanelViewModelDecorated = new Dictionary <string, Lazy <IPanelViewModel, INameMetaData> >(); foreach (var panelView in panelViewKinds) { var panelViewName = panelView.ToString(); this.PanelViewKinds.Add(panelViewName.ToString(), panelView); logger.Trace($"Add panelView {panelViewName} "); } foreach (var panelViewModel in panelViewModelKinds) { var panelViewModelName = panelViewModel.ToString(); this.PanelViewModelKinds.Add(panelViewModelName, panelViewModel); logger.Trace($"Add panelViewModel {panelViewModelName} "); } foreach (var panelViewModel in panelViewModelDecorated) { var panelViewModelName = panelViewModel.Value.ToString(); var panelViewModelDescribeName = panelViewModel.Metadata.Name; this.PanelViewModelDecorated.Add(panelViewModelDescribeName, panelViewModel); logger.Trace($"Add panelViewModel {panelViewModelName} "); } sw.Stop(); logger.Debug($"The PanelNavigationService was instantiated in {sw.ElapsedMilliseconds} [ms] "); }
/// <summary> /// Initializes a new instance of the <see cref="ShowDeprecatedBrowserRibbonViewModel"/> class /// </summary> public ShowDeprecatedBrowserRibbonViewModel() { this.filterStringService = ServiceLocator.Current.GetInstance <IFilterStringService>(); this.openSessions = new ReactiveList <ISession> { ChangeTrackingEnabled = true }; this.openSessions.CountChanged.Select(x => x != 0).ToProperty(this, x => x.HasSession, out this.hasSession); CDPMessageBus.Current.Listen <SessionEvent>().Subscribe(this.SessionChangeEventHandler); this.WhenAnyValue(vm => vm.ShowDeprecatedThings) .Subscribe(_ => this.RefreshAndSendShowDeprecatedThingsEvent()); }
/// <summary> /// Initializes a new instance of the <see cref="ParameterizedCategoryRuleDialogViewModel" /> class. /// </summary> /// <param name="parameterizedCategoryRule"> /// The <see cref="CDP4Common.SiteDirectoryData.ParameterizedCategoryRule" /> that is the subject of the current /// view-model. This is the object /// that will be either created, or edited. /// </param> /// <param name="transaction"> /// The <see cref="ThingTransaction" /> that contains the log of recorded changes. /// </param> /// <param name="session"> /// The <see cref="ISession" /> in which the current <see cref="CDP4Common.CommonData.Thing" /> is to be added or updated /// </param> /// <param name="isRoot"> /// Assert if this <see cref="ParameterizedCategoryRuleDialogViewModel" /> is the root of all /// <see cref="IThingDialogViewModel" /> /// </param> /// <param name="dialogKind"> /// The kind of operation this <see cref="ParameterizedCategoryRuleDialogViewModel" /> performs /// </param> /// <param name="thingDialogNavigationService"> /// The <see cref="IThingDialogNavigationService" /> that is used to navigate to a dialog of a specific /// <see cref="Thing" />. /// </param> /// <param name="container"> /// The Container <see cref="CDP4Common.CommonData.Thing" /> of the created /// <see cref="CDP4Common.SiteDirectoryData.ParameterizedCategoryRule" /> /// </param> /// <param name="chainOfContainers"> /// The optional chain of containers that contains the <paramref name="container" /> argument /// </param> public ParameterizedCategoryRuleDialogViewModel(ParameterizedCategoryRule parameterizedCategoryRule, IThingTransaction transaction, ISession session, bool isRoot, ThingDialogKind dialogKind, IThingDialogNavigationService thingDialogNavigationService, Thing container = null, IEnumerable <Thing> chainOfContainers = null) : base(parameterizedCategoryRule, transaction, session, isRoot, dialogKind, thingDialogNavigationService, container, chainOfContainers) { this.filterStringService = ServiceLocator.Current.GetInstance <IFilterStringService>(); this.WhenAnyValue(vm => vm.Container).Subscribe( _ => { this.PopulatePossibleCategory(); this.PopulatePossibleParameterTypes(); this.UpdateOkCanExecute(); }); this.WhenAnyValue(vm => vm.ParameterType.Count).Subscribe(_ => this.UpdateOkCanExecute()); }
public PanelNavigationService([ImportMany] IEnumerable <Lazy <IPanelView, IRegionMetaData> > panelViewKinds, [ImportMany] IEnumerable <IPanelViewModel> panelViewModelKinds, IRegionManager regionManager, [ImportMany] IEnumerable <Lazy <IPanelViewModel, INameMetaData> > panelViewModelDecorated, IFilterStringService filterStringService, IRegionCollectionSearcher regionCollectionSearcher) { var sw = new Stopwatch(); sw.Start(); logger.Debug("Instantiating the PanelNavigationService"); this.regionManager = regionManager; this.filterStringService = filterStringService; this.regionCollectionSearcher = regionCollectionSearcher; this.PanelViewKinds = new Dictionary <string, Lazy <IPanelView, IRegionMetaData> >(); // TODO T2428 : PanelViewModelKinds seems to be always empty and is used only one time in the Open(Thing thing, ISession session) method. We should probably refactor this part of the code. this.PanelViewModelKinds = new Dictionary <string, IPanelViewModel>(); this.ViewModelViewPairs = new Dictionary <IPanelViewModel, IPanelView>(); this.PanelViewModelDecorated = new Dictionary <string, Lazy <IPanelViewModel, INameMetaData> >(); foreach (var panelView in panelViewKinds) { var panelViewName = panelView.Value.ToString(); this.PanelViewKinds.Add(panelViewName, panelView); logger.Trace("Add panelView {0} ", panelViewName); } foreach (var panelViewModel in panelViewModelKinds) { var panelViewModelName = panelViewModel.ToString(); this.PanelViewModelKinds.Add(panelViewModelName, panelViewModel); logger.Trace("Add panelViewModel {0} ", panelViewModelName); } foreach (var panelViewModel in panelViewModelDecorated) { var panelViewModelName = panelViewModel.Value.ToString(); var panelViewModelDescribeName = panelViewModel.Metadata.Name; this.PanelViewModelDecorated.Add(panelViewModelDescribeName, panelViewModel); logger.Trace("Add panelViewModel {0} ", panelViewModelName); } // sets the event handler for the different regions try { this.regionManager.Regions[RegionNames.LeftPanel].Views.CollectionChanged += this.ViewCollectionChangedEventHandler; } catch (KeyNotFoundException) { logger.Debug("The {0} does not exist", RegionNames.LeftPanel); } try { this.regionManager.Regions[RegionNames.EditorPanel].Views.CollectionChanged += this.ViewCollectionChangedEventHandler; } catch (KeyNotFoundException) { logger.Debug("The {0} does not exist", RegionNames.EditorPanel); } try { this.regionManager.Regions[RegionNames.RightPanel].Views.CollectionChanged += this.ViewCollectionChangedEventHandler; } catch (KeyNotFoundException) { logger.Debug("The {0} does not exist", RegionNames.RightPanel); } sw.Stop(); logger.Debug("The PanelNavigationService was instantiated in {0} [ms]", sw.ElapsedMilliseconds); }