Add layer import GUI

This commit is contained in:
Tiago Conceição
2020-09-07 05:11:44 +01:00
parent 14d21f53e7
commit dcf85cb509
28 changed files with 2108 additions and 272 deletions
+1
View File
@@ -6,6 +6,7 @@
* (Add) PrusaSlicer Printer: Nova Bene4 Mono
* (Add) CWS: Support the GRAY2RGB and RBG2GRAY encoding for Bene Mono
* (Add) Layer issue Z map paired with layer navigation tracker bar
* (Add) Setting: Pixel editor can be configured to exit after each apply operation (#45)
* (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.
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)
+4 -4
View File
@@ -1,4 +1,4 @@
# generated by PrusaSlicer 2.2.0+win64 on 2020-06-29 at 20:32:09 UTC
# generated by PrusaSlicer 2.2.0+win64 on 2020-09-05 at 19:03:56 UTC
absolute_correction = 0
area_fill = 50
bed_custom_model =
@@ -9,9 +9,9 @@ default_sla_print_profile = 0.05 Normal
display_height = 120
display_mirror_x = 0
display_mirror_y = 1
display_orientation = portrait
display_orientation = landscape
display_pixels_x = 2560
display_pixels_y = 1440
display_pixels_y = 1600
display_width = 192
elefant_foot_compensation = 0.2
elefant_foot_min_width = 0.2
@@ -25,7 +25,7 @@ min_exposure_time = 1
min_initial_exposure_time = 1
print_host =
printer_model = SL1
printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_PRUSA3D\nPRINTER_MODEL_SL1\nPRINTER_VENDOR_KELANT\nPRINTER_MODEL_S400\n\nSTART_CUSTOM_VALUES\nFLIP_XY\nLayerOffTime_0\nBottomLightOffDelay_0\nBottomLiftHeight_5\nLiftHeight_5\nBottomLiftSpeed_100\nLiftSpeed_100\nRetractSpeed_100\nBottomLightPWM_255\nLightPWM_255\nAntiAliasing_4 ; Use 0 or 1 for disable AntiAliasing with "printer gamma correction" set to 0, otherwise use multiples of 2 and "gamma correction" set to 1 for enable\nEND_CUSTOM_VALUES
printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_PRUSA3D\nPRINTER_MODEL_SL1\nPRINTER_VENDOR_KELANT\nPRINTER_MODEL_S400\n\nSTART_CUSTOM_VALUES\nLayerOffTime_0\nBottomLightOffDelay_0\nBottomLiftHeight_15\nLiftHeight_15\nBottomLiftSpeed_30\nLiftSpeed_30\nRetractSpeed_300\nBottomLightPWM_255\nLightPWM_255\nAntiAliasing_4 ; Use 0 or 1 for disable AntiAliasing with "printer gamma correction" set to 0, otherwise use multiples of 2 and "gamma correction" set to 1 for enable\nEND_CUSTOM_VALUES
printer_settings_id =
printer_technology = SLA
printer_variant = default
@@ -1,4 +1,4 @@
# generated by PrusaSlicer 2.2.0+win64 on 2020-06-11 at 02:28:40 UTC
# generated by PrusaSlicer 2.2.0+win64 on 2020-09-05 at 15:51:14 UTC
compatible_printers =
compatible_printers_condition =
default_sla_print_profile =
+1 -1
View File
@@ -373,7 +373,7 @@ namespace UVtools.Core.FileFormats
progress.ItemCount = OutputSettings.LayersNum;
var gcode = GCode.ToString();
float currentHeight = 0;
//float currentHeight = 0;
int layerSize = OutputSettings.LayersNum.ToString().Length;
+68
View File
@@ -0,0 +1,68 @@
/*
* 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.ComponentModel;
using System.Runtime.CompilerServices;
namespace UVtools.Core.Obects
{
/// <summary>
/// Implementation of <see cref="INotifyPropertyChanged" /> to simplify models.
/// </summary>
public abstract class BindableBase : INotifyPropertyChanged
{
/// <summary>
/// Multicast event for property change notifications.
/// </summary>
public event PropertyChangedEventHandler PropertyChanged;
/// <summary>
/// Checks if a property already matches a desired value. Sets the property and
/// notifies listeners only when necessary.
/// </summary>
/// <typeparam name="T">Type of the property.</typeparam>
/// <param name="storage">Reference to a property with both getter and setter.</param>
/// <param name="value">Desired value for the property.</param>
/// <param name="propertyName">
/// Name of the property used to notify listeners. This
/// value is optional and can be provided automatically when invoked from compilers that
/// support CallerMemberName.
/// </param>
/// <returns>
/// True if the value was changed, false if the existing value matched the
/// desired value.
/// </returns>
protected bool SetProperty<T>(ref T storage, T value, [CallerMemberName] string propertyName = null)
{
if (Equals(storage, value))
{
return false;
}
storage = value;
OnPropertyChanged(propertyName);
return true;
}
/// <summary>
/// Notifies listeners that a property value has changed.
/// </summary>
/// <param name="propertyName">
/// Name of the property used to notify listeners. This
/// value is optional and can be provided automatically when invoked from compilers
/// that support <see cref="CallerMemberNameAttribute" />.
/// </param>
protected void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
var eventHandler = PropertyChanged;
if (!ReferenceEquals(eventHandler, null))
{
eventHandler(this, new PropertyChangedEventArgs(propertyName));
}
}
}
}
+58
View File
@@ -0,0 +1,58 @@
/*
* 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.Collections.Generic;
namespace UVtools.Core.Obects
{
public class StringTag : IComparable<StringTag>
{
public string Content { get; set; }
public object Tag { get; set; }
public string TagString => Tag.ToString();
public StringTag(string content, object tag = null)
{
Content = content;
Tag = tag;
}
private sealed class ContentEqualityComparer : IEqualityComparer<StringTag>
{
public bool Equals(StringTag x, StringTag y)
{
if (ReferenceEquals(x, y)) return true;
if (ReferenceEquals(x, null)) return false;
if (ReferenceEquals(y, null)) return false;
if (x.GetType() != y.GetType()) return false;
return x.Content == y.Content;
}
public int GetHashCode(StringTag obj)
{
return (obj.Content != null ? obj.Content.GetHashCode() : 0);
}
}
public static IEqualityComparer<StringTag> ContentComparer { get; } = new ContentEqualityComparer();
public int CompareTo(StringTag other)
{
if (ReferenceEquals(this, other)) return 0;
if (ReferenceEquals(null, other)) return 1;
return string.Compare(Content, other.Content, StringComparison.Ordinal);
}
public override string ToString()
{
return Content;
}
}
}
@@ -0,0 +1,59 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Threading.Tasks;
using Emgu.CV;
using Emgu.CV.CvEnum;
namespace UVtools.Core.Operations
{
public sealed class OperationLayerImport
{
public uint InsertAfterLayerIndex { get; set; }
public bool ReplaceStartLayer { get; set; }
public bool ReplaceSubsequentLayers { get; set; }
public bool DiscardRemainingLayers { get; set; }
public List<string> Files { get; } = new List<string>();
public void Sort()
{
Files.Sort((file1, file2) => string.Compare(Path.GetFileNameWithoutExtension(file1), Path.GetFileNameWithoutExtension(file2), StringComparison.Ordinal));
}
public ConcurrentBag<string> Validate(Size resolution)
{
var result = new ConcurrentBag<string>();
Parallel.ForEach(Files, file =>
{
using (Mat mat = CvInvoke.Imread(file, ImreadModes.AnyColor))
{
if (mat.Size != resolution)
{
result.Add(file);
}
}
});
return result;
}
public uint CalculateTotalLayers(uint totalLayers)
{
if (DiscardRemainingLayers)
{
return (uint) (1 + InsertAfterLayerIndex + Files.Count - (ReplaceStartLayer ? 1u : 0u));
}
if (!ReplaceSubsequentLayers)
{
return (uint)(totalLayers + Files.Count - (ReplaceStartLayer ? 1u : 0u));
}
// Need to calculate the total layer count after subsequent replacing, taking in account that layer count can grow
return 0;
}
}
}
-65
View File
@@ -1,65 +0,0 @@
namespace UVtools.GUI.Controls
{
partial class CtrlDescriptionPanel
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.lbDescription = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// lbDescription
//
this.lbDescription.AutoSize = true;
this.lbDescription.Dock = System.Windows.Forms.DockStyle.Fill;
this.lbDescription.Location = new System.Drawing.Point(0, 0);
this.lbDescription.Name = "lbDescription";
this.lbDescription.Padding = new System.Windows.Forms.Padding(20);
this.lbDescription.Size = new System.Drawing.Size(129, 60);
this.lbDescription.TabIndex = 0;
this.lbDescription.Text = "Description";
//
// CtrlDescriptionPanel
//
this.AutoSize = true;
this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.BackColor = System.Drawing.Color.WhiteSmoke;
this.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.Controls.Add(this.lbDescription);
this.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.Name = "CtrlDescriptionPanel";
this.Size = new System.Drawing.Size(129, 60);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label lbDescription;
}
}
@@ -1,19 +0,0 @@
using System.ComponentModel;
using System.Windows.Forms;
namespace UVtools.GUI.Controls
{
public partial class CtrlDescriptionPanel : UserControl
{
public string Description
{
get => lbDescription.Text;
set => lbDescription.Text = value;
}
public CtrlDescriptionPanel()
{
InitializeComponent();
}
}
}
@@ -1,120 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
+14 -2
View File
@@ -28,20 +28,32 @@
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.toolTip = new System.Windows.Forms.ToolTip(this.components);
this.SuspendLayout();
//
// toolTip
//
this.toolTip.AutoPopDelay = 32767;
this.toolTip.InitialDelay = 500;
this.toolTip.ReshowDelay = 100;
this.toolTip.ToolTipIcon = System.Windows.Forms.ToolTipIcon.Info;
this.toolTip.ToolTipTitle = "Information";
//
// CtrlToolWindowContent
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.White;
this.MinimumSize = new System.Drawing.Size(563, 0);
this.MinimumSize = new System.Drawing.Size(540, 0);
this.Name = "CtrlToolWindowContent";
this.Size = new System.Drawing.Size(563, 261);
this.Size = new System.Drawing.Size(540, 261);
this.ResumeLayout(false);
}
#endregion
public System.Windows.Forms.ToolTip toolTip;
}
}
+74 -3
View File
@@ -7,18 +7,84 @@
*/
using System.ComponentModel;
using System.Drawing.Design;
using System.Runtime.CompilerServices;
using System.Windows.Forms;
using UVtools.Core.Extensions;
using UVtools.GUI.Annotations;
namespace UVtools.GUI.Controls
{
public partial class CtrlToolWindowContent : UserControl
public partial class CtrlToolWindowContent : UserControl, INotifyPropertyChanged
{
#region BindableBase
/// <summary>
/// Multicast event for property change notifications.
/// </summary>
public event PropertyChangedEventHandler PropertyChanged;
/// <summary>
/// Checks if a property already matches a desired value. Sets the property and
/// notifies listeners only when necessary.
/// </summary>
/// <typeparam name="T">Type of the property.</typeparam>
/// <param name="storage">Reference to a property with both getter and setter.</param>
/// <param name="value">Desired value for the property.</param>
/// <param name="propertyName">
/// Name of the property used to notify listeners. This
/// value is optional and can be provided automatically when invoked from compilers that
/// support CallerMemberName.
/// </param>
/// <returns>
/// True if the value was changed, false if the existing value matched the
/// desired value.
/// </returns>
[NotifyPropertyChangedInvocator]
protected bool SetProperty<T>(ref T storage, T value, [CallerMemberName] string propertyName = null)
{
if (Equals(storage, value))
{
return false;
}
storage = value;
OnPropertyChanged(propertyName);
return true;
}
/// <summary>
/// Notifies listeners that a property value has changed.
/// </summary>
/// <param name="propertyName">
/// Name of the property used to notify listeners. This
/// value is optional and can be provided automatically when invoked from compilers
/// that support <see cref="CallerMemberNameAttribute" />.
/// </param>
[NotifyPropertyChangedInvocator]
protected void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
var eventHandler = PropertyChanged;
if (!ReferenceEquals(eventHandler, null))
{
eventHandler(this, new PropertyChangedEventArgs(propertyName));
}
}
#endregion
#region Properties
[Editor("System.ComponentModel.Design.MultilineStringEditor", typeof(UITypeEditor))]
[SettingsBindable(true)]
public string Description { get; set; }
private bool _buttonOkEnabled;
[SettingsBindable(true)]
public bool ButtonOkEnabled
{
get => _buttonOkEnabled;
set => SetProperty(ref _buttonOkEnabled, value);
}
[Editor("System.ComponentModel.Design.MultilineStringEditor", typeof(UITypeEditor))]
[SettingsBindable(true)]
public string ButtonOkText { get; set; } = "Ok";
@@ -37,8 +103,8 @@ namespace UVtools.GUI.Controls
[SettingsBindable(true)]
public uint LayerRangeEnd { get; set; }*/
[Editor("System.ComponentModel.Design.MultilineStringEditor", typeof(UITypeEditor))]
[SettingsBindable(true)]
[ReadOnly(true)]
[Browsable(false)]
public virtual string ConfirmationText { get; } = "do this action?";
#endregion
@@ -54,6 +120,11 @@ namespace UVtools.GUI.Controls
public virtual bool ValidateForm() => true;
public DialogResult MessageErrorBox(string message, MessageBoxButtons buttons = MessageBoxButtons.OK) => GUIExtensions.MessageErrorBox($"{Text} Error", message, buttons);
public DialogResult MessageQuestionBox(string message, string title = null, MessageBoxButtons buttons = MessageBoxButtons.YesNo) => GUIExtensions.MessageQuestionBox($"{title ?? Text}", message, buttons);
#endregion
}
}
@@ -117,4 +117,7 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="toolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>
+247 -19
View File
@@ -28,28 +28,51 @@
/// </summary>
private void InitializeComponent()
{
this.checkBox1 = new System.Windows.Forms.CheckBox();
this.cbReplaceStartLayer = new System.Windows.Forms.CheckBox();
this.lbHeight = new System.Windows.Forms.Label();
this.nmInsertAfterLayer = new System.Windows.Forms.NumericUpDown();
this.label1 = new System.Windows.Forms.Label();
this.tsBar = new System.Windows.Forms.ToolStrip();
this.btnAdd = new System.Windows.Forms.ToolStripButton();
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.btnRemove = new System.Windows.Forms.ToolStripButton();
this.lbCount = new System.Windows.Forms.ToolStripLabel();
this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
this.btnClear = new System.Windows.Forms.ToolStripButton();
this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator();
this.btnSort = new System.Windows.Forms.ToolStripButton();
this.cbAutoSort = new System.Windows.Forms.CheckBox();
this.lbResult = new System.Windows.Forms.Label();
this.splitContainer = new System.Windows.Forms.SplitContainer();
this.lbFiles = new System.Windows.Forms.ListBox();
this.pbSelectedImage = new System.Windows.Forms.PictureBox();
this.cbReplaceSubsequentLayers = new System.Windows.Forms.CheckBox();
this.cbDiscardRemainingLayers = new System.Windows.Forms.CheckBox();
((System.ComponentModel.ISupportInitialize)(this.nmInsertAfterLayer)).BeginInit();
this.tsBar.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
this.splitContainer.Panel1.SuspendLayout();
this.splitContainer.Panel2.SuspendLayout();
this.splitContainer.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pbSelectedImage)).BeginInit();
this.SuspendLayout();
//
// checkBox1
// cbReplaceStartLayer
//
this.checkBox1.AutoSize = true;
this.checkBox1.Location = new System.Drawing.Point(212, 74);
this.checkBox1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.checkBox1.Name = "checkBox1";
this.checkBox1.Size = new System.Drawing.Size(153, 24);
this.checkBox1.TabIndex = 33;
this.checkBox1.Text = "Replace this layer";
this.checkBox1.UseVisualStyleBackColor = true;
this.cbReplaceStartLayer.AutoSize = true;
this.cbReplaceStartLayer.Location = new System.Drawing.Point(10, 49);
this.cbReplaceStartLayer.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.cbReplaceStartLayer.Name = "cbReplaceStartLayer";
this.cbReplaceStartLayer.Size = new System.Drawing.Size(153, 24);
this.cbReplaceStartLayer.TabIndex = 33;
this.cbReplaceStartLayer.Text = "Replace this layer";
this.cbReplaceStartLayer.UseVisualStyleBackColor = true;
this.cbReplaceStartLayer.CheckedChanged += new System.EventHandler(this.EventClick);
//
// lbHeight
//
this.lbHeight.AutoSize = true;
this.lbHeight.Location = new System.Drawing.Point(376, 116);
this.lbHeight.Location = new System.Drawing.Point(216, 13);
this.lbHeight.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
this.lbHeight.Name = "lbHeight";
this.lbHeight.Size = new System.Drawing.Size(85, 20);
@@ -58,7 +81,7 @@
//
// nmInsertAfterLayer
//
this.nmInsertAfterLayer.Location = new System.Drawing.Point(230, 111);
this.nmInsertAfterLayer.Location = new System.Drawing.Point(138, 10);
this.nmInsertAfterLayer.Margin = new System.Windows.Forms.Padding(6, 8, 6, 8);
this.nmInsertAfterLayer.Maximum = new decimal(new int[] {
100000,
@@ -66,34 +89,223 @@
0,
0});
this.nmInsertAfterLayer.Name = "nmInsertAfterLayer";
this.nmInsertAfterLayer.Size = new System.Drawing.Size(135, 26);
this.nmInsertAfterLayer.Size = new System.Drawing.Size(74, 26);
this.nmInsertAfterLayer.TabIndex = 30;
this.nmInsertAfterLayer.ValueChanged += new System.EventHandler(this.nmInsertAfterLayer_ValueChanged);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(26, 116);
this.label1.Location = new System.Drawing.Point(6, 13);
this.label1.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(128, 20);
this.label1.TabIndex = 31;
this.label1.Text = "Insert after layer:";
//
// tsBar
//
this.tsBar.Dock = System.Windows.Forms.DockStyle.Bottom;
this.tsBar.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden;
this.tsBar.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.btnAdd,
this.toolStripSeparator1,
this.btnRemove,
this.lbCount,
this.toolStripSeparator2,
this.btnClear,
this.toolStripSeparator3,
this.btnSort});
this.tsBar.Location = new System.Drawing.Point(0, 177);
this.tsBar.Name = "tsBar";
this.tsBar.Size = new System.Drawing.Size(707, 25);
this.tsBar.TabIndex = 35;
//
// btnAdd
//
this.btnAdd.Image = global::UVtools.GUI.Properties.Resources.plus_16x16;
this.btnAdd.ImageTransparentColor = System.Drawing.Color.Magenta;
this.btnAdd.Name = "btnAdd";
this.btnAdd.Size = new System.Drawing.Size(49, 22);
this.btnAdd.Text = "&Add";
this.btnAdd.Click += new System.EventHandler(this.EventClick);
//
// toolStripSeparator1
//
this.toolStripSeparator1.Name = "toolStripSeparator1";
this.toolStripSeparator1.Size = new System.Drawing.Size(6, 25);
//
// btnRemove
//
this.btnRemove.Enabled = false;
this.btnRemove.Image = global::UVtools.GUI.Properties.Resources.minus_16x16;
this.btnRemove.ImageTransparentColor = System.Drawing.Color.Magenta;
this.btnRemove.Name = "btnRemove";
this.btnRemove.Size = new System.Drawing.Size(70, 22);
this.btnRemove.Text = "&Remove";
this.btnRemove.Click += new System.EventHandler(this.EventClick);
//
// lbCount
//
this.lbCount.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right;
this.lbCount.Name = "lbCount";
this.lbCount.Size = new System.Drawing.Size(52, 22);
this.lbCount.Text = "Layers: 0";
//
// toolStripSeparator2
//
this.toolStripSeparator2.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right;
this.toolStripSeparator2.Name = "toolStripSeparator2";
this.toolStripSeparator2.Size = new System.Drawing.Size(6, 25);
//
// btnClear
//
this.btnClear.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right;
this.btnClear.Enabled = false;
this.btnClear.Image = global::UVtools.GUI.Properties.Resources.delete_16x16;
this.btnClear.ImageTransparentColor = System.Drawing.Color.Magenta;
this.btnClear.Name = "btnClear";
this.btnClear.Size = new System.Drawing.Size(54, 22);
this.btnClear.Text = "&Clear";
this.btnClear.Click += new System.EventHandler(this.EventClick);
//
// toolStripSeparator3
//
this.toolStripSeparator3.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right;
this.toolStripSeparator3.Name = "toolStripSeparator3";
this.toolStripSeparator3.Size = new System.Drawing.Size(6, 25);
//
// btnSort
//
this.btnSort.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right;
this.btnSort.Enabled = false;
this.btnSort.Image = global::UVtools.GUI.Properties.Resources.sort_alpha_up_16x16;
this.btnSort.ImageTransparentColor = System.Drawing.Color.Magenta;
this.btnSort.Name = "btnSort";
this.btnSort.Size = new System.Drawing.Size(116, 22);
this.btnSort.Text = "&Sort by file name";
this.btnSort.Click += new System.EventHandler(this.EventClick);
//
// cbAutoSort
//
this.cbAutoSort.AutoSize = true;
this.cbAutoSort.Checked = true;
this.cbAutoSort.CheckState = System.Windows.Forms.CheckState.Checked;
this.cbAutoSort.Location = new System.Drawing.Point(10, 83);
this.cbAutoSort.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.cbAutoSort.Name = "cbAutoSort";
this.cbAutoSort.Size = new System.Drawing.Size(226, 24);
this.cbAutoSort.TabIndex = 36;
this.cbAutoSort.Text = "Auto sort layers by file name";
this.cbAutoSort.UseVisualStyleBackColor = true;
//
// lbResult
//
this.lbResult.AutoSize = true;
this.lbResult.Location = new System.Drawing.Point(6, 117);
this.lbResult.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
this.lbResult.Name = "lbResult";
this.lbResult.Size = new System.Drawing.Size(61, 20);
this.lbResult.TabIndex = 37;
this.lbResult.Text = " ";
//
// splitContainer
//
this.splitContainer.Dock = System.Windows.Forms.DockStyle.Bottom;
this.splitContainer.Location = new System.Drawing.Point(0, 202);
this.splitContainer.Name = "splitContainer";
//
// splitContainer.Panel1
//
this.splitContainer.Panel1.Controls.Add(this.lbFiles);
//
// splitContainer.Panel2
//
this.splitContainer.Panel2.Controls.Add(this.pbSelectedImage);
this.splitContainer.Size = new System.Drawing.Size(707, 376);
this.splitContainer.SplitterDistance = 415;
this.splitContainer.TabIndex = 38;
//
// lbFiles
//
this.lbFiles.Dock = System.Windows.Forms.DockStyle.Fill;
this.lbFiles.FormattingEnabled = true;
this.lbFiles.HorizontalScrollbar = true;
this.lbFiles.ItemHeight = 20;
this.lbFiles.Location = new System.Drawing.Point(0, 0);
this.lbFiles.Name = "lbFiles";
this.lbFiles.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended;
this.lbFiles.Size = new System.Drawing.Size(415, 376);
this.lbFiles.TabIndex = 35;
this.lbFiles.SelectedIndexChanged += new System.EventHandler(this.lbFiles_SelectedIndexChanged);
this.lbFiles.KeyUp += new System.Windows.Forms.KeyEventHandler(this.lbFiles_KeyUp);
this.lbFiles.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.lbFiles_MouseDoubleClick);
//
// pbSelectedImage
//
this.pbSelectedImage.Dock = System.Windows.Forms.DockStyle.Fill;
this.pbSelectedImage.Location = new System.Drawing.Point(0, 0);
this.pbSelectedImage.Name = "pbSelectedImage";
this.pbSelectedImage.Size = new System.Drawing.Size(288, 376);
this.pbSelectedImage.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.pbSelectedImage.TabIndex = 0;
this.pbSelectedImage.TabStop = false;
//
// cbReplaceSubsequentLayers
//
this.cbReplaceSubsequentLayers.AutoSize = true;
this.cbReplaceSubsequentLayers.Location = new System.Drawing.Point(171, 49);
this.cbReplaceSubsequentLayers.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.cbReplaceSubsequentLayers.Name = "cbReplaceSubsequentLayers";
this.cbReplaceSubsequentLayers.Size = new System.Drawing.Size(220, 24);
this.cbReplaceSubsequentLayers.TabIndex = 39;
this.cbReplaceSubsequentLayers.Text = "Replace subsequent layers";
this.cbReplaceSubsequentLayers.UseVisualStyleBackColor = true;
this.cbReplaceSubsequentLayers.CheckedChanged += new System.EventHandler(this.EventClick);
//
// cbDiscardRemainingLayers
//
this.cbDiscardRemainingLayers.AutoSize = true;
this.cbDiscardRemainingLayers.Enabled = false;
this.cbDiscardRemainingLayers.Location = new System.Drawing.Point(399, 49);
this.cbDiscardRemainingLayers.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.cbDiscardRemainingLayers.Name = "cbDiscardRemainingLayers";
this.cbDiscardRemainingLayers.Size = new System.Drawing.Size(200, 24);
this.cbDiscardRemainingLayers.TabIndex = 40;
this.cbDiscardRemainingLayers.Text = "Discard remaining layers";
this.cbDiscardRemainingLayers.UseVisualStyleBackColor = true;
this.cbDiscardRemainingLayers.CheckedChanged += new System.EventHandler(this.EventClick);
//
// CtrlToolLayerImport
//
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.checkBox1);
this.ButtonOkText = "Import";
this.Controls.Add(this.cbDiscardRemainingLayers);
this.Controls.Add(this.cbReplaceSubsequentLayers);
this.Controls.Add(this.lbResult);
this.Controls.Add(this.cbAutoSort);
this.Controls.Add(this.tsBar);
this.Controls.Add(this.cbReplaceStartLayer);
this.Controls.Add(this.lbHeight);
this.Controls.Add(this.nmInsertAfterLayer);
this.Controls.Add(this.label1);
this.Description = "Import layer(s) from local files into a selected height.\r\nNOTE: Images must respe" +
"ct file resolution and greyscale color.";
this.Controls.Add(this.splitContainer);
this.Description = "Import layer(s) from local file(s) into the model at a selected height.\r\nNOTE: Im" +
"ages must respect file resolution and in greyscale color.";
this.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.LayerRangeVisible = false;
this.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.Name = "CtrlToolLayerImport";
this.Size = new System.Drawing.Size(563, 263);
this.Size = new System.Drawing.Size(707, 578);
((System.ComponentModel.ISupportInitialize)(this.nmInsertAfterLayer)).EndInit();
this.tsBar.ResumeLayout(false);
this.tsBar.PerformLayout();
this.splitContainer.Panel1.ResumeLayout(false);
this.splitContainer.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.splitContainer)).EndInit();
this.splitContainer.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pbSelectedImage)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
@@ -101,9 +313,25 @@
#endregion
private System.Windows.Forms.CheckBox checkBox1;
private System.Windows.Forms.CheckBox cbReplaceStartLayer;
private System.Windows.Forms.Label lbHeight;
private System.Windows.Forms.NumericUpDown nmInsertAfterLayer;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.ToolStrip tsBar;
private System.Windows.Forms.ToolStripButton btnAdd;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
private System.Windows.Forms.ToolStripButton btnRemove;
private System.Windows.Forms.ToolStripButton btnClear;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
private System.Windows.Forms.ToolStripButton btnSort;
private System.Windows.Forms.CheckBox cbAutoSort;
private System.Windows.Forms.ToolStripLabel lbCount;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator3;
private System.Windows.Forms.Label lbResult;
private System.Windows.Forms.SplitContainer splitContainer;
private System.Windows.Forms.ListBox lbFiles;
private System.Windows.Forms.PictureBox pbSelectedImage;
private System.Windows.Forms.CheckBox cbReplaceSubsequentLayers;
private System.Windows.Forms.CheckBox cbDiscardRemainingLayers;
}
}
@@ -6,18 +6,248 @@
* of this license document, but changing it is not allowed.
*/
using System;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Text;
using System.Windows.Forms;
using UVtools.Core.Obects;
using UVtools.Core.Operations;
namespace UVtools.GUI.Controls.Tools
{
public partial class CtrlToolLayerImport : CtrlToolWindowContent
{
public CtrlToolLayerImport()
public OperationLayerImport Operation { get; } = new OperationLayerImport();
public CtrlToolLayerImport(uint currentLayer = 0)
{
InitializeComponent();
Text = "Import Layer(s)";
nmInsertAfterLayer.Maximum = Program.SlicerFile.LayerCount;
nmInsertAfterLayer.Value = currentLayer;
nmInsertAfterLayer_ValueChanged(nmInsertAfterLayer, EventArgs.Empty);
}
public void UpdateOperation()
{
Operation.InsertAfterLayerIndex = (uint)nmInsertAfterLayer.Value;
Operation.ReplaceStartLayer = cbReplaceStartLayer.Checked;
Operation.ReplaceSubsequentLayers = cbReplaceSubsequentLayers.Checked;
Operation.DiscardRemainingLayers = cbDiscardRemainingLayers.Checked;
}
public override bool ValidateForm()
{
return true;
UpdateOperation();
var result = Operation.Validate(Program.FrmMain.ActualLayerImage.Size);
if (result.Count == 0) return true;
var message = new StringBuilder();
message.AppendLine($"The following {result.Count} files mismatched the slice resolution of {Program.FrmMain.ActualLayerImage.Size.Width}x{Program.FrmMain.ActualLayerImage.Size.Height}:");
message.AppendLine();
uint count = 0;
foreach (var file in result)
{
count++;
if (count == 20)
{
message.AppendLine("... To many to show ...");
break;
}
message.AppendLine(Path.GetFileNameWithoutExtension(file));
}
message.AppendLine();
message.AppendLine("Do you want to remove all invalid files from list?");
if (MessageErrorBox(message.ToString(), MessageBoxButtons.YesNo) == DialogResult.Yes)
{
foreach (var file in result)
{
Operation.Files.Remove(file);
}
UpdateListBox();
}
return false;
}
private void nmInsertAfterLayer_ValueChanged(object sender, EventArgs e)
{
lbHeight.Text = $"({Program.SlicerFile.GetHeightFromLayer((uint) nmInsertAfterLayer.Value)}mm)";
UpdateResultText();
}
private void EventClick(object sender, EventArgs e)
{
if (ReferenceEquals(sender, cbReplaceStartLayer) ||
ReferenceEquals(sender, cbReplaceSubsequentLayers) ||
ReferenceEquals(sender, cbDiscardRemainingLayers))
{
if (ReferenceEquals(sender, cbReplaceSubsequentLayers))
{
cbDiscardRemainingLayers.Enabled = cbReplaceSubsequentLayers.Checked;
if (!cbReplaceSubsequentLayers.Checked)
{
cbDiscardRemainingLayers.Checked = false;
}
}
UpdateResultText();
return;
}
if (ReferenceEquals(sender, btnAdd))
{
using (var fileOpen = new OpenFileDialog
{
Multiselect = true,
CheckFileExists = true,
Filter = "Image Files(*.PNG;*.BMP;*.JPEG;*.JPG;*.GIF)|*.PNG;*.BMP;*.JPEG;*.JPG;*.GIF"
})
{
if (fileOpen.ShowDialog() != DialogResult.OK) return;
Operation.Files.AddRange(fileOpen.FileNames);
if (cbAutoSort.Checked)
{
Operation.Sort();
}
UpdateListBox();
}
return;
}
if (ReferenceEquals(sender, btnRemove))
{
foreach (StringTag selectedItem in lbFiles.SelectedItems)
{
Operation.Files.Remove(selectedItem.TagString);
}
UpdateListBox();
return;
}
if (ReferenceEquals(sender, btnSort))
{
Operation.Sort();
UpdateListBox();
return;
}
if (ReferenceEquals(sender, btnClear))
{
Operation.Files.Clear();
UpdateListBox();
return;
}
}
private void lbFiles_SelectedIndexChanged(object sender, EventArgs e)
{
if (btnRemove.Enabled = lbFiles.SelectedIndex >= 0)
{
var file = lbFiles.SelectedItem as StringTag;
pbSelectedImage.Image = new Bitmap(file.TagString);
}
else
{
pbSelectedImage.Image = null;
}
}
private void lbFiles_KeyUp(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Escape)
{
lbFiles.SelectedIndices.Clear();
e.Handled = true;
return;
}
if (e.KeyCode == Keys.Delete)
{
btnRemove.PerformClick();
e.Handled = true;
return;
}
if (e.KeyCode == Keys.A && (ModifierKeys & Keys.Control) != 0)
{
lbFiles.BeginUpdate();
for (int i = 0; i < lbFiles.Items.Count; i++)
lbFiles.SetSelected(i, true);
lbFiles.EndUpdate();
e.Handled = true;
return;
}
}
public void UpdateListBox()
{
lbFiles.Items.Clear();
foreach (var file in Operation.Files)
{
var stringTag = new StringTag(Path.GetFileNameWithoutExtension(file), file);
lbFiles.Items.Add(stringTag);
}
ButtonOkEnabled = btnRemove.Enabled = btnSort.Enabled = btnClear.Enabled = Operation.Files.Count > 0;
lbCount.Text = $"Layers: {Operation.Files.Count}";
UpdateResultText();
}
private void UpdateResultText()
{
if (Operation.Files.Count > 0)
{
UpdateOperation();
uint modelTotalLayers = Operation.CalculateTotalLayers(Program.SlicerFile.LayerCount);
string textFactor = "grow";
if (modelTotalLayers < Program.SlicerFile.LayerCount)
{
textFactor = "shrink";
}
else if (modelTotalLayers == Program.SlicerFile.LayerCount)
{
textFactor = "keep";
}
lbResult.Text =
$"{Operation.Files.Count} layers will be imported into model starting from layer {nmInsertAfterLayer.Value} {lbHeight.Text}.\n" +
$"Model will {textFactor} from layers {Program.SlicerFile.LayerCount} ({Program.SlicerFile.TotalHeight}mm) to {modelTotalLayers} ({Program.SlicerFile.GetHeightFromLayer(modelTotalLayers, false)}mm)";
}
else
{
lbResult.Text = string.Empty;
}
}
private void lbFiles_MouseDoubleClick(object sender, MouseEventArgs e)
{
if (lbFiles.SelectedItem is StringTag file)
{
try
{
using (Process.Start(file.TagString))
{ }
}
catch (Exception exception)
{
Debug.WriteLine(exception);
}
return;
}
}
}
}
@@ -117,4 +117,10 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="toolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="tsBar.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>107, 17</value>
</metadata>
</root>
+21
View File
@@ -0,0 +1,21 @@
/*
* 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.Windows.Forms;
namespace UVtools.Core.Extensions
{
public static class GUIExtensions
{
public static DialogResult MessageErrorBox(string title, string message, MessageBoxButtons buttons = MessageBoxButtons.OK) =>
MessageBox.Show(message, title, buttons, MessageBoxIcon.Error);
public static DialogResult MessageQuestionBox(string title, string message, MessageBoxButtons buttons = MessageBoxButtons.YesNo) =>
MessageBox.Show(message, title, buttons, MessageBoxIcon.Question);
}
}
+13 -12
View File
@@ -34,9 +34,9 @@ namespace UVtools.GUI.Forms
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmToolWindow));
this.pnDescription = new System.Windows.Forms.Panel();
this.lbDescription = new System.Windows.Forms.Label();
this.pnActions = new System.Windows.Forms.Panel();
this.btnCancel = new System.Windows.Forms.Button();
this.btnOk = new System.Windows.Forms.Button();
this.pnActions = new System.Windows.Forms.Panel();
this.pnContent = new System.Windows.Forms.Panel();
this.pnLayerRange = new System.Windows.Forms.Panel();
this.gbLayerRange = new System.Windows.Forms.GroupBox();
@@ -86,6 +86,17 @@ namespace UVtools.GUI.Forms
this.lbDescription.Text = "Description";
this.lbDescription.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// pnActions
//
this.pnActions.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.pnActions.Controls.Add(this.btnCancel);
this.pnActions.Controls.Add(this.btnOk);
this.pnActions.Dock = System.Windows.Forms.DockStyle.Bottom;
this.pnActions.Location = new System.Drawing.Point(0, 182);
this.pnActions.Name = "pnActions";
this.pnActions.Size = new System.Drawing.Size(547, 78);
this.pnActions.TabIndex = 8;
//
// btnCancel
//
this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
@@ -119,21 +130,11 @@ namespace UVtools.GUI.Forms
this.btnOk.UseVisualStyleBackColor = true;
this.btnOk.Click += new System.EventHandler(this.EventClick);
//
// pnActions
//
this.pnActions.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.pnActions.Controls.Add(this.btnCancel);
this.pnActions.Controls.Add(this.btnOk);
this.pnActions.Dock = System.Windows.Forms.DockStyle.Bottom;
this.pnActions.Location = new System.Drawing.Point(0, 182);
this.pnActions.Name = "pnActions";
this.pnActions.Size = new System.Drawing.Size(547, 78);
this.pnActions.TabIndex = 8;
//
// pnContent
//
this.pnContent.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.pnContent.BackColor = System.Drawing.Color.White;
this.pnContent.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.pnContent.Dock = System.Windows.Forms.DockStyle.Fill;
this.pnContent.Location = new System.Drawing.Point(0, 170);
this.pnContent.Name = "pnContent";
+32 -9
View File
@@ -11,6 +11,7 @@ using System.ComponentModel;
using System.Drawing;
using System.Drawing.Design;
using System.Windows.Forms;
using UVtools.Core.Extensions;
using UVtools.GUI.Controls;
namespace UVtools.GUI.Forms
@@ -79,8 +80,8 @@ namespace UVtools.GUI.Forms
set => nmLayerRangeEnd.Value = value;
}
[Editor("System.ComponentModel.Design.MultilineStringEditor", typeof(UITypeEditor))]
[SettingsBindable(true)]
[ReadOnly(true)]
[Browsable(false)]
public virtual string ConfirmationText { get; } = "do this action?";
@@ -93,11 +94,17 @@ namespace UVtools.GUI.Forms
InitializeComponent();
}
public FrmToolWindow(string description, string buttonOkText, bool layerRangeVisible = true) : this()
public FrmToolWindow(string description, string buttonOkText, bool layerRangeVisible = true, bool layerRangeEndVisible = true) : this()
{
if (!layerRangeVisible)
{
Height -= pnLayerRange.Height;
}
Description = description;
ButtonOkText = buttonOkText;
LayerRangeVisible = layerRangeVisible;
LayerRangeEndVisible = layerRangeEndVisible;
LayerRangeEnd = Program.SlicerFile.LayerCount - 1;
EventValueChanged(nmLayerRangeStart, EventArgs.Empty);
@@ -109,13 +116,26 @@ namespace UVtools.GUI.Forms
LayerRangeStart = LayerRangeEnd = layerIndex;
}
public FrmToolWindow(CtrlToolWindowContent content, bool layerRangeVisible = true) : this(content.Description, content.ButtonOkText, layerRangeVisible)
public FrmToolWindow(CtrlToolWindowContent content) : this(content.Description, content.ButtonOkText, content.LayerRangeVisible, content.LayerRangeEndVisible)
{
Text = content.Text;
pnContent.Controls.Add(content);
Width = Math.Max(MinimumSize.Width, content.Width);
Height += content.Height;
content.Dock = DockStyle.Fill;
btnOk.Enabled = content.ButtonOkEnabled;
Content = content;
content.PropertyChanged += ContentOnPropertyChanged;
}
private void ContentOnPropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == nameof(Content.ButtonOkEnabled))
{
btnOk.Enabled = Content.ButtonOkEnabled;
return;
}
}
public FrmToolWindow(CtrlToolWindowContent content, uint layerIndex) : this(content)
@@ -217,16 +237,15 @@ namespace UVtools.GUI.Forms
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);
MessageErrorBox("Layer range start can't be higher than layer end.\nPlease fix and try again.");
nmLayerRangeStart.Select();
return;
}
if (!ValidateForm()) return;
if (!ReferenceEquals(Content, null) && !ValidateForm()) return;
if (!ReferenceEquals(Content, null) && !Content.ValidateForm()) return;
if (MessageBox.Show($"Are you sure you want to {Content?.ConfirmationText ?? ConfirmationText}", Text, MessageBoxButtons.YesNo,
MessageBoxIcon.Question) == DialogResult.Yes)
if (MessageQuestionBox($"Are you sure you want to {Content?.ConfirmationText ?? ConfirmationText}") == DialogResult.Yes)
{
DialogResult = DialogResult.OK;
Close();
@@ -250,7 +269,8 @@ namespace UVtools.GUI.Forms
if (layerIndex >= Program.SlicerFile.LayerCount) return;
var layer = Program.SlicerFile[layerIndex];
var text = $"({layer.PositionZ}mm)";
uint layerCount = (uint) Math.Max(0, nmLayerRangeEnd.Value - nmLayerRangeStart.Value + 1);
uint layerCount = LayerRangeEndVisible ? (uint) Math.Max(0, nmLayerRangeEnd.Value - nmLayerRangeStart.Value + 1) : 1;
lbLayerRangeCount.Text = $"({layerCount} layer / {Program.SlicerFile.LayerHeight * layerCount}mm)";
if (layerCount == 0)
@@ -285,6 +305,9 @@ namespace UVtools.GUI.Forms
public virtual bool ValidateForm() => true;
public DialogResult MessageErrorBox(string message) => GUIExtensions.MessageErrorBox($"{Text} Error", message);
public DialogResult MessageQuestionBox(string message, string title = null) => GUIExtensions.MessageQuestionBox($"{title ?? Text}", message);
#endregion
}
+3 -3
View File
@@ -123,15 +123,15 @@
<metadata name="lbDescription.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="pnActions.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="btnCancel.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="btnOk.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="pnActions.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="pnContent.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
+1 -1
View File
@@ -1160,7 +1160,7 @@ namespace UVtools.GUI
if (ReferenceEquals(sender, btnLayerImageActionImport))
{
using (var frm = new FrmToolWindow(new CtrlToolLayerImport(), ActualLayer))
using (var frm = new FrmToolWindow(new CtrlToolLayerImport(ActualLayer)))
{
frm.ShowDialog();
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 89 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 114 B

File diff suppressed because it is too large Load Diff
+20
View File
@@ -590,6 +590,16 @@ namespace UVtools.GUI.Properties {
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap minus_16x16 {
get {
object obj = ResourceManager.GetObject("minus_16x16", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
@@ -750,6 +760,16 @@ namespace UVtools.GUI.Properties {
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap plus_16x16 {
get {
object obj = ResourceManager.GetObject("plus-16x16", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
+8 -2
View File
@@ -310,9 +310,15 @@
<data name="Button-Info-16x16" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Images\Button-Info-16x16.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="plus-16x16" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Images\plus-16x16.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="Global-Network-icon-16x16" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Images\Global-Network-icon-16x16.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="file-import-16x16" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Images\file-import-16x16.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="photo-16x16" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Images\photo-16x16.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
@@ -370,7 +376,7 @@
<data name="expand-alt-16x16" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Images\expand-alt-16x16.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="file-import-16x16" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Images\file-import-16x16.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
<data name="minus_16x16" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Images\minus_16x16.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>
+4 -9
View File
@@ -152,12 +152,6 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Controls\BenchmarkTest.cs" />
<Compile Include="Controls\CtrlDescriptionPanel.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Controls\CtrlDescriptionPanel.Designer.cs">
<DependentUpon>CtrlDescriptionPanel.cs</DependentUpon>
</Compile>
<Compile Include="Controls\CtrlKernel.cs">
<SubType>UserControl</SubType>
</Compile>
@@ -185,6 +179,7 @@
<SubType>Component</SubType>
</Compile>
<Compile Include="Extensions\BitmapExtension.cs" />
<Compile Include="Extensions\GUIExtensions.cs" />
<Compile Include="Forms\FrmBenchmark.cs">
<SubType>Form</SubType>
</Compile>
@@ -326,10 +321,8 @@
<Compile Include="Forms\PEProfileFolder.cs" />
<Compile Include="Mutation.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\Annotations.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="Controls\CtrlDescriptionPanel.resx">
<DependentUpon>CtrlDescriptionPanel.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Controls\CtrlKernel.resx">
<DependentUpon>CtrlKernel.cs</DependentUpon>
</EmbeddedResource>
@@ -482,6 +475,8 @@
<None Include="Images\copy_16x16.png" />
<None Include="Images\microchip_16x16.png" />
<None Include="Images\file-import-16x16.png" />
<None Include="Images\plus-16x16.png" />
<None Include="Images\minus_16x16.png" />
<Content Include="UVtools.ico" />
<None Include="UVtools.png" />
<None Include="Images\Exit-16x16.png" />
+2
View File
@@ -0,0 +1,2 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/CodeInspection/CodeAnnotations/NamespacesWithAnnotations/=UVtools_002EGUI_002EAnnotations/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>