예제 #1
0
        public static void SetStrategy(this StrategyContent control, StrategyContainer strategy)
        {
            strategy.BindStrategyToScope(control);

            control.Strategy = strategy;

            if (strategy.SessionType == SessionType.Emulation)
            {
                control.EmulationService = new EmulationService(strategy);
            }

            control.ChildsLoaded += () =>
            {
                //после загрузки всех дочерних контролов можно запустить инициализацию по истории
                if (strategy.Security == null || strategy.Portfolio == null)
                {
                    return;
                }

                new ResetStrategyCommand(strategy).Process(control);

                if (strategy.SessionType == SessionType.Battle && strategy.GetIsAutoStart())
                {
                    new StartStrategyCommand(strategy).Process(strategy);
                }
            };
        }
        private IStudioControl OpenStrategyControl(StrategyContainer strategy, string contentTemplate)
        {
            return(OpenControl(strategy.Strategy.Id.To <string>(), typeof(StrategyContent), strategy, () =>
            {
                var ctrl = new StrategyContent();

                ctrl.SetStrategy(strategy);
                ctrl.LoadTemplate(contentTemplate ?? GetDefaultContentTemplate(strategy.StrategyInfo.Type, strategy.SessionType), false);

                return ctrl;
            }));
        }