Skip to content

Commit

Permalink
Version 1.7.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
svenhb committed Dec 18, 2023
1 parent 2512c8f commit 3eecee1
Show file tree
Hide file tree
Showing 15 changed files with 258 additions and 106 deletions.
13 changes: 12 additions & 1 deletion GRBL-Plotter/GUI/MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

135 changes: 81 additions & 54 deletions GRBL-Plotter/GUI/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,26 @@ public MainForm()
{
const string reg_key = "HKEY_CURRENT_USER\\SOFTWARE\\GRBL-Plotter";
try
{ Registry.SetValue(reg_key, "update", 0); }
{
Registry.SetValue(reg_key, "update", 0);
Registry.SetValue(reg_key, "start", 0);
Registry.SetValue(reg_key, "stop", 0);
Registry.SetValue(reg_key, "offsetX", "0.0");
Registry.SetValue(reg_key, "offsetY", "0.0");
Registry.SetValue(reg_key, "rotate", "0.0");
}
catch (Exception er) { Logger.Error(er, "MainForm Reading reg-key update "); }
}

CustomButtonsSetEvents(); // for buttons 17 to 32
SetMenuShortCuts(); // Add shortcuts to menu items
LoadRecentList(); // open Recent.txt and fill menu
try
{ cmsPicBoxReloadFile.Text += " | " + Path.GetFileName(Datapath.MakeAbsolutePath(MRUlist[0])); }
catch
{
Logger.Error("MainForm: could not set cmsPicBoxReloadFile.Text");
}

UpdateMenuChecker();

Expand Down Expand Up @@ -267,58 +280,10 @@ private void SplashScreenTimer_Tick(object sender, EventArgs e)
Logger.Info(culture, "++++++ MainForm SplashScreen closed -> mainTimer:{0}", mainTimerCount);

