diff --git a/GRBL-Plotter/GUI/MainForm.cs b/GRBL-Plotter/GUI/MainForm.cs
index 1822c95d4..8bfafc343 100644
--- a/GRBL-Plotter/GUI/MainForm.cs
+++ b/GRBL-Plotter/GUI/MainForm.cs
@@ -1253,6 +1253,7 @@ private void ProcessCommands(string command)
var MyIni = new IniFile(command);
Logger.Info(culture, "Load INI: '{0}'", command);
MyIni.ReadAll(); // ReadImport();
+ UpdateIniVariables();
timerUpdateControlSource = "loadFile";
UpdateWholeApplication();
StatusStripSet(2, "INI File '" + command + "' loaded", Color.Lime);
diff --git a/GRBL-Plotter/GUI/MainForm.resx b/GRBL-Plotter/GUI/MainForm.resx
index 836345db7..39b99fdf1 100644
--- a/GRBL-Plotter/GUI/MainForm.resx
+++ b/GRBL-Plotter/GUI/MainForm.resx
@@ -133,7 +133,7 @@
1
- 214, 12
+ 191, 12
123, 56
diff --git a/GRBL-Plotter/GUI/MainFormFCTB.cs b/GRBL-Plotter/GUI/MainFormFCTB.cs
index 60d0d97dc..60257f1d6 100644
--- a/GRBL-Plotter/GUI/MainFormFCTB.cs
+++ b/GRBL-Plotter/GUI/MainFormFCTB.cs
@@ -1,7 +1,7 @@
/* GRBL-Plotter. Another GCode sender for GRBL.
This file is part of the GRBL-Plotter application.
- Copyright (C) 2015-2023 Sven Hasemann contact: svenhb@web.de
+ Copyright (C) 2015-2024 Sven Hasemann contact: svenhb@web.de
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -75,6 +75,8 @@ public partial class MainForm : Form
private bool manualEdit = false;
private readonly bool logMain = false;
+ private int globalCollectionCounter = 1;
+
#region fCTB FastColoredTextBox related
// highlight code in editor
// 0 : Black, 105 : DimGray , 128 : Gray, 169 : DarkGray!, 192 : Silver, 211 : LightGray , 220 : Gainsboro, 245 : Ghostwhite, 255 : White
@@ -143,10 +145,6 @@ private void MarkErrorLine(int line)
{
if (LineIsInRange(line))
{
- // SetTextSelection(line, line);
- // fCTBCode.Selection.ClearStyle(StyleGWord, StyleXAxis, StyleYAxis);
- // fCTBCode.Selection.SetStyle(ErrorStyle);
-
if (this.fCTBCode.InvokeRequired)
{
this.fCTBCode.BeginInvoke((MethodInvoker)delegate ()
@@ -174,12 +172,6 @@ private void ClearErrorLines()
{
if (LineIsInRange(myline))
{
- // SetTextSelection(myline, myline);
- // fCTBCode.Selection.ClearStyle(ErrorStyle);
- // fCTBCode.Selection.SetStyle(StyleGWord);
- // fCTBCode.Selection.SetStyle(StyleXAxis);
- // fCTBCode.Selection.SetStyle(StyleYAxis);
-
if (this.fCTBCode.InvokeRequired)
{
this.fCTBCode.BeginInvoke((MethodInvoker)delegate ()
@@ -354,7 +346,7 @@ private void InsertTextAtLine(int line, string text)
else
{ Logger.Error("InsertTextAtLine LineIsNOTInRange: {0}", line); }
}
-
+ System.Drawing.Point codeInsert = new System.Drawing.Point();
private int InsertCodeToFctb(string sourceGCode, bool fromFile, int lineSelected, double offsetX, double offsetY)
{
/* if graphic import, add new group,
@@ -373,6 +365,8 @@ private int InsertCodeToFctb(string sourceGCode, bool fromFile, int lineSelected
bool containsGroup = sourceGCode.Contains(XmlMarker.GroupStart);
bool containsFigure = sourceGCode.Contains(XmlMarker.FigureStart);
+ int newID = 0;
+
if (fromFile)
{
if (insertLineCollection > 0)
@@ -428,7 +422,7 @@ private int InsertCodeToFctb(string sourceGCode, bool fromFile, int lineSelected
string line;
int figureCount = 1;
- if(!containsCollection) { tmpCodeFinish.AppendLine(string.Format("{0} \">", XmlMarker.CollectionStart)); }
+ if(!containsCollection) { tmpCodeFinish.AppendLine(string.Format("({0} Id=\"{1}\">)", XmlMarker.CollectionStart, globalCollectionCounter++)); }
for (int k = 0; k < tmpCodeLines.Length; k++) // go through code-lines to insert
{
@@ -451,6 +445,7 @@ private int InsertCodeToFctb(string sourceGCode, bool fromFile, int lineSelected
// Logger.Info("getGCodeFromText figure idStart:{0} digits:{1} final:{2} string:'{3}'-'{4}'", idStart, idCount.ToString().Length, strtIndex, line.Substring(0, idStart), line.Substring(strtIndex));
line = tmp;
}
+ newID = idCount;
}
if (line.Contains(XmlMarker.FigureStart)) // find figure-tag and increment id
{
@@ -469,6 +464,7 @@ private int InsertCodeToFctb(string sourceGCode, bool fromFile, int lineSelected
// Logger.Info("getGCodeFromText figure idStart:{0} digits:{1} final:{2} string:'{3}'-'{4}'", idStart, idCount.ToString().Length, strtIndex, line.Substring(0, idStart), line.Substring(strtIndex));
line = tmp;
}
+ newID = idCount;
}
}
@@ -483,7 +479,7 @@ private int InsertCodeToFctb(string sourceGCode, bool fromFile, int lineSelected
}
if (line.Contains(XmlMarker.CollectionEnd)) useCode = false;
}
- if (!containsCollection) { tmpCodeFinish.AppendLine(string.Format("{0} \">", XmlMarker.CollectionEnd)); }
+ if (!containsCollection) { tmpCodeFinish.AppendLine(string.Format("({0} >)", XmlMarker.CollectionEnd)); }
if (createGroup)
{ tmpCodeFinish.AppendLine("(" + XmlMarker.CollectionStart + " Id=\"0\" Type=\"Existing code\" >)"); } // add startGroup for existing figures
@@ -500,12 +496,14 @@ private int InsertCodeToFctb(string sourceGCode, bool fromFile, int lineSelected
}
Logger.Info("◆◆◆◆ Insert code to existing code at line {0}", insertLineNr);
+ codeInsert = new System.Drawing.Point(insertLineNr, newID);
return insertLineNr;
}
else
{
fCTBCode.Text = sourceGCode;
Logger.Warn("⚠⚠⚠ Insert code was not possible at line: {0}", insertLineNr);
+ codeInsert=new System.Drawing.Point(-1, -1);
return -1;
}
}
@@ -939,7 +937,7 @@ private bool FindFigureMarkSelection(XmlMarkerType marker, int clickedLine, Dist
fCTBCode.Selection.ColumnSelectionMode = false;
- bool gcodeIsSeleced = false; ;
+ bool gcodeIsSeleced = false;
EnableBlockCommands(gcodeIsSeleced);
markedBlockType = marker;
diff --git a/GRBL-Plotter/GUI/MainFormGetCodeTransform.cs b/GRBL-Plotter/GUI/MainFormGetCodeTransform.cs
index 70515a06a..04b22e254 100644
--- a/GRBL-Plotter/GUI/MainFormGetCodeTransform.cs
+++ b/GRBL-Plotter/GUI/MainFormGetCodeTransform.cs
@@ -1,7 +1,7 @@
/* GRBL-Plotter. Another GCode sender for GRBL.
This file is part of the GRBL-Plotter application.
- Copyright (C) 2015-2023 Sven Hasemann contact: svenhb@web.de
+ Copyright (C) 2015-2024 Sven Hasemann contact: svenhb@web.de
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -151,6 +151,7 @@ private void InsertCodeFromForm(string sourceGCode, string sourceForm, GraphicsP
insertLineNr = XmlMarker.FindInsertPositionFigureMostTop(-1); // no group? find figure
createGroup = true;
}
+ codeInsert=new System.Drawing.Point(insertLineNr, 0);
Logger.Info("▀▀▀▀▀▀ InsertCodeFromForm:{0} insertCode:{1} insertAt:{2}", sourceForm, insertCode, insertLineNr);
diff --git a/GRBL-Plotter/GUI/MainFormInterface.cs b/GRBL-Plotter/GUI/MainFormInterface.cs
index 39c449070..4950a6e29 100644
--- a/GRBL-Plotter/GUI/MainFormInterface.cs
+++ b/GRBL-Plotter/GUI/MainFormInterface.cs
@@ -1,7 +1,7 @@
/* GRBL-Plotter. Another GCode sender for GRBL.
This file is part of the GRBL-Plotter application.
- Copyright (C) 2015-2023 Sven Hasemann contact: svenhb@web.de
+ Copyright (C) 2015-2024 Sven Hasemann contact: svenhb@web.de
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -25,6 +25,8 @@ You should have received a copy of the GNU General Public License
* 2021-11-18 add processing of accessory D0-D3 from grbl-Mega-5X - line 139
* 2022-02-24
* 2023-03-09 simplify NULL check; case GrblState.unknown: UpdateControlEnables();
+ * 2024-02-14 l:160 f:ProcessStatusMessage add grblDigialIn -Out
+ * 2024-02-24 l:61 f:OnRaisePosEvent submit Grbl.StatMsg
*/
using System;
@@ -57,6 +59,7 @@ private void OnRaisePosEvent(object sender, PosEventArgs e)
{
// if (logPosEvent) Logger.Trace("OnRaisePosEvent {0} connect {1} status {2}", e.Status.ToString(), _serial_form.serialPortOpen, e.Status.ToString());
Grbl.Status = machineStatus = e.Status;
+ Grbl.StatMsg = e.StatMsg;
/***** Restore saved position after reset and set initial feed rate: *****/
if (ResetDetected || (e.Status == GrblState.reset))
@@ -157,8 +160,17 @@ private void ProcessStatusMessage(ModState StatMsg)
if (StatMsg.A.Contains("D"))
{
string digits = StatMsg.A.Substring(StatMsg.A.IndexOf("D") + 1); // Digital pins in order '3210'
+ int din = 0;
+ int dout = 0;
if (digits.Length == 4)
{
+ for (int i=0; i<4; i++)
+ { dout |= ((digits[i] == '1')? 1:0) << (3-i); }
+ /* SetAccessoryButton(BtnOverrideD3, (dout & 8));
+ SetAccessoryButton(BtnOverrideD2, (dout & 4));
+ SetAccessoryButton(BtnOverrideD1, (dout & 2));
+ SetAccessoryButton(BtnOverrideD0, (dout & 1));
+*/
SetAccessoryButton(BtnOverrideD3, (digits[0] == '1'));
SetAccessoryButton(BtnOverrideD2, (digits[1] == '1'));
SetAccessoryButton(BtnOverrideD1, (digits[2] == '1'));
@@ -170,15 +182,21 @@ private void ProcessStatusMessage(ModState StatMsg)
}
else if (digits.Length == 8)
{
+ for (int i=0; i<4; i++)
+ { din |= ((digits[i] == '1')? 1:0) << i; }
BtnOverrideD3.BackColor = (digits[0] == '1') ? Color.Honeydew : Color.LightPink;
BtnOverrideD2.BackColor = (digits[1] == '1') ? Color.Honeydew : Color.LightPink;
BtnOverrideD1.BackColor = (digits[2] == '1') ? Color.Honeydew : Color.LightPink;
BtnOverrideD0.BackColor = (digits[3] == '1') ? Color.Honeydew : Color.LightPink;
+ for (int i=4; i<8; i++)
+ { dout |= ((digits[i] == '1')? 1:0) << (7-i-4); }
SetAccessoryButton(BtnOverrideD3, (digits[4] == '1'));
SetAccessoryButton(BtnOverrideD2, (digits[5] == '1'));
SetAccessoryButton(BtnOverrideD1, (digits[6] == '1'));
SetAccessoryButton(BtnOverrideD0, (digits[7] == '1'));
}
+ Grbl.grblDigitalIn = (byte)din;
+ Grbl.grblDigitalOut = (byte)dout;
}
else
{
diff --git a/GRBL-Plotter/GUI/MainFormLoadFile.cs b/GRBL-Plotter/GUI/MainFormLoadFile.cs
index a1c35c39a..bcf7e800a 100644
--- a/GRBL-Plotter/GUI/MainFormLoadFile.cs
+++ b/GRBL-Plotter/GUI/MainFormLoadFile.cs
@@ -585,6 +585,7 @@ private bool LoadFile(string fileName)
var MyIni = new IniFile(fileName);
Logger.Info("Load INI: '{0}'", fileName);
MyIni.ReadAll(); // ReadImport();
+ UpdateIniVariables();
timerUpdateControlSource = "loadFile";
UpdateControlEnables();
UpdateWholeApplication();
@@ -853,6 +854,7 @@ private void TbURL_TextChanged(object sender, EventArgs e)
Logger.Info("Load INI (URL): '{0}'", tBURL.Text);
var MyIni = new IniFile(tBURL.Text, true);
MyIni.ReadAll(); // ReadImport();
+ UpdateIniVariables();
timerUpdateControlSource = "tBURL_TextChanged";
UpdateControlEnables();
UpdateWholeApplication();
@@ -1759,6 +1761,7 @@ private void LoadMachineParametersToolStripMenuItem_Click(object sender, EventAr
{
var MyIni = new IniFile(openFileDialog1.FileName);
MyIni.ReadAll();
+ UpdateIniVariables();
LoadSettings(sender, e);
Logger.Info("Load machine parameters as {0}", openFileDialog1.FileName);
}
diff --git a/GRBL-Plotter/GUI/MainFormOtherForms.cs b/GRBL-Plotter/GUI/MainFormOtherForms.cs
index 61c26a8a8..3b601a0ae 100644
--- a/GRBL-Plotter/GUI/MainFormOtherForms.cs
+++ b/GRBL-Plotter/GUI/MainFormOtherForms.cs
@@ -1,7 +1,7 @@
/* GRBL-Plotter. Another GCode sender for GRBL.
This file is part of the GRBL-Plotter application.
- Copyright (C) 2015-2023 Sven Hasemann contact: svenhb@web.de
+ Copyright (C) 2015-2024 Sven Hasemann contact: svenhb@web.de
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -26,6 +26,8 @@ You should have received a copy of the GNU General Public License
* 2023-01-24 line 369 check if _diyControlPad != null
* 2023-01-27 processAutomation removed fullScreen on start (like in ProjectorToolStrip)
* 2023-12-01 l:682 f:OnRaiseProcessEvent add new action "Probing"
+ * 2024-02-07 l:698 f:OnRaiseProcessEvent add Barcode, CreatText, 2D-View
+ * 2024-02-12 split file, new MainFormProcessAutomation.cs
*/
using GrblPlotter.MachineControl;
@@ -60,9 +62,16 @@ public partial class MainForm : Form
ControlSetupForm _setup_form = null;
ControlJogPathCreator _jogPathCreator_form = null;
ControlProjector _projector_form = null;
- ControlProcessAutomation _process_form = null;
+ ProcessAutomation _process_form = null;
GrblSetupForm _grbl_setup_form = null;
+ private void UpdateIniVariables()
+ {
+ _text_form?.UpdateIniVariables();
+ _barcode_form?.UpdateIniVariables();
+ _process_form?.UpdateIniVariables();
+ }
+
#region MAIN-MENU GCode creation
/********************************************************************
* Text
@@ -318,7 +327,7 @@ private void OnRaiseCameraProcessEvent(object sender, ProcessEventArgs e)
{
if (e.Command == "Fiducial")
{
- _process_form?.Feedback(e.Command, e.Value, (e.Value=="finished"));
+ _process_form?.Feedback("Camera Automatic", e.Value, (e.Value == "finished"));
}
}
@@ -368,8 +377,9 @@ private void OnRaiseDIYCommandEvent(object sender, CommandEventArgs e)
if (double.TryParse(num, out double myZ))
{ alternateZ = myZ; }
else
- { _diyControlPad?.SendFeedback("Error in parsing " + num, true);
- }
+ {
+ _diyControlPad?.SendFeedback("Error in parsing " + num, true);
+ }
}
}
}
@@ -449,10 +459,10 @@ private void GetGCodeFromLaser(object sender, EventArgs e)
if (!isStreaming)
{
ClearWorkspace();
- NewCodeStart(false);
- SetFctbCodeText(_laser_form.LaserGCode);
+ NewCodeStart(false);
+ SetFctbCodeText(_laser_form.LaserGCode);
NewCodeEnd();
- FoldBlocks1();
+ FoldBlocks1();
foldLevelSelected = 1;
}
else
@@ -515,7 +525,7 @@ private void OnRaiseProbingProcessEvent(object sender, ProcessEventArgs e)
{
if (e.Command == "Probe")
{
- _process_form?.Feedback(e.Command, e.Value, (e.Value=="finished"));
+ _process_form?.Feedback("Probe Automatic", e.Value, (e.Value == "finished"));
}
}
@@ -666,79 +676,10 @@ private void FormClosed_Projector(object sender, FormClosedEventArgs e)
{ _projector_form = null; EventCollector.SetOpenForm("FCprj"); }
-
/********************************************************************
- * ProcessAutomation - a form to automate process steps
- * _process_form
+ * GRBL Setup
+ * _grbl_setup_form
********************************************************************/
- private void ProcessAutomationFormOpen(object sender, EventArgs e)
- {
- if (_process_form == null)
- {
- _process_form = new ControlProcessAutomation();
- _process_form.FormClosed += FormClosed_Process;
- _process_form.RaiseProcessEvent += OnRaiseProcessEvent;
- EventCollector.SetOpenForm("Fprc");
- }
- else
- {
- _process_form.Visible = false;
- }
-
- _process_form.Show(this);
- _process_form.WindowState = FormWindowState.Normal;
- }
- private void FormClosed_Process(object sender, FormClosedEventArgs e)
- { _process_form = null; EventCollector.SetOpenForm("FCprc"); }
-
- private void OnRaiseProcessEvent(object sender, ProcessEventArgs e)
- {
- if (e.Command == "Load")
- {
- string mypath = Datapath.MakeAbsolutePath(e.Value);
- _process_form?.Feedback(e.Command, e.Value, LoadFile(mypath));
- }
- else if (e.Command == "G-Code")
- {
- SendCommand(e.Value);
- }
- else if (e.Command == "Probe")
- {
- if (_probing_form != null)
- {
- _probing_form.StartProbing(e.Value.ToUpper());
- // when finished, probing form sends event back _probing_form.RaiseProcessEvent += OnRaiseProbingProcessEvent;
- }
- else
- {
- _process_form?.Feedback(e.Command, "Probing form is not open", false);
- }
- }
- else if (e.Command == "Fiducial")
- {
- if (_camera_form != null)
- {
- _camera_form.StartFiducialDetection();
- // when finished, camera form sends event back _camera_form.RaiseProcessEvent += OnRaiseCameraProcessEvent;
- }
- else
- {
- _process_form?.Feedback(e.Command, "Camera form is not open", false);
- }
- }
- else if (e.Command == "Stream")
- {
- StartStreaming(0, fCTBCode.LinesCount - 1);
- }
- else if (e.Command == "CheckForm")
- {
- if (e.Value == "Probe") { _process_form?.Feedback(e.Command, e.Value, (_probing_form != null)); }
- if (e.Value == "Cam") { _process_form?.Feedback(e.Command, e.Value, (_camera_form != null)); }
- }
- }
-
-
-
private void GrblSetupToolStripMenuItem_Click(object sender, EventArgs e)
{
if (_grbl_setup_form == null)
diff --git a/GRBL-Plotter/GUI/MainFormPictureBox.cs b/GRBL-Plotter/GUI/MainFormPictureBox.cs
index 91b092d01..31be33fbd 100644
--- a/GRBL-Plotter/GUI/MainFormPictureBox.cs
+++ b/GRBL-Plotter/GUI/MainFormPictureBox.cs
@@ -1059,6 +1059,7 @@ private void ClearWorkspace()
NewCodeStart(); // ClearWorkspace
fCTBCode.Clear();
NewCodeEnd();
+ globalCollectionCounter = 1;
}
private void CmsPicBoxMoveToFirstPos_Click(object sender, EventArgs e)
diff --git a/GRBL-Plotter/GUI/MainFormProcessAutomation.cs b/GRBL-Plotter/GUI/MainFormProcessAutomation.cs
new file mode 100644
index 000000000..c9a5fcac9
--- /dev/null
+++ b/GRBL-Plotter/GUI/MainFormProcessAutomation.cs
@@ -0,0 +1,269 @@
+/* GRBL-Plotter. Another GCode sender for GRBL.
+ This file is part of the GRBL-Plotter application.
+
+ Copyright (C) 2015-2024 Sven Hasemann contact: svenhb@web.de
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+*/
+/*
+ * 2024-02-12 split file MainFormOtherForms.cs
+*/
+
+using System;
+using System.Reflection;
+using System.Windows.Forms;
+
+namespace GrblPlotter
+{
+ public partial class MainForm : Form
+ {
+ /********************************************************************
+ * ProcessAutomation - a form to automate process steps
+ * _process_form
+ ********************************************************************/
+ private void ProcessAutomationFormOpen(object sender, EventArgs e)
+ {
+ if (_process_form == null)
+ {
+ _process_form = new ProcessAutomation();
+ _process_form.FormClosed += FormClosed_Process;
+ _process_form.RaiseProcessEvent += OnRaiseProcessEvent;
+ EventCollector.SetOpenForm("Fprc");
+ }
+ else
+ {
+ _process_form.Visible = false;
+ }
+
+ if (showFormInFront) _process_form.Show(this);
+ else _process_form.Show(); // this);
+ // _process_form.Show(this);
+ showFormsToolStripMenuItem.Visible = true;
+ _process_form.WindowState = FormWindowState.Normal;
+ }
+ private void FormClosed_Process(object sender, FormClosedEventArgs e)
+ { _process_form = null; EventCollector.SetOpenForm("FCprc"); }
+
+
+
+ /********************************************************************
+ * ProcessAutomation - a form to automate process steps
+ * Process commands
+ ********************************************************************/
+ private void OnRaiseProcessEvent(object sender, ProcessEventArgs e)
+ {
+ string act = e.Command.ToLower();
+ string val = e.Value.ToLower();
+
+ Logger.Trace("➤➤➤➤ OnRaiseProcessEvent {0} {1} ", e.Command, e.Value);
+
+ if (act.Contains("load"))
+ {
+ string mypath = Datapath.MakeAbsolutePath(e.Value);
+ _process_form?.Feedback(e.Command, e.Value, LoadFile(mypath));
+ _process_form?.BringToFront();
+ }
+ else if (act.Contains("g-code"))
+ {
+ if (act.Contains("send"))
+ ProcessCommands(e.Value); //SendCommands(e.Value); includes macro-file
+ if (act.Contains("stream"))
+ StartStreaming(0, fCTBCode.LinesCount - 1);
+ }
+ else if (act == "probe automatic")
+ {
+ if (_probing_form == null)
+ { probingToolLengthToolStripMenuItem.PerformClick(); }
+ if (_probing_form != null)
+ {
+ _probing_form.StartProbing(e.Value.ToUpper());
+ // when finished, probing form sends event back _probing_form.RaiseProcessEvent += OnRaiseProbingProcessEvent;
+ }
+ else
+ {
+ _process_form?.Feedback(e.Command, "Probing form is not open", false);
+ }
+ }
+ else if (act == "camera automatic")
+ {
+ if (_camera_form == null)
+ { toolStripMenuItem1.PerformClick(); }
+ if (_camera_form != null)
+ {
+ _camera_form.StartFiducialDetection();
+ // when finished, camera form sends event back _camera_form.RaiseProcessEvent += OnRaiseCameraProcessEvent;
+ }
+ else
+ {
+ _process_form?.Feedback(e.Command, "Camera form is not open", false);
+ }
+ }
+
+ else if (act.Contains("createtext"))
+ {
+ if (_text_form == null)
+ { textWizzardToolStripMenuItem.PerformClick(); }
+
+ if (_text_form != null)
+ {
+ string opt = "";
+ double size = 0;
+ if (act.Contains(" w")) { opt = "w"; }
+ if (act.Contains(" h")) { opt = "h"; }
+ if (opt != "")
+ {
+ string[] splt = act.Split(opt[0]);
+ if (splt.Length > 1)
+ {
+ if (double.TryParse(splt[1], out double nr))
+ { size = nr; }
+ }
+ }
+ _text_form.SetText(e.Value, opt, size);
+ _process_form?.Feedback(e.Command, e.Value, true);
+ }
+ else
+ {
+ _process_form?.Feedback(e.Command, "Text form is not open", false);
+ }
+ }
+
+ else if (act.Contains("createbarcode")) // == "Barcode 1D Text")
+ {
+ if (_barcode_form == null)
+ { createBarcodeToolStripMenuItem.PerformClick(); }
+
+ if (_barcode_form != null)
+ {
+ if (act.Contains("1d text")) { _barcode_form.SetText1D(e.Value); }
+ else if (act.Contains("1d data")) { _barcode_form.SetText1D(e.Value); }
+ else if (act.Contains("2d text")) { _barcode_form.SetText2D(e.Value); }
+ else if (act.Contains("2d data")) { _barcode_form.SetText2D(e.Value); }
+ else if (act.Contains("2d url")) { _barcode_form.SetUrl2D(e.Value); }
+ else if (act.Contains("2d durl")) { _barcode_form.SetUrl2D(e.Value); }
+ _process_form?.Feedback(e.Command, "Barcode form: " + e.Value, true);
+ }
+ else
+ {
+ _process_form?.Feedback(e.Command, "Barcode form is not open", false);
+ }
+ }
+
+ else if (act.Contains("2d-view"))
+ {
+ if (act.Contains("clear"))
+ {
+ ClearWorkspace(); _process_form?.Feedback(e.Command, "Workspace cleared", true);
+ Properties.Settings.Default.fromFormInsertEnable = true;
+ Graphic2GCode.multiImport = true;
+ }
+
+ else if (act.Contains("offset"))
+ {
+ //Select globalCollectionCounter
+ SetTextSelection(XmlMarker.lastCollection.LineStart, XmlMarker.lastCollection.LineEnd); // select Gcode
+
+ VisuGCode.MarkSelectedCollection(XmlMarker.lastCollection.LineStart); // highlight 2D-view
+ SelectionHandle.SelectedMarkerLine = XmlMarker.lastCollection.LineStart;
+ SelectionHandle.SelectedCollection = XmlMarker.lastCollection.Id;
+
+ string[] tmp = e.Value.Split(';');
+ if (tmp.Length > 2)
+ {
+ int o;
+ double x, y;
+ if (int.TryParse(tmp[0], out o))
+ {
+ if (double.TryParse(tmp[1], out x))
+ {
+ if (double.TryParse(tmp[2], out y))
+ {
+ int lineStart = XmlMarker.GetStartLineOfGroup(codeInsert.Y);
+ if (LineIsInRange(lineStart))
+ SetSelection(lineStart, XmlMarkerType.Group);
+ Logger.Trace("Last codeInsert:{0} {1}", codeInsert.X, lineStart);
+
+ double newx = 0, newy = 0;
+ if (SelectionHandle.IsActive)
+ {
+ System.Drawing.RectangleF dim = SelectionHandle.Bounds;
+ Logger.Trace("SelectionHandle.IsActiv x:{0:0.00} y:{1:0.00} posx:{2:0.00} posy:{3:0.00} width:{4:0.00}", x, y, dim.Left, dim.Y, dim.Width);
+ VisuGCode.GetTransaltionOffset(ref newx, ref newy, -x, y, dim.Left, dim.Y, dim.Width, dim.Height, VisuGCode.GetTranslate(o));
+ Logger.Trace("SelectionHandle.IsActiv newx:{0:0.00} newy:{1:0.00} ", newx, newy);
+ SetFctbCodeText(VisuGCode.TransformGCodeOffset(newx, newy, VisuGCode.Translate.None));
+ }
+ else
+ SetFctbCodeText(VisuGCode.TransformGCodeOffset(-x, -y, VisuGCode.GetTranslate(o)));
+ SelectionHandle.ClearSelected();
+ TransformEnd();
+ _process_form?.Feedback(e.Command, "Offset applied", true);
+ }
+ }
+ }
+ }
+ }
+ else if (act.Contains("rotate"))
+ {
+ double angle;
+ if (double.TryParse(e.Value, out angle))
+ {
+ int lineStart = XmlMarker.GetStartLineOfGroup(codeInsert.Y);
+ if (LineIsInRange(lineStart))
+ SetSelection(lineStart, XmlMarkerType.Group);
+ Logger.Trace("Last codeInsert:{0} {1}", codeInsert.X, lineStart);
+
+ TransformStart("Rotate");
+ SetFctbCodeText(VisuGCode.TransformGCodeRotate(angle, 1, new XyPoint(0,0)));
+ SelectionHandle.ClearSelected();
+ TransformEnd();
+ _process_form?.Feedback(e.Command, "Rotate applied", true);
+ }
+ }
+ else if (act.Contains("scale"))
+ {
+ double sizenew;
+ if (double.TryParse(e.Value, out sizenew))
+ {
+ double size = 100;
+ if (act.Contains("xyx"))
+ {
+ size = 100 * sizenew / VisuGCode.xyzSize.dimx;
+ }
+ else if (act.Contains("xyy"))
+ {
+ size = 100 * sizenew / VisuGCode.xyzSize.dimy;
+ }
+ int lineStart = XmlMarker.GetStartLineOfGroup(codeInsert.Y);
+ if(LineIsInRange(lineStart))
+ SetSelection(lineStart, XmlMarkerType.Group);
+ Logger.Trace("Last codeInsert:{0} {1}", codeInsert.X, lineStart);
+
+ TransformStart("Scale");
+ SetFctbCodeText(VisuGCode.TransformGCodeScale(size, size));
+ SelectionHandle.ClearSelected();
+ TransformEnd();
+ _process_form?.Feedback(e.Command, "Scale applied", true);
+ }
+ }
+ }
+
+ else if (act == "checkform")
+ {
+ if (e.Value == "Probe") { _process_form?.Feedback(e.Command, e.Value, (_probing_form != null)); }
+ if (e.Value == "Cam") { _process_form?.Feedback(e.Command, e.Value, (_camera_form != null)); }
+ }
+ }
+
+ }
+}
diff --git a/GRBL-Plotter/GUI/MainFormStreaming.cs b/GRBL-Plotter/GUI/MainFormStreaming.cs
index 7a3b09fd1..845516af8 100644
--- a/GRBL-Plotter/GUI/MainFormStreaming.cs
+++ b/GRBL-Plotter/GUI/MainFormStreaming.cs
@@ -225,7 +225,7 @@ private void OnRaiseStreamEvent(object sender, StreamEventArgs e)
VisuGCode.ProcessedPath.ProcessedPathClear();
// SetGRBLBuffer();
- _process_form?.Feedback("Stream", "reset", false);
+ _process_form?.Feedback("G-Code Stream", "reset", false);
break;
@@ -284,7 +284,7 @@ private void OnRaiseStreamEvent(object sender, StreamEventArgs e)
if (Grbl.lastErrorNr == 9) // G-code locked out during alarm or jog state -> stop streaming
{ StopStreaming(false); }
- _process_form?.Feedback("Stream", "error", false);
+ _process_form?.Feedback("G-Code Stream", "error", false);
break;
@@ -332,7 +332,7 @@ private void OnRaiseStreamEvent(object sender, StreamEventArgs e)
else
Notifier.SendMessage(msg);
}
- _process_form?.Feedback("Stream", elapsed.ToString(@"hh\:mm\:ss"), true);
+ _process_form?.Feedback("G-Code Stream", elapsed.ToString(@"hh\:mm\:ss"), true);
break;
case GrblStreaming.waitidle:
@@ -402,7 +402,7 @@ private void OnRaiseStreamEvent(object sender, StreamEventArgs e)
if (Properties.Settings.Default.flowControlEnable) // send extra Pause-Code in MainTimer_Tick from Properties.Settings.Default.flowControlText
delayedSend = 2;
- _process_form?.Feedback("Stream", "", false);
+ _process_form?.Feedback("G-Code Stream", "", false);
break;
@@ -629,7 +629,23 @@ private void StartStreaming(int startLine, int endLine)
File.Delete(fileName);
fileName = file1stName + ".nc";
- File.WriteAllText(fileName, txt); // save current GCode
+ // File.WriteAllText(fileName, txt); // save current GCode
+ //
+ int encodeIndex = Properties.Settings.Default.FCTBSaveEncodingIndex;
+ if ((encodeIndex < 0) || (encodeIndex >= GuiVariables.SaveEncoding.Length))
+ encodeIndex = 0;
+
+ string encoding = GuiVariables.SaveEncoding[encodeIndex].BodyName;
+ try
+ {
+ System.IO.File.WriteAllLines(fileName, fCTBCode.Lines, GuiVariables.SaveEncoding[encodeIndex]);
+ }
+ catch (Exception err)
+ {
+ Logger.Error(err, "StartStreaming save code ");
+ MessageBox.Show("Could not save the file: \r\n" + err.Message, "Error");
+ }
+
SaveRecentFile(fileLastProcessed + ".nc"); // update last processed file
SetLastLoadedFile("Start streaming", fileName);
}