/// <summary> /// Gets the value corresponding to a value property. /// The value type can be obtained from <see cref="ValuePropertyTypeTable"/>. /// </summary> /// <param name="propertyName">Property name.</param> /// <param name="value">Value of the property upon return.</param> /// <param name="minValue">Min value of the property upon return. Only applies to enum and booleans.</param> /// <param name="maxValue">Max value of the property upon return. Only applies to enum and booleans.</param> public virtual void PropertyToValue(string propertyName, out object value, out int minValue, out int maxValue) { Debug.Assert(!string.IsNullOrEmpty(propertyName)); Debug.Assert(ValuePropertyTypeTable.ContainsKey(propertyName)); value = null; minValue = -1; maxValue = -1; bool IsHandled = false; switch (ValuePropertyTypeTable[propertyName]) { case ValuePropertyType.Boolean: case ValuePropertyType.Enum: value = NodeTreeHelper.GetEnumValue(Node, propertyName); NodeTreeHelper.GetEnumRange(Node.GetType(), propertyName, out minValue, out maxValue); IsHandled = true; break; case ValuePropertyType.String: value = NodeTreeHelper.GetString(Node, propertyName); IsHandled = true; break; case ValuePropertyType.Guid: value = NodeTreeHelper.GetGuid(Node, propertyName); IsHandled = true; break; } Debug.Assert(IsHandled); }
/// <summary> /// Create cells for the provided state view. /// </summary> /// <param name="context">Context used to build the cell view tree.</param> /// <param name="parentCellView">The parent cell view.</param> public override IFrameCellView BuildNodeCells(IFrameCellViewTreeContext context, IFrameCellViewCollection parentCellView) { IFrameNodeState State = context.StateView.State; int Value = NodeTreeHelper.GetEnumValue(State.Node, PropertyName); Debug.Assert(Value >= 0 && Value < Items.Count); IFrameKeywordFrame KeywordFrame = Items[Value]; IFrameDiscreteContentFocusableCellView CellView = CreateDiscreteContentFocusableCellView(context.StateView, parentCellView, KeywordFrame); ValidateDiscreteContentFocusableCellView(context, KeywordFrame, CellView); return(CellView); }
/// <summary> /// Prints the selection. /// </summary> public virtual void Print() { ILayoutControllerView ControllerView = StateView.ControllerView; Debug.Assert(ControllerView.PrintContext != null); ControllerView.UpdateLayout(); Debug.Assert(RegionHelper.IsValid(StateView.ActualCellSize)); ILayoutTemplateSet TemplateSet = ControllerView.TemplateSet; IList <IFocusFrameSelectorList> SelectorStack = StateView.GetSelectorStack(); ILayoutDiscreteFrame Frame = (ILayoutDiscreteFrame)TemplateSet.PropertyToFrame(StateView.State, PropertyName, SelectorStack); Debug.Assert(Frame != null); int Value = NodeTreeHelper.GetEnumValue(StateView.State.Node, PropertyName); Frame.Print(ControllerView.PrintContext, Value, Point.Origin); }
/// <summary> /// Checks if the enum or boolean associated to the <paramref name="propertyName"/> property of the <paramref name="stateView"/> state has value <paramref name="defaultValue"/>. /// </summary> /// <param name="stateView">The state view for the node with property <paramref name="propertyName"/>.</param> /// <param name="propertyName">Name of the property pointing to the template to check.</param> /// <param name="defaultValue">Expected default value.</param> public virtual bool DiscreteHasDefaultValue(IFocusNodeStateView stateView, string propertyName, int defaultValue) { IFocusNodeState State = stateView.State; Debug.Assert(State.ValuePropertyTypeTable.ContainsKey(propertyName)); bool IsHandled = false; bool Result = false; switch (State.ValuePropertyTypeTable[propertyName]) { case ValuePropertyType.Boolean: case ValuePropertyType.Enum: Result = NodeTreeHelper.GetEnumValue(State.Node, propertyName) == defaultValue; IsHandled = true; break; } Debug.Assert(IsHandled); return(Result); }
private protected virtual void ExecuteChangeDiscreteValue(WriteableChangeDiscreteValueOperation operation) { Node ParentNode = operation.ParentNode; string PropertyName = operation.PropertyName; int NewValue = operation.NewValue; IWriteableNodeState State = (IWriteableNodeState)GetState(ParentNode); Debug.Assert(State != null); Debug.Assert(State.ValuePropertyTypeTable.ContainsKey(PropertyName)); Debug.Assert(State.ValuePropertyTypeTable[PropertyName] == Constants.ValuePropertyType.Boolean || State.ValuePropertyTypeTable[PropertyName] == Constants.ValuePropertyType.Enum); int OldValue = NodeTreeHelper.GetEnumValue(State.Node, PropertyName); NodeTreeHelper.GetEnumRange(Type.FromGetType(State.Node), PropertyName, out int Min, out int Max); Debug.Assert(NewValue >= Min && NewValue <= Max); NodeTreeHelper.SetEnumValue(State.Node, PropertyName, NewValue); operation.Update(State, OldValue); NotifyDiscreteValueChanged(operation); }
/// <summary> /// Copy the selection in the clipboard. /// </summary> /// <param name="dataObject">The clipboard data object that can already contain other custom formats.</param> public override void Copy(IDataObject dataObject) { int Content = NodeTreeHelper.GetEnumValue(StateView.State.Node, PropertyName); dataObject.SetData(typeof(int), Content); }