string[] args = Environment.GetCommandLineArgs();
LoadFiles(args, 1);
/*

if (args.Length > 1)
{
if (Properties.Settings.Default.fromFormInsertEnable)
{
Graphic2GCode.multiImport = true;
bool tmpUseCase = Properties.Settings.Default.importShowUseCaseDialog;
bool tmpOffset = Properties.Settings.Default.importGraphicOffsetOrigin;
decimal tmpOffsetX = Properties.Settings.Default.importGraphicOffsetOriginX;
decimal tmpOffsetY = Properties.Settings.Default.importGraphicOffsetOriginY;
decimal gap = Properties.Settings.Default.importGraphicMultiplyGraphicsDistance;
int maxX = (int)Properties.Settings.Default.importGraphicMultiplyGraphicsDimX;
int countX = 0;
double graphicDimX = 0;
Properties.Settings.Default.importGraphicOffsetOrigin = true;
for (int i = 1; i < args.Length; i++)
{
Logger.Info(culture, "Load files via CommandLineArgs[{0}] {1}", i, args[1]);
Graphic2GCode.multiImportNr = i;
LoadFile(args[i]);
countX++;
Properties.Settings.Default.importShowUseCaseDialog = false; // show dialog just 1 time
graphicDimX = Graphic.actualDimension.maxx;
if (graphicDimX !=0)
Properties.Settings.Default.importGraphicOffsetOriginX += (decimal)graphicDimX + gap;
else
Properties.Settings.Default.importGraphicOffsetOriginX = (decimal)VisuGCode.xyzSize.maxx + gap;
if (countX >= maxX)
{
countX = 0;
Properties.Settings.Default.importGraphicOffsetOriginX = tmpOffsetX;
Properties.Settings.Default.importGraphicOffsetOriginY = (decimal)VisuGCode.xyzSize.maxy + gap;
}
}
LoadFiles(args, 1);

Properties.Settings.Default.importShowUseCaseDialog = tmpUseCase;
Properties.Settings.Default.importGraphicOffsetOrigin = tmpOffset;
Properties.Settings.Default.importGraphicOffsetOriginX = tmpOffsetX;
Properties.Settings.Default.importGraphicOffsetOriginY = tmpOffsetY;
}
else
{
Logger.Info(culture, "Load file via CommandLineArgs[1] {0}", args[1]);
LoadFile(args[1]);
}
}
*/
SplashScreenTimer.Stop();
SplashScreenTimer.Interval = 2000;
SplashScreenTimer.Start();
Expand Down Expand Up @@ -491,6 +456,31 @@ private void MainTimer_Tick(object sender, EventArgs e)
signalShowToolExchangeMessage = false;
ShowToolChangeMessage();
}
if (Properties.Settings.Default.flowCheckRegistryChange)
{
int start = 0, stop = 0;
const string reg_key = "HKEY_CURRENT_USER\\SOFTWARE\\GRBL-Plotter";

try
{
start = (int)Registry.GetValue(reg_key, "start", 0);
Registry.SetValue(reg_key, "start", 0);
stop = (int)Registry.GetValue(reg_key, "stop", 0);
Registry.SetValue(reg_key, "stop", 0);
}
catch (Exception er) { Logger.Error(er, "MainTimer_Tick stream Reading reg-key update "); }

if (start != 0)
{
Logger.Trace("MainTimer_Tick Pause streaming");
StartStreaming(0, fCTBCode.LinesCount - 1); // btnStreamStart.PerformClick();
}
if (stop != 0)
{
Logger.Trace("MainTimer_Tick Stop streaming");
StopStreaming(true); // btnStreamStop.PerformClick();
}
}
}
else
{
Expand All @@ -502,22 +492,57 @@ private void MainTimer_Tick(object sender, EventArgs e)

if (Properties.Settings.Default.flowCheckRegistryChange)
{
int update = 0;
int update = 0, start = 0;
double offX = 0;
double offY = 0;
double rotate = 0;
const string reg_key = "HKEY_CURRENT_USER\\SOFTWARE\\GRBL-Plotter";
try
{
update = (int)Registry.GetValue(reg_key, "update", 0);
Registry.SetValue(reg_key, "update", 0);

if (double.TryParse((string)Registry.GetValue(reg_key, "offsetX", "0.0"), out double ox)) { offX = ox; }
if (double.TryParse((string)Registry.GetValue(reg_key, "offsetY", "0.0"), out double oy)) { offY = oy; }
if (double.TryParse((string)Registry.GetValue(reg_key, "rotate", "0.0"), out double r)) { rotate = r; }
Registry.SetValue(reg_key, "offsetX", "0.0");
Registry.SetValue(reg_key, "offsetY", "0.0");
Registry.SetValue(reg_key, "rotate", "0.0");

start = (int)Registry.GetValue(reg_key, "start", 0);
Registry.SetValue(reg_key, "start", 0);
}
catch (Exception er) { Logger.Error(er, "Reading reg-key update"); }

if (update > 0)
{
Logger.Trace("Automatic update from clipboard");
Logger.Trace("MainTimer_Tick Automatic update from clipboard");
LoadFromClipboard();
EnableCmsCodeBlocks(VisuGCode.CodeBlocksAvailable());
Properties.Settings.Default.counterImportExtension += 1;
}

if ((offX != 0) || (offY != 0))
{
Logger.Trace("MainTimer_Tick OffX:{0} OffY:{1}", offX, offY);
TransformStart("Offset Reg");
fCTBCode.Text = VisuGCode.TransformGCodeOffset(-offX, -offY, 0);// VisuGCode.Translate.Offset1);
TransformEnd();
}

if (rotate != 0)
{
Logger.Trace("MainTimer_Tick Rotate:{0}", rotate);
TransformStart("Rotate Reg");
fCTBCode.Text = VisuGCode.TransformGCodeRotate(rotate, 1, new XyPoint(0, 0));
TransformEnd();
}

if (start != 0)
{
Logger.Trace("MainTimer_Tick Start streaming", rotate);
StartStreaming(0, fCTBCode.LinesCount - 1); // (); btnStreamStart.PerformClick();
}
}

if (loadTimerStep == 0)
Expand Down Expand Up @@ -1346,7 +1371,7 @@ private void UpdatePathDisplay(object sender, EventArgs e)
Properties.Settings.Default.guiDimensionShow = toolStripViewDimension.Checked;
Properties.Settings.Default.guiBackgroundShow = toolStripViewBackground.Checked;
Properties.Settings.Default.machineLimitsFix = toolStripViewMachineFix.Checked;
zoomFactorMin = zoomFactor = 1;
zoomFactor = 1;
VisuGCode.DrawMachineLimit();// ToolTable.GetToolCordinates());
pictureBox1.Invalidate(); // resfresh view
}
Expand Down Expand Up @@ -1656,6 +1681,8 @@ private void ShowFormsToolStripMenuItem_Click(object sender, EventArgs e)
if (_probing_form != null) { _probing_form.WindowState = FormWindowState.Normal; _probing_form.BringToFront(); }
if (_heightmap_form != null) { _heightmap_form.WindowState = FormWindowState.Normal; _heightmap_form.BringToFront(); }
if (_grbl_setup_form != null) { _grbl_setup_form.WindowState = FormWindowState.Normal; _grbl_setup_form.BringToFront(); }
if (_process_form != null) { _process_form.WindowState = FormWindowState.Normal; _process_form.BringToFront(); }
if (_grbl_setup_form != null) { _grbl_setup_form.WindowState = FormWindowState.Normal; _grbl_setup_form.BringToFront(); }
// _streaming_form.SendToBack();
}

