示例#1
0
        private List <string> ParseExport(WhiteBoard w, string workfile, float moveSpeed, float drawSpeed, int downVal, int upVal)
        {
            var exportFile    = new BoardExporter(mainBoard, "Workfile.nc", moveSpeed, drawSpeed, downVal, upVal);
            var drawingbuffer = exportFile.getLines();


            return(drawingbuffer);
        }
示例#2
0
        public static SKPoint GetTransformedToBoard(WhiteBoard v, SKPoint point, SKPoint zero, float scale,
                                                    float rotation)
        {
            var pointinverted = RotateDegrees(InvertXY(point), rotation);

            var w = new SKPoint((zero.X + (pointinverted.X * scale)), (zero.Y + (pointinverted.Y * scale)));

            return(v.BoardToCanvas(w));
        }
示例#3
0
        public BoardExporter(WhiteBoard w, string filename, float moveSpeed, float drawSpeed, int PDown, int PUp)
        {
            board      = w;
            exportFile = filename;

            MoveSpeed  = moveSpeed;
            DrawSpeed  = drawSpeed;
            PenDownVal = PDown;
            PenUpVal   = PUp;
            Parse();
            //Save();
        }
示例#4
0
        public static SKPath CreateArc(ArcSegment a, WhiteBoard w = null)
        {
            if (w == null)

            {
                return(CreateArc(a.Start, a.End, a.End, a.CW));
            }
            else
            {
                return(CreateArc(w.BoardToCanvas(a.Start), w.BoardToCanvas(a.End), w.BoardToCanvas(a.Center), a.CW));
            }
        }
示例#5
0
        public async Task DoWork(WhiteBoard w, string workfile, float moveSpeed, float drawSpeed, int downVal, int upVal)
        {
            Func <List <string> > function =
                new Func <List <string> >(() => ParseExport(w, workfile, moveSpeed, drawSpeed, downVal, upVal));
            var res = await Task.Factory.StartNew <List <string> >(function);

            drawingBuffer = res;

            if (res != null)
            {
                Clipboard.SetText(listToStringLines(drawingBuffer));
                btnDrawOnPlotter.Enabled     = true;
                Parent.lblStatusBtmLeft.Text = "Done Parsing G-code for Export!";
            }
        }
示例#6
0
        public void Draw(WhiteBoard w, SKCanvas h, SKPaint lines, SKPaint moves)
        {
            Parallel.ForEach(DrawCommands, (command) =>
            {
                //command.Value.Draw(w, h, zeroPoint, lines, moves, ScaleFactor, RotationDeg);
                var r = (GcodeDrawCommand)command.Value;

                if (r.DrawType == typeof(GcodeArc))
                {
                    var q = (GcodeArc)command.Value;
                    var i = q.getArc(zeroPoint, ScaleFactor, RotationDeg);
                    SKPaint p;
                    if (q.PenDown)
                    {
                        p = lines;
                    }
                    else
                    {
                        p = moves;
                    }

                    //h.DrawPath(Transformations.CreateArc(i,w),p);
                    h.DrawLine(w.BoardToCanvas(i.Start), w.BoardToCanvas(i.End), p);
                    //TODO: Teken daadwerkelijk een arc!!
                }
                else if (r.DrawType == typeof(GcodeLine))
                {
                    var q = (GcodeLine)command.Value;
                    var i = q.getLine(zeroPoint, ScaleFactor, RotationDeg);
                    SKPaint p;
                    if (q.PenDown)
                    {
                        p = lines;
                    }
                    else
                    {
                        p = moves;
                    }

                    h.DrawLine(w.BoardToCanvas(i.Start), w.BoardToCanvas(i.End), p);
                    //Console.WriteLine("Draw Line!");
                }
                else
                {
                    Console.WriteLine("Not Line or arc!");
                }
            });
        }
示例#7
0
        public SerialControl(MainForm p, WhiteBoard b)
        {
            InitializeComponent();
            mainBoard             = b;
            btnConnectSerial.Text = "Connect";
            cmbComPorts.DropDown += CmbComPorts_DropDown;
            SerialStatus("Idle...");
            currentSettings = new PlotterSettings();
            currentSettings.LoadDefault();
            Parent                   = p;
            drawingBuffer            = new List <string>();
            btnDrawOnPlotter.Enabled = false;
            GState                   = "";

            grpC.SizeChanged += ResizeList;
        }
示例#8
0
        public MainForm()
        {
            InitializeComponent();
            mainBoard = new WhiteBoard(this, 1150, 790, skControl1, RatioLabel, MouseLabel);
            //ParseTest();
            gFiles = new List <GCodeFile>();

            btnLeft.Click     += TranslationButton_clicked;
            btnRight.Click    += TranslationButton_clicked;
            btnUp.Click       += TranslationButton_clicked;
            btnDown.Click     += TranslationButton_clicked;
            btnRotRight.Click += TranslationButton_clicked;
            btnRotLeft.Click  += TranslationButton_clicked;
            btnScaleN.Click   += TranslationButton_clicked;
            btnScaleP.Click   += TranslationButton_clicked;
            serialConControl   = new SerialControl(this, mainBoard);
            this.panelSerial.Controls.Add(serialConControl);
            serialConControl.Dock = DockStyle.Fill;
            lstDraw                       = lstDrawings;
            lblStatusBtmLeft              = lblStatusMain;
            lstSettings.MultiSelect       = false;
            lstSettings.MouseDoubleClick += ChangeSettings;
        }