コード例 #1
0
        public override void Save(SettingsStorage settings)
        {
            settings.SetValue("GridSettings", MdControl.Save());
            settings.SetValue("BuySellSettings", BuySellPanel.Save());

            base.Save(settings);
        }
コード例 #2
0
        public override void Load(SettingsStorage settings)
        {
            MdControl.Load(settings.GetValue <SettingsStorage>("GridSettings"));

            var buySellSettings = settings.GetValue <SettingsStorage>("BuySellSettings");

            if (buySellSettings != null)
            {
                BuySellPanel.Load(buySellSettings);
            }

            base.Load(settings);
        }
コード例 #3
0
 private void OnQuotesCellMouseRightButtonUp(DataGridCell cell, MouseButtonEventArgs e)
 {
     _actions.TryInvokeMouse(MdControl.GetColumnIndex(cell), e.ClickCount == 1 ? MouseAction.RightClick : MouseAction.RightDoubleClick, Keyboard.Modifiers);
 }
コード例 #4
0
        public ScalpingMarketDepthControl()
        {
            InitializeComponent();

            Settings.SecurityChanged += (arg1, arg2) =>
            {
                if (!_isLoaded)
                {
                    _needRequestData = true;
                }

                new RefuseMarketDataCommand(arg1, MarketDataTypes.MarketDepth).Process(this);
                new ClearMarketDepthCommand(arg2).Process(this);
                new RequestMarketDataCommand(arg2, MarketDataTypes.MarketDepth).Process(this);

                UpdateTitle();
            };

            //MdControl.Changed += () => new ControlChangedCommand(this).Process();
            MdControl.CanDrag  += OnQuotesCanDrag;
            MdControl.Dropping += OnQuotesDropping;

            //Quotes.ColumnsMoved += OnColumnsMoved;
            MdControl.CellMouseLeftButtonUp  += OnQuotesCellMouseLeftButtonUp;
            MdControl.CellMouseRightButtonUp += OnQuotesCellMouseRightButtonUp;

            //TODO добавить редактирование дейтсвией в пропгриде
            _actions = new MarketDepthControlActionList(MdControl)
            {
                new MarketDepthControlAction(MouseAction.LeftClick, ModifierKeys.None, (c, q) =>
                {
                    switch (c)
                    {
                    case MarketDepthColumns.Buy:
                    case MarketDepthColumns.Sell:
                        new RegisterOrderCommand(CreateOrder(c, q)).Process(this);
                        break;

                    case MarketDepthColumns.OwnBuy:
                    case MarketDepthColumns.OwnSell:
                        new CancelOrderCommand(CreateOrder(c, q)).Process(this);
                        break;
                    }
                }),
                new MarketDepthControlAction(Key.Escape, ModifierKeys.None, (c, q) => new CancelAllOrdersCommand().Process(this)),
            };

            var cmdSvc = ConfigManager.GetService <IStudioCommandService>();

            //cmdSvc.Register<SubscribeMarketDepthKeyActionCommand>(this, cmd => _actions.Add(new MarketDepthControlAction(cmd.Key, cmd.ModifierKey)));
            //cmdSvc.Register<SubscribeMarketDepthMouseActionCommand>(this, cmd => _actions.Add(new MarketDepthControlAction(cmd.MouseAction, cmd.ModifierKey)));
            //cmdSvc.Register<UnSubscribeMarketDepthKeyActionCommand>(this, cmd => _actions.Remove(new MarketDepthControlAction(cmd.Key, cmd.ModifierKey)));
            //cmdSvc.Register<UnSubscribeMarketDepthMouseActionCommand>(this, cmd => _actions.Remove(new MarketDepthControlAction(cmd.MouseAction, cmd.ModifierKey)));

            cmdSvc.Register <UpdateMarketDepthCommand>(this, false, cmd =>
            {
                if (Settings.Security == null || cmd.Depth.Security == Settings.Security)
                {
                    MdControl.UpdateDepth(cmd.Depth);
                }
            });
            cmdSvc.Register <ClearMarketDepthCommand>(this, false, cmd =>
            {
                if (Settings.Security == null || cmd.Security == Settings.Security)
                {
                    MdControl.Clear();
                }
            });
            cmdSvc.Register <OrderCommand>(this, false, cmd =>
            {
                if (Settings.Security != null && cmd.Order.Security != Settings.Security)
                {
                    return;
                }

                switch (cmd.Action)
                {
                case OrderActions.Registered:
                    MdControl.ProcessNewOrder(cmd.Order);
                    break;

                case OrderActions.Changed:
                    MdControl.ProcessChangedOrder(cmd.Order);
                    break;
                }
            });
            cmdSvc.Register <ResetedCommand>(this, false, cmd => new RequestMarketDataCommand(Settings.Security, MarketDataTypes.MarketDepth).Process(this));
            cmdSvc.Register <BindStrategyCommand>(this, false, cmd =>
            {
                _strategy = cmd.Source;
                UpdateTitle();
            });

            WhenLoaded(() =>
            {
                _isLoaded = true;

                new RequestBindSource(this).SyncProcess(this);

                if (_needRequestData)
                {
                    new RequestMarketDataCommand(Settings.Security, MarketDataTypes.MarketDepth).Process(this);
                }
            });
        }