Skip to content

Commit

Permalink
Merge pull request #2322 from GabeMx5/master
Browse files Browse the repository at this point in the history
Graphics enhancements
  • Loading branch information
arkypita authored Jul 21, 2024
2 parents a9fd5a0 + d5db254 commit 7b004d4
Show file tree
Hide file tree
Showing 14 changed files with 120 additions and 88 deletions.
2 changes: 1 addition & 1 deletion LaserGRBL/ConnectLogForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ void ApplyConfig()

void BtnOpenClick(object sender, EventArgs e)
{
Core.OpenFile(ParentForm);
Core.OpenFile();
}

void BtnRunProgramClick(object sender, EventArgs e)
Expand Down
20 changes: 10 additions & 10 deletions LaserGRBL/Core/GrblCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -595,16 +595,16 @@ void RiseOnFileLoaded(long elapsed, string filename)
public GrblFile LoadedFile
{ get { return file; } }

public void ReOpenFile(System.Windows.Forms.Form parent)
public void ReOpenFile()
{
if (CanReOpenFile)
OpenFile(parent, Settings.GetObject<string>("Core.LastOpenFile", null));
OpenFile(Settings.GetObject<string>("Core.LastOpenFile", null));
}

public static readonly List<string> ImageExtensions = new List<string>(new string[] { ".jpg", ".jpeg", ".bmp", ".png", ".gif" });
public static readonly List<string> GCodeExtensions = new List<string>(new string[] { ".nc", ".cnc", ".tap", ".gcode", ".ngc" });
public static readonly List<string> ProjectFileExtensions = new List<string>(new string[] { ".lps" });
public void OpenFile(Form parent, string filename = null, bool append = false)
public void OpenFile(string filename = null, bool append = false)
{
if (!CanLoadNewFile) return;

Expand All @@ -627,12 +627,12 @@ public void OpenFile(Form parent, string filename = null, bool append = false)
DialogResult dialogResult = DialogResult.Cancel;
try
{
dialogResult = ofd.ShowDialog(parent);
dialogResult = ofd.ShowDialog(FormsHelper.MainForm);
}
catch (System.Runtime.InteropServices.COMException)
{
ofd.AutoUpgradeEnabled = false;
dialogResult = ofd.ShowDialog(parent);
dialogResult = ofd.ShowDialog(FormsHelper.MainForm);
}

if (dialogResult == DialogResult.OK)
Expand All @@ -649,7 +649,7 @@ public void OpenFile(Form parent, string filename = null, bool append = false)
{
try
{
RasterConverter.RasterToLaserForm.CreateAndShowDialog(this, filename, parent, append);
RasterConverter.RasterToLaserForm.CreateAndShowDialog(this, filename, append);
UsageCounters.RasterFile++;
}
catch (Exception ex)
Expand All @@ -662,7 +662,7 @@ public void OpenFile(Form parent, string filename = null, bool append = false)
{
try
{
SvgConverter.SvgToGCodeForm.CreateAndShowDialog(this, filename, parent, append);
SvgConverter.SvgToGCodeForm.CreateAndShowDialog(this, filename, append);
UsageCounters.SvgFile++;
}
catch (Exception ex)
Expand Down Expand Up @@ -695,7 +695,7 @@ public void OpenFile(Form parent, string filename = null, bool append = false)

try
{
RasterConverter.RasterToLaserForm.CreateAndShowDialog(this, bmpname, parent, append);
RasterConverter.RasterToLaserForm.CreateAndShowDialog(this, bmpname, append);
UsageCounters.RasterFile++;
if (System.IO.File.Exists(bmpname))
System.IO.File.Delete(bmpname);
Expand Down Expand Up @@ -738,9 +738,9 @@ public void OpenFile(Form parent, string filename = null, bool append = false)
// Open file
Settings.SetObject("Core.LastOpenFile", imageFilepath);
if (i == 0)
ReOpenFile(parent);
ReOpenFile();
else
OpenFile(parent, imageFilepath, true);
OpenFile(imageFilepath, true);

// Delete temporary image file
System.IO.File.Delete(imageFilepath);
Expand Down
4 changes: 2 additions & 2 deletions LaserGRBL/Generator/CuttingTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ public CuttingTest(GrblCore core)
mCore = core;
}

public static void CreateAndShowDialog(Form parent, GrblCore core)
public static void CreateAndShowDialog(GrblCore core)
{
using (CuttingTest f = new CuttingTest(core))
f.ShowDialog(parent);
f.ShowDialog(FormsHelper.MainForm);
}


Expand Down
4 changes: 2 additions & 2 deletions LaserGRBL/Generator/PowerVsSpeedForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ public PowerVsSpeedForm(GrblCore core)
mCore = core;
}

public static void CreateAndShowDialog(Form parent, GrblCore core)
public static void CreateAndShowDialog(GrblCore core)
{
using (PowerVsSpeedForm f = new PowerVsSpeedForm(core))
f.ShowDialog(parent);
f.ShowDialog(FormsHelper.MainForm);
}


Expand Down
4 changes: 2 additions & 2 deletions LaserGRBL/Generator/ShakeTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ public ShakeTest(GrblCore core)
mCore = core;
}

public static void CreateAndShowDialog(Form parent, GrblCore core)
public static void CreateAndShowDialog(GrblCore core)
{
using (ShakeTest f = new ShakeTest(core))
f.ShowDialog(parent);
f.ShowDialog(FormsHelper.MainForm);
}

private void BtnCreate_Click(object sender, EventArgs e)
Expand Down
4 changes: 2 additions & 2 deletions LaserGRBL/HotKeysManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,9 @@ private bool PerformAction(Form parent, HotKey.Actions action)
case HotKey.Actions.Disconnect:
mCore.HKDisconnect(); break;
case HotKey.Actions.OpenFile:
mCore.OpenFile(Application.OpenForms[0]); break;
mCore.OpenFile(); break;
case HotKey.Actions.ReopenLastFile:
mCore.ReOpenFile(Application.OpenForms[0]); break;
mCore.ReOpenFile(); break;
case HotKey.Actions.SaveFile:
mCore.SaveProgram(parent, false, false, false, 1, false); break;
case HotKey.Actions.ExecuteFile:
Expand Down
1 change: 1 addition & 0 deletions LaserGRBL/LaserGRBL.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@
<Compile Include="SvgIcons\SvgIcons.cs" />
<Compile Include="Tools\Application.cs" />
<Compile Include="Tools\DoubleBufferBmp.cs" />
<Compile Include="Tools\FormsHelper.cs" />
<Compile Include="Tools\Graph.cs" />
<Compile Include="Tools\MobileAverageCalculator.cs" />
<Compile Include="Tools\RetainedSetting.cs" />
Expand Down
4 changes: 2 additions & 2 deletions LaserGRBL/LaserUsage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ private LaserUsage(GrblCore core)
mCore = core;
}

