/// <summary> /// Compares two <see cref="IRowViewModelBase{Thing}"/> of the same type /// </summary> /// <param name="x">The First <see cref="IRowViewModelBase{Thing}"/></param> /// <param name="y">The second <see cref="IRowViewModelBase{Thing}"/></param> /// <returns> /// Less than zero : x is "lower" than y /// Zero: x "equals" y. /// Greater than zero: x is "greater" than y. /// </returns> public int Compare(IRowViewModelBase <Thing> x, IRowViewModelBase <Thing> y) { var xType = x.GetType(); var yType = y.GetType(); if (!PermissibleRowTypes.Contains(xType) || !PermissibleRowTypes.Contains(yType)) { throw new NotSupportedException("The list contains other types of row than the specified ones."); } var isxRowPrameterRow = typeof(ParameterOrOverrideBaseRowViewModel).IsAssignableFrom(xType); var isyRowParameterRow = typeof(ParameterOrOverrideBaseRowViewModel).IsAssignableFrom(yType); if ((isxRowPrameterRow && isyRowParameterRow) || (xType == yType)) { return(this.CompareSameType(x, y, yType)); } if (typeof(ParameterOrOverrideBaseRowViewModel).IsAssignableFrom(xType)) { return(-1); } // xtype is ParameterGroupRow, y parameterOrOverrideBase return(1); }
/// <summary> /// Compares two <see cref="RequirementsSpecification"/> /// </summary> /// <param name="x">The first <see cref="RequirementsSpecification"/> to compare</param> /// <param name="y">The second <see cref="RequirementsSpecification"/> to compare</param> /// <returns> /// Less than zero : x is "lower" than y /// Zero: x "equals" y. /// Greater than zero: x is "greater" than y. /// </returns> public int Compare(IRowViewModelBase <Thing> x, IRowViewModelBase <Thing> y) { if (x == null || y == null) { throw new ArgumentNullException(); } var xspec = x.Thing as RequirementsSpecification; var yspec = y.Thing as RequirementsSpecification; if (xspec == null || yspec == null) { return(0); } if (RequirementsModule.PluginSettings?.OrderSettings != null && RequirementsModule.PluginSettings.OrderSettings.ParameterType != Guid.Empty) { var xOrder = xspec.ParameterValue.FirstOrDefault(z => z.ParameterType.Iid == RequirementsModule.PluginSettings.OrderSettings.ParameterType)?.Value.FirstOrDefault(); var yOrder = yspec.ParameterValue.FirstOrDefault(z => z.ParameterType.Iid == RequirementsModule.PluginSettings.OrderSettings.ParameterType)?.Value.FirstOrDefault(); int xOrderKey, yOrderKey; if (xOrder != null && int.TryParse(xOrder, out xOrderKey) && yOrder != null && int.TryParse(yOrder, out yOrderKey)) { return(xOrderKey > yOrderKey ? 1 : xOrderKey < yOrderKey ? -1 : shortNameThingComparer.Compare(xspec, yspec)); } return(shortNameThingComparer.Compare(xspec, yspec)); } return(shortNameThingComparer.Compare(xspec, yspec)); }
/// <summary> /// Compares two <see cref="IRowViewModelBase{Thing}"/> /// </summary> /// <param name="x">The first <see cref="IRowViewModelBase{Thing}"/> to compare</param> /// <param name="y">The second <see cref="IRowViewModelBase{Thing}"/> to compare</param> /// <returns> /// Less than zero : x is "lower" than y /// Zero: x "equals" y. /// Greater than zero: x is "greater" than y. /// </returns> public int Compare(IRowViewModelBase <Thing> x, IRowViewModelBase <Thing> y) { if (x == null || y == null) { throw new ArgumentNullException(); } var xType = x.GetType(); var yType = y.GetType(); if (!PermissibleRowTypes.Any(type => type.IsAssignableFrom(xType)) || !PermissibleRowTypes.Any(type => type.IsAssignableFrom(yType))) { throw new NotSupportedException("The list contains other types of row than the specified ones."); } if (typeof(RequirementRowViewModel).IsAssignableFrom(xType) && typeof(RequirementsGroupRowViewModel).IsAssignableFrom(yType)) { return(-1); } if (typeof(RequirementsGroupRowViewModel).IsAssignableFrom(xType) && typeof(RequirementRowViewModel).IsAssignableFrom(yType)) { return(1); } if (xType == yType) { return(shortNameThingComparer.Compare((IShortNamedThing)x.Thing, (IShortNamedThing)y.Thing)); } // x is a group, y is ElementUsageRow return(1); }
/// <summary> /// Creates the component rows for this <see cref="CompoundParameterType"/> <see cref="ParameterRowViewModel"/>. /// </summary> private void SetComponentProperties(IRowViewModelBase <Thing> row, Option actualOption, ActualFiniteState actualState) { for (var i = 0; i < ((CompoundParameterType)this.Thing.ParameterType).Component.Count; i++) { var componentRow = new ParameterComponentValueRowViewModel(this.Thing, i, this.Session, actualOption, actualState, row, this.isParameterBaseReadOnlyInDataContext); componentRow.SetValues(); row.ContainedRows.Add(componentRow); } }
/// <summary> /// Compares two <see cref="IRowViewModelBase{Thing}"/> /// </summary> /// <param name="x">The first <see cref="IRowViewModelBase{Thing}"/> to compare</param> /// <param name="y">The second <see cref="IRowViewModelBase{Thing}"/> to compare</param> /// <returns> /// Less than zero : x is "lower" than y /// Zero: x "equals" y. /// Greater than zero: x is "greater" than y. /// </returns> public int Compare(IRowViewModelBase <Thing> x, IRowViewModelBase <Thing> y) { if (!(x.Thing is DomainOfExpertise) || !(y.Thing is DomainOfExpertise)) { throw new InvalidOperationException("one or both of the parameters is not an Element Definition row."); } return(comparer.Compare((DomainOfExpertise)x.Thing, (DomainOfExpertise)y.Thing)); }
/// <summary> /// Adds the <see cref="BooleanExpression"/>s contained in this <see cref="IRowViewModelBase<BooleanExpression>"/> to the list of <see cref="BooleanExpression"/s> /// </summary> private void AddContainedExpression(IRowViewModelBase <BooleanExpression> containedExpressionRow, ICollection <BooleanExpression> booleanExpressions) { booleanExpressions.Add(containedExpressionRow.Thing); if (!containedExpressionRow.ContainedRows.Any()) { return; } foreach (var containedRow in containedExpressionRow.ContainedRows.OfType <IRowViewModelBase <BooleanExpression> >()) { this.AddContainedExpression(containedRow, booleanExpressions); } }
/// <summary> /// Compares two <see cref="IRowViewModelBase{Thing}"/> of the same type /// </summary> /// <param name="x">The First <see cref="IRowViewModelBase{Thing}"/></param> /// <param name="y">The second <see cref="IRowViewModelBase{Thing}"/></param> /// <param name="type">The actual Type</param> /// <returns> /// Less than zero : x is "lower" than y /// Zero: x "equals" y. /// Greater than zero: x is "greater" than y. /// </returns> private int CompareSameType(IRowViewModelBase <Thing> x, IRowViewModelBase <Thing> y, Type type) { if (typeof(ParameterOrOverrideBaseRowViewModel).IsAssignableFrom(type)) { var comparer = new ParameterBaseComparer(); return(comparer.Compare((ParameterBase)x.Thing, (ParameterBase)y.Thing)); } var groupComparer = new ParameterGroupComparer(); return(groupComparer.Compare((ParameterGroup)x.Thing, (ParameterGroup)y.Thing)); }
/// <summary> /// Verify that the <paramref name="parameterRow"/> contains the <paramref name="parameter"/> /// </summary> /// <param name="parameter">The <see cref="ParameterBase"/></param> /// <param name="parameterRow">The <see cref="IRowViewModelBase{T}"/></param> /// <returns>An assert</returns> private static bool VerifyRowContainsTheParameter(ParameterBase parameter, IRowViewModelBase <ParameterOrOverrideBase> parameterRow) { var containerIsTheRightOne = (parameterRow.ContainerViewModel.Thing.Iid == parameter.Container.Iid || (parameterRow.ContainerViewModel.Thing is ElementUsage elementUsage && (elementUsage.ElementDefinition.Iid == parameter.Container.Iid || elementUsage.Iid == parameter.Container.Iid))); var parameterIsTheRightOne = (parameterRow.Thing.Iid == parameter.Iid || (parameter.Iid == Guid.Empty && parameter.ParameterType.Iid == parameterRow.Thing.ParameterType.Iid)); return(containerIsTheRightOne && parameterIsTheRightOne); }
/// <summary> /// Compares two <see cref="IRowViewModelBase{Thing}"/> /// </summary> /// <param name="x">The first <see cref="IRowViewModelBase{Thing}"/> to compare</param> /// <param name="y">The second <see cref="IRowViewModelBase{Thing}"/> to compare</param> /// <returns> /// Less than zero : x is "lower" than y /// Zero: x "equals" y. /// Greater than zero: x is "greater" than y. /// </returns> public int Compare(IRowViewModelBase <Thing> x, IRowViewModelBase <Thing> y) { if (x == null || y == null) { throw new ArgumentNullException(); } if (!(x is PublicationParameterOrOverrideRowViewModel) || !(y is PublicationParameterOrOverrideRowViewModel)) { throw new NotSupportedException("The list contains other types of row than the specified ones."); } var comparer = new ParameterBaseComparer(); return(comparer.Compare((ParameterOrOverrideBase)x.Thing, (ParameterOrOverrideBase)y.Thing)); }
/// <summary> /// Tries to add values to a <see cref="List{T}"/> from a <see cref="IRowViewModelBase{Thing}"/> /// and its childrows /// </summary> /// <typeparam name="T"> /// The type of object the <see cref="List{T}"/> holds data for. /// </typeparam> /// <param name="rowViewModel"> /// The <see cref="IRowViewModelBase{Thing}"/> to be searched. /// </param> /// <param name="values"> /// The <see cref="List{T}"/> containing all the found values. /// </param> private void TryAddValuesFromRowViewModel <T>(IRowViewModelBase <Thing> rowViewModel, ref List <T> values) { var propInfo = rowViewModel.GetType().GetProperty(this.FieldName); if (propInfo != null) { var value = propInfo.GetValue(rowViewModel); if (value is T typedValue) { values.Add(typedValue); } } this.TryAddValuesFromRowViewModels(rowViewModel.ContainedRows, ref values); }
/// <summary> /// Compares two <see cref="IRowViewModelBase{Thing}"/> /// </summary> /// <param name="x">The first <see cref="IRowViewModelBase{Thing}"/> to compare</param> /// <param name="y">The second <see cref="IRowViewModelBase{Thing}"/> to compare</param> /// <returns> /// Less than zero : x is "lower" than y /// Zero: x "equals" y. /// Greater than zero: x is "greater" than y. /// </returns> public int Compare(IRowViewModelBase <Thing> x, IRowViewModelBase <Thing> y) { if (x == null || y == null) { throw new ArgumentNullException(); } var xType = x.GetType(); var yType = y.GetType(); if (!PermissibleRowTypes.Any(type => type.IsAssignableFrom(xType)) || !PermissibleRowTypes.Any(type => type.IsAssignableFrom(yType))) { throw new NotSupportedException("The list contains other types of row than the specified ones."); } if (xType == yType) { return(this.CompareSameType(x, y, yType)); } if ((typeof(ParameterOrOverrideBaseRowViewModel).IsAssignableFrom(xType) || typeof(ParameterSubscriptionRowViewModel).IsAssignableFrom(xType)) && (typeof(ParameterOrOverrideBaseRowViewModel).IsAssignableFrom(yType) || typeof(ParameterSubscriptionRowViewModel).IsAssignableFrom(yType))) { return(this.CompareSameType(x, y, yType)); } if (typeof(ParameterOrOverrideBaseRowViewModel).IsAssignableFrom(xType) || typeof(ParameterSubscriptionRowViewModel).IsAssignableFrom(xType)) { return(-1); } if (typeof(ElementUsageRowViewModel).IsAssignableFrom(xType)) { return(1); } // x is a ParameterGroupRow if (typeof(ParameterOrOverrideBaseRowViewModel).IsAssignableFrom(yType) || typeof(ParameterSubscriptionRowViewModel).IsAssignableFrom(yType)) { return(1); } // x is ParameterGroupRow, y is ElementUsageRow return(-1); }
/// <summary> /// Compares two <see cref="IRowViewModelBase{Thing}"/> of the same type /// </summary> /// <param name="x">The First <see cref="IRowViewModelBase{Thing}"/></param> /// <param name="y">The second <see cref="IRowViewModelBase{Thing}"/></param> /// <param name="type">The actual Type</param> /// <returns> /// Less than zero : x is "lower" than y /// Zero: x "equals" y. /// Greater than zero: x is "greater" than y. /// </returns> private int CompareSameType(IRowViewModelBase <Thing> x, IRowViewModelBase <Thing> y, Type type) { if (type == typeof(ParameterRowViewModel)) { var comparer = new ParameterBaseComparer(); return(comparer.Compare((ParameterBase)x.Thing, (ParameterBase)y.Thing)); } if (type == typeof(ParameterGroupRowViewModel)) { var comparer = new ParameterGroupComparer(); return(comparer.Compare((ParameterGroup)x.Thing, (ParameterGroup)y.Thing)); } var usageComparer = new ElementUsageComparer(); return(usageComparer.Compare((ElementUsage)x.Thing, (ElementUsage)y.Thing)); }
/// <summary> /// Compares two <see cref="IRowViewModelBase{Thing}"/> of the same type /// </summary> /// <param name="x">The First <see cref="IRowViewModelBase{Thing}"/></param> /// <param name="y">The second <see cref="IRowViewModelBase{Thing}"/></param> /// <param name="type">The actual Type</param> /// <returns> /// Less than zero : x is "lower" than y /// Zero: x "equals" y. /// Greater than zero: x is "greater" than y. /// </returns> private int CompareSameType(IRowViewModelBase <Thing> x, IRowViewModelBase <Thing> y, Type type) { if (typeof(ParameterOrOverrideBaseRowViewModel).IsAssignableFrom(type) || typeof(ParameterSubscriptionRowViewModel).IsAssignableFrom(type)) { var comparer = new ParameterBaseComparer(); return(comparer.Compare((ParameterBase)x.Thing, (ParameterBase)y.Thing)); } if (typeof(ParameterGroupRowViewModel).IsAssignableFrom(type)) { var comparer = new ParameterGroupComparer(); return(comparer.Compare((ParameterGroup)x.Thing, (ParameterGroup)y.Thing)); } var usageComparer = new ElementUsageComparer(); return(usageComparer.Compare((ElementUsage)x.Thing, (ElementUsage)y.Thing)); }
/// <summary> /// Sets the state dependent rows contained in this row. /// </summary> private void SetStateProperties(IRowViewModelBase <Thing> row, Option actualOption) { var stateList = this.Thing.StateDependence; foreach (var state in stateList.ActualState.Where(s => s.Kind != ActualFiniteStateKind.FORBIDDEN)) { var stateRow = new ParameterStateRowViewModel(this.Thing, actualOption, state, this.Session, row, this.isDialogReadOnly); if (this.Thing.ParameterType is CompoundParameterType) { this.SetComponentProperties(stateRow, actualOption, state); } else { stateRow.UpdateValues(); } row.ContainedRows.Add(stateRow); } }
/// <summary> /// Builds a string that represents the whole tree for the <see cref="BooleanExpression"/> of the given row. /// </summary> /// <param name="expressionRow"></param> /// <param name="stringBuilder"></param> private static void GetStringExpression(IRowViewModelBase <BooleanExpression> expressionRow, StringBuilder stringBuilder) { if (expressionRow.Thing.ClassKind == ClassKind.RelationalExpression) { stringBuilder.Append("("); stringBuilder.Append(expressionRow.Thing.StringValue.Trim()); stringBuilder.Append(")"); } else { if (expressionRow.ContainerViewModel is IRowViewModelBase <BooleanExpression> ) { stringBuilder.Append("("); } foreach (var containedExpressionRow in expressionRow.ContainedRows) { if (expressionRow.Thing.ClassKind == ClassKind.NotExpression) { stringBuilder.Append($" {expressionRow.Thing.StringValue} "); GetStringExpression(containedExpressionRow as IRowViewModelBase <BooleanExpression>, stringBuilder); } else { GetStringExpression(containedExpressionRow as IRowViewModelBase <BooleanExpression>, stringBuilder); if (containedExpressionRow != expressionRow.ContainedRows.Last()) { stringBuilder.Append($" {expressionRow.Thing.StringValue} "); } } } if (expressionRow.ContainerViewModel is IRowViewModelBase <BooleanExpression> ) { stringBuilder.Append(")"); } } }
/// <summary> /// Compares two <see cref="IRowViewModelBase{Thing}"/> /// </summary> /// <param name="x">The first <see cref="IRowViewModelBase{Thing}"/> to compare</param> /// <param name="y">The second <see cref="IRowViewModelBase{Thing}"/> to compare</param> /// <returns> /// Less than zero : x is "lower" than y /// Zero: x "equals" y. /// Greater than zero: x is "greater" than y. /// </returns> public int Compare(IRowViewModelBase <Thing> x, IRowViewModelBase <Thing> y) { if (x == null || y == null) { throw new ArgumentNullException(); } var xType = x.GetType(); var yType = y.GetType(); if (!PermissibleRowTypes.Any(type => type.IsAssignableFrom(xType))) { throw new ArgumentException(string.Format("argument x is of type {0} which is not supported", xType.Name)); } if (!PermissibleRowTypes.Any(type => type.IsAssignableFrom(yType))) { throw new ArgumentException(string.Format("argument y is of type {0} which is not supported", yType.Name)); } return(BreadCrumbComparer.Compare((IBreadCrumb)x, (IBreadCrumb)y)); }
/// <summary> /// Initialize the listeners and process the state-dependency of this <see cref="ParameterBase"/> /// </summary> /// <param name="row">The row container</param> /// <param name="actualOption">The actual option</param> private void SetStateProperties(IRowViewModelBase <Thing> row, Option actualOption) { this.actualFiniteStateListener.ForEach(x => x.Dispose()); this.actualFiniteStateListener.Clear(); foreach (var state in this.Thing.StateDependence.ActualState) { var listener = CDPMessageBus.Current.Listen <ObjectChangedEvent>(state) .Where(objectChange => objectChange.EventKind == EventKind.Updated) .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(x => this.UpdateActualStateRow(row, actualOption, state)); this.actualFiniteStateListener.Add(listener); } this.StateDependence.ActualState.Sort(new ActualFiniteStateComparer()); var actualFiniteStates = this.StateDependence.ActualState.Where(x => x.Kind == ActualFiniteStateKind.MANDATORY); foreach (var state in actualFiniteStates) { this.UpdateActualStateRow(row, actualOption, state); } }
/// <summary> /// Create or remove a row representing an <see cref="ActualFiniteState"/> /// </summary> /// <param name="row">The row container for the rows to create or remove</param> /// <param name="actualOption">The actual option</param> /// <param name="actualState">The actual state</param> private void UpdateActualStateRow(IRowViewModelBase <Thing> row, Option actualOption, ActualFiniteState actualState) { if (actualState.Kind == ActualFiniteStateKind.FORBIDDEN) { var rowToRemove = row.ContainedRows.OfType <ParameterStateRowViewModel>() .SingleOrDefault(x => x.ActualState == actualState); if (rowToRemove != null) { rowToRemove.Dispose(); row.ContainedRows.Remove(rowToRemove); } return; } // mandatory state var existingRow = row.ContainedRows.OfType <ParameterStateRowViewModel>() .SingleOrDefault(x => x.ActualState == actualState); if (existingRow != null) { return; } var stateRow = new ParameterStateRowViewModel(this.Thing, actualOption, actualState, this.Session, row, this.isParameterBaseReadOnlyInDataContext); if (this.Thing.ParameterType is CompoundParameterType) { this.SetComponentProperties(stateRow, actualOption, actualState); } else { stateRow.SetValues(); } row.ContainedRows.Add(stateRow); }
/// <summary> /// Builds a string that represents the whole tree for the <see cref="BooleanExpression"/> of the given row. /// </summary> private void BuildStringExpression(IRowViewModelBase <BooleanExpression> expressionRow) { if (expressionRow.Thing.ClassKind == ClassKind.RelationalExpression) { this.StringTopExpression += expressionRow.Thing.StringValue; } else { if (expressionRow.ContainerViewModel is IRowViewModelBase <BooleanExpression> ) { this.StringTopExpression += "("; } foreach (var containedExpressionRow in expressionRow.ContainedRows) { if (expressionRow.Thing.ClassKind == ClassKind.NotExpression) { this.StringTopExpression += string.Format(" {0} ", expressionRow.Thing.StringValue); this.BuildStringExpression(containedExpressionRow as IRowViewModelBase <BooleanExpression>); } else { this.BuildStringExpression(containedExpressionRow as IRowViewModelBase <BooleanExpression>); if (containedExpressionRow != expressionRow.ContainedRows.Last()) { this.StringTopExpression += string.Format(" {0} ", expressionRow.Thing.StringValue); } } } if (expressionRow.ContainerViewModel is IRowViewModelBase <BooleanExpression> ) { this.StringTopExpression += ")"; } } }
/// <summary> /// Insert a <see cref="IRowViewModelBase{Thing}"/> into the list given a <see cref="IComparer{T}"/> /// </summary> /// <param name="list">The <see cref="ReactiveList{T}"/></param> /// <param name="row">The <see cref="IRowViewModelBase{Thing}"/> to add</param> /// <param name="comparer">The <see cref="IComparer{T}"/> used to perform the sorting</param> public static void SortedInsert(this ReactiveList <IRowViewModelBase <Thing> > list, IRowViewModelBase <Thing> row, IComparer <IRowViewModelBase <Thing> > comparer) { if (row == null) { throw new ArgumentNullException(nameof(row), $"The {nameof(row)} may not be null"); } if (comparer == null) { throw new ArgumentNullException(nameof(comparer), $"The {nameof(comparer)} may not be null"); } // item is found using the comparer : returns the index of the item found // item not found : returns a negative number that is the bitwise complement // of the index of the next element that is larger or count if none var index = list.BinarySearch(row, comparer); if (index < 0) { list.Insert(~index, row); } else { list.Insert(index, row); } }
/// <summary> /// Initializes a new instance of the <see cref="ParameterOptionRowViewModel"/> class /// </summary> /// <param name="parameterBase">The associated <see cref="ParameterBase"/></param> /// <param name="option">The associated <see cref="Option"/></param> /// <param name="session">The associated <see cref="ISession"/></param> /// <param name="containerViewModel">The container row</param> /// <param name="isReadOnly">A value indicating whether the row is read-only</param> public ParameterOptionRowViewModel(ParameterBase parameterBase, Option option, ISession session, IRowViewModelBase <Thing> containerViewModel, bool isReadOnly) : base(parameterBase, session, option, null, containerViewModel, 0, isReadOnly) { this.Name = this.ActualOption.Name; this.Option = this.ActualOption; var optionListener = CDPMessageBus.Current.Listen <ObjectChangedEvent>(this.Option) .Where(objectChange => objectChange.EventKind == EventKind.Updated) .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(x => { this.Name = this.ActualOption.Name; }); this.Disposables.Add(optionListener); }
/// <summary> /// Initializes a new instance of the <see cref="ParameterOptionRowViewModel"/> class /// </summary> /// <param name="parameterBase">The associated <see cref="ParameterBase"/></param> /// <param name="option">The associated <see cref="Option"/></param> /// <param name="session">The associated <see cref="ISession"/></param> /// <param name="containerViewModel">The container row</param> /// <param name="isDialogReadOnly">Value indicating whether this row should be read-only because the dialog is read-only</param> public ParameterOptionRowViewModel(ParameterBase parameterBase, Option option, ISession session, IRowViewModelBase <Thing> containerViewModel, bool isDialogReadOnly = false) : base(parameterBase, session, option, null, containerViewModel, 0, isDialogReadOnly) { this.Name = this.ActualOption.Name; this.Option = this.ActualOption; }
/// <summary> /// Initializes a new instance of the <see cref="ElementUsageRowViewModel"/> class /// </summary> /// <param name="elementUsage"> /// The <see cref="ElementUsage"/> associated with this row /// </param> /// <param name="option"> /// The selected <see cref="Option"/> for the browser this row is contained in /// </param> /// <param name="session"> /// The session. /// </param> /// <param name="containerRow"> /// The <see cref="ElementDefinitionRowViewModel"/> parent row. /// </param> public ElementUsageRowViewModel(ElementUsage elementUsage, Option option, ISession session, IRowViewModelBase <Thing> containerRow) : base(elementUsage, session, containerRow) { this.Option = option; this.parameterOrOverrideBaseCache = new Dictionary <ParameterBase, IRowViewModelBase <ParameterOrOverrideBase> >(); this.parameterOrOverrideContainerMap = new Dictionary <ParameterBase, ParameterGroup>(); this.parameterGroupCache = new Dictionary <ParameterGroup, ParameterGroupRowViewModel>(); this.parameterGroupContainment = new Dictionary <ParameterGroup, ParameterGroup>(); this.UpdateElementDefinitionProperties(); this.UpdateProperties(); this.UpdateTooltip(); }
/// <summary> /// Initializes a new instance of the <see cref="ParameterStateRowViewModel"/> class /// </summary> /// <param name="parameterBase">The associated <see cref="ParameterBase"/></param> /// <param name="option">The associated <see cref="Option"/></param> /// <param name="actualState">The associated <see cref="ActualFiniteState"/></param> /// <param name="session">The associated <see cref="ISession"/></param> /// <param name="containerViewModel">The container row</param> /// <param name="isReadOnly">A value indicating whether the row is read-only</param> public ParameterStateRowViewModel(ParameterBase parameterBase, Option option, ActualFiniteState actualState, ISession session, IRowViewModelBase <Thing> containerViewModel, bool isReadOnly) : base(parameterBase, session, option, actualState, containerViewModel, 0, isReadOnly) { this.Name = this.ActualState.Name; this.State = this.ActualState.Name; this.IsDefault = this.ActualState.IsDefault; this.Option = this.ActualOption; this.InitializeOptionSubscriptions(); }
/// <summary> /// Initializes a new instance of the <see cref="DiagramDeleteEvent"/> class /// </summary> /// <param name="viewModelDeleted">The view-model instance to delete</param> public DiagramDeleteEvent(IRowViewModelBase <Thing> viewModelDeleted) { this.ViewModel = viewModelDeleted; }
/// <summary> /// Initializes a new instance of the <see cref="ParameterStateRowViewModel"/> class /// </summary> /// <param name="parameterBase">The associated <see cref="ParameterBase"/></param> /// <param name="option">The associated <see cref="Option"/></param> /// <param name="actualState">The associated <see cref="ActualFiniteState"/></param> /// <param name="session">The associated <see cref="ISession"/></param> /// <param name="containerViewModel">The container row</param> /// <param name="isDialogReadOnly">Value indicating whether this row should be read-only because the dialog is read-only</param> public ParameterStateRowViewModel(ParameterBase parameterBase, Option option, ActualFiniteState actualState, ISession session, IRowViewModelBase <Thing> containerViewModel, bool isDialogReadOnly = false) : base(parameterBase, session, option, actualState, containerViewModel, 0, isDialogReadOnly) { this.Name = this.ActualState.Name; this.State = this.ActualState.Name; this.Option = this.ActualOption; }
/// <summary> /// Initializes a new instance of the <see cref="PublicationParameterOrOverrideRowViewModel"/> class /// </summary> /// <param name="parameterOrOverrideBase"> /// The associated <see cref="ParameterOrOverrideBase"/> /// </param> /// <param name="session"> /// The associated <see cref="ISession"/> /// </param> /// <param name="containerViewModel"> /// The container Row. /// </param> public PublicationParameterOrOverrideRowViewModel(ParameterOrOverrideBase parameterOrOverrideBase, ISession session, IRowViewModelBase <Thing> containerViewModel) : base(parameterOrOverrideBase, session, containerViewModel, false) { this.WhenAnyValue(vm => vm.ToBePublished).Subscribe(_ => this.ToBePublishedChanged()); this.IsCheckable = true; this.SetProperties(); }
/// <summary> /// Adds the list of <see cref="ParameterBase"/> /// </summary> /// <param name="addedParameterBase">The <see cref="ParameterBase"/>s to add</param> protected void AddParameterBase(IEnumerable <ParameterBase> addedParameterBase) { foreach (var parameterBase in addedParameterBase) { IRowViewModelBase <ParameterBase> row = null; var parameter = parameterBase as Parameter; if (parameter != null) { row = new ParameterRowViewModel(parameter, this.Session, this, typeof(T) == typeof(ElementUsage)); this.AddParameterOrOverrideListener(parameter); } var parameterOverride = parameterBase as ParameterOverride; if (parameterOverride != null) { row = new ParameterOverrideRowViewModel(parameterOverride, this.Session, this); this.AddParameterOrOverrideListener(parameterOverride); } var parameterSubscription = parameterBase as ParameterSubscription; if (parameterSubscription != null) { var subscribedParameter = parameterSubscription.Container as Parameter; if (subscribedParameter != null) { row = new ParameterSubscriptionRowViewModel(parameterSubscription, this.Session, this, typeof(T) == typeof(ElementUsage)); } var subscribedParameterOverride = parameterSubscription.Container as ParameterOverride; if (subscribedParameterOverride != null) { row = new ParameterSubscriptionRowViewModel(parameterSubscription, this.Session, this, false); } this.AddParameterSubscriptionListener(parameterSubscription); } if (row == null) { throw new NotSupportedException("The ParameterBase is neither a Parameter or a Subscription."); } this.parameterBaseCache.Add(parameterBase, row); var group = parameterBase.Group; this.parameterBaseContainerMap.Add(parameterBase, group); if (group == null) { this.ContainedRows.SortedInsert(row, ChildRowComparer); } else { ParameterGroupRowViewModel parameterGroupRowViewModel; if (this.parameterGroupCache.TryGetValue(group, out parameterGroupRowViewModel)) { parameterGroupRowViewModel.ContainedRows.SortedInsert(row, ParameterGroupRowViewModel.ChildRowComparer); } } } }
/// <summary> /// Initializes a new instance of the <see cref="ParameterStateRowViewModel"/> class /// </summary> /// <param name="parameterBase">The associated <see cref="ParameterBase"/></param> /// <param name="option">The associated <see cref="Option"/></param> /// <param name="actualState">The associated <see cref="ActualFiniteState"/></param> /// <param name="session">The associated <see cref="ISession"/></param> /// <param name="containerViewModel">The container row</param> /// <param name="isReadOnly">A value indicating whether the row is read-only</param> public ParameterStateRowViewModel(ParameterBase parameterBase, Option option, ActualFiniteState actualState, ISession session, IRowViewModelBase <Thing> containerViewModel, bool isReadOnly) : base(parameterBase, session, option, actualState, containerViewModel, 0, isReadOnly) { this.Name = this.ActualState.Name; this.State = this.ActualState.Name; this.IsDefault = this.ActualState.IsDefault; this.Option = this.ActualOption; foreach (var possibleFiniteState in this.ActualState.PossibleState) { var stateListener = CDPMessageBus.Current.Listen <ObjectChangedEvent>(possibleFiniteState) .Where(objectChange => objectChange.EventKind == EventKind.Updated) .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(x => { this.Name = this.ActualState.Name; }); this.Disposables.Add(stateListener); } }