Example #1
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);
     }
 }
Example #2
0
        /// <summary>
        /// Преобразует MacroElemType в MacroElemTypeShorted.
        /// </summary>
        /// <param name="t">Экземпляр класса MacroElemType.</param>
        public static MacroElemTypeShorted NormalToShorted(MacroElemType t)
        {
            switch (t)
            {
            case (MacroElemType.Tool): return(MacroElemTypeShorted.T);

            case (MacroElemType.MoveToPoint): return(MacroElemTypeShorted.MTP);

            case (MacroElemType.MoveRelative): return(MacroElemTypeShorted.MR);

            case (MacroElemType.Delay): return(MacroElemTypeShorted.D);

            case (MacroElemType.None): return(MacroElemTypeShorted.N);

            case (MacroElemType.ToolAndDelay): return(MacroElemTypeShorted.TAD);

            case (MacroElemType.MoveToPointAndDelay): return(MacroElemTypeShorted.MTPAD);

            case (MacroElemType.MoveRelativeAndDelay): return(MacroElemTypeShorted.MRAD);

            default: return(MacroElemTypeShorted.T);
            }
        }