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-05-13 05:24:36 +0300
committerTiago Conceição <Tiago_caza@hotmail.com>2021-05-13 05:24:36 +0300
commitedd9984a31a90791edf3bcf594855d08507428b5 (patch)
treebe296b13d7587d6d14811ddc2bff1821fa59e324 /UVtools.WPF
parent3cd46728f1ca599d1f2211d9ff07273135d670af (diff)
v2.11.2v2.11.2
- (Improvement) Applied some refactorings on code - (Fix) MDLP, GR1 and CXDLP: Bad enconde of display width, display height and layer height properties
Diffstat (limited to 'UVtools.WPF')
-rw-r--r--UVtools.WPF/App.axaml.cs8
-rw-r--r--UVtools.WPF/Controls/AdvancedImageBox.axaml7
-rw-r--r--UVtools.WPF/Controls/AdvancedImageBox.axaml.cs8
-rw-r--r--UVtools.WPF/Controls/KernelControl.axaml.cs36
-rw-r--r--UVtools.WPF/Controls/Tools/ToolDynamicLayerHeightControl.axaml.cs2
-rw-r--r--UVtools.WPF/Controls/Tools/ToolMaskControl.axaml.cs4
-rw-r--r--UVtools.WPF/Controls/UserControlEx.cs2
-rw-r--r--UVtools.WPF/Controls/WindowEx.cs2
-rw-r--r--UVtools.WPF/MainWindow.GCode.cs8
-rw-r--r--UVtools.WPF/MainWindow.Issues.cs10
-rw-r--r--UVtools.WPF/MainWindow.Progress.cs2
-rw-r--r--UVtools.WPF/MainWindow.axaml.cs10
-rw-r--r--UVtools.WPF/Structures/AppVersionChecker.cs4
-rw-r--r--UVtools.WPF/UVtools.WPF.csproj2
-rw-r--r--UVtools.WPF/Windows/ShortcutsWindow.axaml11
-rw-r--r--UVtools.WPF/Windows/ShortcutsWindow.axaml.cs29
16 files changed, 90 insertions, 55 deletions
diff --git a/UVtools.WPF/App.axaml.cs b/UVtools.WPF/App.axaml.cs
index f6854f0..20c37ca 100644
--- a/UVtools.WPF/App.axaml.cs
+++ b/UVtools.WPF/App.axaml.cs
@@ -33,7 +33,7 @@ namespace UVtools.WPF
public static MainWindow MainWindow;
public static FileFormat SlicerFile = null;
- public static AppVersionChecker VersionChecker { get; } = new AppVersionChecker();
+ public static AppVersionChecker VersionChecker { get; } = new();
public override void Initialize()
{
@@ -95,8 +95,8 @@ namespace UVtools.WPF
#region Utilities
- public static string AppExecutable = Path.Combine(ApplicationPath, About.Software);
- public static string AppExecutableQuoted = $"\"{AppExecutable}\"";
+ public static readonly string AppExecutable = Path.Combine(ApplicationPath, About.Software);
+ public static readonly string AppExecutableQuoted = $"\"{AppExecutable}\"";
public static void NewInstance(string filePath)
{
try
@@ -182,7 +182,7 @@ namespace UVtools.WPF
return res;
}
- public static Bitmap GetBitmapFromAsset(string url) => new Bitmap(GetAsset(url));
+ public static Bitmap GetBitmapFromAsset(string url) => new(GetAsset(url));
public static string ApplicationPath => Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
diff --git a/UVtools.WPF/Controls/AdvancedImageBox.axaml b/UVtools.WPF/Controls/AdvancedImageBox.axaml
index 3b2d361..2c288f6 100644
--- a/UVtools.WPF/Controls/AdvancedImageBox.axaml
+++ b/UVtools.WPF/Controls/AdvancedImageBox.axaml
@@ -6,8 +6,7 @@
x:Class="UVtools.WPF.Controls.AdvancedImageBox">
<Grid
RowDefinitions="*,Auto"
- ColumnDefinitions="*,Auto"
- >
+ ColumnDefinitions="*,Auto">
<ContentControl
Name="ViewPort"
@@ -16,7 +15,7 @@
<ScrollBar
Name="VerticalScrollBar"
- Grid.Column="1"
+ Grid.Row="0" Grid.Column="1"
Orientation="Vertical"
ViewportSize="{Binding #ViewPort.Bounds.Height}"
Minimum="0"
@@ -26,7 +25,7 @@
<ScrollBar
Name="HorizontalScrollBar"
- Grid.Row="1"
+ Grid.Row="1" Grid.Column="0"
Orientation="Horizontal"
ViewportSize="{Binding #ViewPort.Bounds.Width}"
Minimum="0"
diff --git a/UVtools.WPF/Controls/AdvancedImageBox.axaml.cs b/UVtools.WPF/Controls/AdvancedImageBox.axaml.cs
index 7776ce0..02e8f87 100644
--- a/UVtools.WPF/Controls/AdvancedImageBox.axaml.cs
+++ b/UVtools.WPF/Controls/AdvancedImageBox.axaml.cs
@@ -30,7 +30,7 @@ namespace UVtools.WPF.Controls
public Vector Offset
{
- get => new Vector(HorizontalScrollBar.Value, VerticalScrollBar.Value);
+ get => new(HorizontalScrollBar.Value, VerticalScrollBar.Value);
set
{
HorizontalScrollBar.Value = value.X;
@@ -49,7 +49,7 @@ namespace UVtools.WPF.Controls
private PropertyChangedEventHandler _propertyChanged;
private readonly List<string> events = new ();
- public event PropertyChangedEventHandler PropertyChanged
+ public new event PropertyChangedEventHandler PropertyChanged
{
add { _propertyChanged += value; events.Add("added"); }
remove { _propertyChanged -= value; events.Add("removed"); }
@@ -1259,7 +1259,7 @@ namespace UVtools.WPF.Controls
/// Resets the zoom to 100%.
/// </summary>
/// <param name="source">The source that initiated the action.</param>
- private void PerformActualSize()
+ public void PerformActualSize()
{
SizeMode = SizeModes.Normal;
//SetZoom(100, ImageZoomActions.ActualSize | (Zoom < 100 ? ImageZoomActions.ZoomIn : ImageZoomActions.ZoomOut));
@@ -1512,7 +1512,7 @@ namespace UVtools.WPF.Controls
var offsetX = Offset.X % pixelSize;
var offsetY = Offset.Y % pixelSize;
- Pen pen = new Pen(PixelGridColor);
+ Pen pen = new(PixelGridColor);
for (double x = viewport.X + pixelSize - offsetX; x < viewport.Right; x += pixelSize)
{
context.DrawLine(pen, new Avalonia.Point(x, viewport.X), new Avalonia.Point(x, viewport.Bottom));
diff --git a/UVtools.WPF/Controls/KernelControl.axaml.cs b/UVtools.WPF/Controls/KernelControl.axaml.cs
index 3c8926b..1e4535a 100644
--- a/UVtools.WPF/Controls/KernelControl.axaml.cs
+++ b/UVtools.WPF/Controls/KernelControl.axaml.cs
@@ -46,7 +46,7 @@ namespace UVtools.WPF.Controls
set => RaiseAndSetIfChanged(ref _matrixHeight, value);
}
- public Size MatrixSize => new Size((int)_matrixWidth, (int)_matrixHeight);
+ public Size MatrixSize => new((int)_matrixWidth, (int)_matrixHeight);
public int AnchorX
{
@@ -61,7 +61,7 @@ namespace UVtools.WPF.Controls
}
- public Point Anchor => new Point(_anchorX, _anchorY);
+ public Point Anchor => new(_anchorX, _anchorY);
public KernelControl()
@@ -90,28 +90,26 @@ namespace UVtools.WPF.Controls
return;
}
- using (var kernel = CvInvoke.GetStructuringElement(SelectedKernelShape, MatrixSize, Anchor))
+ using var kernel = CvInvoke.GetStructuringElement(SelectedKernelShape, MatrixSize, Anchor);
+ string text = string.Empty;
+ for (int y = 0; y < kernel.Height; y++)
{
- string text = string.Empty;
- for (int y = 0; y < kernel.Height; y++)
+ var span = kernel.GetPixelRowSpan<byte>(y);
+ var line = string.Empty;
+ for (int x = 0; x < span.Length; x++)
{
- var span = kernel.GetPixelRowSpan<byte>(y);
- var line = string.Empty;
- for (int x = 0; x < span.Length; x++)
- {
- line += $" {span[x]}";
- }
-
- line = line.Remove(0, 1);
- text += line;
- if (y < kernel.Height - 1)
- {
- text += '\n';
- }
+ line += $" {span[x]}";
}
- MatrixText = text;
+ line = line.Remove(0, 1);
+ text += line;
+ if (y < kernel.Height - 1)
+ {
+ text += '\n';
+ }
}
+
+ MatrixText = text;
}
public void ResetKernel()
diff --git a/UVtools.WPF/Controls/Tools/ToolDynamicLayerHeightControl.axaml.cs b/UVtools.WPF/Controls/Tools/ToolDynamicLayerHeightControl.axaml.cs
index 489c950..10398aa 100644
--- a/UVtools.WPF/Controls/Tools/ToolDynamicLayerHeightControl.axaml.cs
+++ b/UVtools.WPF/Controls/Tools/ToolDynamicLayerHeightControl.axaml.cs
@@ -17,7 +17,7 @@ namespace UVtools.WPF.Controls.Tools
public double MinimumLayerHeight => Layer.RoundHeight(SlicerFile.LayerHeight * 2);
public double MaximumLayerHeight => FileFormat.MaximumLayerHeight;
- private DataGrid ExposureTable;
+ private readonly DataGrid ExposureTable;
public ToolDynamicLayerHeightControl()
{
diff --git a/UVtools.WPF/Controls/Tools/ToolMaskControl.axaml.cs b/UVtools.WPF/Controls/Tools/ToolMaskControl.axaml.cs
index bd389d6..c368acf 100644
--- a/UVtools.WPF/Controls/Tools/ToolMaskControl.axaml.cs
+++ b/UVtools.WPF/Controls/Tools/ToolMaskControl.axaml.cs
@@ -28,7 +28,7 @@ namespace UVtools.WPF.Controls.Tools
set
{
if(!RaiseAndSetIfChanged(ref _isMaskInverted, value)) return;
- if (!Operation.HaveMask) return;
+ if (!Operation.HaveInputMask) return;
Operation.InvertMask();
MaskImage = Operation.Mask.ToBitmap();
}
@@ -62,7 +62,7 @@ namespace UVtools.WPF.Controls.Tools
{
if(!RaiseAndSetIfChanged(ref _maskImage, value)) return;
RaisePropertyChanged(nameof(InfoMaskResolutionStr));
- ParentWindow.ButtonOkEnabled = Operation.HaveMask;
+ ParentWindow.ButtonOkEnabled = Operation.HaveInputMask;
}
}
diff --git a/UVtools.WPF/Controls/UserControlEx.cs b/UVtools.WPF/Controls/UserControlEx.cs
index 47a2bd4..0b1a806 100644
--- a/UVtools.WPF/Controls/UserControlEx.cs
+++ b/UVtools.WPF/Controls/UserControlEx.cs
@@ -15,7 +15,7 @@ namespace UVtools.WPF.Controls
private PropertyChangedEventHandler _propertyChanged;
private readonly List<string> events = new();
- public event PropertyChangedEventHandler PropertyChanged
+ public new event PropertyChangedEventHandler PropertyChanged
{
add { _propertyChanged += value; events.Add("added"); }
remove { _propertyChanged -= value; events.Add("removed"); }
diff --git a/UVtools.WPF/Controls/WindowEx.cs b/UVtools.WPF/Controls/WindowEx.cs
index e3a643d..5d7b0c3 100644
--- a/UVtools.WPF/Controls/WindowEx.cs
+++ b/UVtools.WPF/Controls/WindowEx.cs
@@ -29,7 +29,7 @@ namespace UVtools.WPF.Controls
private PropertyChangedEventHandler _propertyChanged;
private readonly List<string> events = new();
- public event PropertyChangedEventHandler PropertyChanged
+ public new event PropertyChangedEventHandler PropertyChanged
{
add { _propertyChanged += value; events.Add("added"); }
remove { _propertyChanged -= value; events.Add("removed"); }
diff --git a/UVtools.WPF/MainWindow.GCode.cs b/UVtools.WPF/MainWindow.GCode.cs
index 18a7b27..716864a 100644
--- a/UVtools.WPF/MainWindow.GCode.cs
+++ b/UVtools.WPF/MainWindow.GCode.cs
@@ -48,11 +48,9 @@ namespace UVtools.WPF
try
{
- using (TextWriter tw = new StreamWriter(file))
- {
- tw.Write(SlicerFile.GCodeStr);
- tw.Close();
- }
+ await using TextWriter tw = new StreamWriter(file);
+ await tw.WriteAsync(SlicerFile.GCodeStr);
+ tw.Close();
}
catch (Exception e)
{
diff --git a/UVtools.WPF/MainWindow.Issues.cs b/UVtools.WPF/MainWindow.Issues.cs
index c765f6f..6871d75 100644
--- a/UVtools.WPF/MainWindow.Issues.cs
+++ b/UVtools.WPF/MainWindow.Issues.cs
@@ -43,7 +43,7 @@ namespace UVtools.WPF
private set => RaiseAndSetIfChanged(ref _issues, value);
}
- public readonly List<LayerIssue> IgnoredIssues = new List<LayerIssue>();
+ public readonly List<LayerIssue> IgnoredIssues = new();
public bool IssueCanGoPrevious => Issues.Count > 0 && _issueSelectedIndex > 0;
public bool IssueCanGoNext => Issues.Count > 0 && _issueSelectedIndex < Issues.Count - 1;
@@ -83,8 +83,8 @@ namespace UVtools.WPF
"Warning: Removing an island can cause other issues to appear if there is material present in the layers above it.\n" +
"Always check previous and next layers before performing an island removal.", $"Remove {IssuesGrid.SelectedItems.Count} Issues?") != ButtonResult.Yes) return;
- Dictionary<uint, List<LayerIssue>> processIssues = new Dictionary<uint, List<LayerIssue>>();
- List<uint> layersRemove = new List<uint>();
+ Dictionary<uint, List<LayerIssue>> processIssues = new();
+ List<uint> layersRemove = new();
foreach (LayerIssue issue in IssuesGrid.SelectedItems)
@@ -335,7 +335,7 @@ namespace UVtools.WPF
private void IssuesGridOnSelectionChanged(object? sender, SelectionChangedEventArgs e)
{
- if (!(IssuesGrid.SelectedItem is LayerIssue issue))
+ if (IssuesGrid.SelectedItem is not LayerIssue issue)
{
ShowLayer();
return;
@@ -374,7 +374,7 @@ namespace UVtools.WPF
private void IssuesGridOnCellPointerPressed(object? sender, DataGridCellPointerPressedEventArgs e)
{
if (e.PointerPressedEventArgs.ClickCount == 2) return;
- if (!(IssuesGrid.SelectedItem is LayerIssue issue)) return;
+ if (IssuesGrid.SelectedItem is not LayerIssue) return;
// Double clicking an issue will center and zoom into the
// selected issue. Left click on an issue will zoom to fit.
diff --git a/UVtools.WPF/MainWindow.Progress.cs b/UVtools.WPF/MainWindow.Progress.cs
index 6f2d304..14f5eaf 100644
--- a/UVtools.WPF/MainWindow.Progress.cs
+++ b/UVtools.WPF/MainWindow.Progress.cs
@@ -18,7 +18,7 @@ namespace UVtools.WPF
{
#region Members
public OperationProgress Progress { get; } = new();
- private Timer _progressTimer = new(200) { AutoReset = true };
+ private readonly Timer _progressTimer = new(200) { AutoReset = true };
private long _progressLastTotalSeconds;
private LogItem _progressLogItem;
private bool _isProgressVisible;
diff --git a/UVtools.WPF/MainWindow.axaml.cs b/UVtools.WPF/MainWindow.axaml.cs
index 29d85ba..b8c454e 100644
--- a/UVtools.WPF/MainWindow.axaml.cs
+++ b/UVtools.WPF/MainWindow.axaml.cs
@@ -814,7 +814,7 @@ namespace UVtools.WPF
public async void MenuFileSettingsClicked()
{
- SettingsWindow settingsWindow = new SettingsWindow();
+ SettingsWindow settingsWindow = new();
await settingsWindow.ShowDialog(this);
}
@@ -891,7 +891,7 @@ namespace UVtools.WPF
IsGUIEnabled = false;
ShowProgressWindow($"Downloading: {VersionChecker.Filename}", false);
- var task = await Task.Factory.StartNew(async () =>
+ var task = await Task.Factory.StartNew( () =>
{
try
{
@@ -1262,7 +1262,7 @@ namespace UVtools.WPF
}
else
{
- await Dispatcher.UIThread.InvokeAsync(async () =>
+ await Dispatcher.UIThread.InvokeAsync(() =>
{
ProgressShow(title, canCancel);
/*try
@@ -1285,7 +1285,7 @@ namespace UVtools.WPF
if (sender is not MenuItem item) return;
if (item.Tag is not FileExtension fileExtension) return;
- SaveFileDialog dialog = new SaveFileDialog
+ SaveFileDialog dialog = new()
{
InitialFileName = Path.GetFileNameWithoutExtension(SlicerFile.FileFullPath),
Filters = Helpers.ToAvaloniaFilter(fileExtension.Description, fileExtension.Extension),
@@ -1434,7 +1434,7 @@ namespace UVtools.WPF
{
if (!IsFileLoaded) return;
string fileNameNoExt = Path.GetFileNameWithoutExtension(SlicerFile.FileFullPath);
- OpenFolderDialog dialog = new OpenFolderDialog
+ OpenFolderDialog dialog = new()
{
Directory = string.IsNullOrEmpty(Settings.General.DefaultDirectoryExtractFile)
? Path.GetDirectoryName(SlicerFile.FileFullPath)
diff --git a/UVtools.WPF/Structures/AppVersionChecker.cs b/UVtools.WPF/Structures/AppVersionChecker.cs
index c043435..83ba22a 100644
--- a/UVtools.WPF/Structures/AppVersionChecker.cs
+++ b/UVtools.WPF/Structures/AppVersionChecker.cs
@@ -88,7 +88,7 @@ namespace UVtools.WPF.Structures
public string VersionAnnouncementText => $"New version v{_version} is available!";
- public string UrlLatestRelease => $"{About.Website}/releases/latest";
+ public string UrlLatestRelease = $"{About.Website}/releases/latest";
public string DownloadLink => string.IsNullOrEmpty(Filename) ? null : $"{About.Website}/releases/download/v{_version}/{Filename}";
@@ -181,7 +181,7 @@ namespace UVtools.WPF.Structures
var targetDir = Path.Combine(App.ApplicationPath, upgradeFolder);
using (var stream = File.Open(DownloadedFile, FileMode.Open))
{
- using ZipArchive zip = new ZipArchive(stream, ZipArchiveMode.Read);
+ using ZipArchive zip = new(stream, ZipArchiveMode.Read);
zip.ExtractToDirectory(targetDir, true);
}
diff --git a/UVtools.WPF/UVtools.WPF.csproj b/UVtools.WPF/UVtools.WPF.csproj
index e1abb73..f5b81db 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.11.1</Version>
+ <Version>2.11.2</Version>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
diff --git a/UVtools.WPF/Windows/ShortcutsWindow.axaml b/UVtools.WPF/Windows/ShortcutsWindow.axaml
new file mode 100644
index 0000000..bfd309f
--- /dev/null
+++ b/UVtools.WPF/Windows/ShortcutsWindow.axaml
@@ -0,0 +1,11 @@
+<controls:WindowEx 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"
+ xmlns:controls="clr-namespace:UVtools.WPF.Controls"
+ mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
+ x:Class="UVtools.WPF.Windows.ShortcutsWindow"
+ WindowStartupLocation="CenterOwner"
+ Title="ShortcutsWindow">
+ Welcome to Avalonia!
+</controls:WindowEx>
diff --git a/UVtools.WPF/Windows/ShortcutsWindow.axaml.cs b/UVtools.WPF/Windows/ShortcutsWindow.axaml.cs
new file mode 100644
index 0000000..45f8ce7
--- /dev/null
+++ b/UVtools.WPF/Windows/ShortcutsWindow.axaml.cs
@@ -0,0 +1,29 @@
+/*
+ * 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 Avalonia;
+using Avalonia.Markup.Xaml;
+using UVtools.WPF.Controls;
+
+namespace UVtools.WPF.Windows
+{
+ public partial class ShortcutsWindow : WindowEx
+ {
+ public ShortcutsWindow()
+ {
+ InitializeComponent();
+#if DEBUG
+ this.AttachDevTools();
+#endif
+ }
+
+ private void InitializeComponent()
+ {
+ AvaloniaXamlLoader.Load(this);
+ }
+ }
+}