mirror of
https://github.com/riegera2412/UVtools.git
synced 2026-07-09 01:52:32 +02:00
7ac20d7afa
* (Add) Issue: Overhangs - Detects potential overhangs on layers (#64) * (Add) PrusaSlicer Printer: Phrozen Sonic Mini 4K * (Improvement) CWS: Allow read files with "slice*" filenames as content (#67) * (Improvement) Allow convert chitubox files to CWS Bene4 Mono printer, must configure a printer containing "Bene4 Mono" name on Chitubox (#67) * (Improvement) Edit print parameters: Show changes on confirm dialog * (Improvement) Edit print parameters: Dedicated reset button hides when value is unchanged * (Improvement) More detailed descriptions on error messages * (Fix) Some islands wont remove from list when many selected and click remove * (Fix) Extract: Use trail zeros to layer filenames * (Fix) MSI installer not creating shortcuts (#66)
175 lines
5.9 KiB
C#
175 lines
5.9 KiB
C#
/*
|
|
* GNU AFFERO GENERAL PUBLIC LICENSE
|
|
* Version 3, 19 November 2007
|
|
* Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
|
* 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.Extensions;
|
|
using UVtools.Core.FileFormats;
|
|
using UVtools.Core.Operations;
|
|
using UVtools.GUI.Extensions;
|
|
|
|
namespace UVtools.GUI.Controls.Tools
|
|
{
|
|
public partial class CtrlToolEditParameters : CtrlToolWindowContent
|
|
{
|
|
public OperationEditParameters Operation { get; }
|
|
public RowControl[] RowControls;
|
|
|
|
public sealed class RowControl
|
|
{
|
|
public FileFormat.PrintParameterModifier Modifier { get; }
|
|
|
|
public Label Name { get; }
|
|
public Label OldValue { get; }
|
|
public NumericUpDown NewValue { get; }
|
|
public Label Unit { get; }
|
|
public Button ResetButton { get; }
|
|
|
|
public RowControl(FileFormat.PrintParameterModifier modifier)
|
|
{
|
|
Modifier = modifier;
|
|
|
|
Name = new Label
|
|
{
|
|
Text = $"{modifier.Name}:",
|
|
TextAlign = ContentAlignment.MiddleLeft,
|
|
AutoSize = true,
|
|
Dock = DockStyle.Fill,
|
|
Tag = this,
|
|
};
|
|
|
|
OldValue = new Label
|
|
{
|
|
Text = modifier.OldValue.ToString(CultureInfo.InvariantCulture),
|
|
TextAlign = ContentAlignment.MiddleCenter,
|
|
AutoSize = true,
|
|
Dock = DockStyle.Fill,
|
|
Tag = this
|
|
};
|
|
|
|
NewValue = new NumericUpDown
|
|
{
|
|
DecimalPlaces = modifier.DecimalPlates,
|
|
Minimum = modifier.Minimum,
|
|
Maximum = modifier.Maximum,
|
|
Value = modifier.OldValue.Clamp(modifier.Minimum, modifier.Maximum),
|
|
Tag = this,
|
|
Width = 100,
|
|
Dock = DockStyle.Fill,
|
|
//AutoSize = true
|
|
};
|
|
NewValue.ValueChanged += NewValue_ValueChanged;
|
|
|
|
Unit = new Label
|
|
{
|
|
Text = modifier.ValueUnit,
|
|
TextAlign = ContentAlignment.MiddleLeft,
|
|
AutoSize = true,
|
|
Dock = DockStyle.Fill,
|
|
Tag = this
|
|
};
|
|
|
|
ResetButton = new Button
|
|
{
|
|
Image = Properties.Resources.undo_16x16,
|
|
Dock = DockStyle.Fill,
|
|
BackColor = Color.LightGray,
|
|
Enabled = false,
|
|
Visible = false,
|
|
Tag = this
|
|
};
|
|
ResetButton.Click += ResetButton_Clicked;
|
|
}
|
|
|
|
private void NewValue_ValueChanged(object sender, EventArgs e)
|
|
{
|
|
Modifier.NewValue = NewValue.Value;
|
|
ResetButton.Visible = ResetButton.Enabled = Modifier.HasChanged;
|
|
}
|
|
|
|
private void ResetButton_Clicked(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;*/
|
|
|
|
NewValue.Value = Modifier.OldValue;
|
|
NewValue.Select();
|
|
return;
|
|
|
|
}
|
|
}
|
|
|
|
public CtrlToolEditParameters()
|
|
{
|
|
InitializeComponent();
|
|
|
|
Program.SlicerFile.RefreshPrintParametersModifiersValues();
|
|
Operation = new OperationEditParameters(Program.SlicerFile.PrintParameterModifiers);
|
|
SetOperation(Operation);
|
|
|
|
if (Operation.Modifiers is null || Operation.Modifiers.Length == 0)
|
|
{
|
|
CanRun = false;
|
|
return;
|
|
}
|
|
|
|
table.SetDoubleBuffered();
|
|
|
|
int rowIndex = 1;
|
|
RowControls = new RowControl[Operation.Modifiers.Length];
|
|
//table.RowCount = Operation.Modifiers.Length+1;
|
|
foreach (var modifier in Operation.Modifiers)
|
|
{
|
|
byte column = 0;
|
|
table.RowStyles.Add(new RowStyle(SizeType.AutoSize));
|
|
|
|
var rowControl = new RowControl(modifier);
|
|
table.Controls.Add(rowControl.Name, column++, rowIndex);
|
|
table.Controls.Add(rowControl.OldValue, column++, rowIndex);
|
|
table.Controls.Add(rowControl.NewValue, column++, rowIndex);
|
|
table.Controls.Add(rowControl.Unit, column++, rowIndex);
|
|
table.Controls.Add(rowControl.ResetButton, column++, rowIndex);
|
|
|
|
RowControls[rowIndex-1] = rowControl;
|
|
|
|
rowIndex++;
|
|
}
|
|
}
|
|
|
|
public override bool UpdateOperation()
|
|
{
|
|
base.UpdateOperation();
|
|
|
|
foreach (var rowControl in RowControls)
|
|
{
|
|
rowControl.Modifier.NewValue = rowControl.NewValue.Value;
|
|
//if(!modifier.HasChanged) continue;
|
|
//Program.SlicerFile.SetValueFromPrintParameterModifier(modifier, modifier.NewValue);
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
public override void ExtraActionCall(object sender)
|
|
{
|
|
if (ReferenceEquals(sender, ParentToolWindow.btnActionExtra))
|
|
{
|
|
foreach (var rowControl in RowControls)
|
|
{
|
|
rowControl.NewValue.Value = rowControl.Modifier.OldValue;
|
|
}
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
}
|