internal static void CreateAndShowDialog(Form parent, GrblCore core)
internal static void CreateAndShowDialog(GrblCore core)
{
using (LaserUsage sf = new LaserUsage(core))
sf.ShowDialog(parent);
sf.ShowDialog(FormsHelper.MainForm);
}

private void LaserUsage_Load(object sender, EventArgs e)
Expand Down
28 changes: 14 additions & 14 deletions LaserGRBL/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ private void MainForm_Load(object sender, EventArgs e)
{
using (LegalDisclaimer lds = new LegalDisclaimer())
{
lds.ShowDialog();
lds.ShowDialog(FormsHelper.MainForm);
if (lds.accepted)
{
canrun = true;
Expand Down Expand Up @@ -347,7 +347,7 @@ private void ManageCommandLineArgs(string[] args)
else
{
if (Core.CanLoadNewFile)
Core.OpenFile(this, filename, false);
Core.OpenFile(filename, false);
else
MessageBox.Show(Strings.MsgboxCannotOpenFileNow);
}
Expand Down Expand Up @@ -617,7 +617,7 @@ void ExitToolStripMenuItemClick(object sender, EventArgs e)
private void MnFileOpen_Click(object sender, EventArgs e)
{
Project.ClearSettings();
Core.OpenFile(this);
Core.OpenFile();
}

private void MnFileSend_Click(object sender, EventArgs e)
Expand Down Expand Up @@ -853,7 +853,7 @@ protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
private void MnReOpenFile_Click(object sender, EventArgs e)
{
Project.ClearSettings();
Core.ReOpenFile(this);
Core.ReOpenFile();
}


Expand Down Expand Up @@ -885,7 +885,7 @@ private void MnStartFromPosition_Click(object sender, EventArgs e)

private void MnFileAppend_Click(object sender, EventArgs e)
{
Core.OpenFile(this, null, true);
Core.OpenFile(null, true);
}

private void hungarianToolStripMenuItem_Click(object sender, EventArgs e)
Expand Down Expand Up @@ -1001,10 +1001,10 @@ private void MainForm_DragDrop(object sender, DragEventArgs e)

void dropDispatcherTimer_Tick(object sender, EventArgs e)
{
if (this.droppedFile != null)
if (droppedFile != null)
{
Core.OpenFile(this, this.droppedFile);
this.droppedFile = null;
Core.OpenFile(droppedFile);
droppedFile = null;
dropDispatcherTimer.Stop();
}
}
Expand Down Expand Up @@ -1196,32 +1196,32 @@ private void MnConfigureOrturWiFi_Click(object sender, EventArgs e)

private void TTlaserLife_Click(object sender, EventArgs e)
{
LaserUsage.CreateAndShowDialog(this, Core);
LaserUsage.CreateAndShowDialog(Core);
}

private void laserUsageStatsToolStripMenuItem_Click(object sender, EventArgs e)
{
LaserUsage.CreateAndShowDialog(this, Core);
LaserUsage.CreateAndShowDialog(Core);
}

private void MnGrayscaleTest_Click(object sender, EventArgs e)
{
Generator.PowerVsSpeedForm.CreateAndShowDialog(this, Core);
Generator.PowerVsSpeedForm.CreateAndShowDialog(Core);
}

private void MnCuttingTest_Click(object sender, EventArgs e)
{
Generator.CuttingTest.CreateAndShowDialog(this, Core);
Generator.CuttingTest.CreateAndShowDialog(Core);
}

private void MnAccuracyTest_Click(object sender, EventArgs e)
{
Core.OpenFile(this, "LaserGRBL.Generator.SVG.LaserGRBL-accuracy-test-file.svg", false);
Core.OpenFile("LaserGRBL.Generator.SVG.LaserGRBL-accuracy-test-file.svg", false);
}

private void shakeTestToolStripMenuItem_Click(object sender, EventArgs e)
{
Generator.ShakeTest.CreateAndShowDialog(this, Core);
Generator.ShakeTest.CreateAndShowDialog(Core);
}

private void autoSizeToolStripMenuItem_Click(object sender, EventArgs e)
Expand Down
Loading

0 comments on commit 7b004d4

Please sign in to comment.