Example #1
0
        /// <summary>
        /// Загрузить параметры с файла.
        /// </summary>
        public static void Load()
        {
            if (!File.Exists(Filename))
            {
                MessageBox.Show("Can`t find logPolitics file.\n'" + Filename + "' not found\n", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                try
                {
                    Reset();
                    Save();
                }
                catch
                {
                    MessageBox.Show("Something Went Wrong", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Environment.Exit(1);
                }
                MessageBox.Show("Done", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            var data = ExOperators.Load(Filename);

            SavePrintLog               = bool.Parse(data["SavePrintLog"]);
            SaveSerialMonitorLog       = bool.Parse(data["SaveSerialMonitorLog"]);
            SaveManualControlLog       = bool.Parse(data["SaveManualControlLog"]);
            SaveGlobalPrintLog         = bool.Parse(data["SaveGlobalPrintLog"]);
            SaveGlobalVectLog          = bool.Parse(data["SaveGlobalVectLog"]);
            PrintLogNameFormat         = data["PrintLogNameFormat"];
            SerialMonitorLogNameFormat = data["SerialMonitorLogNameFormat"];
            ManualControlLogNameFormat = data["ManualControlLogNameFormat"];
            MacroLogNameFormat         = data["MacroLogNameFormat"];
            GlobalPrintLogNameFormat   = data["GlobalPrintLogNameFormat"];
            GlobalVectLogNameFormat    = data["GlobalVectLogNameFormat"];
        }
        /// <summary>
        /// Загружает параметры с файла опций.
        /// </summary>
        public static void Load()
        {
            Ver = Application.ProductVersion;
            try
            {
                Build = int.Parse(File.ReadAllLines(BuildFilename)[1]);
                File.WriteAllText(BuildFilename, "<!--Don`t EDIT this FILE!-->\n" + ++Build);
            }
            catch { MessageBox.Show("Can`t find build file.\n'" + BuildFilename + "' not found.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); };
            if (!File.Exists(Filename))
            {
                MessageBox.Show("Can`t find options file.\n'" + Filename + "' not found\n", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                try { Reset(); Save(); }
                catch { MessageBox.Show("Something Went Wrong", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); Environment.Exit(1); }
                MessageBox.Show("Done", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            var data = ExOperators.Load(Filename);

            StepHeightConst          = int.Parse(data["StepHeightConst"]);
            MaxDisConst              = int.Parse(data["MaxDisConst"]);
            UseAutoSpeed             = bool.Parse(data["UseAutoSpeed"]);
            XMM                      = float.Parse(data["XMM"], CultureInfo.InvariantCulture);
            YMM                      = float.Parse(data["YMM"], CultureInfo.InvariantCulture);
            Mainbd                   = int.Parse(data["Mainbd"]);
            Mainport                 = data["Mainport"];
            DefSpo                   = ExOperators.GetEnum <StartPrintOption>(data["Def_SPO"]);
            DefRbo                   = ExOperators.GetEnum <ReturnBackOption>(data["Def_RBO"]);
            DefPrintBack             = ExOperators.ColorFromHex(data["Def_print_back"]);
            DefPrintDraw             = ExOperators.ColorFromHex(data["Def_print_draw"]);
            DefViewBack              = ExOperators.ColorFromHex(data["Def_view_back"]);
            DefViewDraw              = ExOperators.ColorFromHex(data["Def_view_draw"]);
            MaxHeightSteps           = int.Parse(data["MaxHeightSteps"]);
            MaxWidthSteps            = int.Parse(data["MaxWidthSteps"]);
            IgnoreRegisterExtentions = bool.Parse(data["ignoreRegisterExtentions"]);
            PathToArduino            = data["PathToArduino"];
            DefBoard                 = ArduinoBoard.Boards.ToList().Find(p => p.ProgramName == data["def_board"]);
            UpKoof                   = int.Parse(data["UpKoof"]);
            Lang                     = data["Language"];
            PreloadPlugins           = bool.Parse(data["PreloadPlugins"]);
        }