Esempio n. 1
0
        /// <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"]);
        }
Esempio n. 2
0
 /// <summary>
 /// —оздает новый экземпл¤р класса <see cref="Macro"/>, загружа¤ его из файла.
 /// </summary>
 /// <param name="filename">»м¤ файла.</param>
 public Macro(string filename)
 {
     try
     {
         Elems = new List <MacroElem>(0);
         XmlDocument document = new XmlDocument();
         document.Load(filename);
         Name        = document.ChildNodes[1].ChildNodes[0].Attributes[0].Value;
         Discr       = document.ChildNodes[1].ChildNodes[0].Attributes[1].Value;
         PicFileName = document.ChildNodes[1].ChildNodes[0].Attributes[2].Value;
         string[] PicSizeValues = document.ChildNodes[1].ChildNodes[0].Attributes[3].Value.Split('_');
         PicSize        = new SizeF(float.Parse(PicSizeValues[0], CultureInfo.InvariantCulture), float.Parse(PicSizeValues[1], CultureInfo.InvariantCulture));
         CreatedVersion = new Version(
             int.Parse(document.ChildNodes[1].ChildNodes[1].Attributes[0].Value),
             int.Parse(document.ChildNodes[1].ChildNodes[1].Attributes[1].Value),
             int.Parse(document.ChildNodes[1].ChildNodes[1].Attributes[2].Value),
             int.Parse(document.ChildNodes[1].ChildNodes[1].Attributes[3].Value));
         Elems = new List <MacroElem>();
         for (int i = 2; i <= document.ChildNodes[1].ChildNodes.Count - 1; i++)
         {
             MacroElemType type          = MacroElem.ShortedTypeToNormal(ExOperators.GetEnum <MacroElemTypeShorted>(document.ChildNodes[1].ChildNodes[i].Attributes[0].Value));
             int           toolmove      = int.Parse(document.ChildNodes[1].ChildNodes[i].Attributes[1].Value);
             string[]      MoveToPointS  = document.ChildNodes[1].ChildNodes[i].Attributes[2].Value.Split('_');
             PointF        MoveToPoint   = new PointF(float.Parse(MoveToPointS[0], CultureInfo.InvariantCulture), float.Parse(MoveToPointS[1], CultureInfo.InvariantCulture));
             string[]      MoveRelativeS = document.ChildNodes[1].ChildNodes[i].Attributes[3].Value.Split('_');
             PointF        MoveRelative  = new PointF(float.Parse(MoveRelativeS[0], CultureInfo.InvariantCulture), float.Parse(MoveRelativeS[1], CultureInfo.InvariantCulture));
             float         Delay         = float.Parse(document.ChildNodes[1].ChildNodes[i].Attributes[4].Value, CultureInfo.InvariantCulture);
             Elems.Add(new MacroElem()
             {
                 Delay = Delay, MoveRelative = MoveRelative, MoveToPoint = MoveToPoint, ToolMove = toolmove, Type = type
             });
         }
     }
     catch (Exception e)
     {
         throw new FileLoadException("Unknown error", e);
     }
 }
Esempio n. 3
0
 private void comboBox_macro_keybind_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listBox_macroses.SelectedIndex != -1)
     {
         var a = main.Elems[listBox_macroses.SelectedIndex];
         main.Elems[listBox_macroses.SelectedIndex] = new MacroPackElem()
         {
             Options = new MacroPackElemOption {
                 Caption = a.Options.Caption, CharBind = a.Options.CharBind, KeyBind = ExOperators.GetEnum <Key>(comboBox_macro_keybind.Text)
             }, Path = a.Path
         };
         main.Elems[listBox_macroses.SelectedIndex].SetMacro(a.GetMacro());
     }
 }