Exemplo n.º 1
0
        public SearchElementLeftSide(WrapPanel picgridIn, Grid gridIn, Window windowIn)
        {
            InitializeComponent();
            picgrid         = picgridIn;
            grid            = gridIn;
            window          = (MainWindow)windowIn;
            window.Closing += delegate { watchlist.Close(); };
            watchlist       = new Watchlist(generalSearch, tagsSearch, artistSearch, charaSearch, parodySearch);
            watchlist.Show();

            this.Height = 1080;
            this.Width  = 228;
            this.HorizontalAlignment = HorizontalAlignment.Left;
            this.VerticalAlignment   = VerticalAlignment.Top;
            this.Name   = "sElement";
            this.Margin = new Thickness(50, 0, 0, 0);
        }
Exemplo n.º 2
0
        //opening windows
        public void OpenWindow(object param)
        {
            var parameter = param.ToString().Split('/');

            switch (parameter[0])
            {
            case "watchlist":
                var view = new Watchlist();
                view.DataContext = new WatchlistViewModel(parameter[1], view);
                view.Show();
                break;

            case "clients":
                if (CheckIfWindowIsOpened(typeof(Clients)))
                {
                    break;
                }
                //_clientsViewModel.Timer.Start();
                new Clients {
                    DataContext = ClientsViewModel
                }.Show();
                break;

            case "newOrder":
                if (CheckIfWindowIsOpened(typeof(NewOrder)))
                {
                    break;
                }
                new NewOrder {
                    DataContext = new NewOrderViewModel()
                }.Show();
                break;

            case "newStoporder":
                if (CheckIfWindowIsOpened(typeof(NewStopOrder)))
                {
                    break;
                }
                new NewStopOrder {
                    DataContext = new NewStopOrderViewModel()
                }.Show();
                break;

            case "trades":
                if (CheckIfWindowIsOpened(typeof(ClientTrades)))
                {
                    break;
                }
                new ClientTrades {
                    DataContext = ClientTradesViewModel
                }.Show();
                break;

            case "orders":
                if (CheckIfWindowIsOpened(typeof(ClientOrders)))
                {
                    break;
                }
                new ClientOrders {
                    DataContext = ClientOrdersViewModel
                }.Show();
                break;

            case "stoporders":
                if (CheckIfWindowIsOpened(typeof(ClientStoporders)))
                {
                    break;
                }
                new ClientStoporders {
                    DataContext = ClientOrdersViewModel
                }.Show();
                break;

            case "allTradesCounterFile":
                new AllTradesCounterWindow {
                    DataContext = new AllTradesCounterFromFile()
                }.Show();
                break;

            case "unitedPortfolio":
                new UnitedPortfolio {
                    DataContext = new UnitedPortfolioViewModel()
                }.Show();
                break;

            case "admin":
                if (CheckIfWindowIsOpened(typeof(AdminWindow)))
                {
                    break;
                }
                //new AdminWindow { DataContext = new AdminViewModel(Hub, DialogCoordinator.Instance) }.Show();
                new AdminWindow {
                    DataContext = AdminViewModel
                }.Show();
                break;

            case "news":
                if (CheckIfWindowIsOpened(typeof(Views.News)))
                {
                    break;
                }
                new Views.News {
                    DataContext = NewsViewModel
                }.Show();
                break;

            case "cart":
                if (CheckIfWindowIsOpened(typeof(Cart)))
                {
                    break;
                }
                new Cart {
                    DataContext = CartViewModel
                }.Show();
                break;

            case "fastOrder":
                var window = new FastOrder();
                window.DataContext = new FastOrderViewModel(null, null, window);
                window.Show();
                break;

            case "alerts":
                new Alerts(AlertsViewModel).Show();
                break;

            case "balance":
                new BalanceReport {
                    DataContext = BalanceReportViewModel
                }.Show();
                break;

            case "calendar":
                new CalendarMainWindow().Show();
                break;
            }
        }
