Example #1
0
        void SetActiveStreams(PlayerWrapper pw)
        {
            for (int i = 0; i < pw.Player.FileHeader.StreamsCount; i++)
            {
                Player.Stream s = pw.Player[i];

                switch (s.Header.Type)
                {
                case StreamType.Stock: s.IsActive = readStock.IsChecked == true; break;

                //  case StreamType.Ticks: s.IsActive = readTicks.IsChecked == true; break;
                case StreamType.Orders: s.IsActive = readOwns.IsChecked == true; break;

                case StreamType.Trades: s.IsActive = readOwns.IsChecked == true; break;
                    //  case StreamType.Messages: s.IsActive = readMsgs.IsChecked == true; break;
                }
            }
        }
Example #2
0
        private void ButtonAdd_Click(object sender, RoutedEventArgs e)
        {
            System.Windows.Forms.OpenFileDialog fd = new System.Windows.Forms.OpenFileDialog();

            fd.Filter           = "История торгов QScalp (*." + cfg.HistoryFileExt + ")|*." + cfg.HistoryFileExt;
            fd.RestoreDirectory = true;
            fd.InitialDirectory = cfg.u.RecorderFolder;
            fd.Title            = "Добавить файлы для воспроизведения";
            fd.Multiselect      = true;
            if (fd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                StopPlay();

                foreach (string fn in fd.FileNames)
                {
                    bool unique = true;

                    foreach (PlayerWrapper epw in players)
                    {
                        if (epw.Player.FilePath == fn)
                        {
                            unique = false;
                            break;
                        }
                    }

                    if (unique)
                    {
                        PlayerWrapper pw = new PlayerWrapper(fn);

                        if (players.Count == 0)
                        {
                            DateTime localDateTime = pw.Player.FileHeader.BaseDateTime.ToLocalTime();

                            dateYear.Content  = localDateTime.Year.ToString();
                            dateMonth.Content = localDateTime.Month;
                            dateDay.Content   = localDateTime.Day;
                            timeHour.Content  = localDateTime.Hour;
                            timeMin.Content   = localDateTime.Minute;
                            timeSec.Content   = localDateTime.Second;

                            bool stock    = false;
                            bool ticks    = false;
                            bool orders   = false;
                            bool trades   = false;
                            bool messages = false;

                            bool stockExist = false;

                            for (int i = 0; i < pw.Player.FileHeader.StreamsCount; i++)
                            {
                                Player.Stream s = pw.Player[i];

                                switch (s.Header.Type)
                                {
                                case StreamType.Stock:
                                    stock = true;

                                    if (stockExist)
                                    {
                                        s.IsActive = false;
                                    }
                                    {
                                        stockExist = true;

                                        if ((cfg.u.SecCode != s.Header.Security.SecCode ||
                                             cfg.u.ClassCode != s.Header.Security.ClassCode ||
                                             cfg.u.PriceRatio != s.Header.PriceRatio ||
                                             cfg.u.PriceStep != s.Header.PriceStep) &&
                                            MessageBox.Show(this, "В добавляемом файле обнаружены данные биржевого стакана\n"
                                                            + s.Header.Security + " (шаг " + ((double)s.Header.PriceStep / s.Header.PriceRatio)
                                                            + " пт). Настроить привод на этот инструмент?", cfg.ProgName, MessageBoxButton.OKCancel,
                                                            MessageBoxImage.Question) == MessageBoxResult.OK)
                                        {
                                            UserSettings35 old = cfg.u.Clone();

                                            cfg.u.SecCode    = s.Header.Security.SecCode;
                                            cfg.u.ClassCode  = s.Header.Security.ClassCode;
                                            cfg.u.PriceRatio = s.Header.PriceRatio;
                                            cfg.u.PriceStep  = s.Header.PriceStep;

                                            cfg.Reinit();

                                            if (ConfigChecker != null)
                                            {
                                                ConfigChecker(old);
                                            }
                                        }
                                    }

                                    break;

                                case StreamType.Ticks: ticks = true; break;

                                case StreamType.Orders: orders = true; break;

                                case StreamType.Trades: trades = true; break;

                                case StreamType.Messages: messages = true; break;
                                }
                            }

                            readStock.IsChecked = stock;
                            //  readTicks.IsChecked = ticks;
                            readOwns.IsChecked = orders || trades;
                            //    readMsgs.IsChecked = messages;

                            players.Add(pw);
                        }
                        else
                        {
                            SetActiveStreams(pw);
                            players.Add(pw);
                        }
                    }
                }
            }
            else if (players.Count == 0)
            {
                MktProvider.SetMode(true, readOwns.IsChecked == true);
            }
        }