Example #1
0
        private void LoadFile(string file)
        {
            string[] Glines  = System.IO.File.ReadAllLines(file);
            int      counter = 0;

            foreach (var v in Glines)
            {
                if (v != "")
                {
                    fileLines.Add(counter, v);
                    counter++;
                }
            }

            foreach (var Entry in fileLines)
            {
                var command = new GCodeCommand(Entry.Value, Entry.Key);
                CodeLines.Add(Entry.Key, command);
            }

            DrawSegment lastSegment = null;
            bool        PDown       = false;
            float       FeedRate    = 0;

            for (int i = 0; i < CodeLines.Count; i++)
            {
                int classif = Util.ClassifyCommand(CodeLines[i]);

                switch (classif)
                {
                case (0):
                    FeedRate = (int)CodeLines[i].getParameters()['F'];
                    break;

                case (1):
                case (2):
                    SegmentLine d = new SegmentLine(CodeLines[i], PDown, FeedRate, lastSegment);
                    lastSegment = d;
                    OriginalSegments.Add(d.Index, d);
                    break;

                case (3):
                case (4):
                    SegmentArc a = new SegmentArc(CodeLines[i], PDown, FeedRate, lastSegment);
                    lastSegment = a;
                    OriginalSegments.Add(a.Index, a);
                    break;

                case (11):
                    PDown = false;
                    break;

                case (12):
                    PDown = true;
                    break;
                }
            }
        }
Example #2
0
        public SegmentLine(GCodeCommand command, bool pen, float feed, DrawSegment Previous = null)
        {
            if (Previous == null)
            {
                End = new SKPoint(0.0f, 0.0f);
            }
            else
            {
                Start = Previous.End;
            }

            End      = command.getEndPoint();
            Command  = command;
            Index    = command.getIndex();
            PenDown  = pen;
            FeedRate = feed;
        }