Пример #1
0
        /// <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;
        }
 void IBindable <ViewModelControlCollection> .Bind(ViewModelControlCollection target)
 {
     foreach (IBindable <ViewModelControlCollection> item in Items)
     {
         item.Bind(target);
     }
 }
        /// <summary>
        /// Cleans up when this <see cref="ViewModelStrategyEditCollection"/> is no longer required.
        /// </summary>
        /// <param name="disposing">True if this object is being disposed.</param>
        protected virtual void Dispose(bool disposing)
        {
            if (!_disposed)
            {
                if (disposing)
                {
                    foreach (StrategyEditViewModel strategyEdit in this)
                    {
                        foreach (ControlViewModel control in _controls)
                        {
                            string targetParameter = control.UnderlyingControl.ParameterRef;

                            if (strategyEdit.Sources.Contains(targetParameter))
                            {
                                control.UnbindStrategyEdit(strategyEdit);
                            }
                        }
                    }

                    _controls = null;
                }

                _disposed = true;
            }
        }
Пример #4
0
        void IBindable <ViewModelControlCollection> .Bind(ViewModelControlCollection target)
        {
            _log.Debug(m => m("Binding state rules for control Id={0}.", _owningControl.Id));

            foreach (IBindable <ViewModelControlCollection> item in Items)
            {
                item.Bind(target);
            }
        }
        /// <summary>
        /// Initializes a new <see cref="ViewModelStrategyEditCollection"/>.
        /// </summary>
        /// <param name="underlyingStrategyEdits">Set of <see cref="StrategyEdit_t"/>s that this collection is responsible for.</param>
        /// <param name="controls">Collection of controls for the strategy this <see cref="ViewModelStrategyEditCollection"/>
        /// corresponds to.</param>
        public ViewModelStrategyEditCollection(StrategyEditCollection underlyingStrategyEdits, ViewModelControlCollection controls)
        {
            foreach (StrategyEdit_t strategyEdit in underlyingStrategyEdits)
            {
                _controls = controls;

                StrategyEditViewModel strategyEditViewModel = new StrategyEditViewModel(strategyEdit);

                Add(strategyEditViewModel);

                strategyEditViewModel.Bind(from c in _controls
                                           where c.ParameterRef != null && strategyEdit.Sources.Contains(c.ParameterRef)
                                           select c);
            }
        }