Exemplo n.º 3
0
        private void OpenSavedWindows()
        {
            Task.Run(() =>
            {
                //Dispatcher.Invoke(() => {
                //    if (OpenWindows.Default.Clients)
                //        OpenWindow("clients");
                //    if (OpenWindows.Default.Trades)
                //        OpenWindow("trades");
                //    if (OpenWindows.Default.Orders)
                //        OpenWindow("orders");
                //    if (OpenWindows.Default.Stoporders)
                //        OpenWindow("stoporders");
                //});
                try
                {
                    //open watchlist first
                    var watchlists = WindowDataHandler.WindowPlacements.Where(w => w.Value.WindowType == typeof(Watchlist).ToString()).ToList();
                    if (watchlists.Count != 0)
                    {
                        //if there are any watchlists open them and wait for sub to take place
                        foreach (var watchlist in watchlists)
                        {
                            Dispatcher.Invoke(

                                () =>
                            {
                                var view         = new Watchlist();
                                view.DataContext = new WatchlistViewModel(watchlist.Value.Args, view, watchlist.Key);
                                view.Show();
                            });
                        }
                        Thread.Sleep(1000);
                    }
                    //then open other windows
                    foreach (var window in WindowDataHandler.WindowPlacements.Where(w => w.Value.WindowType != typeof(Watchlist).ToString()))
                    {
                        //create view
                        dynamic view = null;
                        //if level2
                        if (window.Value.WindowType == typeof(Level2).ToString() && window.Value.Args != null)
                        {
                            Dispatcher.Invoke(() =>
                            {
                                view = Activator.CreateInstance(Type.GetType(window.Value.WindowType), window.Value.Args);
                            });
                        }
                        //if alltrades
                        else if (window.Value.WindowType == typeof(AllTrades).ToString() && window.Value.Args != null)
                        {
                            //if (window.Value.Args is AllTradesArgs)
                            Dispatcher.Invoke(() =>
                            {
                                view = new AllTrades();
                            });
                            //else
                            //    Dispatcher.Invoke(() =>
                            //    {
                            //        view = new AllTrades((AllTradesArgs)((JObject)window.Value.Args).ToObject(typeof(AllTradesArgs)));
                            //    });
                        }
                        //if other
                        else
                        {
                            //if special window
                            if (window.Value.Args is string && window.Value.Args == "special_window")
                            {
                                Dispatcher.Invoke(() => OpenWindow(window.Value.ViewModelType));
                                continue;
                            }
                            Dispatcher.Invoke(() =>
                            {
                                view = Activator.CreateInstance(Type.GetType(window.Value.WindowType));
                            });
                        }
                        //create viewmodel
                        dynamic context = null;
                        //if chart
                        if (window.Value.ViewModelType == typeof(SciChartViewModel).ToString())
                        {
                            if (window.Value.Args != null /* && !(window.Value.Args is string)*/)
                            {
                                //ChartArgs args;
                                //if (window.Value.Args is ChartArgs)
                                ChartArgs args = window.Value.Args;
                                //else
                                //    args = (ChartArgs)((JObject)window.Value.Args).ToObject(typeof(ChartArgs));
                                context = new SciChartViewModel(
                                    window.Value.Board, window.Value.Seccode, view, window.Key, args.DaysBack,
                                    args.SelectedTimeframe, args.ToggleTrendlines);
                            }
                            else
                            {
//to avoid errors
                                context = Activator.CreateInstance(Type.GetType(window.Value.ViewModelType),
                                                                   window.Value.Board, window.Value.Seccode, view, window.Key, 0, "5 mins");
                            }
                        }
                        //if any other
                        else
                        {
                            Dispatcher.Invoke(() => {
                                context = Activator.CreateInstance(Type.GetType(window.Value.ViewModelType),
                                                                   window.Value.Board, window.Value.Seccode, view, window.Key);
                            });
                        }
                        //check if window is anchored
                        if (context is IAnchor)
                        {
                            context.IsAnchorEnabled = window.Value.IsAnchored;
                        }

                        Dispatcher.Invoke(() =>
                        {
                            view.DataContext = context;
                            view.Show();
                        });
                    }
                }
                catch (Exception e)
                {
                    Dialog.ShowMessageAsync(this, "Error", "There was an error opening your workspace");
                    WindowDataHandler.WindowPlacements.Clear();
                }
            });
        }