Exemplo n.º 1
0
 private void cmsPicBoxMoveGraphicsOrigin_Click(object sender, EventArgs e)
 {
     unDo.setCode(fCTBCode.Text, cmsPicBoxMoveGraphicsOrigin.Text, this);
     clearTextSelection(fCTBCodeClickedLineNow);
     VisuGCode.markSelectedFigure(-1);
     fCTBCode.Text = VisuGCode.transformGCodeOffset(grbl.posMarker.X, grbl.posMarker.Y, VisuGCode.translate.None);
     transformEnd();
     grbl.posMarker = new xyPoint(0, 0);
 }
Exemplo n.º 2
0
        private void OnRaiseCameraClickEvent(object sender, XYEventArgs e)
        {
            if (e.Command == "a")
            {
                if (fCTBCode.LinesCount > 1)
                {
                    VisuGCode.markSelectedFigure(-1);                                                 // rotate all figures
                    transformStart(string.Format("Rotate {0:0.00}", e.Angle));
                    fCTBCode.Text = VisuGCode.transformGCodeRotate(e.Angle, e.Scale, e.Point, false); // use given center
                    transformEnd();
                }
            }
            else
            {
                double   realStepX = Math.Round(e.Point.X, 3);
                double   realStepY = Math.Round(e.Point.Y, 3);
                int      speed     = 1000;
                string   s         = "";
                string[] line      = e.Command.Split(';');
                foreach (string cmd in line)
                {
                    if (cmd.Trim() == "G92")
                    {
                        s = String.Format(cmd + " X{0} Y{1}", realStepX, realStepY).Replace(',', '.');
                        sendCommand(s);
                    }
                    else if ((cmd.Trim().IndexOf("G0") >= 0) || (cmd.Trim().IndexOf("G1") >= 0))        // no jogging
                    {
                        s = String.Format(cmd + " X{0} Y{1}", realStepX, realStepY).Replace(',', '.');
                        sendCommand(s);
                    }
                    else if ((cmd.Trim().IndexOf("G90") == 0) || (cmd.Trim().IndexOf("G91") == 0))      // no G0 G1, then jogging
                    {
                        speed = 100 + (int)Math.Sqrt(realStepX * realStepX + realStepY * realStepY) * 120;
                        s     = String.Format("{0} X{1} Y{2} F{3}", cmd, realStepX, realStepY, speed).Replace(',', '.');
                        if (grbl.isMarlin)
                        {
                            s = String.Format("{0}; G1 X{1} Y{2} F{3}", cmd, realStepX, realStepY, speed).Replace(',', '.');
                        }

                        sendCommands(s, true);
                    }
                    else
                    {
                        sendCommand(cmd.Trim());
                    }
                }
            }
        }
Exemplo n.º 3
0
        // if startline > 0 start with pause
        private void startStreaming(int startLine = 0)
        {
            Logger.Trace("startStreaming serialPortOpen:{0} ", _serial_form.serialPortOpen);
            isStreamingRequestStop     = false;
            lblInfoOkString            = Localization.getString("mainInfoSendCode");
            notifierUpdateMarker       = false;
            notifierUpdateMarkerFinish = false;
            if (fCTBCode.LinesCount > 1)
            {
                if (!isStreaming)
                {
                    clearErrorLines();
                    Logger.Info("Start streaming at line:{0}  showProgress:{1}  backgroundImage:{2}", startLine, Properties.Settings.Default.guiProgressShow, Properties.Settings.Default.guiBackgroundImageEnable);
                    expandCodeBlocksToolStripMenuItem_Click(null, null);
                    VisuGCode.ProcessedPath.processedPathClear();
                    MainTimer.Stop();
                    MainTimer.Start();

                    isStreaming      = true;
                    isStreamingPause = false;
                    isStreamingCheck = false;
                    isStreamingOk    = true;
                    VisuGCode.markSelectedFigure(0);
                    if (startLine > 0)
                    {
                        btnStreamStart.Image = Properties.Resources.btn_pause;
                        //              isStreamingPause = true;
                    }

                    if (!grbl.isVersion_0)
                    {
                        gBoxOverride.Height = 175;
                        gBoxOverrideBig     = true;
                    }

                    timerUpdateControlSource = "startStreaming";
                    updateControls();
                    timeInit = DateTime.UtcNow;
                    elapsed  = TimeSpan.Zero;
                    setInfoLabel(Localization.getString("mainInfoSendCode"), Color.Lime);
                    for (int i = 0; i < fCTBCode.LinesCount; i++)
                    {
                        fCTBCode.UnbookmarkLine(i);
                    }

                    //save gcode
                    string fileName = Application.StartupPath + "\\" + fileLastProcessed;
                    string txt      = fCTBCode.Text;
                    File.WriteAllText(fileName + ".nc", txt);
                    File.Delete(fileName + ".xml");
                    SaveRecentFile(fileLastProcessed + ".nc");

                    lblElapsed.Text = "Time " + elapsed.ToString(@"hh\:mm\:ss");
                    _serial_form.startStreaming(fCTBCode.Lines, startLine);
                    btnStreamStart.Image   = Properties.Resources.btn_pause;
                    btnStreamCheck.Enabled = false;
                    onPaint_setBackground();                // Generante a background-image for pictureBox to avoid frequent drawing of pen-up/down paths
                    VisuGCode.setPathAsLandMark();
                    ControlPowerSaving.SuppressStandby();
                }
                else
                {
                    if (!isStreamingPause)
                    {
                        Logger.Info("Pause streaming - pause stream");
                        btnStreamStart.Image = Properties.Resources.btn_play;
                        _serial_form.pauseStreaming();
                        //            isStreamingPause = true;
                        statusStripSet(0, Localization.getString("statusStripeStreamingStatusSaved"), Color.LightGreen);
                    }
                    else
                    {
                        Logger.Info("Pause streaming - continue stream  ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄");
                        btnStreamStart.Image = Properties.Resources.btn_pause;
                        _serial_form.pauseStreaming();
                        isStreamingPause = false;
                        statusStripClear(0);
                    }
                }
            }
        }