diff --git a/LaserGRBL/ConnectLogForm.cs b/LaserGRBL/ConnectLogForm.cs index fd4471a7..43dd67c2 100644 --- a/LaserGRBL/ConnectLogForm.cs +++ b/LaserGRBL/ConnectLogForm.cs @@ -200,7 +200,7 @@ void ApplyConfig() void BtnOpenClick(object sender, EventArgs e) { - Core.OpenFile(ParentForm); + Core.OpenFile(); } void BtnRunProgramClick(object sender, EventArgs e) diff --git a/LaserGRBL/Core/GrblCore.cs b/LaserGRBL/Core/GrblCore.cs index 2b1337f0..72c29a9c 100644 --- a/LaserGRBL/Core/GrblCore.cs +++ b/LaserGRBL/Core/GrblCore.cs @@ -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("Core.LastOpenFile", null)); + OpenFile(Settings.GetObject("Core.LastOpenFile", null)); } public static readonly List ImageExtensions = new List(new string[] { ".jpg", ".jpeg", ".bmp", ".png", ".gif" }); public static readonly List GCodeExtensions = new List(new string[] { ".nc", ".cnc", ".tap", ".gcode", ".ngc" }); public static readonly List ProjectFileExtensions = new List(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; @@ -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) @@ -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) @@ -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) @@ -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); @@ -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); diff --git a/LaserGRBL/Generator/CuttingTest.cs b/LaserGRBL/Generator/CuttingTest.cs index bbb95190..31da254e 100644 --- a/LaserGRBL/Generator/CuttingTest.cs +++ b/LaserGRBL/Generator/CuttingTest.cs @@ -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); } diff --git a/LaserGRBL/Generator/PowerVsSpeedForm.cs b/LaserGRBL/Generator/PowerVsSpeedForm.cs index f741317c..ea595b4c 100644 --- a/LaserGRBL/Generator/PowerVsSpeedForm.cs +++ b/LaserGRBL/Generator/PowerVsSpeedForm.cs @@ -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); } diff --git a/LaserGRBL/Generator/ShakeTest.cs b/LaserGRBL/Generator/ShakeTest.cs index 4a1abe63..66a6467b 100644 --- a/LaserGRBL/Generator/ShakeTest.cs +++ b/LaserGRBL/Generator/ShakeTest.cs @@ -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) diff --git a/LaserGRBL/HotKeysManager.cs b/LaserGRBL/HotKeysManager.cs index f62161b1..1cc6d207 100644 --- a/LaserGRBL/HotKeysManager.cs +++ b/LaserGRBL/HotKeysManager.cs @@ -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: diff --git a/LaserGRBL/LaserGRBL.csproj b/LaserGRBL/LaserGRBL.csproj index 4817352b..490390f6 100644 --- a/LaserGRBL/LaserGRBL.csproj +++ b/LaserGRBL/LaserGRBL.csproj @@ -177,6 +177,7 @@ + diff --git a/LaserGRBL/LaserUsage.cs b/LaserGRBL/LaserUsage.cs index 3a098e96..bb7348a3 100644 --- a/LaserGRBL/LaserUsage.cs +++ b/LaserGRBL/LaserUsage.cs @@ -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) diff --git a/LaserGRBL/MainForm.cs b/LaserGRBL/MainForm.cs index be96bc2d..aaeac0ee 100644 --- a/LaserGRBL/MainForm.cs +++ b/LaserGRBL/MainForm.cs @@ -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; @@ -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); } @@ -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) @@ -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(); } @@ -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) @@ -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(); } } @@ -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) diff --git a/LaserGRBL/Obj3D/Objects3D.cs b/LaserGRBL/Obj3D/Objects3D.cs index c34996d0..4b9c2de5 100644 --- a/LaserGRBL/Obj3D/Objects3D.cs +++ b/LaserGRBL/Obj3D/Objects3D.cs @@ -14,8 +14,7 @@ public class Object3DVertex public double X { get; set; } public double Y { get; set; } public double Z { get; set; } - public float Alpha { get; set; } - public GLColor NewColor { get; set; } + public float Intensity { get; set; } public GrblCommand Command { get; set; } } @@ -117,12 +116,12 @@ protected void NewDisplayList(bool first = false, int? lineWidth = null, int sti mDisplayLists.Add(mCurrentDisplayList); } - public void AddVertex(double x, double y, double z, GLColor color, GrblCommand command = null) + public void AddVertex(double x, double y, double z, GLColor color, GrblCommand command = null, float intensity = 1) { VertexCounter++; mGL.Color(color); mGL.Vertex(x, y, z); - mCurrentDisplayList.Vertices.Add(new Object3DVertex { X = x, Y = y, Z = z, Alpha = color.A, Command = command }); + mCurrentDisplayList.Vertices.Add(new Object3DVertex { X = x, Y = y, Z = z, Intensity = intensity, Command = command }); if (command != null) command.LinkedDisplayList = mCurrentDisplayList; } @@ -240,7 +239,7 @@ protected override void Draw() for (int i = 0; i >= left; i -= gridSize) DrawVerticalLine(i, f, TicksColor); for (int i = 0; i <= top; i += gridSize) DrawHorizontalLine(i, f, TicksColor); for (int i = 0; i >= bottom; i -= gridSize) DrawHorizontalLine(i, f, TicksColor); - f = -1; + f = -5; DrawVerticalLine(0, f, OriginsColor); DrawHorizontalLine(0, f, OriginsColor); } @@ -262,8 +261,9 @@ public class Grbl3D : Object3D public readonly GrblCore Core; private readonly bool mJustLaserOffMovements; private Object3DDisplayList mBoundingBoxDisplayList; - public Color Color; - public Color BoundingBoxColor; + public GLColor BackgroundColor; + public GLColor Color; + public GLColor BoundingBoxColor; private double mLoadingPercentage = 0; public bool ShowBoundingBox { get; set; } = true; private const int BOUNDING_RECT_LINE_WIDTH = 1; @@ -272,11 +272,12 @@ public class Grbl3D : Object3D public delegate void OnLoadingPercentageChangeDlg(); public static event OnLoadingPercentageChangeDlg OnLoadingPercentageChange; - public Grbl3D(GrblCore core, string name, bool justLaserOffMovements, Color color, Color boundingBoxColor) : base(name, core.PreviewLineSize.Value) + public Grbl3D(GrblCore core, string name, bool justLaserOffMovements, Color color, Color backgroundColor, Color boundingBoxColor) : base(name, core.PreviewLineSize.Value) { Core = core; mJustLaserOffMovements = justLaserOffMovements; Color = color; + BackgroundColor = backgroundColor; BoundingBoxColor = boundingBoxColor; } @@ -294,10 +295,25 @@ private set } } + private float Map(float value, float outMin, float outMax) + { + return value * (outMax - outMin) + outMin; + } + + private GLColor Blend(GLColor color, float intensity) + { + GLColor result = new GLColor(); + result.R = Map(intensity, BackgroundColor.R, color.R); + result.G = Map(intensity, BackgroundColor.G, color.G); + result.B = Map(intensity, BackgroundColor.B, color.B); + result.A = 1; + return result; + } + protected override void Draw() { + const int zPos = 0; NewDisplayList(true, BOUNDING_RECT_LINE_WIDTH, BOUNDING_RECT_STIPPLE); - float zPos = 0; GrblCommand.StatePositionBuilder spb = new GrblCommand.StatePositionBuilder(); Core.LoadedFile.InUse = true; @@ -334,25 +350,20 @@ protected override void Draw() if (spb.G0G1 && cmd.IsLinearMovement) { GLColor color = Color; + float intensity = 1; if (spb.LaserBurning && !mJustLaserOffMovements) { - color.A = spb.GetCurrentAlpha(Core.LoadedFile.Range.SpindleRange) / 255f; + intensity = spb.GetCurrentAlpha(Core.LoadedFile.Range.SpindleRange) / 255f; } else { - if (mJustLaserOffMovements) - { - color = Color; - } - else - { - color.A = 0; - } + intensity = mJustLaserOffMovements ? 1 : 0; } - if (color != null) + if (intensity > 0) { - AddVertex((float)spb.X.Previous, (float)spb.Y.Previous, zPos, color, cmd); - AddVertex((float)spb.X.Number, (float)spb.Y.Number, zPos, color, cmd); + color = Blend(color, intensity); + AddVertex((float)spb.X.Previous, (float)spb.Y.Previous, zPos, color, cmd, intensity); + AddVertex((float)spb.X.Number, (float)spb.Y.Number, zPos, color, cmd, intensity); } } else if (spb.G2G3 && cmd.IsArcMovement) @@ -363,7 +374,8 @@ protected override void Draw() double? lastX = null; double? lastY = null; GLColor color = Color; - color.A = spb.GetCurrentAlpha(Core.LoadedFile.Range.SpindleRange); + float intensity = spb.GetCurrentAlpha(Core.LoadedFile.Range.SpindleRange) / 255f; + color = Blend(color, intensity); double startAngle = ah.StartAngle; double endAngle = ah.StartAngle + ah.AngularWidth; int sign = Math.Sign(ah.AngularWidth); @@ -374,13 +386,13 @@ protected override void Draw() double y = ah.CenterY + ah.RectH / 2 * Math.Sin(angle); if (lastX != null && lastY != null) { - AddVertex((double)lastX, (double)lastY, zPos, color, cmd); + AddVertex((double)lastX, (double)lastY, zPos, color, cmd, intensity); } else { - AddVertex(x, y, zPos, color, cmd); + AddVertex(x, y, zPos, color, cmd, intensity); } - AddVertex(x, y, zPos, color, cmd); + AddVertex(x, y, zPos, color, cmd, intensity); lastX = x; lastY = y; } @@ -406,8 +418,7 @@ public override void Invalidate() mBoundingBoxDisplayList.Begin(mGL, BOUNDING_RECT_LINE_WIDTH, BOUNDING_RECT_STIPPLE); foreach (Object3DVertex vertex in mBoundingBoxDisplayList.Vertices) { - vertex.NewColor = BoundingBoxColor; - mGL.Color(vertex.NewColor); + mGL.Color(BoundingBoxColor); mGL.Vertex(vertex.X, vertex.Y, vertex.Z); } mBoundingBoxDisplayList.End(mGL); @@ -421,7 +432,7 @@ public override void Invalidate() list.Begin(mGL, LineWidth); foreach (Object3DVertex vertex in list.Vertices) { - GLColor newColor; + Color newColor; if (mJustLaserOffMovements || !Core.ShowExecutedCommands.Value) { newColor = Color; @@ -437,11 +448,6 @@ public override void Invalidate() case GrblCommand.CommandStatus.InvalidResponse: newColor = ColorScheme.PreviewCommandKO; break; - /* - case GrblCommand.CommandStatus.Queued: - newColor = Color.Blue; - break; - */ case GrblCommand.CommandStatus.WaitingResponse: newColor = ColorScheme.PreviewCommandWait; break; @@ -450,9 +456,8 @@ public override void Invalidate() break; } } - vertex.NewColor = newColor; - vertex.NewColor.A = vertex.Alpha; - mGL.Color(vertex.NewColor); + newColor = Blend(newColor, vertex.Intensity); + mGL.Color(newColor); mGL.Vertex(vertex.X, vertex.Y, vertex.Z); } list.End(mGL); diff --git a/LaserGRBL/RasterConverter/RasterToLaserForm.cs b/LaserGRBL/RasterConverter/RasterToLaserForm.cs index 7f7a6eed..73190922 100644 --- a/LaserGRBL/RasterConverter/RasterToLaserForm.cs +++ b/LaserGRBL/RasterConverter/RasterToLaserForm.cs @@ -179,12 +179,12 @@ void WTTick(object sender, EventArgs e) WB.Running = true; } - internal static void CreateAndShowDialog(GrblCore core, string filename, Form parent, bool append) + internal static void CreateAndShowDialog(GrblCore core, string filename, bool append) { using (RasterToLaserForm f = new RasterToLaserForm(core, filename, append)) { - f.Icon = parent.Icon; - f.ShowDialog(parent); + f.Icon = FormsHelper.MainForm.Icon; + f.ShowDialog(FormsHelper.MainForm); } } diff --git a/LaserGRBL/SvgConverter/ConvertSizeAndOptionForm.cs b/LaserGRBL/SvgConverter/ConvertSizeAndOptionForm.cs index 4d2eb92f..3ae022df 100644 --- a/LaserGRBL/SvgConverter/ConvertSizeAndOptionForm.cs +++ b/LaserGRBL/SvgConverter/ConvertSizeAndOptionForm.cs @@ -48,11 +48,11 @@ public override string ToString() } } - internal static void CreateAndShowDialog(GrblCore core, string filename, Form parent, bool append) + internal static void CreateAndShowDialog(GrblCore core, string filename, bool append) { using (SvgToGCodeForm f = new SvgToGCodeForm(core, filename, append)) { - f.ShowDialogForm(parent); + f.ShowDialogForm(); if (f.DialogResult == DialogResult.OK) { Settings.SetObject("GrayScaleConversion.VectorizeOptions.BorderSpeed", f.IIBorderTracing.CurrentValue); @@ -101,7 +101,7 @@ private void AssignMinMaxLimit() IIMaxPower.MaxValue = (int)GrblCore.Configuration.MaxPWM; } - public void ShowDialogForm(Form parent) + public void ShowDialogForm() { IIBorderTracing.CurrentValue = Settings.GetObject("GrayScaleConversion.VectorizeOptions.BorderSpeed", 1000); @@ -123,7 +123,7 @@ public void ShowDialogForm(Form parent) RefreshPerc(); - ShowDialog(parent); + ShowDialog(FormsHelper.MainForm); } diff --git a/LaserGRBL/Tools/FormsHelper.cs b/LaserGRBL/Tools/FormsHelper.cs new file mode 100644 index 00000000..8ee314ff --- /dev/null +++ b/LaserGRBL/Tools/FormsHelper.cs @@ -0,0 +1,9 @@ +using System.Windows.Forms; + +namespace LaserGRBL +{ + public static class FormsHelper + { + public static Form MainForm => Application.OpenForms[0]; + } +} diff --git a/LaserGRBL/UserControls/GrblPanel3D.cs b/LaserGRBL/UserControls/GrblPanel3D.cs index a73532f3..78ec623c 100644 --- a/LaserGRBL/UserControls/GrblPanel3D.cs +++ b/LaserGRBL/UserControls/GrblPanel3D.cs @@ -316,8 +316,8 @@ private void DrawScene() oldGrbl3D?.Dispose(); oldGrbl3DOff?.Dispose(); mMessage = Strings.PrepareDrawing; - Grbl3D newGrbl3D = new Grbl3D(Core, "LaserOn", false, ColorScheme.PreviewLaserPower, ColorScheme.PreviewJobRange); - Grbl3D newGrbl3DOff = new Grbl3D(Core, "LaserOff", true, ColorScheme.PreviewOtherMovement, ColorScheme.PreviewJobRange); + Grbl3D newGrbl3D = new Grbl3D(Core, "LaserOn", false, ColorScheme.PreviewLaserPower, ColorScheme.PreviewBackColor, ColorScheme.PreviewJobRange); + Grbl3D newGrbl3DOff = new Grbl3D(Core, "LaserOff", true, ColorScheme.PreviewOtherMovement, ColorScheme.PreviewBackColor, ColorScheme.PreviewJobRange); mMessage = null; lock (mGrbl3DLock) { @@ -332,10 +332,12 @@ private void DrawScene() { mInvalidateAll = false; mGrbl3D.Color = ColorScheme.PreviewLaserPower; + mGrbl3D.BackgroundColor = ColorScheme.PreviewBackColor; mGrbl3D.BoundingBoxColor = ColorScheme.PreviewJobRange; mGrbl3D.InvalidateAll(); mGrbl3DOff.Color = ColorScheme.PreviewOtherMovement; - mGrbl3DOff.InvalidateAll(); + mGrbl3DOff.BackgroundColor = ColorScheme.PreviewBackColor; + mGrbl3DOff.InvalidateAll(); } if (Core.ShowLaserOffMovements.Value) { @@ -829,14 +831,19 @@ private void DoGDIDraw(PaintEventArgs e) mMousePos.Value.Y >= mPadding.Top && mMousePos.Value.Y <= Height - mPadding.Bottom) { - using (Pen pCross = new Pen(ColorScheme.PreviewCrossCursor)) + Color loShadowColor = Color.FromArgb( + 128, + ColorScheme.PreviewBackColor.R, + ColorScheme.PreviewBackColor.G, + ColorScheme.PreviewBackColor.B + ); + using (Pen pCross = new Pen(loShadowColor)) { - int halfCrossSize = 4; - e.Graphics.DrawLine(pCross, new Point(mPadding.Left, mMousePos.Value.Y), new Point(mMousePos.Value.X - 5, mMousePos.Value.Y)); - e.Graphics.DrawLine(pCross, new Point(mMousePos.Value.X + halfCrossSize, mMousePos.Value.Y), new Point(Width - mPadding.Right, mMousePos.Value.Y)); - e.Graphics.DrawLine(pCross, new Point(mMousePos.Value.X, mPadding.Top), new Point(mMousePos.Value.X, mMousePos.Value.Y - halfCrossSize)); - e.Graphics.DrawLine(pCross, new Point(mMousePos.Value.X, mMousePos.Value.Y + halfCrossSize), new Point(mMousePos.Value.X, Height - mPadding.Bottom)); - e.Graphics.DrawRectangle(pCross, mMousePos.Value.X - halfCrossSize, mMousePos.Value.Y - halfCrossSize, halfCrossSize * 2, halfCrossSize * 2); + DrawCross(e.Graphics, pCross, new Point(mMousePos.Value.X + 1, mMousePos.Value.Y + 1)); + } + using (Pen pCross = new Pen(ColorScheme.PreviewCrossCursor)) + { + DrawCross(e.Graphics, pCross, mMousePos.Value); ShowCursor = false; } } @@ -848,6 +855,16 @@ private void DoGDIDraw(PaintEventArgs e) } } + private void DrawCross(Graphics g, Pen pCross, Point point) + { + const int halfCrossSize = 4; + g.DrawLine(pCross, new Point(mPadding.Left, point.Y), new Point(point.X - 5, point.Y)); + g.DrawLine(pCross, new Point(point.X + halfCrossSize, point.Y), new Point(Width - mPadding.Right, point.Y)); + g.DrawLine(pCross, new Point(point.X, mPadding.Top), new Point(point.X, point.Y - halfCrossSize)); + g.DrawLine(pCross, new Point(point.X, point.Y + halfCrossSize), new Point(point.X, Height - mPadding.Bottom)); + g.DrawRectangle(pCross, point.X - halfCrossSize, point.Y - halfCrossSize, halfCrossSize * 2, halfCrossSize * 2); + } + private string GetShortcut(HotKeysManager.HotKey.Actions action) { string shortcut = Core.GetHotKeyString(action);