Skip to content

Commit 7b004d4

Browse files
authored
Merge pull request #2322 from GabeMx5/master
Graphics enhancements
2 parents a9fd5a0 + d5db254 commit 7b004d4

File tree

14 files changed

+120
-88
lines changed

14 files changed

+120
-88
lines changed

LaserGRBL/ConnectLogForm.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ void ApplyConfig()
200200

201201
void BtnOpenClick(object sender, EventArgs e)
202202
{
203-
Core.OpenFile(ParentForm);
203+
Core.OpenFile();
204204
}
205205

206206
void BtnRunProgramClick(object sender, EventArgs e)

LaserGRBL/Core/GrblCore.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -595,16 +595,16 @@ void RiseOnFileLoaded(long elapsed, string filename)
595595
public GrblFile LoadedFile
596596
{ get { return file; } }
597597

598-
public void ReOpenFile(System.Windows.Forms.Form parent)
598+
public void ReOpenFile()
599599
{
600600
if (CanReOpenFile)
601-
OpenFile(parent, Settings.GetObject<string>("Core.LastOpenFile", null));
601+
OpenFile(Settings.GetObject<string>("Core.LastOpenFile", null));
602602
}
603603

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

@@ -627,12 +627,12 @@ public void OpenFile(Form parent, string filename = null, bool append = false)
627627
DialogResult dialogResult = DialogResult.Cancel;
628628
try
629629
{
630-
dialogResult = ofd.ShowDialog(parent);
630+
dialogResult = ofd.ShowDialog(FormsHelper.MainForm);
631631
}
632632
catch (System.Runtime.InteropServices.COMException)
633633
{
634634
ofd.AutoUpgradeEnabled = false;
635-
dialogResult = ofd.ShowDialog(parent);
635+
dialogResult = ofd.ShowDialog(FormsHelper.MainForm);
636636
}
637637

638638
if (dialogResult == DialogResult.OK)
@@ -649,7 +649,7 @@ public void OpenFile(Form parent, string filename = null, bool append = false)
649649
{
650650
try
651651
{
652-
RasterConverter.RasterToLaserForm.CreateAndShowDialog(this, filename, parent, append);
652+
RasterConverter.RasterToLaserForm.CreateAndShowDialog(this, filename, append);
653653
UsageCounters.RasterFile++;
654654
}
655655
catch (Exception ex)
@@ -662,7 +662,7 @@ public void OpenFile(Form parent, string filename = null, bool append = false)
662662
{
663663
try
664664
{
665-
SvgConverter.SvgToGCodeForm.CreateAndShowDialog(this, filename, parent, append);
665+
SvgConverter.SvgToGCodeForm.CreateAndShowDialog(this, filename, append);
666666
UsageCounters.SvgFile++;
667667
}
668668
catch (Exception ex)
@@ -695,7 +695,7 @@ public void OpenFile(Form parent, string filename = null, bool append = false)
695695

696696
try
697697
{
698-
RasterConverter.RasterToLaserForm.CreateAndShowDialog(this, bmpname, parent, append);
698+
RasterConverter.RasterToLaserForm.CreateAndShowDialog(this, bmpname, append);
699699
UsageCounters.RasterFile++;
700700
if (System.IO.File.Exists(bmpname))
701701
System.IO.File.Delete(bmpname);
@@ -738,9 +738,9 @@ public void OpenFile(Form parent, string filename = null, bool append = false)
738738
// Open file
739739
Settings.SetObject("Core.LastOpenFile", imageFilepath);
740740
if (i == 0)
741-
ReOpenFile(parent);
741+
ReOpenFile();
742742
else
743-
OpenFile(parent, imageFilepath, true);
743+
OpenFile(imageFilepath, true);
744744

745745
// Delete temporary image file
746746
System.IO.File.Delete(imageFilepath);

LaserGRBL/Generator/CuttingTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ public CuttingTest(GrblCore core)
4343
mCore = core;
4444
}
4545

46-
public static void CreateAndShowDialog(Form parent, GrblCore core)
46+
public static void CreateAndShowDialog(GrblCore core)
4747
{
4848
using (CuttingTest f = new CuttingTest(core))
49-
f.ShowDialog(parent);
49+
f.ShowDialog(FormsHelper.MainForm);
5050
}
5151

5252

LaserGRBL/Generator/PowerVsSpeedForm.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ public PowerVsSpeedForm(GrblCore core)
4343
mCore = core;
4444
}
4545

46-
public static void CreateAndShowDialog(Form parent, GrblCore core)
46+
public static void CreateAndShowDialog(GrblCore core)
4747
{
4848
using (PowerVsSpeedForm f = new PowerVsSpeedForm(core))
49-
f.ShowDialog(parent);
49+
f.ShowDialog(FormsHelper.MainForm);
5050
}
5151

5252

LaserGRBL/Generator/ShakeTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ public ShakeTest(GrblCore core)
2626
mCore = core;
2727
}
2828

29-
public static void CreateAndShowDialog(Form parent, GrblCore core)
29+
public static void CreateAndShowDialog(GrblCore core)
3030
{
3131
using (ShakeTest f = new ShakeTest(core))
32-
f.ShowDialog(parent);
32+
f.ShowDialog(FormsHelper.MainForm);
3333
}
3434

3535
private void BtnCreate_Click(object sender, EventArgs e)

