Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/sn4k3/UVtools.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTiago Conceição <Tiago_caza@hotmail.com>2021-12-27 01:44:43 +0300
committerTiago Conceição <Tiago_caza@hotmail.com>2021-12-27 01:44:43 +0300
commitd5eb7d018280921bbc89bfc4758d60846ec14d56 (patch)
tree30edeff26ee8d6920289513b21956748aa4231f6
parent91e1929ba9ed06422ba8d4e57cf08a4a11883140 (diff)
v2.27.4v2.27.4
- **UI:** - (Add) When converting file formats with multiple available versions, it will prompt to select the version to use - (Add) Remove CTBv4 from convert menu (Will require readjust settings for default extension if you are using an below extension) (#286) - (Change) Rename CTBv3 to CTB on the convert menu - (Fix) CXDLP: Set version 3 was setting wrong information
-rw-r--r--CHANGELOG.md8
-rw-r--r--UVtools.Core/FileFormats/CXDLPFile.cs13
-rw-r--r--UVtools.Core/FileFormats/ChituboxFile.cs6
-rw-r--r--UVtools.Core/FileFormats/FDGFile.cs4
-rw-r--r--UVtools.Core/FileFormats/FileFormat.cs31
-rw-r--r--UVtools.Core/FileFormats/ImageFile.cs2
-rw-r--r--UVtools.Core/FileFormats/PHZFile.cs4
-rw-r--r--UVtools.Core/FileFormats/PhotonWorkshopFile.cs2
-rw-r--r--UVtools.Core/FileFormats/VDTFile.cs2
-rw-r--r--UVtools.Core/UVtools.Core.csproj2
-rw-r--r--UVtools.WPF/Controls/WindowEx.cs2
-rw-r--r--UVtools.WPF/MainWindow.axaml.cs21
-rw-r--r--UVtools.WPF/UVtools.WPF.csproj2
-rw-r--r--UVtools.WPF/Windows/VersionSelectorWindow.axaml46
-rw-r--r--UVtools.WPF/Windows/VersionSelectorWindow.axaml.cs58
15 files changed, 186 insertions, 17 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8212f7a..da5862e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,13 @@
# Changelog
+## 26/12/2021 - v2.27.4
+
+- **UI:**
+ - (Add) When converting file formats with multiple available versions, it will prompt to select the version to use
+ - (Add) Remove CTBv4 from convert menu (Will require readjust settings for default extension if you are using an below extension) (#286)
+ - (Change) Rename CTBv3 to CTB on the convert menu
+- (Fix) CXDLP: Set version 3 was setting wrong information
+
## 24/12/2021 - v2.27.3
- **Encrypted CTB:**
diff --git a/UVtools.Core/FileFormats/CXDLPFile.cs b/UVtools.Core/FileFormats/CXDLPFile.cs
index b1be1e4..d766379 100644
--- a/UVtools.Core/FileFormats/CXDLPFile.cs
+++ b/UVtools.Core/FileFormats/CXDLPFile.cs
@@ -419,12 +419,23 @@ namespace UVtools.Core.FileFormats
public override uint[] AvailableVersions { get; } = { 2, 3 };
+ public override uint DefaultVersion => 2;
+
public override uint Version
{
get => HeaderSettings.Version;
set
{
- base.Version = value;
+ if (base.Version == 3)
+ {
+ base.Version = 2;
+ SlicerInfoV3Settings.MyControl = 1;
+ }
+ else
+ {
+ base.Version = value;
+ }
+
HeaderSettings.Version = (ushort)base.Version;
}
}
diff --git a/UVtools.Core/FileFormats/ChituboxFile.cs b/UVtools.Core/FileFormats/ChituboxFile.cs
index 1c13442..c993e98 100644
--- a/UVtools.Core/FileFormats/ChituboxFile.cs
+++ b/UVtools.Core/FileFormats/ChituboxFile.cs
@@ -1068,10 +1068,10 @@ namespace UVtools.Core.FileFormats
public override FileExtension[] FileExtensions { get; } = {
new(typeof(ChituboxFile), "photon", "Chitubox Photon"),
new(typeof(ChituboxFile), "cbddlp", "Chitubox CBDDLP"),
- new(typeof(ChituboxFile), "ctb", $"Chitubox CTBv{USED_VERSION}"),
+ new(typeof(ChituboxFile), "ctb", "Chitubox CTB"),
//new(typeof(ChituboxFile), "v2.ctb", "Chitubox CTBv2"),
//new(typeof(ChituboxFile), "v3.ctb", "Chitubox CTBv3"),
- new(typeof(ChituboxFile), "v4.ctb", "Chitubox CTBv4", false),
+ //new(typeof(ChituboxFile), "v4.ctb", "Chitubox CTBv4", false, false),
//new(typeof(ChituboxFile), "encrypted.ctb", "Chitubox encrypted CTB"),
};
@@ -1206,6 +1206,8 @@ namespace UVtools.Core.FileFormats
public override uint[] AvailableVersions { get; } = { 1, 2, 3, 4 };
+ public override uint DefaultVersion => USED_VERSION;
+
public override uint Version
{
get => HeaderSettings.Version;
diff --git a/UVtools.Core/FileFormats/FDGFile.cs b/UVtools.Core/FileFormats/FDGFile.cs
index 289a156..bdc88cc 100644
--- a/UVtools.Core/FileFormats/FDGFile.cs
+++ b/UVtools.Core/FileFormats/FDGFile.cs
@@ -660,7 +660,9 @@ namespace UVtools.Core.FileFormats
new(200, 125)
};
- public override uint[] AvailableVersions { get; } = { 1, 2 };
+ public override uint[] AvailableVersions { get; } = { 2 };
+
+ public override uint DefaultVersion => 2;
public override uint Version
{
diff --git a/UVtools.Core/FileFormats/FileFormat.cs b/UVtools.Core/FileFormats/FileFormat.cs
index 78a3bec..4bd1b01 100644
--- a/UVtools.Core/FileFormats/FileFormat.cs
+++ b/UVtools.Core/FileFormats/FileFormat.cs
@@ -725,6 +725,8 @@ namespace UVtools.Core.FileFormats
private bool _haveModifiedLayers;
+ private uint _version;
+
private byte _antiAliasing = 1;
private ushort _bottomLayerCount = DefaultBottomLayerCount;
@@ -775,7 +777,6 @@ namespace UVtools.Core.FileFormats
private bool _suppressRebuildGCode;
private readonly Timer _queueTimerPrintTime = new(QueueTimerPrintTime){AutoReset = false};
- private uint _version;
#endregion
@@ -883,9 +884,22 @@ namespace UVtools.Core.FileFormats
public string FileExtension => Path.GetExtension(FileFullPath);
public string FilenameNoExt => GetFileNameStripExtensions(FileFullPath);
+ /// <summary>
+ /// Gets the available versions to set in this file format
+ /// </summary>
public virtual uint[] AvailableVersions { get; }
/// <summary>
+ /// Gets the amount of available versions in this file format
+ /// </summary>
+ public virtual byte AvailableVersionsCount => (byte)(AvailableVersions?.Length ?? 0);
+
+ /// <summary>
+ /// Gets the default version to use in this file when not setting the version
+ /// </summary>
+ public virtual uint DefaultVersion => 0;
+
+ /// <summary>
/// Gets or sets the version of this file format
/// </summary>
public virtual uint Version
@@ -899,7 +913,7 @@ namespace UVtools.Core.FileFormats
}
RequireFullEncode = true;
- RaiseAndSet(ref _version, value);
+ RaiseAndSetIfChanged(ref _version, value);
}
}
@@ -3463,9 +3477,10 @@ namespace UVtools.Core.FileFormats
/// </summary>
/// <param name="to">Target file format</param>
/// <param name="fileFullPath">Output path file</param>
+ /// <param name="version">File version to use</param>
/// <param name="progress"></param>
/// <returns>The converted file if successful, otherwise null</returns>
- public virtual FileFormat Convert(Type to, string fileFullPath, OperationProgress progress = null)
+ public virtual FileFormat Convert(Type to, string fileFullPath, uint version = 0, OperationProgress progress = null)
{
if (!IsValid) return null;
var found = AvailableFormats.Any(format => to == format.GetType());
@@ -3480,6 +3495,11 @@ namespace UVtools.Core.FileFormats
if (!slicerFile.OnBeforeConvertFrom(this)) return null;
if (!OnBeforeConvertTo(slicerFile)) return null;
+ if (version > 0 && version != DefaultVersion)
+ {
+ slicerFile.Version = version;
+ }
+
slicerFile.SuppressRebuildPropertiesWork(() =>
{
slicerFile.LayerManager.Init(LayerManager.CloneLayers());
@@ -3589,10 +3609,11 @@ namespace UVtools.Core.FileFormats
/// </summary>
/// <param name="to">Target file format</param>
/// <param name="fileFullPath">Output path file</param>
+ /// <param name="version">File version</param>
/// <param name="progress"></param>
/// <returns>TThe converted file if successful, otherwise null</returns>
- public FileFormat Convert(FileFormat to, string fileFullPath, OperationProgress progress = null)
- => Convert(to.GetType(), fileFullPath, progress);
+ public FileFormat Convert(FileFormat to, string fileFullPath, uint version = 0, OperationProgress progress = null)
+ => Convert(to.GetType(), fileFullPath, version, progress);
/// <summary>
/// Validate AntiAlias Level
diff --git a/UVtools.Core/FileFormats/ImageFile.cs b/UVtools.Core/FileFormats/ImageFile.cs
index f80b8f1..e13b738 100644
--- a/UVtools.Core/FileFormats/ImageFile.cs
+++ b/UVtools.Core/FileFormats/ImageFile.cs
@@ -107,7 +107,7 @@ namespace UVtools.Core.FileFormats
this[0].LayerMat.Save(FileFullPath);
}
- public override FileFormat Convert(Type to, string fileFullPath, OperationProgress progress = null)
+ public override FileFormat Convert(Type to, string fileFullPath, uint version = 0, OperationProgress progress = null)
{
throw new NotSupportedException();
}
diff --git a/UVtools.Core/FileFormats/PHZFile.cs b/UVtools.Core/FileFormats/PHZFile.cs
index 6b1a692..ea78b7f 100644
--- a/UVtools.Core/FileFormats/PHZFile.cs
+++ b/UVtools.Core/FileFormats/PHZFile.cs
@@ -679,7 +679,9 @@ namespace UVtools.Core.FileFormats
new(200, 125)
};
- public override uint[] AvailableVersions { get; } = { 1, 2 };
+ public override uint[] AvailableVersions { get; } = { 2 };
+
+ public override uint DefaultVersion => 2;
public override uint Version
{
diff --git a/UVtools.Core/FileFormats/PhotonWorkshopFile.cs b/UVtools.Core/FileFormats/PhotonWorkshopFile.cs
index 7fdbb2a..322907f 100644
--- a/UVtools.Core/FileFormats/PhotonWorkshopFile.cs
+++ b/UVtools.Core/FileFormats/PhotonWorkshopFile.cs
@@ -1109,6 +1109,8 @@ namespace UVtools.Core.FileFormats
public override uint[] AvailableVersions { get; } = { VERSION_1, VERSION_515, VERSION_516 };
+ public override uint DefaultVersion => VERSION_1;
+
public override uint Version
{
get => FileMarkSettings.Version;
diff --git a/UVtools.Core/FileFormats/VDTFile.cs b/UVtools.Core/FileFormats/VDTFile.cs
index 1504a63..98341e3 100644
--- a/UVtools.Core/FileFormats/VDTFile.cs
+++ b/UVtools.Core/FileFormats/VDTFile.cs
@@ -272,6 +272,8 @@ namespace UVtools.Core.FileFormats
public override uint[] AvailableVersions { get; } = { 1 };
+ public override uint DefaultVersion => 1;
+
public override uint Version
{
get => ManifestFile.FileVersion;
diff --git a/UVtools.Core/UVtools.Core.csproj b/UVtools.Core/UVtools.Core.csproj
index b6446e6..5b360be 100644
--- a/UVtools.Core/UVtools.Core.csproj
+++ b/UVtools.Core/UVtools.Core.csproj
@@ -10,7 +10,7 @@
<RepositoryUrl>https://github.com/sn4k3/UVtools</RepositoryUrl>
<PackageProjectUrl>https://github.com/sn4k3/UVtools</PackageProjectUrl>
<Description>MSLA/DLP, file analysis, calibration, repair, conversion and manipulation</Description>
- <Version>2.27.3</Version>
+ <Version>2.27.4</Version>
<Copyright>Copyright © 2020 PTRTECH</Copyright>
<PackageIcon>UVtools.png</PackageIcon>
<Platforms>AnyCPU;x64</Platforms>
diff --git a/UVtools.WPF/Controls/WindowEx.cs b/UVtools.WPF/Controls/WindowEx.cs
index 5d7b0c3..7901b47 100644
--- a/UVtools.WPF/Controls/WindowEx.cs
+++ b/UVtools.WPF/Controls/WindowEx.cs
@@ -80,7 +80,7 @@ namespace UVtools.WPF.Controls
public UserSettings Settings => UserSettings.Instance;
- public FileFormat SlicerFile
+ public virtual FileFormat SlicerFile
{
get => App.SlicerFile;
set => App.SlicerFile = value;
diff --git a/UVtools.WPF/MainWindow.axaml.cs b/UVtools.WPF/MainWindow.axaml.cs
index 35fbe7b..e4b6de6 100644
--- a/UVtools.WPF/MainWindow.axaml.cs
+++ b/UVtools.WPF/MainWindow.axaml.cs
@@ -1637,7 +1637,7 @@ namespace UVtools.WPF
try
{
convertedFile = SlicerFile.Convert(convertToFormat,
- Path.Combine(directory, $"{filename}.{convertFileExtension}"),
+ Path.Combine(directory, $"{filename}.{convertFileExtension}"), 0,
Progress);
return true;
}
@@ -1940,6 +1940,22 @@ namespace UVtools.WPF
if (sender is not MenuItem item) return;
if (item.Tag is not FileExtension fileExtension) return;
+ var fileFormat = fileExtension.GetFileFormat();
+ uint version = fileFormat.DefaultVersion;
+ if (fileFormat.AvailableVersionsCount > 1)
+ {
+ var versionSelectorWindow = new VersionSelectorWindow(fileFormat, fileExtension);
+ await versionSelectorWindow.ShowDialog(this);
+ switch (versionSelectorWindow.DialogResult)
+ {
+ case DialogResults.OK:
+ version = versionSelectorWindow.Version;
+ break;
+ case DialogResults.Cancel:
+ return;
+ }
+ }
+
SaveFileDialog saveDialog = new()
{
InitialFileName = Path.GetFileNameWithoutExtension(SlicerFile.FileFullPath),
@@ -1952,7 +1968,6 @@ namespace UVtools.WPF
var result = await saveDialog.ShowAsync(this);
if (string.IsNullOrEmpty(result)) return;
-
IsGUIEnabled = false;
ShowProgressWindow($"Converting {Path.GetFileName(SlicerFile.FileFullPath)} to {Path.GetExtension(result)}");
@@ -1960,7 +1975,7 @@ namespace UVtools.WPF
{
try
{
- return SlicerFile.Convert(fileExtension.GetFileFormat(), result, Progress) is not null;
+ return SlicerFile.Convert(fileFormat, result, version, Progress) is not null;
}
catch (OperationCanceledException)
{
diff --git a/UVtools.WPF/UVtools.WPF.csproj b/UVtools.WPF/UVtools.WPF.csproj
index 8517234..717d6a9 100644
--- a/UVtools.WPF/UVtools.WPF.csproj
+++ b/UVtools.WPF/UVtools.WPF.csproj
@@ -12,7 +12,7 @@
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<RepositoryUrl>https://github.com/sn4k3/UVtools</RepositoryUrl>
<RepositoryType>Git</RepositoryType>
- <Version>2.27.3</Version>
+ <Version>2.27.4</Version>
<Platforms>AnyCPU;x64</Platforms>
<PackageIcon>UVtools.png</PackageIcon>
<PackageReadmeFile>README.md</PackageReadmeFile>
diff --git a/UVtools.WPF/Windows/VersionSelectorWindow.axaml b/UVtools.WPF/Windows/VersionSelectorWindow.axaml
new file mode 100644
index 0000000..eadbd84
--- /dev/null
+++ b/UVtools.WPF/Windows/VersionSelectorWindow.axaml
@@ -0,0 +1,46 @@
+<Window xmlns="https://github.com/avaloniaui"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ mc:Ignorable="d" d:DesignWidth="400" d:DesignHeight="450"
+ x:Class="UVtools.WPF.Windows.VersionSelectorWindow"
+ CanResize="False"
+ Title="Version selector"
+ SizeToContent="Height"
+ Width="400"
+ Padding="10"
+ WindowStartupLocation="CenterOwner"
+ Icon="/Assets/Icons/UVtools.ico">
+ <StackPanel Spacing="20">
+ <TextBlock TextWrapping="Wrap" Text="{Binding DescriptionText}"/>
+ <Grid RowDefinitions="Auto" ColumnDefinitions="Auto,10,*">
+ <TextBlock Grid.Row="0" Grid.Column="0"
+ VerticalAlignment="Center"
+ Text="Version:"/>
+ <ComboBox Grid.Row="0" Grid.Column="2"
+ HorizontalAlignment="Stretch"
+ Items="{Binding SlicerFile.AvailableVersions}"
+ SelectedItem="{Binding Version}"/>
+ </Grid>
+
+ <Border DockPanel.Dock="Bottom" Classes="FooterActions" Margin="-10" Padding="10,15">
+ <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Spacing="5">
+ <Button Command="{Binding SelectVersion}" IsDefault="True">
+ <StackPanel Orientation="Horizontal" Spacing="5">
+ <Image Source="/Assets/Icons/accept-16x16.png"/>
+ <TextBlock Text="{Binding Version, StringFormat=Select v{0}}" VerticalAlignment="Center"/>
+ </StackPanel>
+ </Button>
+ <Button Content="Use the default" Command="{Binding SelectDefault}"/>
+ <Button Command="{Binding Close}" IsCancel="True">
+ <StackPanel Orientation="Horizontal" Spacing="5">
+ <Image Source="/Assets/Icons/exit-16x16.png"/>
+ <TextBlock Text="Cancel" VerticalAlignment="Center"/>
+ </StackPanel>
+ </Button>
+ </StackPanel>
+ </Border>
+
+ </StackPanel>
+
+</Window>
diff --git a/UVtools.WPF/Windows/VersionSelectorWindow.axaml.cs b/UVtools.WPF/Windows/VersionSelectorWindow.axaml.cs
new file mode 100644
index 0000000..1fb4ed9
--- /dev/null
+++ b/UVtools.WPF/Windows/VersionSelectorWindow.axaml.cs
@@ -0,0 +1,58 @@
+using Avalonia.Markup.Xaml;
+using UVtools.Core.FileFormats;
+using UVtools.WPF.Controls;
+
+namespace UVtools.WPF.Windows
+{
+ public partial class VersionSelectorWindow : WindowEx
+ {
+ private uint _version;
+
+ public string DescriptionText =>
+ $"This file format \"{FileExtension.Description}\" contains multiple available versions. Some versions may require a specific firmware version in order to run.\n" +
+ "Select the version you wish to use on the output file.\n" +
+ $"If unsure, use the default version {SlicerFile.DefaultVersion}.";
+
+ public sealed override FileFormat SlicerFile { get; set; }
+
+ public FileExtension FileExtension { get; set; }
+
+ public uint Version
+ {
+ get => _version;
+ set => RaiseAndSetIfChanged(ref _version, value);
+ }
+
+ public VersionSelectorWindow()
+ {
+ InitializeComponent();
+ DialogResult = DialogResults.Cancel;
+ }
+
+ public VersionSelectorWindow(FileFormat slicerFile, FileExtension fileExtension) : this()
+ {
+ SlicerFile = slicerFile;
+ FileExtension = fileExtension;
+ Version = slicerFile.DefaultVersion;
+ Title += $" - {FileExtension.Description}";
+ DataContext = this;
+ }
+
+ private void InitializeComponent()
+ {
+ AvaloniaXamlLoader.Load(this);
+ }
+
+ public void SelectVersion()
+ {
+ DialogResult = Version == SlicerFile.DefaultVersion ? DialogResults.Unknown : DialogResults.OK;
+ Close();
+ }
+
+ public void SelectDefault()
+ {
+ DialogResult = DialogResults.Unknown;
+ Close();
+ }
+ }
+}