コード例 #1
0
ファイル: Config.cs プロジェクト: alexevil1979/alexevil
        // **********************************************************************

        public static void LoadUserConfig(string fn)
        {
            try
            {
                using (Stream fs = File.OpenRead(fn))
                {
                    XmlSerializer xs = new XmlSerializer(typeof(UserSettings35));
                    u = (UserSettings35)xs.Deserialize(fs);
                }

                Reinit();
            }
            catch (Exception e)
            {
                if (!(u == null && e is FileNotFoundException))
                {
                    // Program.ShowMessage("Ошибка загрузки конфигурационного файла:\n" + e.Message
                    //   + "\nИспользованы исходные настройки.", MessageBoxImage.Exclamation);

                    if (u == null)
                    {
                        u = new UserSettings35();
                        Reinit();
                    }
                }
            }
        }
コード例 #2
0
        // **********************************************************************
        // *                               Clone()                              *
        // **********************************************************************

        public UserSettings35 Clone()
        {
            UserSettings35 u = (UserSettings35)MemberwiseClone();

            u.GuideSources = (GuideSource[])GuideSources.Clone();
            u.ToneSources  = (ToneSource[])ToneSources.Clone();

            return(u);
        }
コード例 #3
0
ファイル: Config.cs プロジェクト: alexevil1979/alexevil
        // **********************************************************************
        // *                             Constructor                            *
        // **********************************************************************

        static cfg()
        {
            // ------------------------------------------------------------

            Version ver = Assembly.GetExecutingAssembly().GetName().Version;

            FullProgName = ProgName + " " + ver.Major.ToString() + "." + ver.Minor.ToString();

            // ------------------------------------------------------------

            ExecFile = Assembly.GetExecutingAssembly().Location;
            string fs = ExecFile.Remove(ExecFile.LastIndexOf('.') + 1);

            UserCfgFile = fs + UserCfgFileExt;
            StatCfgFile = fs + "sc";

            AsmPath      = fs.Remove(fs.LastIndexOf('\\') + 1);
            TradeLogFile = fs + "trades." + TradeLogFileExt;

            // ------------------------------------------------------------

            BaseCulture = (CultureInfo)CultureInfo.CurrentCulture.Clone();
            BaseCulture.NumberFormat.NumberDecimalDigits = 0;

            PriceFormat = (NumberFormatInfo)NumberFormatInfo.CurrentInfo.Clone();

            // ------------------------------------------------------------

#if DEBUG
            s = new StatSettings();
            u = new UserSettings35();
            Reinit();
#endif

            // ------------------------------------------------------------
        }
コード例 #4
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);
            }
        }