/// <summary>
        /// Evaluates all strategy edits within the currently selected strategy.
        /// </summary>
        /// <param name="inputValueProvider">Provider that providers access to any additional FIX field values that may
        /// be required in the Edit evaluation.</param>
        /// <returns>Summary state of all StrategyEdits after the evaluation.</returns>
        public bool EvaluateAllStrategyEdits(IInitialFixValueProvider inputValueProvider)
        {
            FixFieldValueProvider additionalValues = inputValueProvider == null ?
                                                     FixFieldValueProvider.Empty : new FixFieldValueProvider(inputValueProvider, _underlyingStrategy.Parameters);

            return(StrategyEdits.EvaluateAll(additionalValues));
        }
        /// <summary>
        /// Initializes a new <see cref="StrategyViewModel"/>
        /// </summary>
        /// <param name="strategy"><see cref="Strategy_t"/> for this View Model.</param>
        public StrategyViewModel(Strategy_t strategy, IInitialFixValueProvider initialValueProvider)
        {
            _underlyingStrategy = strategy;

            Controls      = new ViewModelControlCollection(strategy, initialValueProvider);
            StrategyEdits = Controls.StrategyEdits;
        }
Example #3
0
        /// <summary>
        /// Evaluate all the <see cref="StrategyEdit_t">StrategyEdit</see>s for this strategy.
        /// </summary>
        /// <param name="inputValueProvider">Provider that providers access to any additional FIX field values that may
        /// be required in the Edit evaluation.</param>
        /// <param name="shortCircuit">If true, this method returns as soon as any error is found; if false, all StrategyEdits
        /// are evaluated before the method returns.</param>
        public bool EvaluateAllStrategyEdits(IInitialFixValueProvider inputValueProvider, bool shortCircuit)
        {
            FixFieldValueProvider additionalValues = inputValueProvider == null ?
                                                     FixFieldValueProvider.Empty : new FixFieldValueProvider(inputValueProvider, Parameters);

            return(_strategyEdits.EvaluateAll(additionalValues, shortCircuit));
        }
        /// <summary>
        /// Evaluates all strategy edits within the currently selected strategy.
        /// </summary>
        /// <param name="inputValueProvider">Provider that providers access to any additional FIX field values that may
        /// be required in the Edit evaluation.</param>
        /// <returns>Summary state of all StrategyEdits after the evaluation.</returns>
        public bool EvaluateAffectedStrategyEdits(IInitialFixValueProvider inputValueProvider, FixField updatedField)
        {
            FixFieldValueProvider additionalValues = inputValueProvider == null ?
                                                     FixFieldValueProvider.Empty : new FixFieldValueProvider(inputValueProvider, _underlyingStrategy.Parameters);

            bool result = StrategyEdits.EvaluateAffected(additionalValues, updatedField);

            foreach (ControlViewModel control in Controls)
            {
                control.OnValueChangeCompleted();
            }

            return(result);
        }
        /// <summary>
        /// Initializes a new <see cref="ViewModelControlCollection"/>
        /// </summary>
        /// <param name="strategy">Strategy that the underlying controls belong to.</param>
        /// <param name="mode">Data entry mode.</param>
        public ViewModelControlCollection(Strategy_t strategy, IInitialFixValueProvider initialValueProvider)
        {
            foreach (Control_t control in strategy.Controls)
            {
                ControlViewModel controlViewModel = ControlViewModel.Create(strategy, control, initialValueProvider);

                Add(controlViewModel);

                controlViewModel.ValueChangeCompleted   += new EventHandler <ValueChangeCompletedEventArgs>(ControlValueChangeCompleted);
                controlViewModel.ValidationStateChanged += new EventHandler <ValidationStateChangedEventArgs>(ControlValidationStateChanged);

                // Special treatment for radio buttons under Framework 3.5
#if !NET462
                if (control is RadioButton_t)
                {
                    RegisterRadioButton(control as RadioButton_t, controlViewModel as RadioButtonViewModel);
                }
#endif
            }

            _strategyEdits = new ViewModelStrategyEditCollection(strategy.StrategyEdits, this);

            BindStateRules();
        }
Example #6
0
        /// <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);
        }
 /// <summary>
 /// Initializes a new <see cref="FixFieldValueProvider"/> instance using the supplied set of input
 /// values and parameters.
 /// </summary>
 /// <param name="fixValues">Input FIX fields to use.</param>
 /// <param name="parameters">Parameters to use.</param>
 public FixFieldValueProvider(IInitialFixValueProvider initialValueProvider, ParameterCollection parameters)
 {
     _initialValueProvider = initialValueProvider;
     _parameters           = parameters;
 }