LaserGRBL/HotKeysManager.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,9 @@ private bool PerformAction(Form parent, HotKey.Actions action)
251251
case HotKey.Actions.Disconnect:
252252
mCore.HKDisconnect(); break;
253253
case HotKey.Actions.OpenFile:
254-
mCore.OpenFile(Application.OpenForms[0]); break;
254+
mCore.OpenFile(); break;
255255
case HotKey.Actions.ReopenLastFile:
256-
mCore.ReOpenFile(Application.OpenForms[0]); break;
256+
mCore.ReOpenFile(); break;
257257
case HotKey.Actions.SaveFile:
258258
mCore.SaveProgram(parent, false, false, false, 1, false); break;
259259
case HotKey.Actions.ExecuteFile:

LaserGRBL/LaserGRBL.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@
177177
<Compile Include="SvgIcons\SvgIcons.cs" />
178178
<Compile Include="Tools\Application.cs" />
179179
<Compile Include="Tools\DoubleBufferBmp.cs" />
180+
<Compile Include="Tools\FormsHelper.cs" />
180181
<Compile Include="Tools\Graph.cs" />
181182
<Compile Include="Tools\MobileAverageCalculator.cs" />
182183
<Compile Include="Tools\RetainedSetting.cs" />

LaserGRBL/LaserUsage.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ private LaserUsage(GrblCore core)
2020
mCore = core;
2121
}
2222

23-
internal static void CreateAndShowDialog(Form parent, GrblCore core)
23+
internal static void CreateAndShowDialog(GrblCore core)
2424
{
2525
using (LaserUsage sf = new LaserUsage(core))
26-
sf.ShowDialog(parent);
26+
sf.ShowDialog(FormsHelper.MainForm);
2727
}
2828

2929
private void LaserUsage_Load(object sender, EventArgs e)

LaserGRBL/MainForm.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ private void MainForm_Load(object sender, EventArgs e)
282282
{
283283
using (LegalDisclaimer lds = new LegalDisclaimer())
284284
{
285-
lds.ShowDialog();
285+
lds.ShowDialog(FormsHelper.MainForm);
286286
if (lds.accepted)
287287
{
288288
canrun = true;
@@ -347,7 +347,7 @@ private void ManageCommandLineArgs(string[] args)
347347
else
348348
{
349349
if (Core.CanLoadNewFile)
350-
Core.OpenFile(this, filename, false);
350+
Core.OpenFile(filename, false);
351351
else
352352
MessageBox.Show(Strings.MsgboxCannotOpenFileNow);
353353
}
@@ -617,7 +617,7 @@ void ExitToolStripMenuItemClick(object sender, EventArgs e)
617617
private void MnFileOpen_Click(object sender, EventArgs e)
618618
{
619619
Project.ClearSettings();
620-
Core.OpenFile(this);
620+
Core.OpenFile();
621621
}
622622

623623
private void MnFileSend_Click(object sender, EventArgs e)
@@ -853,7 +853,7 @@ protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
853853
private void MnReOpenFile_Click(object sender, EventArgs e)
854854
{
855855
Project.ClearSettings();
856-
Core.ReOpenFile(this);
856+
Core.ReOpenFile();
857857
}
858858

859859

@@ -885,7 +885,7 @@ private void MnStartFromPosition_Click(object sender, EventArgs e)
885885

886886
private void MnFileAppend_Click(object sender, EventArgs e)
887887
{
888-
Core.OpenFile(this, null, true);
888+
Core.OpenFile(null, true);
889889
}
890890

891891
private void hungarianToolStripMenuItem_Click(object sender, EventArgs e)
@@ -1001,10 +1001,10 @@ private void MainForm_DragDrop(object sender, DragEventArgs e)
10011001

10021002
void dropDispatcherTimer_Tick(object sender, EventArgs e)
10031003
{
1004-
if (this.droppedFile != null)
1004+
if (droppedFile != null)
10051005
{
1006-
Core.OpenFile(this, this.droppedFile);
1007-
this.droppedFile = null;
1006+
Core.OpenFile(droppedFile);
1007+
droppedFile = null;
10081008
dropDispatcherTimer.Stop();
10091009
}
10101010
}
@@ -1196,32 +1196,32 @@ private void MnConfigureOrturWiFi_Click(object sender, EventArgs e)
11961196

11971197
private void TTlaserLife_Click(object sender, EventArgs e)
11981198
{
1199-
LaserUsage.CreateAndShowDialog(this, Core);
1199+
LaserUsage.CreateAndShowDialog(Core);
12001200
}
12011201

12021202
private void laserUsageStatsToolStripMenuItem_Click(object sender, EventArgs e)
12031203
{
1204-
LaserUsage.CreateAndShowDialog(this, Core);
1204+
LaserUsage.CreateAndShowDialog(Core);
12051205
}
12061206

12071207
private void MnGrayscaleTest_Click(object sender, EventArgs e)
12081208
{
1209-
Generator.PowerVsSpeedForm.CreateAndShowDialog(this, Core);
1209+
Generator.PowerVsSpeedForm.CreateAndShowDialog(Core);
12101210
}
12111211

12121212
private void MnCuttingTest_Click(object sender, EventArgs e)
12131213
{
1214-
Generator.CuttingTest.CreateAndShowDialog(this, Core);
1214+
Generator.CuttingTest.CreateAndShowDialog(Core);
12151215
}
12161216

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

12221222
private void shakeTestToolStripMenuItem_Click(object sender, EventArgs e)
12231223
{
1224-
Generator.ShakeTest.CreateAndShowDialog(this, Core);
1224+
Generator.ShakeTest.CreateAndShowDialog(Core);
12251225
}
12261226

12271227
private void autoSizeToolStripMenuItem_Click(object sender, EventArgs e)

0 commit comments

Comments
 (0)