Example #1
0
 // todo: simplify to list.firstOr Default, remove
 private ButtonBase GetPressedCommonButton(SystemToolButton btnType)
 {
     var coll = panelCommonTools.Controls;
     foreach (Control c in coll)
     {
         var btn = c as ButtonBase;
         if (btn == null)
             continue;
         if (btn.Tag == null)
             continue;
         var sets = btn.Tag as ChartToolButtonSettings;
         if (sets == null)
             continue;
         if (btnType == sets.SystemTool)
             return btn;
     }
     return null;
 }
 public static Cortege2 <string, bool> GetButtonDisplayName(SystemToolButton type)
 {
     return(buttonsNames.ContainsKey(type) ? buttonsNames[type] : new Cortege2 <string, bool>());
 }
Example #3
0
        private void ExecuteCommonButtonsCommand(SystemToolButton btn, out bool newBtnState)
        {
            var pressedBtn = GetPressedCommonButton(btn);
            CheckBox checkBox = null;
            if (pressedBtn != null)
                checkBox = pressedBtn as CheckBox;
            // стандартное поведение терминальной кнопки - сразу отпуститься
            newBtnState = false;

            switch (btn)
            {
                case SystemToolButton.RobotsStart:
                    StartStopRobotFarm();
                    if (checkBox == null)
                        return;
                    newBtnState = checkBox.Checked;
                    break;
                case SystemToolButton.Indicators:
                case SystemToolButton.ZoomIn:
                case SystemToolButton.ZoomOut:
                    if (ActiveMdiChild == null || !(ActiveMdiChild is ChartForm))
                        return;
                    var chart = (ChartForm) ActiveMdiChild;
                    switch (btn)
                    {
                        case SystemToolButton.Indicators:
                            chart.chart.MenuitemIndicatorsDlgClick(null, null);
                            break;
                        case SystemToolButton.ZoomIn:
                            chart.chart.ZoomIn();
                            break;
                        case SystemToolButton.ZoomOut:
                            chart.chart.ZoomOut();
                            break;
                    }
                    break;
                case SystemToolButton.Account:
                    MenuWindowAccountClick(this, null);
                    break;
                case SystemToolButton.SetOrder:
                    MenuItemNewOrderClick(null, null);
                    break;
                case SystemToolButton.RollGraph:
                    if (checkBox == null)
                        return;
                    if (ActiveMdiChild == null || ActiveMdiChild is ChartForm == false)
                        return;
                    chart = (ChartForm) ActiveMdiChild;
                    newBtnState = checkBox.Checked;
                    chart.chart.chart.StockSeries.AutoScroll = newBtnState;
                    break;
                case SystemToolButton.RollAllGraphs:
                    if (checkBox == null)
                        return;
                    newBtnState = checkBox.Checked;
                    foreach (var ch in Charts)
                        ch.chart.chart.StockSeries.AutoScroll = newBtnState;
                    break;
                case SystemToolButton.Forecast:
                    if (ActiveMdiChild == null || !(ActiveMdiChild is ChartForm))
                        return;
                    chart = (ChartForm) ActiveMdiChild;
                    chart.chart.PublishForecast();
                    break;

                case SystemToolButton.MakeSignalChart:
                    if (ActiveMdiChild == null || !(ActiveMdiChild is ChartForm))
                        return;
                    chart = (ChartForm) ActiveMdiChild;
                    OnPublishTradeSignal(chart.chart);
                    break;

                case SystemToolButton.MakeSignalText:
                    if (ActiveMdiChild == null || !(ActiveMdiChild is ChartForm))
                        return;
                    chart = (ChartForm) ActiveMdiChild;
                    OnMakeNewSignalMessage(chart.chart);
                    break;
                case SystemToolButton.ChatWindow:
                    EnsureChatWindow();
                    break;
                case SystemToolButton.RobotPortfolio:
                    if (menuitemRobotPortfolio.Enabled)
                        MenuItemRobotsSetupClick(this, new EventArgs());
                    break;
                case SystemToolButton.RobotState:
                    if (menuitemRobotState.Enabled)
                        MenuitemRobotStateClick(this, new EventArgs());
                    break;
                case SystemToolButton.TradeSignals:
                    EnsureSubscriptionForm(SubscriptionControl.ActivePage.Subscription);
                    break;
            }
        }