diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d2138f..171090f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,10 +13,11 @@ * (Add) Setting: Pixel editor can be configured to exit after each apply operation (#45) * (Add) More abstraction on GUI and operations * (Improvement) Redesign tools and mutator windows +* (Improvement) Kernel option on some mutators is now hidden by default * (Improvement) When zoom into issue or drawing now it checks bounds of zoom rectangle and only performs ZoomToFit is it will be larger then the viewPort after zoom. Otherwise, it will zoom to the fixed zoom level (Auto zoom to region setting dropped as merged into this) (#42) * (Improvement) Layer and Issues Repair: Detailed description and warning text in this dialog has been moved from main form into tooltips. It's useful information for new users, but not needed to be visible each time repair is run. -* (Improvement) Flip: Better performance on "make copy" -* (Improvement) Rotate: Disallow operation when selecting an angle of -360, 0 and 360 +* (Improvement) Tool - Flip: Better performance on "make copy" +* (Improvement) Tool - Rotate: Disallow operation when selecting an angle of -360, 0 and 360 Less frequently used settings for gap and noise removal iterations have been moved to an advanced settings group that is hidden by default, and can be shown if changes in those settings is desired. For many users, those advanced settings can be left on default and never adjusted. (#43) * (Change) Erode, dilate, gap closing and noise removal converted into one window (Morph model) * (Change) Shortcuts: + and - to go up and down on layers were change to W and S keys. Reason: + and - are bound to zoom and can lead to problems @@ -31,7 +32,7 @@ Less frequently used settings for gap and noise removal iterations have been mov * (Fix) CTB: Add support for CTB v3 (ezrec/uv3dp#97, #36) * (Fix) SL1: Bottle volume doesn't accept decimal numbers * (Fix) Tool - Change resolution: Confirmation text was set to remove layers -* (Fix) Fade iteration now working as expected on some mutators +* (Fix) Fade iteration now working as expected * (Fix) Pattern: When select big margins and cols/rows it triggers an error because value hits the maximum variable size * (Fix) Mask: A crash when check "Invert" when mask is not loaded * (Fix) Some text and phrases diff --git a/UVtools.Core/FileFormats/FileFormat.cs b/UVtools.Core/FileFormats/FileFormat.cs index cb30a88..1defd94 100644 --- a/UVtools.Core/FileFormats/FileFormat.cs +++ b/UVtools.Core/FileFormats/FileFormat.cs @@ -55,20 +55,37 @@ namespace UVtools.Core.FileFormats { #region Instances - public static PrintParameterModifier InitialLayerCount { get; } = new PrintParameterModifier("Initial Layer Count", @"Modify 'Initial Layer Count' value", null,0, ushort.MaxValue, 0); - public static PrintParameterModifier InitialExposureSeconds { get; } = new PrintParameterModifier("Initial Exposure Time", @"Modify 'Initial Exposure Time' seconds", "s", 0.1M, byte.MaxValue); - public static PrintParameterModifier ExposureSeconds { get; } = new PrintParameterModifier("Exposure Time", @"Modify 'Exposure Time' seconds", "s", 0.1M, byte.MaxValue); + public static PrintParameterModifier InitialLayerCount { get; } = new PrintParameterModifier("Initial Layer Count", @"Modify 'Initial Layer Count' value", "layers",0, ushort.MaxValue, 0); + public static PrintParameterModifier InitialExposureSeconds { get; } = new PrintParameterModifier("Initial Exposure Time", @"Modify 'Initial Exposure Time' seconds", "s", 0.1M, byte.MaxValue, 2); + public static PrintParameterModifier ExposureSeconds { get; } = new PrintParameterModifier("Exposure Time", @"Modify 'Exposure Time' seconds", "s", 0.1M, byte.MaxValue, 2); - public static PrintParameterModifier BottomLayerOffTime { get; } = new PrintParameterModifier("Bottom Layer Off Time", @"Modify 'Bottom Layer Off Time' seconds", "s"); + public static PrintParameterModifier BottomLayerOffTime { get; } = new PrintParameterModifier("Bottom Layer Off Time", @"Modify 'Bottom Layer Off Time' seconds", "s", 2); public static PrintParameterModifier LayerOffTime { get; } = new PrintParameterModifier("Layer Off Time", @"Modify 'Layer Off Time' seconds", "s"); - public static PrintParameterModifier BottomLiftHeight { get; } = new PrintParameterModifier("Bottom Lift Height", @"Modify 'Bottom Lift Height' millimeters between bottom layers", "mm"); - public static PrintParameterModifier BottomLiftSpeed { get; } = new PrintParameterModifier("Bottom Lift Speed", @"Modify 'Bottom Lift Speed' mm/min between bottom layers", "mm/min"); - public static PrintParameterModifier LiftHeight { get; } = new PrintParameterModifier("Lift Height", @"Modify 'Lift Height' millimeters between layers", "mm"); - public static PrintParameterModifier LiftSpeed { get; } = new PrintParameterModifier("Lift Speed", @"Modify 'Lift Speed' mm/min between layers", "mm/min", 10, 5000); - public static PrintParameterModifier RetractSpeed { get; } = new PrintParameterModifier("Retract Speed", @"Modify 'Retract Speed' mm/min between layers", "mm/min", 10, 5000); + public static PrintParameterModifier BottomLiftHeight { get; } = new PrintParameterModifier("Bottom Lift Height", @"Modify 'Bottom Lift Height' millimeters between bottom layers", "mm", 2); + public static PrintParameterModifier BottomLiftSpeed { get; } = new PrintParameterModifier("Bottom Lift Speed", @"Modify 'Bottom Lift Speed' mm/min between bottom layers", "mm/min", 2); + public static PrintParameterModifier LiftHeight { get; } = new PrintParameterModifier("Lift Height", @"Modify 'Lift Height' millimeters between layers", "mm", 2); + public static PrintParameterModifier LiftSpeed { get; } = new PrintParameterModifier("Lift Speed", @"Modify 'Lift Speed' mm/min between layers", "mm/min", 10, 5000, 2); + public static PrintParameterModifier RetractSpeed { get; } = new PrintParameterModifier("Retract Speed", @"Modify 'Retract Speed' mm/min between layers", "mm/min", 10, 5000, 2); public static PrintParameterModifier BottomLightPWM { get; } = new PrintParameterModifier("Bottom Light PWM", @"Modify 'Bottom Light PWM' value", null, 50, byte.MaxValue, 0); public static PrintParameterModifier LightPWM { get; } = new PrintParameterModifier("Light PWM", @"Modify 'Light PWM' value", null, 50, byte.MaxValue, 0); + + public static PrintParameterModifier[] Parameters = { + InitialLayerCount, + InitialExposureSeconds, + ExposureSeconds, + + BottomLayerOffTime, + LayerOffTime, + BottomLiftHeight, + BottomLiftSpeed, + LiftHeight, + LiftSpeed, + RetractSpeed, + + BottomLightPWM, + LightPWM + }; #endregion #region Properties @@ -102,6 +119,21 @@ namespace UVtools.Core.FileFormats /// Gets the number of decimal plates /// public byte DecimalPlates { get; } + + /// + /// Gets or sets the current / old value + /// + public decimal OldValue { get; set; } + + /// + /// Gets or sets the new value + /// + public decimal NewValue { get; set; } + + /// + /// Gets if the value has changed + /// + public bool HasChanged => OldValue == NewValue; #endregion #region Constructor @@ -119,7 +151,7 @@ namespace UVtools.Core.FileFormats #region Overrides public override string ToString() { - return $"{nameof(Name)}: {Name}, {nameof(Description)}: {Description}, {nameof(ValueUnit)}: {ValueUnit}, {nameof(Minimum)}: {Minimum}, {nameof(Maximum)}: {Maximum}"; + return $"{nameof(Name)}: {Name}, {nameof(Description)}: {Description}, {nameof(ValueUnit)}: {ValueUnit}, {nameof(Minimum)}: {Minimum}, {nameof(Maximum)}: {Maximum}, {nameof(DecimalPlates)}: {DecimalPlates}, {nameof(OldValue)}: {OldValue}, {nameof(NewValue)}: {NewValue}, {nameof(HasChanged)}: {HasChanged}"; } #endregion } diff --git a/UVtools.Core/Operations/OperationEditParameters.cs b/UVtools.Core/Operations/OperationEditParameters.cs new file mode 100644 index 0000000..5798f71 --- /dev/null +++ b/UVtools.Core/Operations/OperationEditParameters.cs @@ -0,0 +1,36 @@ +/* + * 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 UVtools.Core.FileFormats; + +namespace UVtools.Core.Operations +{ + public class OperationEditParameters : Operation + { + public override string Title => "Edit Parameters"; + public override string Description => + "Edits the available print parameters."; + + public override string ConfirmationText => null; + + public override string ProgressTitle => null; + + public override string ProgressAction => null; + + public FileFormat.PrintParameterModifier[] Modifiers { get; set; } + + public OperationEditParameters() + { + } + + public OperationEditParameters(FileFormat.PrintParameterModifier[] modifiers) + { + Modifiers = modifiers; + } + } +} diff --git a/UVtools.GUI/Controls/Tools/CtrlToolEditEditParameters.Designer.cs b/UVtools.GUI/Controls/Tools/CtrlToolEditEditParameters.Designer.cs new file mode 100644 index 0000000..2563e65 --- /dev/null +++ b/UVtools.GUI/Controls/Tools/CtrlToolEditEditParameters.Designer.cs @@ -0,0 +1,152 @@ +namespace UVtools.GUI.Controls.Tools +{ + partial class CtrlToolEditParameters + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.table = new System.Windows.Forms.TableLayoutPanel(); + this.lbValue = new System.Windows.Forms.Label(); + this.lbProperty = new System.Windows.Forms.Label(); + this.lbUnit = new System.Windows.Forms.Label(); + this.lbOldValue = new System.Windows.Forms.Label(); + this.lbAction = new System.Windows.Forms.Label(); + this.table.SuspendLayout(); + this.SuspendLayout(); + // + // table + // + this.table.AutoSize = true; + this.table.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.table.CellBorderStyle = System.Windows.Forms.TableLayoutPanelCellBorderStyle.InsetDouble; + this.table.ColumnCount = 5; + this.table.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); + this.table.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); + this.table.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); + this.table.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); + this.table.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.table.Controls.Add(this.lbAction, 4, 0); + this.table.Controls.Add(this.lbOldValue, 1, 0); + this.table.Controls.Add(this.lbUnit, 3, 0); + this.table.Controls.Add(this.lbValue, 2, 0); + this.table.Controls.Add(this.lbProperty, 0, 0); + this.table.Dock = System.Windows.Forms.DockStyle.Fill; + this.table.Location = new System.Drawing.Point(0, 0); + this.table.Name = "table"; + this.table.RowCount = 1; + this.table.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.table.Size = new System.Drawing.Size(540, 26); + this.table.TabIndex = 0; + // + // lbValue + // + this.lbValue.AutoSize = true; + this.lbValue.Dock = System.Windows.Forms.DockStyle.Fill; + this.lbValue.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lbValue.Location = new System.Drawing.Point(183, 3); + this.lbValue.Name = "lbValue"; + this.lbValue.Size = new System.Drawing.Size(55, 20); + this.lbValue.TabIndex = 0; + this.lbValue.Text = "Value"; + this.lbValue.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // lbProperty + // + this.lbProperty.AutoSize = true; + this.lbProperty.Dock = System.Windows.Forms.DockStyle.Fill; + this.lbProperty.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lbProperty.Location = new System.Drawing.Point(6, 3); + this.lbProperty.Name = "lbProperty"; + this.lbProperty.Size = new System.Drawing.Size(76, 20); + this.lbProperty.TabIndex = 1; + this.lbProperty.Text = "Property"; + this.lbProperty.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // lbUnit + // + this.lbUnit.AutoSize = true; + this.lbUnit.Dock = System.Windows.Forms.DockStyle.Fill; + this.lbUnit.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lbUnit.Location = new System.Drawing.Point(247, 3); + this.lbUnit.Name = "lbUnit"; + this.lbUnit.Size = new System.Drawing.Size(42, 20); + this.lbUnit.TabIndex = 3; + this.lbUnit.Text = "Unit"; + this.lbUnit.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // lbOldValue + // + this.lbOldValue.AutoSize = true; + this.lbOldValue.Dock = System.Windows.Forms.DockStyle.Fill; + this.lbOldValue.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lbOldValue.Location = new System.Drawing.Point(91, 3); + this.lbOldValue.Name = "lbOldValue"; + this.lbOldValue.Size = new System.Drawing.Size(83, 20); + this.lbOldValue.TabIndex = 4; + this.lbOldValue.Text = "Old value"; + this.lbOldValue.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // lbAction + // + this.lbAction.AutoSize = true; + this.lbAction.Dock = System.Windows.Forms.DockStyle.Fill; + this.lbAction.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lbAction.Location = new System.Drawing.Point(298, 3); + this.lbAction.Name = "lbAction"; + this.lbAction.Size = new System.Drawing.Size(236, 20); + this.lbAction.TabIndex = 5; + this.lbAction.Text = "Reset"; + this.lbAction.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // CtrlToolEditParameters + // + this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.AutoSize = true; + this.Controls.Add(this.table); + this.Description = ""; + this.ExtraButtonVisible = true; + this.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.LayerRangeVisible = false; + this.Name = "CtrlToolEditParameters"; + this.Size = new System.Drawing.Size(540, 26); + this.table.ResumeLayout(false); + this.table.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.TableLayoutPanel table; + private System.Windows.Forms.Label lbValue; + private System.Windows.Forms.Label lbProperty; + private System.Windows.Forms.Label lbOldValue; + private System.Windows.Forms.Label lbUnit; + private System.Windows.Forms.Label lbAction; + } +} diff --git a/UVtools.GUI/Controls/Tools/CtrlToolEditEditParameters.cs b/UVtools.GUI/Controls/Tools/CtrlToolEditEditParameters.cs new file mode 100644 index 0000000..59d6a3f --- /dev/null +++ b/UVtools.GUI/Controls/Tools/CtrlToolEditEditParameters.cs @@ -0,0 +1,141 @@ +/* + * 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; +using System.Drawing; +using System.Globalization; +using System.Windows.Forms; +using UVtools.Core.FileFormats; +using UVtools.Core.Operations; + +namespace UVtools.GUI.Controls.Tools +{ + public partial class CtrlToolEditParameters : CtrlToolWindowContent + { + public OperationEditParameters Operation { get; } + public NumericUpDown[] NumericUpDownProperties; + + public CtrlToolEditParameters() + { + InitializeComponent(); + Operation = new OperationEditParameters(Program.SlicerFile.PrintParameterModifiers); + SetOperation(Operation); + + if (Operation.Modifiers is null || Operation.Modifiers.Length == 0) + { + CanRun = false; + return; + } + + int rowIndex = 1; + NumericUpDownProperties = new NumericUpDown[Operation.Modifiers.Length]; + foreach (var modifier in Operation.Modifiers) + { + modifier.OldValue = decimal.Parse(Program.SlicerFile.GetValueFromPrintParameterModifier(modifier).ToString()); + table.RowStyles.Add(new RowStyle(SizeType.AutoSize)); + + Label nameLabel = new Label + { + Text = $"{modifier.Name}:", + TextAlign = ContentAlignment.MiddleLeft, + AutoSize = true, + Dock = DockStyle.Fill + }; + table.Controls.Add(nameLabel, 0, rowIndex); + toolTip.SetToolTip(nameLabel, modifier.Description); + + Label oldValueLabel = new Label + { + Text = modifier.OldValue.ToString(CultureInfo.InvariantCulture), + TextAlign = ContentAlignment.MiddleCenter, + AutoSize = true, + Dock = DockStyle.Fill + }; + table.Controls.Add(oldValueLabel, 1, rowIndex); + + NumericUpDown numericValue = new NumericUpDown + { + Value = modifier.OldValue, + DecimalPlaces = modifier.DecimalPlates, + Minimum = modifier.Minimum, + Maximum = modifier.Maximum, + Tag = modifier, + Width = 100, + Dock = DockStyle.Fill + //AutoSize = true + }; + NumericUpDownProperties[rowIndex - 1] = numericValue; + table.Controls.Add(numericValue, 2, rowIndex); + + if (!string.IsNullOrEmpty(modifier.ValueUnit)) + { + Label unitLabel = new Label + { + Text = modifier.ValueUnit, + TextAlign = ContentAlignment.MiddleLeft, + AutoSize = true, + Dock = DockStyle.Fill, + }; + table.Controls.Add(unitLabel, 3, rowIndex); + } + + Button resetButton = new Button + { + Image = Properties.Resources.refresh_16x16, + Dock = DockStyle.Fill, + BackColor = Color.WhiteSmoke, + Tag = numericValue + }; + resetButton.Click += ResetClicked; + table.Controls.Add(resetButton, 4, rowIndex); + + rowIndex++; + } + } + + public override bool UpdateOperation() + { + base.UpdateOperation(); + + foreach (var numUpDown in NumericUpDownProperties) + { + if (!(numUpDown.Tag is FileFormat.PrintParameterModifier modifier)) continue; + modifier.NewValue = modifier.NewValue; + if(!modifier.HasChanged) continue; + Program.SlicerFile.SetValueFromPrintParameterModifier(modifier, modifier.NewValue); + } + + return true; + } + + public override void ExtraActionCall(object sender) + { + if (sender is Button button) + { + foreach (var numUpDown in NumericUpDownProperties) + { + if (numUpDown.Tag is FileFormat.PrintParameterModifier modifier) + { + numUpDown.Value = modifier.OldValue; + } + } + return; + } + } + + private void ResetClicked(object sender, EventArgs e) + { + if (!(sender is Button button)) return; + if (!(button.Tag is NumericUpDown numericUpDown)) return; + if (!(numericUpDown.Tag is FileFormat.PrintParameterModifier modifier)) return; + numericUpDown.Value = modifier.OldValue; + return; + + } + } +} diff --git a/UVtools.GUI/Controls/Tools/CtrlToolEditEditParameters.resx b/UVtools.GUI/Controls/Tools/CtrlToolEditEditParameters.resx new file mode 100644 index 0000000..8766f29 --- /dev/null +++ b/UVtools.GUI/Controls/Tools/CtrlToolEditEditParameters.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file diff --git a/UVtools.GUI/FrmMain.cs b/UVtools.GUI/FrmMain.cs index f5c0c0b..aac5750 100644 --- a/UVtools.GUI/FrmMain.cs +++ b/UVtools.GUI/FrmMain.cs @@ -45,6 +45,7 @@ namespace UVtools.GUI #region Properties public static readonly OperationMenuItem[] MenuTools = { + new OperationMenuItem(new OperationEditParameters(), Resources.Wrench_16x16), new OperationMenuItem(new OperationRepairLayers(), Resources.toolbox_16x16), new OperationMenuItem(new OperationMove(), Resources.move_16x16), new OperationMenuItem(new OperationResize(), Resources.crop_16x16), diff --git a/UVtools.GUI/UVtools.GUI.csproj b/UVtools.GUI/UVtools.GUI.csproj index c258392..890ae06 100644 --- a/UVtools.GUI/UVtools.GUI.csproj +++ b/UVtools.GUI/UVtools.GUI.csproj @@ -176,6 +176,12 @@ CtrlToolBlur.cs + + UserControl + + + CtrlToolEditEditParameters.cs + UserControl @@ -332,6 +338,9 @@ CtrlToolBlur.cs + + CtrlToolEditEditParameters.cs + CtrlToolRepairLayers.cs diff --git a/UVtools.InstallerMM/UVtools.InstallerMM.wxs b/UVtools.InstallerMM/UVtools.InstallerMM.wxs index 5df4324..70f43d2 100644 --- a/UVtools.InstallerMM/UVtools.InstallerMM.wxs +++ b/UVtools.InstallerMM/UVtools.InstallerMM.wxs @@ -163,6 +163,12 @@ + + + + + +