diff --git a/UVtools.Core/Layer/Layer.cs b/UVtools.Core/Layer/Layer.cs index 9e68056..c8ccd27 100644 --- a/UVtools.Core/Layer/Layer.cs +++ b/UVtools.Core/Layer/Layer.cs @@ -641,7 +641,7 @@ namespace UVtools.Core } } - public void MutatePixelDimming(Mat evenPatternMask, Mat oddPatternMask = null, ushort borderSize = 5, bool dimOnlyBorders = false) + public void PixelDimming(OperationPixelDimming operation, Mat evenPatternMask, Mat oddPatternMask = null) { var anchor = new Point(-1, -1); var kernel = CvInvoke.GetStructuringElement(ElementShape.Rectangle, new Size(3, 3), anchor); @@ -655,9 +655,9 @@ namespace UVtools.Core using (Mat erode = new Mat()) using (Mat diff = new Mat()) { - CvInvoke.Erode(dst, erode, kernel, anchor, borderSize, BorderType.Reflect101, default); + CvInvoke.Erode(dst, erode, kernel, anchor, (int) operation.BorderSize, BorderType.Reflect101, default); CvInvoke.Subtract(dst, erode, diff); - if (dimOnlyBorders) + if (operation.BordersOnly) { CvInvoke.BitwiseAnd(diff, Index % 2 == 0 ? evenPatternMask : oddPatternMask, dst); CvInvoke.Add(erode, dst, dst); diff --git a/UVtools.Core/Layer/LayerManager.cs b/UVtools.Core/Layer/LayerManager.cs index 871fa2d..c99e9f6 100644 --- a/UVtools.Core/Layer/LayerManager.cs +++ b/UVtools.Core/Layer/LayerManager.cs @@ -419,23 +419,22 @@ namespace UVtools.Core progress.Token.ThrowIfCancellationRequested(); } - public void MutatePixelDimming(uint startLayerIndex, uint endLayerIndex, Matrix evenPattern = null, - Matrix oddPattern = null, ushort borderSize = 5, bool dimOnlyBorders = false, OperationProgress progress = null) + public void PixelDimming(OperationPixelDimming operation, OperationProgress progress = null) { - if (ReferenceEquals(progress, null)) progress = new OperationProgress(); - progress.Reset("Dimming pixels", endLayerIndex - startLayerIndex + 1); + if (progress is null) progress = new OperationProgress(); + progress.Reset(operation.ProgressAction, operation.LayerRangeCount); - if (ReferenceEquals(evenPattern, null)) + if (operation.EvenPattern is null) { - evenPattern = new Matrix(2, 2) + operation.EvenPattern = new Matrix(2, 2) { [0, 0] = 127, [0, 1] = 255, [1, 0] = 255, [1, 1] = 127, }; - if (ReferenceEquals(oddPattern, null)) + if (operation.OddPattern is null) { - oddPattern = new Matrix(2, 2) + operation.OddPattern = new Matrix(2, 2) { [0, 0] = 255, [0, 1] = 127, [1, 0] = 127, [1, 1] = 255, @@ -443,36 +442,32 @@ namespace UVtools.Core } } - if (ReferenceEquals(oddPattern, null)) + if (operation.OddPattern is null) { - oddPattern = evenPattern; + operation.OddPattern = operation.EvenPattern; } using (Mat mat = this[0].LayerMat) + using (Mat matEven = mat.CloneBlank()) + using (Mat matOdd = mat.CloneBlank()) { - using (var matEven = mat.CloneBlank()) - { - using (Mat matOdd = mat.CloneBlank()) - { - CvInvoke.Repeat(evenPattern, mat.Rows / evenPattern.Rows + 1, mat.Cols / evenPattern.Cols + 1, matEven); - CvInvoke.Repeat(oddPattern, mat.Rows / oddPattern.Rows + 1, mat.Cols / oddPattern.Cols + 1, matOdd); + CvInvoke.Repeat(operation.EvenPattern, mat.Rows / operation.EvenPattern.Rows + 1, + mat.Cols / operation.EvenPattern.Cols + 1, matEven); + CvInvoke.Repeat(operation.OddPattern, mat.Rows / operation.OddPattern.Rows + 1, + mat.Cols / operation.OddPattern.Cols + 1, matOdd); - using (var evenPatternMask = new Mat(matEven, new Rectangle(0, 0, mat.Width, mat.Height))) + using (var evenPatternMask = new Mat(matEven, new Rectangle(0, 0, mat.Width, mat.Height))) + using (var oddPatternMask = new Mat(matOdd, new Rectangle(0, 0, mat.Width, mat.Height))) + { + Parallel.For(operation.LayerIndexStart, operation.LayerIndexEnd + 1, layerIndex => + { + if (progress.Token.IsCancellationRequested) return; + this[layerIndex].PixelDimming(operation, evenPatternMask, oddPatternMask); + lock (progress.Mutex) { - using (var oddPatternMask = new Mat(matOdd, new Rectangle(0, 0, mat.Width, mat.Height))) - { - Parallel.For(startLayerIndex, endLayerIndex + 1, layerIndex => - { - if (progress.Token.IsCancellationRequested) return; - this[layerIndex].MutatePixelDimming(evenPatternMask, oddPatternMask, borderSize, dimOnlyBorders); - lock (progress.Mutex) - { - progress++; - } - }); - } + progress++; } - } + }); } } diff --git a/UVtools.Core/Operations/OperationPixelDimming.cs b/UVtools.Core/Operations/OperationPixelDimming.cs new file mode 100644 index 0000000..c3c0090 --- /dev/null +++ b/UVtools.Core/Operations/OperationPixelDimming.cs @@ -0,0 +1,59 @@ +/* + * GNU AFFERO GENERAL PUBLIC LICENSE + * Version 3, 19 November 2007 + * Copyright (C) 2007 Free Software Foundation, Inc. + * Everyone is permitted to copy and distribute verbatim copies + * of this license document, but changing it is not allowed. + */ + +using System.Text; +using Emgu.CV; +using UVtools.Core.Objects; + +namespace UVtools.Core.Operations +{ + public class OperationPixelDimming : Operation + { + #region Overrides + public override string Title => "Pixel dimming"; + public override string Description => + "Dims pixels in a chosen pattern over white pixels neighborhood. The selected pattern will be repeated over the image width and height as a mask. Benefits are:\n" + + "1) Reduce layer expansion in big masses\n" + + "2) Reduce cross layer exposure\n" + + "3) Extend pixels life\n" + + "NOTE: Run only this tool after all repairs and other transformations."; + + public override string ConfirmationText => + $"dim pixels from layers {LayerIndexStart} to {LayerIndexEnd}"; + + public override string ProgressTitle => + $"Dimming from layers {LayerIndexStart} to {LayerIndexEnd}"; + + public override string ProgressAction => "Dimmed layers"; + + public override StringTag Validate(params object[] parameters) + { + var sb = new StringBuilder(); + if (BorderSize == 0 && BordersOnly) + { + sb.AppendLine("Border size must be positive in order to use \"Dims only the borders\" function."); + } + + if (EvenPattern is null && OddPattern is null) + { + sb.AppendLine("Either even or odd pattern must contain a valid matrix."); + } + + return new StringTag(sb.ToString()); + } + #endregion + + #region Properties + + public uint BorderSize { get; set; } + public bool BordersOnly { get; set; } + public Matrix EvenPattern { get; set; } + public Matrix OddPattern { get; set; } + #endregion + } +} diff --git a/UVtools.GUI/Controls/CtrlToolWindowContent.cs b/UVtools.GUI/Controls/CtrlToolWindowContent.cs index f60a241..de259d0 100644 --- a/UVtools.GUI/Controls/CtrlToolWindowContent.cs +++ b/UVtools.GUI/Controls/CtrlToolWindowContent.cs @@ -150,11 +150,12 @@ namespace UVtools.GUI.Controls /// /// Updates operation object with items retrieved from form fields /// - public virtual void UpdateOperation() + public virtual bool UpdateOperation() { - if (ParentToolWindow is null) return; + if (ParentToolWindow is null) return true; BaseOperation.LayerIndexStart = ParentToolWindow.LayerRangeStart; BaseOperation.LayerIndexEnd = ParentToolWindow.LayerRangeEnd; + return true; } /// @@ -164,7 +165,7 @@ namespace UVtools.GUI.Controls public virtual bool ValidateForm() { if (BaseOperation is null) return true; - UpdateOperation(); + if(!UpdateOperation()) return false; return ValidateFormFromString(BaseOperation.Validate()); } diff --git a/UVtools.GUI/Controls/Tools/CtrlToolChangeResolution.cs b/UVtools.GUI/Controls/Tools/CtrlToolChangeResolution.cs index bc48df7..5b64658 100644 --- a/UVtools.GUI/Controls/Tools/CtrlToolChangeResolution.cs +++ b/UVtools.GUI/Controls/Tools/CtrlToolChangeResolution.cs @@ -58,10 +58,12 @@ namespace UVtools.GUI.Controls.Tools } } - public override void UpdateOperation() + public override bool UpdateOperation() { + base.UpdateOperation(); Operation.NewResolutionX = NewResolutionX; Operation.NewResolutionY = NewResolutionY; + return true; } } } diff --git a/UVtools.GUI/Controls/Tools/CtrlToolFlip.cs b/UVtools.GUI/Controls/Tools/CtrlToolFlip.cs index 400c05c..0b5a1c4 100644 --- a/UVtools.GUI/Controls/Tools/CtrlToolFlip.cs +++ b/UVtools.GUI/Controls/Tools/CtrlToolFlip.cs @@ -34,11 +34,12 @@ namespace UVtools.GUI.Controls.Tools cbFlipDirection.SelectedIndex = 0; } - public override void UpdateOperation() + public override bool UpdateOperation() { base.UpdateOperation(); Operation.FlipDirection = (Enumerations.FlipDirection)cbFlipDirection.SelectedItem; Operation.MakeCopy = cbMakeCopy.Checked; + return true; } } } diff --git a/UVtools.GUI/Controls/Tools/CtrlToolLayerClone.cs b/UVtools.GUI/Controls/Tools/CtrlToolLayerClone.cs index 42e0e07..5486dc3 100644 --- a/UVtools.GUI/Controls/Tools/CtrlToolLayerClone.cs +++ b/UVtools.GUI/Controls/Tools/CtrlToolLayerClone.cs @@ -39,10 +39,11 @@ namespace UVtools.GUI.Controls.Tools lbHeights.Text = $"Heights: {Program.SlicerFile.TotalHeight}mm → {Program.SlicerFile.TotalHeight + extraHeight}mm (+ {extraHeight}mm)"; } - public override void UpdateOperation() + public override bool UpdateOperation() { base.UpdateOperation(); Operation.Clones = (uint) nmClones.Value; + return true; } } } diff --git a/UVtools.GUI/Controls/Tools/CtrlToolLayerImport.cs b/UVtools.GUI/Controls/Tools/CtrlToolLayerImport.cs index cc16913..41b591a 100644 --- a/UVtools.GUI/Controls/Tools/CtrlToolLayerImport.cs +++ b/UVtools.GUI/Controls/Tools/CtrlToolLayerImport.cs @@ -34,12 +34,13 @@ namespace UVtools.GUI.Controls.Tools nmInsertAfterLayer_ValueChanged(nmInsertAfterLayer, EventArgs.Empty); } - public override void UpdateOperation() + public override bool UpdateOperation() { Operation.InsertAfterLayerIndex = (uint)nmInsertAfterLayer.Value; Operation.ReplaceStartLayer = cbReplaceStartLayer.Checked; Operation.ReplaceSubsequentLayers = cbReplaceSubsequentLayers.Checked; Operation.DiscardRemainingLayers = cbDiscardRemainingLayers.Checked; + return true; } diff --git a/UVtools.GUI/Controls/Tools/CtrlToolLayerReHeight.cs b/UVtools.GUI/Controls/Tools/CtrlToolLayerReHeight.cs index 972316e..4cb552d 100644 --- a/UVtools.GUI/Controls/Tools/CtrlToolLayerReHeight.cs +++ b/UVtools.GUI/Controls/Tools/CtrlToolLayerReHeight.cs @@ -46,10 +46,11 @@ namespace UVtools.GUI.Controls.Tools ButtonOkEnabled = cbMultiplier.SelectedIndex >= 0; } - public override void UpdateOperation() + public override bool UpdateOperation() { base.UpdateOperation(); Operation.Item = (OperationLayerReHeight.OperationLayerReHeightItem)cbMultiplier.SelectedItem; + return true; } } } diff --git a/UVtools.GUI/Controls/Tools/CtrlToolMorph.cs b/UVtools.GUI/Controls/Tools/CtrlToolMorph.cs index 0950188..62046d2 100644 --- a/UVtools.GUI/Controls/Tools/CtrlToolMorph.cs +++ b/UVtools.GUI/Controls/Tools/CtrlToolMorph.cs @@ -30,7 +30,7 @@ namespace UVtools.GUI.Controls.Tools } - public override void UpdateOperation() + public override bool UpdateOperation() { base.UpdateOperation(); Operation.IterationsStart = (uint) nmIterationsStart.Value; @@ -39,6 +39,7 @@ namespace UVtools.GUI.Controls.Tools Operation.MorphOperation = (MorphOp)((StringTag) cbMorphOperation.SelectedItem).Tag; Operation.Kernel.Anchor = ctrlKernel.KernelAnchor; Operation.Kernel.Matrix = ctrlKernel.GetMatrix(); + return true; } private void EventCheckedChanged(object sender, EventArgs e) diff --git a/UVtools.GUI/Controls/Tools/CtrlToolMove.cs b/UVtools.GUI/Controls/Tools/CtrlToolMove.cs index aa31e41..eba8f68 100644 --- a/UVtools.GUI/Controls/Tools/CtrlToolMove.cs +++ b/UVtools.GUI/Controls/Tools/CtrlToolMove.cs @@ -49,7 +49,7 @@ namespace UVtools.GUI.Controls.Tools lbPlacementY.Text = $"Placement Y: {Operation.DstRoi.Y} / {Operation.ImageHeight - Operation.SrcRoi.Height}"; } - public override void UpdateOperation() + public override bool UpdateOperation() { base.UpdateOperation(); byte i = 0; @@ -73,6 +73,7 @@ namespace UVtools.GUI.Controls.Tools Operation.MarginTop = (int)nmMarginTop.Value; Operation.MarginRight = (int)nmMarginRight.Value; Operation.MarginBottom = (int)nmMarginBottom.Value; + return true; } } } diff --git a/UVtools.GUI/Controls/Tools/CtrlToolPattern.cs b/UVtools.GUI/Controls/Tools/CtrlToolPattern.cs index 086b493..b28e9ca 100644 --- a/UVtools.GUI/Controls/Tools/CtrlToolPattern.cs +++ b/UVtools.GUI/Controls/Tools/CtrlToolPattern.cs @@ -50,7 +50,7 @@ namespace UVtools.GUI.Controls.Tools EventValueChanged(this, EventArgs.Empty); } - public override void UpdateOperation() + public override bool UpdateOperation() { base.UpdateOperation(); @@ -77,6 +77,7 @@ namespace UVtools.GUI.Controls.Tools Operation.Cols = (ushort)nmCols.Value; Operation.Rows = (ushort)nmRows.Value; + return true; } private void EventValueChanged(object sender, EventArgs e) diff --git a/UVtools.GUI/Forms/FrmMutationPixelDimming.Designer.cs b/UVtools.GUI/Controls/Tools/CtrlToolPixelDimming.Designer.cs similarity index 65% rename from UVtools.GUI/Forms/FrmMutationPixelDimming.Designer.cs rename to UVtools.GUI/Controls/Tools/CtrlToolPixelDimming.Designer.cs index 3a3042b..4ce5bbd 100644 --- a/UVtools.GUI/Forms/FrmMutationPixelDimming.Designer.cs +++ b/UVtools.GUI/Controls/Tools/CtrlToolPixelDimming.Designer.cs @@ -1,15 +1,13 @@ -using UVtools.GUI.Controls; - -namespace UVtools.GUI.Forms +namespace UVtools.GUI.Controls.Tools { - partial class FrmMutationPixelDimming + partial class CtrlToolPixelDimming { - /// + /// /// Required designer variable. /// private System.ComponentModel.IContainer components = null; - /// + /// /// Clean up any resources being used. /// /// true if managed resources should be disposed; otherwise, false. @@ -22,52 +20,16 @@ namespace UVtools.GUI.Forms base.Dispose(disposing); } - #region Windows Form Designer generated code + #region Component Designer generated code - /// - /// Required method for Designer support - do not modify + /// + /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { - this.components = new System.ComponentModel.Container(); - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmMutationPixelDimming)); - this.lbDescription = new System.Windows.Forms.Label(); - this.lbX = new System.Windows.Forms.Label(); - this.lbLayerRange = new System.Windows.Forms.Label(); - this.nmLayerRangeStart = new System.Windows.Forms.NumericUpDown(); - this.nmLayerRangeEnd = new System.Windows.Forms.NumericUpDown(); - this.lbLayerRangeTo = new System.Windows.Forms.Label(); - this.cmLayerRange = new System.Windows.Forms.ContextMenuStrip(this.components); - this.btnLayerRangeAllLayers = new System.Windows.Forms.ToolStripMenuItem(); - this.btnLayerRangeCurrentLayer = new System.Windows.Forms.ToolStripMenuItem(); - this.btnLayerRangeBottomLayers = new System.Windows.Forms.ToolStripMenuItem(); - this.btnLayerRangeNormalLayers = new System.Windows.Forms.ToolStripMenuItem(); - this.toolTip = new System.Windows.Forms.ToolTip(this.components); - this.label1 = new System.Windows.Forms.Label(); - this.label6 = new System.Windows.Forms.Label(); - this.label2 = new System.Windows.Forms.Label(); - this.label3 = new System.Windows.Forms.Label(); - this.label4 = new System.Windows.Forms.Label(); - this.label5 = new System.Windows.Forms.Label(); - this.label7 = new System.Windows.Forms.Label(); - this.btnCancel = new System.Windows.Forms.Button(); - this.btnMutate = new System.Windows.Forms.Button(); - this.nmBorderSize = new System.Windows.Forms.NumericUpDown(); - this.tbEvenPattern = new System.Windows.Forms.TextBox(); - this.nmPixelDimBrightness = new System.Windows.Forms.NumericUpDown(); - this.groupBox1 = new System.Windows.Forms.GroupBox(); - this.btnDimPatternStrips = new System.Windows.Forms.Button(); - this.btnDimPatternWaves = new System.Windows.Forms.Button(); - this.btnPatternRandom = new System.Windows.Forms.Button(); - this.btnDimPatternSlashes = new System.Windows.Forms.Button(); - this.btnDimPatternHearts = new System.Windows.Forms.Button(); - this.btnDimPatternRhombus = new System.Windows.Forms.Button(); - this.btnDimPatternPyramid = new System.Windows.Forms.Button(); - this.btnDimPatternCrosses = new System.Windows.Forms.Button(); - this.btnDimPatternSparse = new System.Windows.Forms.Button(); - this.btnDimPatternChessBoard = new System.Windows.Forms.Button(); - this.tbOddPattern = new System.Windows.Forms.TextBox(); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CtrlToolPixelDimming)); + this.cbDimsOnlyBorders = new System.Windows.Forms.CheckBox(); this.groupBox2 = new System.Windows.Forms.GroupBox(); this.label13 = new System.Windows.Forms.Label(); this.label11 = new System.Windows.Forms.Label(); @@ -80,429 +42,47 @@ namespace UVtools.GUI.Forms this.nmInfillThickness = new System.Windows.Forms.NumericUpDown(); this.label9 = new System.Windows.Forms.Label(); this.label10 = new System.Windows.Forms.Label(); - this.btnImportImageMask = new System.Windows.Forms.Button(); - this.btnLayerRangeSelect = new UVtools.GUI.Controls.SplitButton(); - this.cbDimsOnlyBorders = new System.Windows.Forms.CheckBox(); + this.label6 = new System.Windows.Forms.Label(); + this.label5 = new System.Windows.Forms.Label(); + this.tbOddPattern = new System.Windows.Forms.TextBox(); + this.groupBox1 = new System.Windows.Forms.GroupBox(); this.btnDimPatternSolid = new System.Windows.Forms.Button(); - ((System.ComponentModel.ISupportInitialize)(this.nmLayerRangeStart)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.nmLayerRangeEnd)).BeginInit(); - this.cmLayerRange.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.nmBorderSize)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.nmPixelDimBrightness)).BeginInit(); - this.groupBox1.SuspendLayout(); + this.btnDimPatternStrips = new System.Windows.Forms.Button(); + this.label7 = new System.Windows.Forms.Label(); + this.btnDimPatternWaves = new System.Windows.Forms.Button(); + this.btnPatternRandom = new System.Windows.Forms.Button(); + this.btnDimPatternSlashes = new System.Windows.Forms.Button(); + this.btnDimPatternHearts = new System.Windows.Forms.Button(); + this.btnDimPatternRhombus = new System.Windows.Forms.Button(); + this.btnDimPatternPyramid = new System.Windows.Forms.Button(); + this.btnDimPatternCrosses = new System.Windows.Forms.Button(); + this.btnDimPatternSparse = new System.Windows.Forms.Button(); + this.btnDimPatternChessBoard = new System.Windows.Forms.Button(); + this.nmPixelDimBrightness = new System.Windows.Forms.NumericUpDown(); + this.label3 = new System.Windows.Forms.Label(); + this.label4 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.tbEvenPattern = new System.Windows.Forms.TextBox(); + this.label1 = new System.Windows.Forms.Label(); + this.nmBorderSize = new System.Windows.Forms.NumericUpDown(); + this.lbX = new System.Windows.Forms.Label(); this.groupBox2.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.nmInfillSpacing)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.nmInfillThickness)).BeginInit(); + this.groupBox1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.nmPixelDimBrightness)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.nmBorderSize)).BeginInit(); this.SuspendLayout(); // - // lbDescription - // - this.lbDescription.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lbDescription.Location = new System.Drawing.Point(13, 14); - this.lbDescription.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); - this.lbDescription.Name = "lbDescription"; - this.lbDescription.Size = new System.Drawing.Size(584, 128); - this.lbDescription.TabIndex = 0; - this.lbDescription.Text = "Description"; - // - // lbX - // - this.lbX.AutoSize = true; - this.lbX.Location = new System.Drawing.Point(17, 190); - this.lbX.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); - this.lbX.Name = "lbX"; - this.lbX.Size = new System.Drawing.Size(93, 20); - this.lbX.TabIndex = 3; - this.lbX.Text = "Border size:"; - this.toolTip.SetToolTip(this.lbX, resources.GetString("lbX.ToolTip")); - // - // lbLayerRange - // - this.lbLayerRange.AutoSize = true; - this.lbLayerRange.Location = new System.Drawing.Point(13, 150); - this.lbLayerRange.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); - this.lbLayerRange.Name = "lbLayerRange"; - this.lbLayerRange.Size = new System.Drawing.Size(97, 20); - this.lbLayerRange.TabIndex = 9; - this.lbLayerRange.Text = "Layer range:"; - this.toolTip.SetToolTip(this.lbLayerRange, resources.GetString("lbLayerRange.ToolTip")); - // - // nmLayerRangeStart - // - this.nmLayerRangeStart.Location = new System.Drawing.Point(118, 147); - this.nmLayerRangeStart.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.nmLayerRangeStart.Maximum = new decimal(new int[] { - 100000, - 0, - 0, - 0}); - this.nmLayerRangeStart.Name = "nmLayerRangeStart"; - this.nmLayerRangeStart.Size = new System.Drawing.Size(120, 26); - this.nmLayerRangeStart.TabIndex = 0; - // - // nmLayerRangeEnd - // - this.nmLayerRangeEnd.Location = new System.Drawing.Point(314, 147); - this.nmLayerRangeEnd.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.nmLayerRangeEnd.Maximum = new decimal(new int[] { - 100000, - 0, - 0, - 0}); - this.nmLayerRangeEnd.Name = "nmLayerRangeEnd"; - this.nmLayerRangeEnd.Size = new System.Drawing.Size(120, 26); - this.nmLayerRangeEnd.TabIndex = 1; - // - // lbLayerRangeTo - // - this.lbLayerRangeTo.AutoSize = true; - this.lbLayerRangeTo.Location = new System.Drawing.Point(275, 150); - this.lbLayerRangeTo.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); - this.lbLayerRangeTo.Name = "lbLayerRangeTo"; - this.lbLayerRangeTo.Size = new System.Drawing.Size(31, 20); - this.lbLayerRangeTo.TabIndex = 12; - this.lbLayerRangeTo.Text = "To:"; - // - // cmLayerRange - // - this.cmLayerRange.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.btnLayerRangeAllLayers, - this.btnLayerRangeCurrentLayer, - this.btnLayerRangeBottomLayers, - this.btnLayerRangeNormalLayers}); - this.cmLayerRange.Name = "cmLayerRange"; - this.cmLayerRange.Size = new System.Drawing.Size(226, 92); - // - // btnLayerRangeAllLayers - // - this.btnLayerRangeAllLayers.Name = "btnLayerRangeAllLayers"; - this.btnLayerRangeAllLayers.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift) - | System.Windows.Forms.Keys.A))); - this.btnLayerRangeAllLayers.Size = new System.Drawing.Size(225, 22); - this.btnLayerRangeAllLayers.Text = "&All Layers"; - this.btnLayerRangeAllLayers.Click += new System.EventHandler(this.ItemClicked); - // - // btnLayerRangeCurrentLayer - // - this.btnLayerRangeCurrentLayer.Name = "btnLayerRangeCurrentLayer"; - this.btnLayerRangeCurrentLayer.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift) - | System.Windows.Forms.Keys.C))); - this.btnLayerRangeCurrentLayer.Size = new System.Drawing.Size(225, 22); - this.btnLayerRangeCurrentLayer.Text = "&Current Layer"; - this.btnLayerRangeCurrentLayer.Click += new System.EventHandler(this.ItemClicked); - // - // btnLayerRangeBottomLayers - // - this.btnLayerRangeBottomLayers.Name = "btnLayerRangeBottomLayers"; - this.btnLayerRangeBottomLayers.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift) - | System.Windows.Forms.Keys.B))); - this.btnLayerRangeBottomLayers.Size = new System.Drawing.Size(225, 22); - this.btnLayerRangeBottomLayers.Text = "&Bottom Layers"; - this.btnLayerRangeBottomLayers.Click += new System.EventHandler(this.ItemClicked); - // - // btnLayerRangeNormalLayers - // - this.btnLayerRangeNormalLayers.Name = "btnLayerRangeNormalLayers"; - this.btnLayerRangeNormalLayers.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift) - | System.Windows.Forms.Keys.N))); - this.btnLayerRangeNormalLayers.Size = new System.Drawing.Size(225, 22); - this.btnLayerRangeNormalLayers.Text = "&Normal Layers"; - this.btnLayerRangeNormalLayers.Click += new System.EventHandler(this.ItemClicked); - // - // toolTip - // - this.toolTip.AutoPopDelay = 32767; - this.toolTip.InitialDelay = 500; - this.toolTip.IsBalloon = true; - this.toolTip.ReshowDelay = 100; - this.toolTip.ToolTipIcon = System.Windows.Forms.ToolTipIcon.Info; - this.toolTip.ToolTipTitle = "Information"; - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(246, 190); - this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(25, 20); - this.label1.TabIndex = 16; - this.label1.Text = "px"; - this.toolTip.SetToolTip(this.label1, resources.GetString("label1.ToolTip")); - // - // label6 - // - this.label6.AutoSize = true; - this.label6.Location = new System.Drawing.Point(19, 478); - this.label6.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); - this.label6.Name = "label6"; - this.label6.Size = new System.Drawing.Size(548, 20); - this.label6.TabIndex = 25; - this.label6.Text = "(Leave this field empty to use only the even layer pattern for the layers range)"; - this.toolTip.SetToolTip(this.label6, resources.GetString("label6.ToolTip")); - // - // label2 - // - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(17, 243); - this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(94, 80); - this.label2.TabIndex = 18; - this.label2.Text = "Even Layer\r\nPattern:\r\n0 = Black\r\n255 = White"; - // - // label3 - // - this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(7, 94); - this.label3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(65, 20); - this.label3.TabIndex = 19; - this.label3.Text = "Pattern:"; - // - // label4 - // - this.label4.AutoSize = true; - this.label4.Location = new System.Drawing.Point(7, 34); - this.label4.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); - this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(89, 20); - this.label4.TabIndex = 21; - this.label4.Text = "Brightness:"; - // - // label5 - // - this.label5.AutoSize = true; - this.label5.Location = new System.Drawing.Point(17, 363); - this.label5.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); - this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(94, 100); - this.label5.TabIndex = 24; - this.label5.Text = "Odd Layer\r\nPattern:\r\n0 = Black\r\n255 = White\r\n(Optional)"; - // - // label7 - // - this.label7.AutoSize = true; - this.label7.Location = new System.Drawing.Point(233, 34); - this.label7.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); - this.label7.Name = "label7"; - this.label7.Size = new System.Drawing.Size(60, 20); - this.label7.TabIndex = 30; - this.label7.Text = "(0-254)"; - // - // btnCancel - // - this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.btnCancel.Image = global::UVtools.GUI.Properties.Resources.Cancel_24x24; - this.btnCancel.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; - this.btnCancel.Location = new System.Drawing.Point(434, 854); - this.btnCancel.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.btnCancel.Name = "btnCancel"; - this.btnCancel.Size = new System.Drawing.Size(150, 48); - this.btnCancel.TabIndex = 6; - this.btnCancel.Text = "&Cancel"; - this.btnCancel.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - this.btnCancel.UseVisualStyleBackColor = true; - this.btnCancel.Click += new System.EventHandler(this.ItemClicked); - // - // btnMutate - // - this.btnMutate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.btnMutate.Image = global::UVtools.GUI.Properties.Resources.Ok_24x24; - this.btnMutate.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; - this.btnMutate.Location = new System.Drawing.Point(276, 854); - this.btnMutate.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.btnMutate.Name = "btnMutate"; - this.btnMutate.Size = new System.Drawing.Size(150, 48); - this.btnMutate.TabIndex = 5; - this.btnMutate.Text = "&Dim"; - this.btnMutate.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - this.btnMutate.UseVisualStyleBackColor = true; - this.btnMutate.Click += new System.EventHandler(this.ItemClicked); - // - // nmBorderSize - // - this.nmBorderSize.Location = new System.Drawing.Point(118, 187); - this.nmBorderSize.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.nmBorderSize.Maximum = new decimal(new int[] { - 1000, - 0, - 0, - 0}); - this.nmBorderSize.Name = "nmBorderSize"; - this.nmBorderSize.Size = new System.Drawing.Size(120, 26); - this.nmBorderSize.TabIndex = 3; - this.nmBorderSize.Value = new decimal(new int[] { - 5, - 0, - 0, - 0}); - // - // tbEvenPattern - // - this.tbEvenPattern.Location = new System.Drawing.Point(118, 221); - this.tbEvenPattern.Multiline = true; - this.tbEvenPattern.Name = "tbEvenPattern"; - this.tbEvenPattern.ScrollBars = System.Windows.Forms.ScrollBars.Both; - this.tbEvenPattern.Size = new System.Drawing.Size(469, 124); - this.tbEvenPattern.TabIndex = 17; - this.tbEvenPattern.Text = "127 255 255 255\r\n255 255 127 255"; - this.tbEvenPattern.WordWrap = false; - // - // nmPixelDimBrightness - // - this.nmPixelDimBrightness.Location = new System.Drawing.Point(112, 31); - this.nmPixelDimBrightness.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.nmPixelDimBrightness.Maximum = new decimal(new int[] { - 254, - 0, - 0, - 0}); - this.nmPixelDimBrightness.Name = "nmPixelDimBrightness"; - this.nmPixelDimBrightness.Size = new System.Drawing.Size(113, 26); - this.nmPixelDimBrightness.TabIndex = 20; - this.nmPixelDimBrightness.Value = new decimal(new int[] { - 127, - 0, - 0, - 0}); - // - // groupBox1 - // - this.groupBox1.Controls.Add(this.btnDimPatternSolid); - this.groupBox1.Controls.Add(this.btnDimPatternStrips); - this.groupBox1.Controls.Add(this.label7); - this.groupBox1.Controls.Add(this.btnDimPatternWaves); - this.groupBox1.Controls.Add(this.btnPatternRandom); - this.groupBox1.Controls.Add(this.btnDimPatternSlashes); - this.groupBox1.Controls.Add(this.btnDimPatternHearts); - this.groupBox1.Controls.Add(this.btnDimPatternRhombus); - this.groupBox1.Controls.Add(this.btnDimPatternPyramid); - this.groupBox1.Controls.Add(this.btnDimPatternCrosses); - this.groupBox1.Controls.Add(this.btnDimPatternSparse); - this.groupBox1.Controls.Add(this.btnDimPatternChessBoard); - this.groupBox1.Controls.Add(this.nmPixelDimBrightness); - this.groupBox1.Controls.Add(this.label3); - this.groupBox1.Controls.Add(this.label4); - this.groupBox1.Location = new System.Drawing.Point(12, 517); - this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(575, 162); - this.groupBox1.TabIndex = 22; - this.groupBox1.TabStop = false; - this.groupBox1.Text = "Pixel dimming generator"; - // - // btnDimPatternStrips - // - this.btnDimPatternStrips.Location = new System.Drawing.Point(332, 25); - this.btnDimPatternStrips.Name = "btnDimPatternStrips"; - this.btnDimPatternStrips.Size = new System.Drawing.Size(94, 35); - this.btnDimPatternStrips.TabIndex = 31; - this.btnDimPatternStrips.Text = "Strips"; - this.btnDimPatternStrips.UseVisualStyleBackColor = true; - this.btnDimPatternStrips.Click += new System.EventHandler(this.ItemClicked); - // - // btnDimPatternWaves - // - this.btnDimPatternWaves.Location = new System.Drawing.Point(232, 106); - this.btnDimPatternWaves.Name = "btnDimPatternWaves"; - this.btnDimPatternWaves.Size = new System.Drawing.Size(94, 35); - this.btnDimPatternWaves.TabIndex = 29; - this.btnDimPatternWaves.Text = "Waves"; - this.btnDimPatternWaves.UseVisualStyleBackColor = true; - this.btnDimPatternWaves.Click += new System.EventHandler(this.ItemClicked); - // - // btnPatternRandom - // - this.btnPatternRandom.Location = new System.Drawing.Point(6, 121); - this.btnPatternRandom.Name = "btnPatternRandom"; - this.btnPatternRandom.Size = new System.Drawing.Size(94, 35); - this.btnPatternRandom.TabIndex = 29; - this.btnPatternRandom.Text = "Random"; - this.btnPatternRandom.UseVisualStyleBackColor = true; - this.btnPatternRandom.Visible = false; - this.btnPatternRandom.Click += new System.EventHandler(this.ItemClicked); - // - // btnDimPatternSlashes - // - this.btnDimPatternSlashes.Location = new System.Drawing.Point(332, 106); - this.btnDimPatternSlashes.Name = "btnDimPatternSlashes"; - this.btnDimPatternSlashes.Size = new System.Drawing.Size(94, 35); - this.btnDimPatternSlashes.TabIndex = 28; - this.btnDimPatternSlashes.Text = "Slashes"; - this.btnDimPatternSlashes.UseVisualStyleBackColor = true; - this.btnDimPatternSlashes.Click += new System.EventHandler(this.ItemClicked); - // - // btnDimPatternHearts - // - this.btnDimPatternHearts.Location = new System.Drawing.Point(432, 106); - this.btnDimPatternHearts.Name = "btnDimPatternHearts"; - this.btnDimPatternHearts.Size = new System.Drawing.Size(94, 35); - this.btnDimPatternHearts.TabIndex = 27; - this.btnDimPatternHearts.Text = "Hearts"; - this.btnDimPatternHearts.UseVisualStyleBackColor = true; - this.btnDimPatternHearts.Click += new System.EventHandler(this.ItemClicked); - // - // btnDimPatternRhombus - // - this.btnDimPatternRhombus.Location = new System.Drawing.Point(112, 106); - this.btnDimPatternRhombus.Name = "btnDimPatternRhombus"; - this.btnDimPatternRhombus.Size = new System.Drawing.Size(113, 35); - this.btnDimPatternRhombus.TabIndex = 26; - this.btnDimPatternRhombus.Text = "Rhombus"; - this.btnDimPatternRhombus.UseVisualStyleBackColor = true; - this.btnDimPatternRhombus.Click += new System.EventHandler(this.ItemClicked); - // - // btnDimPatternPyramid - // - this.btnDimPatternPyramid.Location = new System.Drawing.Point(432, 65); - this.btnDimPatternPyramid.Name = "btnDimPatternPyramid"; - this.btnDimPatternPyramid.Size = new System.Drawing.Size(94, 35); - this.btnDimPatternPyramid.TabIndex = 25; - this.btnDimPatternPyramid.Text = "Pyramid"; - this.btnDimPatternPyramid.UseVisualStyleBackColor = true; - this.btnDimPatternPyramid.Click += new System.EventHandler(this.ItemClicked); - // - // btnDimPatternCrosses - // - this.btnDimPatternCrosses.Location = new System.Drawing.Point(332, 65); - this.btnDimPatternCrosses.Name = "btnDimPatternCrosses"; - this.btnDimPatternCrosses.Size = new System.Drawing.Size(94, 35); - this.btnDimPatternCrosses.TabIndex = 24; - this.btnDimPatternCrosses.Text = "Crosses"; - this.btnDimPatternCrosses.UseVisualStyleBackColor = true; - this.btnDimPatternCrosses.Click += new System.EventHandler(this.ItemClicked); - // - // btnDimPatternSparse - // - this.btnDimPatternSparse.Location = new System.Drawing.Point(232, 65); - this.btnDimPatternSparse.Name = "btnDimPatternSparse"; - this.btnDimPatternSparse.Size = new System.Drawing.Size(94, 35); - this.btnDimPatternSparse.TabIndex = 23; - this.btnDimPatternSparse.Text = "Sparse"; - this.btnDimPatternSparse.UseVisualStyleBackColor = true; - this.btnDimPatternSparse.Click += new System.EventHandler(this.ItemClicked); - // - // btnDimPatternChessBoard - // - this.btnDimPatternChessBoard.Location = new System.Drawing.Point(112, 65); - this.btnDimPatternChessBoard.Name = "btnDimPatternChessBoard"; - this.btnDimPatternChessBoard.Size = new System.Drawing.Size(114, 35); - this.btnDimPatternChessBoard.TabIndex = 22; - this.btnDimPatternChessBoard.Text = "Chess Board"; - this.btnDimPatternChessBoard.UseVisualStyleBackColor = true; - this.btnDimPatternChessBoard.Click += new System.EventHandler(this.ItemClicked); - // - // tbOddPattern - // - this.tbOddPattern.Location = new System.Drawing.Point(118, 351); - this.tbOddPattern.Multiline = true; - this.tbOddPattern.Name = "tbOddPattern"; - this.tbOddPattern.ScrollBars = System.Windows.Forms.ScrollBars.Both; - this.tbOddPattern.Size = new System.Drawing.Size(469, 124); - this.tbOddPattern.TabIndex = 23; - this.tbOddPattern.Text = "255 255 127 255\r\n127 255 255 255"; - this.tbOddPattern.WordWrap = false; + // cbDimsOnlyBorders + // + this.cbDimsOnlyBorders.AutoSize = true; + this.cbDimsOnlyBorders.Location = new System.Drawing.Point(301, 9); + this.cbDimsOnlyBorders.Name = "cbDimsOnlyBorders"; + this.cbDimsOnlyBorders.Size = new System.Drawing.Size(181, 24); + this.cbDimsOnlyBorders.TabIndex = 42; + this.cbDimsOnlyBorders.Text = "Dims only the borders"; + this.cbDimsOnlyBorders.UseVisualStyleBackColor = true; // // groupBox2 // @@ -517,10 +97,10 @@ namespace UVtools.GUI.Forms this.groupBox2.Controls.Add(this.nmInfillThickness); this.groupBox2.Controls.Add(this.label9); this.groupBox2.Controls.Add(this.label10); - this.groupBox2.Location = new System.Drawing.Point(12, 685); + this.groupBox2.Location = new System.Drawing.Point(-1, 506); this.groupBox2.Name = "groupBox2"; this.groupBox2.Size = new System.Drawing.Size(575, 160); - this.groupBox2.TabIndex = 26; + this.groupBox2.TabIndex = 41; this.groupBox2.TabStop = false; this.groupBox2.Text = "Infill generator"; // @@ -596,7 +176,7 @@ namespace UVtools.GUI.Forms this.btnInfillPatternWaves.TabIndex = 28; this.btnInfillPatternWaves.Text = "Waves"; this.btnInfillPatternWaves.UseVisualStyleBackColor = true; - this.btnInfillPatternWaves.Click += new System.EventHandler(this.ItemClicked); + this.btnInfillPatternWaves.Click += new System.EventHandler(this.EventClick); // // btnInfillPatternSquareGrid // @@ -606,7 +186,7 @@ namespace UVtools.GUI.Forms this.btnInfillPatternSquareGrid.TabIndex = 26; this.btnInfillPatternSquareGrid.Text = "Square Grid"; this.btnInfillPatternSquareGrid.UseVisualStyleBackColor = true; - this.btnInfillPatternSquareGrid.Click += new System.EventHandler(this.ItemClicked); + this.btnInfillPatternSquareGrid.Click += new System.EventHandler(this.EventClick); // // btnInfillPatternRectilinear // @@ -616,7 +196,7 @@ namespace UVtools.GUI.Forms this.btnInfillPatternRectilinear.TabIndex = 22; this.btnInfillPatternRectilinear.Text = "Rectilinear"; this.btnInfillPatternRectilinear.UseVisualStyleBackColor = true; - this.btnInfillPatternRectilinear.Click += new System.EventHandler(this.ItemClicked); + this.btnInfillPatternRectilinear.Click += new System.EventHandler(this.EventClick); // // nmInfillThickness // @@ -661,36 +241,61 @@ namespace UVtools.GUI.Forms this.label10.TabIndex = 21; this.label10.Text = "Thickness:"; // - // btnImportImageMask + // label6 // - this.btnImportImageMask.Location = new System.Drawing.Point(161, 88); - this.btnImportImageMask.Name = "btnImportImageMask"; - this.btnImportImageMask.Size = new System.Drawing.Size(273, 32); - this.btnImportImageMask.TabIndex = 30; - this.btnImportImageMask.Text = "Import grayscale image as mask"; - this.btnImportImageMask.UseVisualStyleBackColor = true; - this.btnImportImageMask.Visible = false; - this.btnImportImageMask.Click += new System.EventHandler(this.ItemClicked); + this.label6.AutoSize = true; + this.label6.Location = new System.Drawing.Point(6, 299); + this.label6.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(548, 20); + this.label6.TabIndex = 40; + this.label6.Text = "(Leave this field empty to use only the even layer pattern for the layers range)"; + this.toolTip.SetToolTip(this.label6, resources.GetString("label6.ToolTip")); // - // btnLayerRangeSelect + // label5 // - this.btnLayerRangeSelect.Location = new System.Drawing.Point(446, 146); - this.btnLayerRangeSelect.Menu = this.cmLayerRange; - this.btnLayerRangeSelect.Name = "btnLayerRangeSelect"; - this.btnLayerRangeSelect.Size = new System.Drawing.Size(141, 26); - this.btnLayerRangeSelect.TabIndex = 2; - this.btnLayerRangeSelect.Text = "Select"; - this.btnLayerRangeSelect.UseVisualStyleBackColor = true; + this.label5.AutoSize = true; + this.label5.Location = new System.Drawing.Point(4, 184); + this.label5.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(94, 100); + this.label5.TabIndex = 39; + this.label5.Text = "Odd Layer\r\nPattern:\r\n0 = Black\r\n255 = White\r\n(Optional)"; // - // cbDimsOnlyBorders + // tbOddPattern // - this.cbDimsOnlyBorders.AutoSize = true; - this.cbDimsOnlyBorders.Location = new System.Drawing.Point(314, 188); - this.cbDimsOnlyBorders.Name = "cbDimsOnlyBorders"; - this.cbDimsOnlyBorders.Size = new System.Drawing.Size(181, 24); - this.cbDimsOnlyBorders.TabIndex = 31; - this.cbDimsOnlyBorders.Text = "Dims only the borders"; - this.cbDimsOnlyBorders.UseVisualStyleBackColor = true; + this.tbOddPattern.Location = new System.Drawing.Point(105, 172); + this.tbOddPattern.Multiline = true; + this.tbOddPattern.Name = "tbOddPattern"; + this.tbOddPattern.ScrollBars = System.Windows.Forms.ScrollBars.Both; + this.tbOddPattern.Size = new System.Drawing.Size(469, 124); + this.tbOddPattern.TabIndex = 38; + this.tbOddPattern.Text = "255 255 127 255\r\n127 255 255 255"; + this.tbOddPattern.WordWrap = false; + // + // groupBox1 + // + this.groupBox1.Controls.Add(this.btnDimPatternSolid); + this.groupBox1.Controls.Add(this.btnDimPatternStrips); + this.groupBox1.Controls.Add(this.label7); + this.groupBox1.Controls.Add(this.btnDimPatternWaves); + this.groupBox1.Controls.Add(this.btnPatternRandom); + this.groupBox1.Controls.Add(this.btnDimPatternSlashes); + this.groupBox1.Controls.Add(this.btnDimPatternHearts); + this.groupBox1.Controls.Add(this.btnDimPatternRhombus); + this.groupBox1.Controls.Add(this.btnDimPatternPyramid); + this.groupBox1.Controls.Add(this.btnDimPatternCrosses); + this.groupBox1.Controls.Add(this.btnDimPatternSparse); + this.groupBox1.Controls.Add(this.btnDimPatternChessBoard); + this.groupBox1.Controls.Add(this.nmPixelDimBrightness); + this.groupBox1.Controls.Add(this.label3); + this.groupBox1.Controls.Add(this.label4); + this.groupBox1.Location = new System.Drawing.Point(-1, 338); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(575, 162); + this.groupBox1.TabIndex = 37; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "Pixel dimming generator"; // // btnDimPatternSolid // @@ -700,16 +305,224 @@ namespace UVtools.GUI.Forms this.btnDimPatternSolid.TabIndex = 32; this.btnDimPatternSolid.Text = "Solid"; this.btnDimPatternSolid.UseVisualStyleBackColor = true; - this.btnDimPatternSolid.Click += new System.EventHandler(this.ItemClicked); + this.btnDimPatternSolid.Click += new System.EventHandler(this.EventClick); // - // FrmMutationPixelDimming + // btnDimPatternStrips + // + this.btnDimPatternStrips.Location = new System.Drawing.Point(332, 25); + this.btnDimPatternStrips.Name = "btnDimPatternStrips"; + this.btnDimPatternStrips.Size = new System.Drawing.Size(94, 35); + this.btnDimPatternStrips.TabIndex = 31; + this.btnDimPatternStrips.Text = "Strips"; + this.btnDimPatternStrips.UseVisualStyleBackColor = true; + this.btnDimPatternStrips.Click += new System.EventHandler(this.EventClick); + // + // label7 + // + this.label7.AutoSize = true; + this.label7.Location = new System.Drawing.Point(233, 34); + this.label7.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(60, 20); + this.label7.TabIndex = 30; + this.label7.Text = "(0-254)"; + // + // btnDimPatternWaves + // + this.btnDimPatternWaves.Location = new System.Drawing.Point(232, 106); + this.btnDimPatternWaves.Name = "btnDimPatternWaves"; + this.btnDimPatternWaves.Size = new System.Drawing.Size(94, 35); + this.btnDimPatternWaves.TabIndex = 29; + this.btnDimPatternWaves.Text = "Waves"; + this.btnDimPatternWaves.UseVisualStyleBackColor = true; + this.btnDimPatternWaves.Click += new System.EventHandler(this.EventClick); + // + // btnPatternRandom + // + this.btnPatternRandom.Location = new System.Drawing.Point(6, 121); + this.btnPatternRandom.Name = "btnPatternRandom"; + this.btnPatternRandom.Size = new System.Drawing.Size(94, 35); + this.btnPatternRandom.TabIndex = 29; + this.btnPatternRandom.Text = "Random"; + this.btnPatternRandom.UseVisualStyleBackColor = true; + this.btnPatternRandom.Visible = false; + // + // btnDimPatternSlashes + // + this.btnDimPatternSlashes.Location = new System.Drawing.Point(332, 106); + this.btnDimPatternSlashes.Name = "btnDimPatternSlashes"; + this.btnDimPatternSlashes.Size = new System.Drawing.Size(94, 35); + this.btnDimPatternSlashes.TabIndex = 28; + this.btnDimPatternSlashes.Text = "Slashes"; + this.btnDimPatternSlashes.UseVisualStyleBackColor = true; + this.btnDimPatternSlashes.Click += new System.EventHandler(this.EventClick); + // + // btnDimPatternHearts + // + this.btnDimPatternHearts.Location = new System.Drawing.Point(432, 106); + this.btnDimPatternHearts.Name = "btnDimPatternHearts"; + this.btnDimPatternHearts.Size = new System.Drawing.Size(94, 35); + this.btnDimPatternHearts.TabIndex = 27; + this.btnDimPatternHearts.Text = "Hearts"; + this.btnDimPatternHearts.UseVisualStyleBackColor = true; + this.btnDimPatternHearts.Click += new System.EventHandler(this.EventClick); + // + // btnDimPatternRhombus + // + this.btnDimPatternRhombus.Location = new System.Drawing.Point(112, 106); + this.btnDimPatternRhombus.Name = "btnDimPatternRhombus"; + this.btnDimPatternRhombus.Size = new System.Drawing.Size(113, 35); + this.btnDimPatternRhombus.TabIndex = 26; + this.btnDimPatternRhombus.Text = "Rhombus"; + this.btnDimPatternRhombus.UseVisualStyleBackColor = true; + this.btnDimPatternRhombus.Click += new System.EventHandler(this.EventClick); + // + // btnDimPatternPyramid + // + this.btnDimPatternPyramid.Location = new System.Drawing.Point(432, 65); + this.btnDimPatternPyramid.Name = "btnDimPatternPyramid"; + this.btnDimPatternPyramid.Size = new System.Drawing.Size(94, 35); + this.btnDimPatternPyramid.TabIndex = 25; + this.btnDimPatternPyramid.Text = "Pyramid"; + this.btnDimPatternPyramid.UseVisualStyleBackColor = true; + this.btnDimPatternPyramid.Click += new System.EventHandler(this.EventClick); + // + // btnDimPatternCrosses + // + this.btnDimPatternCrosses.Location = new System.Drawing.Point(332, 65); + this.btnDimPatternCrosses.Name = "btnDimPatternCrosses"; + this.btnDimPatternCrosses.Size = new System.Drawing.Size(94, 35); + this.btnDimPatternCrosses.TabIndex = 24; + this.btnDimPatternCrosses.Text = "Crosses"; + this.btnDimPatternCrosses.UseVisualStyleBackColor = true; + this.btnDimPatternCrosses.Click += new System.EventHandler(this.EventClick); + // + // btnDimPatternSparse + // + this.btnDimPatternSparse.Location = new System.Drawing.Point(232, 65); + this.btnDimPatternSparse.Name = "btnDimPatternSparse"; + this.btnDimPatternSparse.Size = new System.Drawing.Size(94, 35); + this.btnDimPatternSparse.TabIndex = 23; + this.btnDimPatternSparse.Text = "Sparse"; + this.btnDimPatternSparse.UseVisualStyleBackColor = true; + this.btnDimPatternSparse.Click += new System.EventHandler(this.EventClick); + // + // btnDimPatternChessBoard + // + this.btnDimPatternChessBoard.Location = new System.Drawing.Point(112, 65); + this.btnDimPatternChessBoard.Name = "btnDimPatternChessBoard"; + this.btnDimPatternChessBoard.Size = new System.Drawing.Size(114, 35); + this.btnDimPatternChessBoard.TabIndex = 22; + this.btnDimPatternChessBoard.Text = "Chess Board"; + this.btnDimPatternChessBoard.UseVisualStyleBackColor = true; + this.btnDimPatternChessBoard.Click += new System.EventHandler(this.EventClick); + // + // nmPixelDimBrightness + // + this.nmPixelDimBrightness.Location = new System.Drawing.Point(112, 31); + this.nmPixelDimBrightness.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.nmPixelDimBrightness.Maximum = new decimal(new int[] { + 254, + 0, + 0, + 0}); + this.nmPixelDimBrightness.Name = "nmPixelDimBrightness"; + this.nmPixelDimBrightness.Size = new System.Drawing.Size(113, 26); + this.nmPixelDimBrightness.TabIndex = 20; + this.nmPixelDimBrightness.Value = new decimal(new int[] { + 127, + 0, + 0, + 0}); + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(7, 94); + this.label3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(65, 20); + this.label3.TabIndex = 19; + this.label3.Text = "Pattern:"; + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(7, 34); + this.label4.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(89, 20); + this.label4.TabIndex = 21; + this.label4.Text = "Brightness:"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(4, 64); + this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(94, 80); + this.label2.TabIndex = 36; + this.label2.Text = "Even Layer\r\nPattern:\r\n0 = Black\r\n255 = White"; + // + // tbEvenPattern + // + this.tbEvenPattern.Location = new System.Drawing.Point(105, 42); + this.tbEvenPattern.Multiline = true; + this.tbEvenPattern.Name = "tbEvenPattern"; + this.tbEvenPattern.ScrollBars = System.Windows.Forms.ScrollBars.Both; + this.tbEvenPattern.Size = new System.Drawing.Size(469, 124); + this.tbEvenPattern.TabIndex = 35; + this.tbEvenPattern.Text = "127 255 255 255\r\n255 255 127 255"; + this.tbEvenPattern.WordWrap = false; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(233, 11); + this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(25, 20); + this.label1.TabIndex = 34; + this.label1.Text = "px"; + this.toolTip.SetToolTip(this.label1, resources.GetString("label1.ToolTip")); + // + // nmBorderSize + // + this.nmBorderSize.Location = new System.Drawing.Point(105, 8); + this.nmBorderSize.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.nmBorderSize.Maximum = new decimal(new int[] { + 1000, + 0, + 0, + 0}); + this.nmBorderSize.Name = "nmBorderSize"; + this.nmBorderSize.Size = new System.Drawing.Size(120, 26); + this.nmBorderSize.TabIndex = 32; + this.nmBorderSize.Value = new decimal(new int[] { + 5, + 0, + 0, + 0}); + // + // lbX + // + this.lbX.AutoSize = true; + this.lbX.Location = new System.Drawing.Point(4, 11); + this.lbX.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.lbX.Name = "lbX"; + this.lbX.Size = new System.Drawing.Size(93, 20); + this.lbX.TabIndex = 33; + this.lbX.Text = "Border size:"; + this.toolTip.SetToolTip(this.lbX, resources.GetString("lbX.ToolTip")); + // + // CtrlToolPixelDimming // this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.CancelButton = this.btnCancel; - this.ClientSize = new System.Drawing.Size(599, 916); + this.AutoSize = true; + this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; this.Controls.Add(this.cbDimsOnlyBorders); - this.Controls.Add(this.btnImportImageMask); this.Controls.Add(this.groupBox2); this.Controls.Add(this.label6); this.Controls.Add(this.label5); @@ -718,38 +531,20 @@ namespace UVtools.GUI.Forms this.Controls.Add(this.label2); this.Controls.Add(this.tbEvenPattern); this.Controls.Add(this.label1); - this.Controls.Add(this.btnLayerRangeSelect); - this.Controls.Add(this.lbLayerRangeTo); - this.Controls.Add(this.nmLayerRangeEnd); - this.Controls.Add(this.nmLayerRangeStart); - this.Controls.Add(this.lbLayerRange); - this.Controls.Add(this.btnMutate); - this.Controls.Add(this.btnCancel); this.Controls.Add(this.nmBorderSize); this.Controls.Add(this.lbX); - this.Controls.Add(this.lbDescription); + this.Description = ""; this.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.KeyPreview = true; - this.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "FrmMutationPixelDimming"; - this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Form1"; - this.TopMost = true; - ((System.ComponentModel.ISupportInitialize)(this.nmLayerRangeStart)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.nmLayerRangeEnd)).EndInit(); - this.cmLayerRange.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.nmBorderSize)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.nmPixelDimBrightness)).EndInit(); - this.groupBox1.ResumeLayout(false); - this.groupBox1.PerformLayout(); + this.Name = "CtrlToolPixelDimming"; + this.Size = new System.Drawing.Size(577, 669); this.groupBox2.ResumeLayout(false); this.groupBox2.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.nmInfillSpacing)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.nmInfillThickness)).EndInit(); + this.groupBox1.ResumeLayout(false); + this.groupBox1.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.nmPixelDimBrightness)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.nmBorderSize)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); @@ -757,43 +552,12 @@ namespace UVtools.GUI.Forms #endregion - private System.Windows.Forms.Label lbDescription; - private System.Windows.Forms.Label lbX; - private System.Windows.Forms.Button btnCancel; - private System.Windows.Forms.Button btnMutate; - private System.Windows.Forms.Label lbLayerRange; - private System.Windows.Forms.NumericUpDown nmLayerRangeStart; - private System.Windows.Forms.NumericUpDown nmLayerRangeEnd; - private System.Windows.Forms.Label lbLayerRangeTo; - private Controls.SplitButton btnLayerRangeSelect; - private System.Windows.Forms.ContextMenuStrip cmLayerRange; - private System.Windows.Forms.ToolStripMenuItem btnLayerRangeAllLayers; - private System.Windows.Forms.ToolStripMenuItem btnLayerRangeCurrentLayer; - private System.Windows.Forms.ToolStripMenuItem btnLayerRangeBottomLayers; - private System.Windows.Forms.ToolStripMenuItem btnLayerRangeNormalLayers; - private System.Windows.Forms.ToolTip toolTip; - private System.Windows.Forms.NumericUpDown nmBorderSize; - private System.Windows.Forms.Label label1; - private System.Windows.Forms.TextBox tbEvenPattern; - private System.Windows.Forms.Label label2; - private System.Windows.Forms.Label label3; - private System.Windows.Forms.NumericUpDown nmPixelDimBrightness; - private System.Windows.Forms.Label label4; - private System.Windows.Forms.GroupBox groupBox1; - private System.Windows.Forms.Button btnDimPatternChessBoard; - private System.Windows.Forms.Button btnDimPatternSparse; - private System.Windows.Forms.Button btnDimPatternPyramid; - private System.Windows.Forms.Button btnDimPatternCrosses; - private System.Windows.Forms.Button btnDimPatternRhombus; - private System.Windows.Forms.Button btnDimPatternHearts; - private System.Windows.Forms.Button btnDimPatternSlashes; - private System.Windows.Forms.Button btnPatternRandom; - private System.Windows.Forms.Button btnDimPatternWaves; - private System.Windows.Forms.Label label5; - private System.Windows.Forms.TextBox tbOddPattern; - private System.Windows.Forms.Label label6; - private System.Windows.Forms.Label label7; + private System.Windows.Forms.CheckBox cbDimsOnlyBorders; private System.Windows.Forms.GroupBox groupBox2; + private System.Windows.Forms.Label label13; + private System.Windows.Forms.Label label11; + private System.Windows.Forms.NumericUpDown nmInfillSpacing; + private System.Windows.Forms.Label label12; private System.Windows.Forms.Label label8; private System.Windows.Forms.Button btnInfillPatternWaves; private System.Windows.Forms.Button btnInfillPatternSquareGrid; @@ -801,13 +565,29 @@ namespace UVtools.GUI.Forms private System.Windows.Forms.NumericUpDown nmInfillThickness; private System.Windows.Forms.Label label9; private System.Windows.Forms.Label label10; - private System.Windows.Forms.Label label11; - private System.Windows.Forms.NumericUpDown nmInfillSpacing; - private System.Windows.Forms.Label label12; - private System.Windows.Forms.Label label13; - private System.Windows.Forms.Button btnImportImageMask; - private System.Windows.Forms.Button btnDimPatternStrips; - private System.Windows.Forms.CheckBox cbDimsOnlyBorders; + private System.Windows.Forms.Label label6; + private System.Windows.Forms.Label label5; + private System.Windows.Forms.TextBox tbOddPattern; + private System.Windows.Forms.GroupBox groupBox1; private System.Windows.Forms.Button btnDimPatternSolid; + private System.Windows.Forms.Button btnDimPatternStrips; + private System.Windows.Forms.Label label7; + private System.Windows.Forms.Button btnDimPatternWaves; + private System.Windows.Forms.Button btnPatternRandom; + private System.Windows.Forms.Button btnDimPatternSlashes; + private System.Windows.Forms.Button btnDimPatternHearts; + private System.Windows.Forms.Button btnDimPatternRhombus; + private System.Windows.Forms.Button btnDimPatternPyramid; + private System.Windows.Forms.Button btnDimPatternCrosses; + private System.Windows.Forms.Button btnDimPatternSparse; + private System.Windows.Forms.Button btnDimPatternChessBoard; + private System.Windows.Forms.NumericUpDown nmPixelDimBrightness; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.TextBox tbEvenPattern; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.NumericUpDown nmBorderSize; + private System.Windows.Forms.Label lbX; } -} \ No newline at end of file +} diff --git a/UVtools.GUI/Forms/FrmMutationPixelDimming.cs b/UVtools.GUI/Controls/Tools/CtrlToolPixelDimming.cs similarity index 50% rename from UVtools.GUI/Forms/FrmMutationPixelDimming.cs rename to UVtools.GUI/Controls/Tools/CtrlToolPixelDimming.cs index a9eef4d..576e3f4 100644 --- a/UVtools.GUI/Forms/FrmMutationPixelDimming.cs +++ b/UVtools.GUI/Controls/Tools/CtrlToolPixelDimming.cs @@ -8,193 +8,100 @@ using System; using System.Globalization; -using System.Text; using System.Windows.Forms; using Emgu.CV; -using Emgu.CV.CvEnum; using UVtools.Core.Extensions; +using UVtools.Core.Operations; -namespace UVtools.GUI.Forms +namespace UVtools.GUI.Controls.Tools { - public partial class FrmMutationPixelDimming : Form + public partial class CtrlToolPixelDimming : CtrlToolWindowContent { - class MatrixTexbox + #region Subclasses + class TexboxMatrix { - public Matrix Pattern; - public TextBox Textbox; + public Matrix Pattern { get; set; } + public TextBox Textbox { get; } - public MatrixTexbox(Matrix pattern, TextBox textbox) + public TexboxMatrix(TextBox textbox) { - Pattern = pattern; Textbox = textbox; } } - #region Properties - - private Mutation Mutation { get; } - - public uint LayerRangeStart - { - get => (uint) nmLayerRangeStart.Value; - set => nmLayerRangeStart.Value = value; - } - - public uint LayerRangeEnd - { - get => (uint)Math.Min(nmLayerRangeEnd.Value, Program.SlicerFile.LayerCount-1); - set => nmLayerRangeEnd.Value = value; - } - - public uint BorderSize - { - get => (uint)nmBorderSize.Value; - set => nmBorderSize.Value = value; - } - - public bool DimsOnlyBorders - { - get => cbDimsOnlyBorders.Checked; - set => cbDimsOnlyBorders.Checked = value; - } - - public Matrix EvenPattern { get; private set; } - public Matrix OddPattern { get; private set; } - - #endregion - #region Constructors - public FrmMutationPixelDimming(Mutation mutation) + public OperationPixelDimming Operation { get; } + + public CtrlToolPixelDimming() { InitializeComponent(); - Mutation = mutation; - DialogResult = DialogResult.Cancel; - - nmBorderSize.Select(); - - Text = $"Mutate: {mutation.MenuName}"; - lbDescription.Text = Mutation.Description; - - nmLayerRangeEnd.Value = Program.SlicerFile.LayerCount-1; - - ItemClicked(btnDimPatternChessBoard, null); - } - #endregion - - #region Overrides - protected override void OnKeyUp(KeyEventArgs e) - { - base.OnKeyUp(e); - if (e.KeyCode == Keys.Enter) - { - if (tbEvenPattern.ContainsFocus || tbOddPattern.ContainsFocus) return; - btnMutate.PerformClick(); - e.Handled = true; - return; - } - - if ((ModifierKeys & Keys.Shift) == Keys.Shift && (ModifierKeys & Keys.Control) == Keys.Control) - { - if (e.KeyCode == Keys.A) - { - btnLayerRangeAllLayers.PerformClick(); - e.Handled = true; - return; - } - - if (e.KeyCode == Keys.C) - { - btnLayerRangeCurrentLayer.PerformClick(); - e.Handled = true; - return; - } - - if (e.KeyCode == Keys.B) - { - btnLayerRangeBottomLayers.PerformClick(); - e.Handled = true; - return; - } - - if (e.KeyCode == Keys.N) - { - btnLayerRangeNormalLayers.PerformClick(); - e.Handled = true; - return; - } - } + Operation = new OperationPixelDimming(); + SetOperation(Operation); + EventClick(btnDimPatternChessBoard, null); } - #endregion - - #region Events - private void ItemClicked(object sender, EventArgs e) + public override bool UpdateOperation() { - if (ReferenceEquals(sender, btnLayerRangeAllLayers)) - { - nmLayerRangeStart.Value = 0; - nmLayerRangeEnd.Value = Program.SlicerFile.LayerCount-1; - return; - } + base.UpdateOperation(); + Operation.BorderSize = (uint) nmBorderSize.Value; + Operation.BordersOnly = cbDimsOnlyBorders.Checked; - if (ReferenceEquals(sender, btnLayerRangeCurrentLayer)) - { - nmLayerRangeStart.Value = Program.FrmMain.ActualLayer; - nmLayerRangeEnd.Value = Program.FrmMain.ActualLayer; - return; - } - if (ReferenceEquals(sender, btnLayerRangeBottomLayers)) - { - nmLayerRangeStart.Value = 0; - nmLayerRangeEnd.Value = Program.SlicerFile.InitialLayerCount-1; - return; - } - - if (ReferenceEquals(sender, btnLayerRangeNormalLayers)) - { - nmLayerRangeStart.Value = Program.SlicerFile.InitialLayerCount - 1; - nmLayerRangeEnd.Value = Program.SlicerFile.LayerCount - 1; - return; - } - - if (ReferenceEquals(sender, btnImportImageMask)) - { - using (var fileOpen = new OpenFileDialog + var matrixTextbox = new[] { - CheckFileExists = true, - Filter = "Image Files(*.PNG;*.BMP;*.JPEG;*.JPG;*.GIF)|*.PNG;*.BMP;*.JPEG;*.JPG;*.GIF" - }) - { - if (fileOpen.ShowDialog() != DialogResult.OK) return; + new TexboxMatrix(tbEvenPattern), + new TexboxMatrix(tbOddPattern), + }; - using (var image = CvInvoke.Imread(fileOpen.FileName, ImreadModes.Grayscale)) + + foreach (var item in matrixTextbox) + { + if (string.IsNullOrWhiteSpace(item.Textbox.Text)) + { + item.Pattern = null; + } + else + { + for (var row = 0; row < item.Textbox.Lines.Length; row++) { - StringBuilder sb = new StringBuilder(); - for (int y = 0; y < image.Height; y++) + + var bytes = item.Textbox.Lines[row].Trim().Split(' '); + if (row == 0) { - var span = image.GetPixelRowSpan(y); - string line = string.Empty; - for (int x = 0; x < span.Length; x++) + item.Pattern = new Matrix(item.Textbox.Lines.Length, bytes.Length); + } + else + { + if (item.Pattern.Cols != bytes.Length) { - line += $"{span[x]} "; + MessageBoxError($"Row {row + 1} have invalid number of pixels, the pattern must have equal pixel count per line, per defined on line 1"); + return false; } - - line = line.Trim(); - sb.Append(line); - - if(y < image.Height-1) - sb.AppendLine(); } - tbEvenPattern.Text = sb.ToString(); - tbOddPattern.Text = string.Empty; + for (int col = 0; col < bytes.Length; col++) + { + if (byte.TryParse(bytes[col], out var value)) + { + item.Pattern[row, col] = value; + } + else + { + MessageBoxError($"{bytes[col]} is a invalid number, use values from 0 to 255"); + return false; + } + } } - } - return; } + Operation.EvenPattern = matrixTextbox[0].Pattern; + Operation.OddPattern = matrixTextbox[1].Pattern; + return true; + } + + private void EventClick(object sender, EventArgs e) + { if (ReferenceEquals(sender, btnDimPatternSolid)) { tbEvenPattern.Text = nmPixelDimBrightness.Value.ToString(CultureInfo.InvariantCulture); @@ -217,7 +124,7 @@ namespace UVtools.GUI.Forms if (ReferenceEquals(sender, btnDimPatternSparse)) { - + tbEvenPattern.Text = string.Format( "{0} 255 255 255{1}" + "255 255 {0} 255" @@ -298,7 +205,7 @@ namespace UVtools.GUI.Forms "255 255 {0} 255 {0} 255{1}" + "255 255 255 {0} 255 255{1}" + "255 255 255 255 255 255" - + , nmPixelDimBrightness.Value, Environment.NewLine); return; } @@ -377,13 +284,13 @@ namespace UVtools.GUI.Forms for (byte col = 0; col < size; col++) { //byte value = bytes[rnd.Next(0, bytes.Length)]; - byte value = (byte) rnd.Next(0, 2); + byte value = (byte)rnd.Next(0, 2); text += value == 1 ? "255" : nmPixelDimBrightness.Value.ToString(CultureInfo.InvariantCulture); - if (col < size-1) + if (col < size - 1) text += " "; } - if (row < size-1) text += Environment.NewLine; + if (row < size - 1) text += Environment.NewLine; } tbEvenPattern.Text = text; @@ -393,7 +300,7 @@ namespace UVtools.GUI.Forms if (ReferenceEquals(sender, btnInfillPatternRectilinear)) { - tbEvenPattern.Text = $"0{Environment.NewLine}".Repeat((int) nmInfillSpacing.Value) + $"255{Environment.NewLine}".Repeat((int)nmInfillSpacing.Value); + tbEvenPattern.Text = $"0{Environment.NewLine}".Repeat((int)nmInfillSpacing.Value) + $"255{Environment.NewLine}".Repeat((int)nmInfillSpacing.Value); tbEvenPattern.Text = tbEvenPattern.Text.Trim('\n', '\r'); tbOddPattern.Text = string.Empty; @@ -407,7 +314,7 @@ namespace UVtools.GUI.Forms p1 += p1.Repeat((int)nmInfillThickness.Value); - var p2 = "255 ".Repeat((int) nmInfillSpacing.Value) + "255 ".Repeat((int) nmInfillThickness.Value); + var p2 = "255 ".Repeat((int)nmInfillSpacing.Value) + "255 ".Repeat((int)nmInfillThickness.Value); p2 = p2.Trim() + Environment.NewLine; p2 += p2.Repeat((int)nmInfillThickness.Value); @@ -422,12 +329,12 @@ namespace UVtools.GUI.Forms { var p1 = string.Empty; var pos = 0; - for (sbyte dir = 1; dir >= -1; dir-=2) + for (sbyte dir = 1; dir >= -1; dir -= 2) { while (pos >= 0 && pos <= nmInfillSpacing.Value) { p1 += "0 ".Repeat(pos); - p1 += "255 ".Repeat((int) nmInfillThickness.Value); + p1 += "255 ".Repeat((int)nmInfillThickness.Value); p1 += "0 ".Repeat((int)nmInfillSpacing.Value - pos); p1 = p1.Trim() + Environment.NewLine; @@ -441,105 +348,6 @@ namespace UVtools.GUI.Forms tbOddPattern.Text = string.Empty; return; } - - if (ReferenceEquals(sender, btnMutate)) - { - if (!btnMutate.Enabled) return; - if (LayerRangeStart > LayerRangeEnd) - { - MessageBox.Show("Layer range start can't be higher than layer end.\nPlease fix and try again.", Text, MessageBoxButtons.OK, MessageBoxIcon.Error); - nmLayerRangeStart.Select(); - return; - } - - if (BorderSize == 0 && DimsOnlyBorders) - { - MessageBox.Show("Border size must be positive in order to use \"Dims only the borders\" function.", Text, MessageBoxButtons.OK, MessageBoxIcon.Error); - return; - } - - var matrixTextbox = new[] - { - new MatrixTexbox(EvenPattern, tbEvenPattern), - new MatrixTexbox(OddPattern, tbOddPattern), - }; - - - foreach (var item in matrixTextbox) - { - if (string.IsNullOrWhiteSpace(item.Textbox.Text)) - { - item.Pattern = null; - } - else - { - for (var row = 0; row < item.Textbox.Lines.Length; row++) - { - - var bytes = item.Textbox.Lines[row].Trim().Split(' '); - if (row == 0) - { - /*if (tbPattern.Lines.Length % 2 != 0 || bytes.Length % 2 != 0) - { - MessageBox.Show($"Rows and columns must be in even numbers", Text, MessageBoxButtons.OK, MessageBoxIcon.Error); - return; - }*/ - item.Pattern = new Matrix(item.Textbox.Lines.Length, bytes.Length); - } - else - { - if (item.Pattern.Cols != bytes.Length) - { - MessageBox.Show($"Row {row + 1} have invalid number of pixels, the pattern must have equal pixel count per line, per defined on line 1", Text, MessageBoxButtons.OK, MessageBoxIcon.Error); - return; - } - } - - for (int col = 0; col < bytes.Length; col++) - { - if (byte.TryParse(bytes[col], out var value)) - { - item.Pattern[row, col] = value; - } - else - { - MessageBox.Show($"{bytes[col]} is a invalid number, use values from 0 to 255", Text, MessageBoxButtons.OK, MessageBoxIcon.Error); - return; - } - } - } - } - } - - - EvenPattern = matrixTextbox[0].Pattern; - OddPattern = matrixTextbox[1].Pattern; - - - /*if (X == 100 && Y == 100) - { - MessageBox.Show($"X and Y cant be 100% together.", Text, MessageBoxButtons.OK, MessageBoxIcon.Error); - return; - }*/ - - if (MessageBox.Show($"Are you sure you want to {Mutation.Mutate}?", Text, MessageBoxButtons.YesNo, - MessageBoxIcon.Question) == DialogResult.Yes) - { - DialogResult = DialogResult.OK; - Close(); - } - - return; - } - - if (ReferenceEquals(sender, btnCancel)) - { - DialogResult = DialogResult.Cancel; - return; - } } - - - #endregion } } diff --git a/UVtools.GUI/Forms/FrmMutationPixelDimming.resx b/UVtools.GUI/Controls/Tools/CtrlToolPixelDimming.resx similarity index 93% rename from UVtools.GUI/Forms/FrmMutationPixelDimming.resx rename to UVtools.GUI/Controls/Tools/CtrlToolPixelDimming.resx index 5195000..0ba2a96 100644 --- a/UVtools.GUI/Forms/FrmMutationPixelDimming.resx +++ b/UVtools.GUI/Controls/Tools/CtrlToolPixelDimming.resx @@ -118,29 +118,21 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - 148, 17 - - - Selects the number of iterations/passes to perform on each layer using this mutator. -Enable the "Fade in/out" to fade the iteration over layers, you can use a start iteration higher than end to perform a inverse fade. -WARNING: Using high iteration values can destroy your model depending on the mutator being used, please use low values or with caution! - - - Selects the layers range within start layer and end layer where mutator will operate. -Select same layer start as end to operate only within that layer. -Note: "Layer Start" start can't be higher than "Layer End". - - 17, 17 - - Selects the number of iterations/passes to perform on each layer using this mutator. -Enable the "Fade in/out" to fade the iteration over layers, you can use a start iteration higher than end to perform a inverse fade. -WARNING: Using high iteration values can destroy your model depending on the mutator being used, please use low values or with caution! - Selects the layers range within start layer and end layer where mutator will operate. Select same layer start as end to operate only within that layer. Note: "Layer Start" start can't be higher than "Layer End". + + Selects the number of iterations/passes to perform on each layer using this mutator. +Enable the "Fade in/out" to fade the iteration over layers, you can use a start iteration higher than end to perform a inverse fade. +WARNING: Using high iteration values can destroy your model depending on the mutator being used, please use low values or with caution! + + + Selects the number of iterations/passes to perform on each layer using this mutator. +Enable the "Fade in/out" to fade the iteration over layers, you can use a start iteration higher than end to perform a inverse fade. +WARNING: Using high iteration values can destroy your model depending on the mutator being used, please use low values or with caution! + \ No newline at end of file diff --git a/UVtools.GUI/Controls/Tools/CtrlToolResize.cs b/UVtools.GUI/Controls/Tools/CtrlToolResize.cs index d21b85d..5c5071b 100644 --- a/UVtools.GUI/Controls/Tools/CtrlToolResize.cs +++ b/UVtools.GUI/Controls/Tools/CtrlToolResize.cs @@ -43,13 +43,14 @@ namespace UVtools.GUI.Controls.Tools ButtonOkEnabled = Operation.CanValidate(); } - public override void UpdateOperation() + public override bool UpdateOperation() { base.UpdateOperation(); Operation.X = nmX.Value; Operation.Y = nmY.Value; Operation.ConstrainXY = cbConstrainXY.Checked; Operation.IsFade = cbFade.Checked; + return true; } } } diff --git a/UVtools.GUI/Controls/Tools/CtrlToolRotate.cs b/UVtools.GUI/Controls/Tools/CtrlToolRotate.cs index 2cddf99..b506ac9 100644 --- a/UVtools.GUI/Controls/Tools/CtrlToolRotate.cs +++ b/UVtools.GUI/Controls/Tools/CtrlToolRotate.cs @@ -22,10 +22,11 @@ namespace UVtools.GUI.Controls.Tools SetOperation(Operation); } - public override void UpdateOperation() + public override bool UpdateOperation() { base.UpdateOperation(); Operation.AngleDegrees = nmDegrees.Value; + return true; } private void EventValueChanged(object sender, EventArgs e) diff --git a/UVtools.GUI/FrmMain.cs b/UVtools.GUI/FrmMain.cs index ed12e87..f1f24ce 100644 --- a/UVtools.GUI/FrmMain.cs +++ b/UVtools.GUI/FrmMain.cs @@ -52,6 +52,7 @@ namespace UVtools.GUI new OperationMenuItem(new OperationSolidify(), Resources.square_solid_16x16), new OperationMenuItem(new OperationMorph(), Resources.Geometry_16x16), new OperationMenuItem(new OperationMask(), Resources.mask_16x16), + new OperationMenuItem(new OperationPixelDimming(), Resources.pixel_16x16), new OperationMenuItem(new OperationChangeResolution(), Resources.resize_16x16), new OperationMenuItem(new OperationLayerReHeight(), Resources.ladder_16x16), new OperationMenuItem(new OperationPattern(), Resources.pattern_16x16) @@ -111,7 +112,7 @@ namespace UVtools.GUI "Mask" ) },*/ - { + /*{ LayerManager.Mutate.PixelDimming, new Mutation(LayerManager.Mutate.PixelDimming, "Pixel Dimming", Resources.chessboard_16x16, "Dims pixels in a chosen pattern over white pixels neighborhood. The selected pattern will be repeated over the image width and height as a mask. Benefits are:\n" + @@ -121,7 +122,7 @@ namespace UVtools.GUI "NOTE: Run only this tool after all repairs and other transformations.", "Dim" ) - }, + },*/ /*{ LayerManager.Mutate.Erode, new Mutation(LayerManager.Mutate.Erode, null, Resources.compress_alt_16x16, @@ -3700,7 +3701,7 @@ namespace UVtools.GUI } break;*/ - case LayerManager.Mutate.PixelDimming: + /*case LayerManager.Mutate.PixelDimming: using (FrmMutationPixelDimming inputBox = new FrmMutationPixelDimming(Mutations[mutator])) { if (inputBox.ShowDialog() != DialogResult.OK) return; @@ -3711,9 +3712,9 @@ namespace UVtools.GUI evenPattern = inputBox.EvenPattern; oddPattern = inputBox.OddPattern; } - - break; - case LayerManager.Mutate.ThresholdPixels: + + break;*/ + /*case LayerManager.Mutate.ThresholdPixels: using (FrmMutationThreshold inputBox = new FrmMutationThreshold(Mutations[mutator])) { if (inputBox.ShowDialog() != DialogResult.OK) return; @@ -3743,7 +3744,7 @@ namespace UVtools.GUI } } - break; + break;*/ } DisableGUI(); @@ -3783,10 +3784,10 @@ namespace UVtools.GUI SlicerFile.LayerManager.Mask(layerStart, layerEnd, mat, progress); mat?.Dispose(); break;*/ - case LayerManager.Mutate.PixelDimming: - SlicerFile.LayerManager.MutatePixelDimming(layerStart, layerEnd, evenPattern, oddPattern, + /*case LayerManager.Mutate.PixelDimming: + SlicerFile.LayerManager.PixelDimming(layerStart, layerEnd, evenPattern, oddPattern, (ushort) iterationsStart, fade, progress); - break; + break;*/ /*case LayerManager.Mutate.Erode: SlicerFile.LayerManager.MutateErode(layerStart, layerEnd, (int) iterationsStart, (int) iterationsEnd, fade, progress, kernel, kernelAnchor); @@ -4519,6 +4520,9 @@ namespace UVtools.GUI case OperationMask operation: SlicerFile.LayerManager.Mask(operation, FrmLoading.RestartProgress()); break; + case OperationPixelDimming operation: + SlicerFile.LayerManager.PixelDimming(operation, FrmLoading.RestartProgress()); + break; case OperationChangeResolution operation: SlicerFile.LayerManager.ChangeResolution(operation, FrmLoading.RestartProgress(false)); diff --git a/UVtools.GUI/UVtools.GUI.csproj b/UVtools.GUI/UVtools.GUI.csproj index f818526..e7aa69a 100644 --- a/UVtools.GUI/UVtools.GUI.csproj +++ b/UVtools.GUI/UVtools.GUI.csproj @@ -170,6 +170,12 @@ Component + + UserControl + + + CtrlToolPixelDimming.cs + UserControl @@ -271,12 +277,6 @@ FrmMutationThreshold.cs - - Form - - - FrmMutationPixelDimming.cs - Form @@ -330,6 +330,9 @@ CtrlToolWindowContent.cs + + CtrlToolPixelDimming.cs + CtrlToolMask.cs @@ -381,9 +384,6 @@ FrmMutationThreshold.cs - - FrmMutationPixelDimming.cs - FrmToolWindow.cs