public void ControlMarket_PreviewKeyUp(object sender, KeyEventArgs e)
 {
     if (e.Key == Key.L && IsMouseInControlStock())
     {
         SelectionMode.IsModeDrawLevel           = false;
         ControlStockInstance.IsNeedRepaintDeals = true;
     }
     else if (e.Key == Key.Z && IsMouseInControlStock())
     {
         SelectionMode.IsModeStopLossTakeProfit  = false;
         ControlStockInstance.IsNeedRepaintDeals = true;
     }
     else if (e.Key == Key.Q && IsMouseInControlStock())
     {
         SelectionMode.IsModeStopLossInvert      = false;
         ControlStockInstance.IsNeedRepaintDeals = true;
     }
     else if (e.Key == Key.S && IsMouseInControlStock())
     {
         SelectionMode.IsModeStopOrder           = false;
         ControlStockInstance.IsNeedRepaintDeals = true;
     }
     else if (((e.SystemKey == Key.LeftAlt) || e.SystemKey == Key.RightAlt) &&
              IsMouseInControlStock())
     {
         SelectionMode.IsModeRestOrder = false;
     }
     {
         ControlDealsInstance.UpdateLevelsAndCondOrders();
         ControlStockInstance.IsNeedRepaintDeals = true;
     }
 }
        public void ControlMarket_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            var t = sender.GetType();

            //TODO normal
            if (t.Name != "MainWindow")
            {
                return;
            }
            //Thread.Sleep(0);

            //ControlStockInstance.LastClickCoord = 3.0;

            //TODO get key's list from config
            if (e.Key == Key.RightCtrl || e.Key == Key.LeftCtrl)
            {
                ExecuteCommand(EventsViewModel.CmdCancellAllOrders);
                ExecuteCommand(EventsViewModel.CmdCloseAllPositions);
            }
            else if (e.Key == Key.NumPad0)
            {
                InvertPosition();
            }
            else if (e.Key == Key.Up || e.Key == Key.Down)
            {
                SendThrowOrder(e.Key);
            }
            else if (e.Key == Key.LeftShift || e.Key == Key.RightShift)
            {
                TriggerCenteringStock();
            }

            else if (e.Key == Key.Space)
            {
                ExecuteCommand(EventsViewModel.CmdCancellAllOrders);
            }

            else if (e.Key == Key.L && IsMouseInControlStock())
            {
                SelectionMode.IsModeDrawLevel           = true;
                ControlStockInstance.IsNeedRepaintDeals = true;
            }
            else if (e.Key == Key.Z && IsMouseInControlStock())
            {
                SelectionMode.IsModeStopLossTakeProfit  = true;
                ControlStockInstance.IsNeedRepaintDeals = true;
            }
            else if (e.Key == Key.Q && IsMouseInControlStock())
            {
                SelectionMode.IsModeStopLossInvert      = true;
                ControlStockInstance.IsNeedRepaintDeals = true;
            }
            else if (e.Key == Key.S && IsMouseInControlStock())
            {
                SelectionMode.IsModeStopOrder           = true;
                ControlStockInstance.IsNeedRepaintDeals = true;
            }
            else if (((e.SystemKey == Key.LeftAlt) || e.SystemKey == Key.RightAlt) &&
                     IsMouseInControlStock())
            {
                SelectionMode.IsModeRestOrder           = true;
                ControlStockInstance.IsNeedRepaintDeals = true;
            }
            else if (e.Key == Key.Add && IsMouseInControlMarket())
            {
                ExecuteCommand(EventsViewModel.CmdIncreaseMinStep);
            }

            else if (e.Key == Key.Subtract && IsMouseInControlMarket())
            {
                ExecuteCommand(EventsViewModel.CmdDecreaseMinStep);
            }


            ControlDealsInstance.UpdateLevelsAndCondOrders();
        }