Exemplo n.º 1
0
        private void ContextMenuAction(object param)
        {
            if (SelectedItem == null)
            {
                return;
            }
            var str = param.ToString().Split('/');

            switch (str[0])
            {
            case "Logbook":
            {
                var view = new LogBook();
                view.DataContext = new LogBookViewModel(SelectedItem.Board, SelectedItem.Seccode, view);
                view.Show();
                break;
            }

            case "Level2":
            {
                var view = new Level2();
                view.DataContext = new Level2ViewModel(SelectedItem.Board, SelectedItem.Seccode, view);
                view.Show();
                break;
            }

            case "AllTrades":
            {
                var view = new AllTradesSimple();
                view.DataContext = new AllTradesSimpleViewModel(SelectedItem.Board, SelectedItem.Seccode, view);
                view.Show();
                break;
            }

            case "AllTradesPro":
            {
                var view = new AllTrades();
                view.DataContext = new AllTradesViewModel(SelectedItem.Board, SelectedItem.Seccode, view);
                view.Show();
                break;
            }

            case "TradesCounter":
            {
                new AllTradesCounterWindow {
                    DataContext = new AllTradesCounterViewModel(SelectedItem.Board, SelectedItem.Seccode)
                }.Show();
                break;
            }

            case "Chart":
            {
                var view = new SciChartWindow();
                view.DataContext = new SciChartViewModel(SelectedItem.Board, SelectedItem.Seccode, view);
                view.Show();
                break;
            }

            case "NewOrder":
            {
                new NewOrder
                {
                    DataContext = new NewOrderViewModel
                    {
                        Board   = SelectedItem.Board,
                        Seccode = SelectedItem.Seccode
                    }
                }.Show();
                break;
            }

            case "NewStoporder":
            {
                new NewStopOrder
                {
                    DataContext = new NewStopOrderViewModel
                    {
                        Board   = SelectedItem.Board,
                        Seccode = SelectedItem.Seccode
                    }
                }.Show();
                break;
            }

            case "Cart":
                Application.Current.Dispatcher.Invoke(
                    () => ((MainWindowViewModel)Application.Current.MainWindow.DataContext).CartViewModel.Orders
                    .Add(new CartItem
                {
                    Board   = SelectedItem.Board,
                    Seccode = SelectedItem.Seccode,
                    Client  = SelectClient(SelectedItem.Board)[0],
                    Union   = SelectClient(SelectedItem.Board)[1],
                    Mkt     = true
                }));
                break;

            case "Spread":
            {
                new Spread
                {
                    DataContext = new SpreadViewModel(SelectedItem.Board, SelectedItem.Seccode)
                }.Show();
                break;
            }

            case "FastOrder":
            {
                var view = new FastOrder();
                view.DataContext = new FastOrderViewModel(SelectedItem.Board, SelectedItem.Seccode, view);
                view.Show();
                break;
            }

            case "Alert":
            {
                if (MainWindowViewModel.CheckIfWindowIsOpened(typeof(Alerts)))
                {
                    MainWindowViewModel.AlertsViewModel.AddAlert(SelectedItem.Board, SelectedItem.Seccode);
                }
                else
                {
                    new Alerts(MainWindowViewModel.AlertsViewModel).Show();
                    MainWindowViewModel.AlertsViewModel.AddAlert(SelectedItem.Board, SelectedItem.Seccode);
                }
                break;
            }
            }
        }