コード例 #1
0
        private void ExecuteLoadMarketMonitoringReport()
        {
            // Create OpenFileDialog
            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();

            string startupPath      = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName;
            string initialDirectory = startupPath + @"\View\Icons";

            dlg.InitialDirectory = initialDirectory;

            // Set filter for file extension and default file extension
            dlg.DefaultExt = ".png";
            dlg.Filter     = "Market monitoring reports | *.png";

            // Display OpenFileDialog by calling ShowDialog method
            bool?result = dlg.ShowDialog();

            // Get the selected file name and display in a TextBox
            if (result != true)
            {
                return;
            }

            // Open document
            string filename = dlg.FileName;

            MarketMonitoringWindow win = new MarketMonitoringWindow
            {
                DataContext =
                    new MarketMonitoringViewModel(CurrentMarketID, model.MarketInformationDict[CurrentMarketID],
                                                  OneSecIntervalTimer)
            };

            win.Show();
        }
コード例 #2
0
        private void ExecuteLoadMarketMonitoringReport()
        {
            try
            {
                //Получаем имя открываемого файла
                string filename = GetFileName();

                //Если ничего не открыли, уходим из метода
                if (filename == string.Empty)
                {
                    return;
                }

                //Десериализируем
                MarketInformation mi = GetMiFromXML(filename);

                //Создаем и показываем окно
                var vm  = new MarketMonitoringViewModel(mi, OneSecIntervalTimer, THIS_IS_HISTORY);
                var win = new MarketMonitoringWindow();
                win.DataContext = vm;
                win.Show();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }
コード例 #3
0
        private void ExecuteMarketMonitor()
        {
            var vm  = new MarketMonitoringViewModel(CurrentMarket, OneSecIntervalTimer, THIS_IS_NOT_HISTORY);
            var win = new MarketMonitoringWindow();

            win.DataContext = vm;

            //подписываемся на событие закрытия окна, для остановки WF
            win.Closed += vm.ViewClosed;

            win.Show();
        }
コード例 #4
0
        private void ExecuteMarketMonitor()
        {
            if (MarketsAreInMonitoring.ContainsKey(CurrentMarketID))
            {
                return;
            }

            MarketMonitoringWindow win = new MarketMonitoringWindow();

            MarketInformation         m  = model.MarketInformationDict[CurrentMarketID];
            MarketMonitoringViewModel vm = new MarketMonitoringViewModel(CurrentMarketID, m, OneSecIntervalTimer);

            win.DataContext = vm;

            //добавляем рынок в список окон мониторинга
            MarketsAreInMonitoring.Add(CurrentMarketID, new Tuple <MarketMonitoringWindow, MarketMonitoringViewModel>(win, vm));

            //при закрытии окна удаляем CurrentMarketID из списка мониторинга
            win.Closed += (sender, e) =>
            {
                MarketMonitoringWindow window = sender as MarketMonitoringWindow;

                string s = string.Empty;
                foreach (var item in MarketsAreInMonitoring)
                {
                    if (item.Value.Item1 != window)
                    {
                        continue;
                    }

                    s = item.Key;
                    break;
                }

                if (s == string.Empty)
                {
                    return;
                }

                MarketsAreInMonitoring[s].Item2.Dispose();
                MarketsAreInMonitoring.Remove(s);
            };

            win.Show();
        }