/// <summary> /// Writes the Grid.Row or Grid.Column attribute as appropriate for this control based on orientation of /// the panel this control is a member of. /// </summary> /// <param name="writer">WpfXmlWriter to use to write the XAML to.</param> /// <param name="control">Control.</param> public static void WriteGridAttribute(WpfXmlWriter writer, Control_t control) { bool isVertical = ((control as IParentable <StrategyPanel_t>).Parent.Orientation == Orientation_t.Vertical); writer.WriteAttribute(isVertical ? WpfXmlWriterAttribute.GridRow : WpfXmlWriterAttribute.GridColumn, control.Index.ToString()); }
// This is a bit of a hack to address a design deficiency in FIXatdl 1.1, whereby when doing order amendments // the state of any helper controls is not directly available from the input FIX fields. // To simplify matters, we only apply this algorithm in the scenario when the StateRule's immediate Edit_t // has a toggleable control as its source and the operator is 'EQ' (this is the same as atdl4j as at the // time of writing). private void UpdateRelatedHelperControls(Control_t control) { foreach (StateRule_t stateRule in control.StateRules) { Edit_t <Control_t> edit = stateRule.Edit; if (stateRule.Value == Atdl.NullValue && edit.Operator == Operator_t.Equal) { string sourceControlId = edit.Field; if (IsValidControlId(sourceControlId)) { Control_t sourceControl = this[sourceControlId]; bool result; if (sourceControl.IsToggleable && bool.TryParse(edit.Value, out result)) { // If the control is a radio button, then we can only set directly, un-set // has be done by setting its companion control if (sourceControl is CheckBox_t || !result) { sourceControl.SetValue(!result); } else { SetCompanionRadioButton(sourceControl as RadioButton_t); } } } } } }
/// <summary> /// Initializes a new ControlViewModel using the supplied <see cref="Control_t"/> as underlying control and the /// supplied <see cref="IParameter"/> as referenced parameter. /// </summary> /// <param name="control">Underlying Control_t for this ControlViewModel.</param> /// <param name="referencedParameter">Parameter that this control relates to. May be null.</param> protected ControlViewModel(Control_t control, IParameter referencedParameter) { UnderlyingControl = control; _referencedParameter = referencedParameter; // Set default data entry mode DataEntryMode = DataEntryMode.Create; _validationState = new ControlValidationState(control.Id); }
/// <summary> /// Loads the initial values for each control based on the InitPolicy, InitFixField and InitValue attributes. /// </summary> /// <param name="controlInitValueProvider">Value provider for initializing control values from InitFixField.</param> /// <remarks>The spec states: 'If the value of the initPolicy attribute is undefined or equal to "UseValue" and the initValue attribute is /// defined then initialize with initValue. If the value is equal to "UseFixField" then attempt to initialize with the value of /// the tag specified in the initFixField attribute. If the value is equal to "UseFixField" and it is not possible to access the /// value of the specified fix tag then revert to using initValue. If the value is equal to "UseFixField", the field is not accessible, /// and initValue is not defined, then do not initialize.</remarks> public void LoadDefaults(FixFieldValueProvider controlInitValueProvider) { Control_t control = null; try { foreach (Control_t thisControl in this) { control = thisControl; thisControl.LoadInitValue(controlInitValueProvider); } } catch (System.Exception ex) { throw ThrowHelper.Rethrow(this, ex, ErrorMessages.InitControlValueError, control != null ? control.Id : "(unknown)"); } }
/// <summary> /// Factory method for creating new ControlViewModel instances. /// </summary> /// <param name="underlyingStrategy"><see cref="Strategy_t"/> that this ControlViewModel's <see cref="Control_t"/> is a member of.</param> /// <param name="control">Underlying Control_t for this ControlViewModel.</param> /// <returns>New ControlViewModel instance.</returns> public static ControlViewModel Create(Strategy_t underlyingStrategy, Control_t control, IInitialFixValueProvider initialValueProvider) { IParameter referencedParameter = null; if (control.ParameterRef != null) { referencedParameter = underlyingStrategy.Parameters[control.ParameterRef]; if (referencedParameter == null) { throw ThrowHelper.New <ReferencedObjectNotFoundException>(ErrorMessages.UnresolvedParameterRefError, control.ParameterRef); } } ControlViewModel controlViewModel; #if !NET_40 // This is to workaround a bug in .NET Framework 3.5 where it is possible for more than one radio button in a // group to be checked at a time. if (control is RadioButton_t) { controlViewModel = new RadioButtonViewModel(control as RadioButton_t, referencedParameter); } else #endif if (control is ListControlBase) { controlViewModel = ListControlViewModel.Create(control as ListControlBase, referencedParameter); } else if (InvalidatableControlViewModel.IsInvalidatable(control)) { controlViewModel = InvalidatableControlViewModel.Create(control, referencedParameter); } else { controlViewModel = new ControlViewModel(control, referencedParameter); } controlViewModel._stateRules = new ViewModelStateRuleCollection(controlViewModel, control.StateRules); controlViewModel._fixFieldValues = new FixFieldValueProvider(initialValueProvider, underlyingStrategy.Parameters); return(controlViewModel); }
private static void RenderControlLabel(WpfXmlWriter writer, Control_t control, GridCoordinate gridCoordinate) { string label = control.Label; string forControl = control.Id; // Assumes that a control label will always be in the first cell of a 2 x 1 grid. if (!string.IsNullOrEmpty(label)) { using (writer.New(WpfXmlWriterTag.Label)) { writer.WriteAttribute(WpfXmlWriterAttribute.GridColumn, gridCoordinate.Column.ToString()); writer.WriteAttribute(WpfXmlWriterAttribute.GridRow, gridCoordinate.Row.ToString()); if (!string.IsNullOrEmpty(forControl)) { writer.WriteAttribute(WpfXmlWriterAttribute.Target, string.Format("{{Binding ElementName={0}}}", CleanName(forControl))); writer.WriteAttribute(WpfXmlWriterAttribute.IsEnabled, string.Format("{{Binding Path=Controls[{0}].Enabled}}", CleanName(forControl))); writer.WriteAttribute(WpfXmlWriterAttribute.Visibility, string.Format("{{Binding Path=Controls[{0}].Visibility}}", CleanName(forControl))); } writer.WriteAttribute(WpfXmlWriterAttribute.Content, label); } } }
public StateRuleCollection(Control_t owner) { _owner = owner; }
/// <summary> /// Non-specific control render method - this method should never get called. /// </summary> /// <param name="control">Control to render.</param> public void Visit(Control_t control) { throw new NotImplementedException(); }
/// <summary> /// Processes each control, i.e., renders the XAML for the supplied control. /// </summary> /// <param name="control">Control to generate XAML for.</param> public void ProcessControl(Control_t control) { control.DoVisit(this); }
/// <summary> /// Determines whether the supplied control is an invalidatable control. /// </summary> /// <param name="control">Control_t to check.</param> /// <returns>true if the control is invalidatable; false otherwise.</returns> public static bool IsInvalidatable(Control_t control) { return(control is SingleSpinner_t || control is DoubleSpinner_t || control is Clock_t); }
/// <summary> /// Factory method for creating new InvalidatableControlViewModel instances. /// </summary> /// <param name="control">Underlying Control_t for this ControlViewModel.</param> /// <param name="referencedParameter">Parameter that the specified Control_t relates to. May be null.</param> /// <returns>New instance of InvalidatableControlViewModel.</returns> public static InvalidatableControlViewModel Create(Control_t control, IParameter referencedParameter) { return(new InvalidatableControlViewModel(control, referencedParameter)); }
/// <summary> /// Initializes a new <see cref="InvalidatableControlViewModel"/> instance. /// </summary> /// <param name="control">Control that this control view model corresponds to.</param> /// <param name="referencedParameter">Parameter for this control. May be null.</param> private InvalidatableControlViewModel(Control_t control, IParameter referencedParameter) : base(control, referencedParameter) { }