mirror of
https://github.com/riegera2412/UVtools.git
synced 2026-07-09 01:52:32 +02:00
7788fffa9f
* (Add) Shortcut "ESC" under Islands list view to deselect all items * (Add) Shortcut "CTRL+A" under Islands list view to select all items * (Add) Shortcut "*" under Islands list view to invert selection * (Add) Shortcut "CTRL+F" to go to a layer number * (Change) Layer image is now a RGB image for better manipulation and draws * (Change) Layer difference now shows previous and next layers (only pixels not present on current layer) were previous are pink and next are cyan, if a pixel are present in both layers a red pixel will be painted. * (Fix) Save modified layers on .cbddlp and .cbt corrupts the file to print when Anti-Aliasing is used (> 1) * (Fix) cbdlp layer encoding
123 lines
3.8 KiB
C#
123 lines
3.8 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.Globalization;
|
|
using System.Windows.Forms;
|
|
using PrusaSL1Reader;
|
|
|
|
namespace PrusaSL1Viewer
|
|
{
|
|
public partial class FrmInputBox : Form
|
|
{
|
|
#region Properties
|
|
private string _description;
|
|
public string Description
|
|
{
|
|
get => _description;
|
|
set {
|
|
lbDescription.Text = value;
|
|
_description = value;
|
|
}
|
|
}
|
|
|
|
public string ValueUint { get; }
|
|
public decimal NewValue
|
|
{
|
|
get => numNewValue.Value;
|
|
private set => numNewValue.Value = value;
|
|
}
|
|
|
|
private decimal _currentValue;
|
|
public decimal CurrentValue
|
|
{
|
|
get => _currentValue;
|
|
set { _currentValue = value; tbCurrentValue.Text = value.ToString(CultureInfo.InvariantCulture)+ValueUint; }
|
|
}
|
|
#endregion
|
|
|
|
#region Constructors
|
|
public FrmInputBox()
|
|
{
|
|
InitializeComponent();
|
|
DialogResult = DialogResult.Cancel;
|
|
numNewValue.Select();
|
|
|
|
|
|
}
|
|
|
|
public FrmInputBox(FileFormat.PrintParameterModifier modifier, decimal currentValue, byte decimals = 2) : this(modifier.Name,
|
|
modifier.Description, currentValue, modifier.ValueUnit, modifier.Minimum, modifier.Maximum, decimals)
|
|
{ }
|
|
public FrmInputBox(string title, string description, decimal currentValue, string valueUnit = null, decimal minValue = 0, decimal maxValue = 100, byte decimals = 2, string valueLabel = "Value") : this()
|
|
{
|
|
Text = title;
|
|
lbCurrentValue.Text = $"Current {valueLabel}";
|
|
lbNewValue.Text = $"New {valueLabel}";
|
|
Description = description;
|
|
ValueUint = valueUnit ?? string.Empty;
|
|
CurrentValue = currentValue;
|
|
numNewValue.Minimum = minValue;
|
|
numNewValue.Maximum = maxValue;
|
|
numNewValue.DecimalPlaces = decimals;
|
|
NewValue = currentValue;
|
|
}
|
|
#endregion
|
|
|
|
#region Overrides
|
|
protected override void OnKeyUp(KeyEventArgs e)
|
|
{
|
|
base.OnKeyUp(e);
|
|
if (e.KeyCode == Keys.Enter)
|
|
{
|
|
btnModify.PerformClick();
|
|
e.Handled = true;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Events
|
|
private void ValueChanged(object sender, EventArgs e)
|
|
{
|
|
if (ReferenceEquals(sender, numNewValue))
|
|
{
|
|
btnModify.Enabled = numNewValue.Value != CurrentValue;
|
|
|
|
return;
|
|
}
|
|
}
|
|
|
|
private void ItemClicked(object sender, EventArgs e)
|
|
{
|
|
if (ReferenceEquals(sender, btnModify))
|
|
{
|
|
if (!btnModify.Enabled) return;
|
|
if (MessageBox.Show($"Are you sure you want to {Description}?\nFrom {CurrentValue}{ValueUint} to {NewValue}{ValueUint}", Text, MessageBoxButtons.YesNo,
|
|
MessageBoxIcon.Question) == DialogResult.Yes)
|
|
{
|
|
DialogResult = DialogResult.OK;
|
|
if (NewValue == CurrentValue) // Should never happen!
|
|
{
|
|
DialogResult = DialogResult.Cancel;
|
|
}
|
|
Close();
|
|
}
|
|
|
|
return;
|
|
}
|
|
|
|
if (ReferenceEquals(sender, btnCancel))
|
|
{
|
|
DialogResult = DialogResult.Cancel;
|
|
return;
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
}
|