Expand Down
19 changes: 17 additions & 2 deletions GRBL-Plotter/GUI/MainForm.resx
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
<value>1</value>
</data>
<data name="fCTBCode.AutoScrollMinSize" type="System.Drawing.Size, System.Drawing">
<value>214, 12</value>
<value>191, 12</value>
</data>
<metadata name="cmsFCTB.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>123, 56</value>
Expand Down Expand Up @@ -4704,6 +4704,15 @@ to how much it lost (this is the problem with steppers in general). Otherwise, G
<data name="cmsPicBoxReloadFile.ToolTipText" xml:space="preserve">
<value>Reload last loaded file</value>
</data>
<data name="cmsPicBoxReloadFile2.Size" type="System.Drawing.Size, System.Drawing">
<value>236, 22</value>
</data>
<data name="cmsPicBoxReloadFile2.Text" xml:space="preserve">
<value>Reload File 2</value>
</data>
<data name="cmsPicBoxReloadFile2.Visible" type="System.Boolean, mscorlib">
<value>False</value>
</data>
<data name="cmsPicBoxPasteFromClipboard.Size" type="System.Drawing.Size, System.Drawing">
<value>236, 22</value>
</data>
Expand Down Expand Up @@ -4897,7 +4906,7 @@ to how much it lost (this is the problem with steppers in general). Otherwise, G
<value>Copy 2D-View image to clipboard</value>
</data>
<data name="cmsPictureBox.Size" type="System.Drawing.Size, System.Drawing">
<value>237, 496</value>
<value>237, 518</value>
</data>
<data name="&gt;&gt;cmsPictureBox.Name" xml:space="preserve">
<value>cmsPictureBox</value>
Expand Down Expand Up @@ -8160,6 +8169,12 @@ Dil
<data name="&gt;&gt;cmsPicBoxReloadFile.Type" xml:space="preserve">
<value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;cmsPicBoxReloadFile2.Name" xml:space="preserve">
<value>cmsPicBoxReloadFile2</value>
</data>
<data name="&gt;&gt;cmsPicBoxReloadFile2.Type" xml:space="preserve">
<value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;cmsPicBoxPasteFromClipboard.Name" xml:space="preserve">
<value>cmsPicBoxPasteFromClipboard</value>
</data>
Expand Down
17 changes: 13 additions & 4 deletions GRBL-Plotter/GUI/MainFormFCTB.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,9 @@ private void FctbCode_TextChangedDelayed(object sender, FastColoredTextBoxNS.Tex
{
if (Gcode.LoggerTrace && logMain)
Logger.Trace("Event fCTBCode_TextChanged manualEdit:{0} resetView:{1}", manualEdit, resetView);
fCTBCode.Cursor = Cursors.IBeam;
pictureBox1.Cursor = Cursors.Cross;

if (resetView && !manualEdit)
{
try
Expand Down Expand Up @@ -319,6 +322,10 @@ private void FctbCheckUnknownCode()

private int SetFctbCodeText(string code, bool insertCode = false)
{
fCTBCode.Cursor = Cursors.WaitCursor;
pictureBox1.Cursor = Cursors.WaitCursor;
Application.DoEvents();

CmsPicBoxEnable();
ClearErrorLines();
Logger.Trace("---- SetFctbCodeText insertCode:{0} enabled:{1}", insertCode, Properties.Settings.Default.fromFormInsertEnable);
Expand Down Expand Up @@ -578,7 +585,7 @@ private int InsertCodeToFctb(string sourceGCode, bool fromFile, int lineSelected
fCTBCode.UnbookmarkLine(fCTBCodeClickedLineLast);
fCTBCode.BookmarkLine(fCTBCodeClickedLineNow);

// VisuGCode.SetPosMarkerLine(fCTBCodeClickedLineNow, !isStreaming);
VisuGCode.SetPosMarkerLine(fCTBCodeClickedLineNow, false); // !isStreaming);
pictureBox1.Invalidate(); // avoid too much events // toolStrip_tb_StreamLine.Text = fCTBCodeClickedLineNow.ToString();

}
Expand Down Expand Up @@ -711,13 +718,15 @@ private void SelectNextFigureGroupTile(int direction)

fCTBCode.UnbookmarkLine(fCTBCodeClickedLineLast);
fCTBCode.BookmarkLine(fCTBCodeClickedLineNow);
fCTBCode.DoCaretVisible();
// fCTBCode.DoCaretVisible();
if ((markerType != XmlMarkerType.None) && VisuGCode.CodeBlocksAvailable() && !isStreaming)
{
SelectionHandle.SelectedMarkerType = markerType;
SelectionHandle.SelectedMarkerLine = fCTBCodeClickedLineNow;
}
VisuGCode.SetPosMarkerLine(fCTBCodeClickedLineNow, !isStreaming);
VisuGCode.SetPosMarkerLine(fCTBCodeClickedLineNow, false); // !isStreaming);
if (fCTBCodeClickedLineNow > 0)
fCTBCode.GotoNextBookmark(fCTBCodeClickedLineNow - 1);// .DoCaretVisible();
pictureBox1.Invalidate(); // avoid too much events // toolStrip_tb_StreamLine.Text = fCTBCodeClickedLineNow.ToString();
}

Expand Down Expand Up @@ -1027,7 +1036,7 @@ private void EnableCmsCodeBlocks(bool enable)
}
else // group not present, try figure / switch to figure
{
markedBlockType = marker = XmlMarkerType.Figure;
markedBlockType = XmlMarkerType.Figure;
}
}
else if (marker == XmlMarkerType.Figure)
Expand Down
Loading

0 comments on commit 3eecee1

Please sign in to comment.