diff options
author | Tiago Conceição <Tiago_caza@hotmail.com> | 2020-09-16 22:31:59 +0300 |
---|---|---|
committer | Tiago Conceição <Tiago_caza@hotmail.com> | 2020-09-16 22:31:59 +0300 |
commit | 5859a20d309893cb4ed06e092d78858c77efe6e9 (patch) | |
tree | 920109a368eeb439c8233008f2c33c25ff922aec | |
parent | 49a6299cefd503f84d4af6a88f43b4843f9da2b2 (diff) |
WPFv0.8.2.2
94 files changed, 807 insertions, 37 deletions
diff --git a/UVtools.WPF/App.axaml.cs b/UVtools.WPF/App.axaml.cs index 62a22e2..d4730d7 100644 --- a/UVtools.WPF/App.axaml.cs +++ b/UVtools.WPF/App.axaml.cs @@ -1,11 +1,21 @@ -using Avalonia; +using System.Diagnostics; +using Avalonia; using Avalonia.Controls.ApplicationLifetimes; using Avalonia.Markup.Xaml; +using Avalonia.ThemeManager; +using MessageBox.Avalonia.DTO; +using MessageBox.Avalonia.Enums; +using MessageBox.Avalonia.Models; +using UVtools.Core.FileFormats; namespace UVtools.WPF { public class App : Application { + public static IThemeSelector? Selector { get; set; } + + public static FileFormat SlicerFile = null; + public override void Initialize() { AvaloniaXamlLoader.Load(this); @@ -15,10 +25,24 @@ namespace UVtools.WPF { if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) { - desktop.MainWindow = new MainWindow(); + Selector = ThemeSelector.Create("Themes"); + Selector.LoadSelectedTheme("UVtools.theme"); + desktop.MainWindow = new MainWindow + { + //DataContext = Selector + }; + desktop.Exit += (sender, e) + => Selector.SaveSelectedTheme("UVtools.theme"); + + Debug.WriteLine(Selector.Themes[1].Name); } base.OnFrameworkInitializationCompleted(); } + + #region Utilities + + + #endregion } } diff --git a/UVtools.WPF/Assets/Icons/Back-16x16.png b/UVtools.WPF/Assets/Icons/Back-16x16.png Binary files differnew file mode 100644 index 0000000..c28c621 --- /dev/null +++ b/UVtools.WPF/Assets/Icons/Back-16x16.png diff --git a/UVtools.WPF/Assets/Icons/Button-Info-16x16.png b/UVtools.WPF/Assets/Icons/Button-Info-16x16.png Binary files differnew file mode 100644 index 0000000..560873d --- /dev/null +++ b/UVtools.WPF/Assets/Icons/Button-Info-16x16.png diff --git a/UVtools.WPF/Assets/Icons/CNCMachine-16x16.png b/UVtools.WPF/Assets/Icons/CNCMachine-16x16.png Binary files differnew file mode 100644 index 0000000..e2a5e4b --- /dev/null +++ b/UVtools.WPF/Assets/Icons/CNCMachine-16x16.png diff --git a/UVtools.WPF/Assets/Icons/Cancel-24x24.png b/UVtools.WPF/Assets/Icons/Cancel-24x24.png Binary files differnew file mode 100644 index 0000000..74e4559 --- /dev/null +++ b/UVtools.WPF/Assets/Icons/Cancel-24x24.png diff --git a/UVtools.WPF/Assets/Icons/Cancel-32x32.png b/UVtools.WPF/Assets/Icons/Cancel-32x32.png Binary files differnew file mode 100644 index 0000000..a732caa --- /dev/null +++ b/UVtools.WPF/Assets/Icons/Cancel-32x32.png diff --git a/UVtools.WPF/Assets/Icons/DataList-16x16.png b/UVtools.WPF/Assets/Icons/DataList-16x16.png Binary files differnew file mode 100644 index 0000000..a4e784c --- /dev/null +++ b/UVtools.WPF/Assets/Icons/DataList-16x16.png diff --git a/UVtools.WPF/Assets/Icons/Donate-16x16.png b/UVtools.WPF/Assets/Icons/Donate-16x16.png Binary files differnew file mode 100644 index 0000000..37378b3 --- /dev/null +++ b/UVtools.WPF/Assets/Icons/Donate-16x16.png diff --git a/UVtools.WPF/Assets/Icons/GCode-16x16.png b/UVtools.WPF/Assets/Icons/GCode-16x16.png Binary files differnew file mode 100644 index 0000000..127cecc --- /dev/null +++ b/UVtools.WPF/Assets/Icons/GCode-16x16.png diff --git a/UVtools.WPF/Assets/Icons/Geometry-16x16.png b/UVtools.WPF/Assets/Icons/Geometry-16x16.png Binary files differnew file mode 100644 index 0000000..da022c5 --- /dev/null +++ b/UVtools.WPF/Assets/Icons/Geometry-16x16.png diff --git a/UVtools.WPF/Assets/Icons/Global-Network-icon-16x16.png b/UVtools.WPF/Assets/Icons/Global-Network-icon-16x16.png Binary files differnew file mode 100644 index 0000000..0c4e3be --- /dev/null +++ b/UVtools.WPF/Assets/Icons/Global-Network-icon-16x16.png diff --git a/UVtools.WPF/Assets/Icons/Lock-16x16.png b/UVtools.WPF/Assets/Icons/Lock-16x16.png Binary files differnew file mode 100644 index 0000000..8af4d26 --- /dev/null +++ b/UVtools.WPF/Assets/Icons/Lock-16x16.png diff --git a/UVtools.WPF/Assets/Icons/Next-16x16.png b/UVtools.WPF/Assets/Icons/Next-16x16.png Binary files differnew file mode 100644 index 0000000..9d8f5e4 --- /dev/null +++ b/UVtools.WPF/Assets/Icons/Next-16x16.png diff --git a/UVtools.WPF/Assets/Icons/Ok-24x24.png b/UVtools.WPF/Assets/Icons/Ok-24x24.png Binary files differnew file mode 100644 index 0000000..e4cc79d --- /dev/null +++ b/UVtools.WPF/Assets/Icons/Ok-24x24.png diff --git a/UVtools.WPF/Assets/Icons/PhotoInfo-16x16.png b/UVtools.WPF/Assets/Icons/PhotoInfo-16x16.png Binary files differnew file mode 100644 index 0000000..f6a4c2f --- /dev/null +++ b/UVtools.WPF/Assets/Icons/PhotoInfo-16x16.png diff --git a/UVtools.WPF/Assets/Icons/Wrench-16x16.png b/UVtools.WPF/Assets/Icons/Wrench-16x16.png Binary files differnew file mode 100644 index 0000000..2838a76 --- /dev/null +++ b/UVtools.WPF/Assets/Icons/Wrench-16x16.png diff --git a/UVtools.WPF/Assets/Icons/accept-16x16.png b/UVtools.WPF/Assets/Icons/accept-16x16.png Binary files differnew file mode 100644 index 0000000..3b3abf8 --- /dev/null +++ b/UVtools.WPF/Assets/Icons/accept-16x16.png diff --git a/UVtools.WPF/Assets/Icons/arrow-down-16x16.png b/UVtools.WPF/Assets/Icons/arrow-down-16x16.png Binary files differnew file mode 100644 index 0000000..9ce51bb --- /dev/null +++ b/UVtools.WPF/Assets/Icons/arrow-down-16x16.png diff --git a/UVtools.WPF/Assets/Icons/arrow-down-double-16x16.png b/UVtools.WPF/Assets/Icons/arrow-down-double-16x16.png Binary files differnew file mode 100644 index 0000000..7393d68 --- /dev/null +++ b/UVtools.WPF/Assets/Icons/arrow-down-double-16x16.png diff --git a/UVtools.WPF/Assets/Icons/arrow-end-16x16.png b/UVtools.WPF/Assets/Icons/arrow-end-16x16.png Binary files differnew file mode 100644 index 0000000..ce9d9c7 --- /dev/null +++ b/UVtools.WPF/Assets/Icons/arrow-end-16x16.png diff --git a/UVtools.WPF/Assets/Icons/arrow-top-16x16.png b/UVtools.WPF/Assets/Icons/arrow-top-16x16.png Binary files differnew file mode 100644 index 0000000..8afa1a0 --- /dev/null +++ b/UVtools.WPF/Assets/Icons/arrow-top-16x16.png diff --git a/UVtools.WPF/Assets/Icons/arrow-up-16x16.png b/UVtools.WPF/Assets/Icons/arrow-up-16x16.png Binary files differnew file mode 100644 index 0000000..585744a --- /dev/null +++ b/UVtools.WPF/Assets/Icons/arrow-up-16x16.png diff --git a/UVtools.WPF/Assets/Icons/blur-16x16.png b/UVtools.WPF/Assets/Icons/blur-16x16.png Binary files differnew file mode 100644 index 0000000..8132066 --- /dev/null +++ b/UVtools.WPF/Assets/Icons/blur-16x16.png diff --git a/UVtools.WPF/Assets/Icons/bowling-ball-16x16.png b/UVtools.WPF/Assets/Icons/bowling-ball-16x16.png Binary files differnew file mode 100644 index 0000000..f231665 --- /dev/null +++ b/UVtools.WPF/Assets/Icons/bowling-ball-16x16.png diff --git a/UVtools.WPF/Assets/Icons/burn-16x16.png b/UVtools.WPF/Assets/Icons/burn-16x16.png Binary files differnew file mode 100644 index 0000000..217963c --- /dev/null +++ b/UVtools.WPF/Assets/Icons/burn-16x16.png diff --git a/UVtools.WPF/Assets/Icons/checkbox-marked-16x16.png b/UVtools.WPF/Assets/Icons/checkbox-marked-16x16.png Binary files differnew file mode 100644 index 0000000..ab94ab3 --- /dev/null +++ b/UVtools.WPF/Assets/Icons/checkbox-marked-16x16.png diff --git a/UVtools.WPF/Assets/Icons/checkbox-unmarked-16x16.png b/UVtools.WPF/Assets/Icons/checkbox-unmarked-16x16.png Binary files differnew file mode 100644 index 0000000..697bb74 --- /dev/null +++ b/UVtools.WPF/Assets/Icons/checkbox-unmarked-16x16.png diff --git a/UVtools.WPF/Assets/Icons/chessboard-16x16.png b/UVtools.WPF/Assets/Icons/chessboard-16x16.png Binary files differnew file mode 100644 index 0000000..e12226e --- /dev/null +++ b/UVtools.WPF/Assets/Icons/chessboard-16x16.png diff --git a/UVtools.WPF/Assets/Icons/clipboard-16x16.png b/UVtools.WPF/Assets/Icons/clipboard-16x16.png Binary files differnew file mode 100644 index 0000000..42f9370 --- /dev/null +++ b/UVtools.WPF/Assets/Icons/clipboard-16x16.png diff --git a/UVtools.WPF/Assets/Icons/code-16x16.png b/UVtools.WPF/Assets/Icons/code-16x16.png Binary files differnew file mode 100644 index 0000000..6aa33a4 --- /dev/null +++ b/UVtools.WPF/Assets/Icons/code-16x16.png diff --git a/UVtools.WPF/Assets/Icons/compress-alt-16x16.png b/UVtools.WPF/Assets/Icons/compress-alt-16x16.png Binary files differnew file mode 100644 index 0000000..a2129b8 --- /dev/null +++ b/UVtools.WPF/Assets/Icons/compress-alt-16x16.png diff --git a/UVtools.WPF/Assets/Icons/convert-16x16.png b/UVtools.WPF/Assets/Icons/convert-16x16.png Binary files differnew file mode 100644 index 0000000..76cf3c4 --- /dev/null +++ b/UVtools.WPF/Assets/Icons/convert-16x16.png diff --git a/UVtools.WPF/Assets/Icons/copy_16x16.png b/UVtools.WPF/Assets/Icons/copy_16x16.png Binary files differnew file mode 100644 index 0000000..562239a --- /dev/null +++ b/UVtools.WPF/Assets/Icons/copy_16x16.png diff --git a/UVtools.WPF/Assets/Icons/crop-16x16.png b/UVtools.WPF/Assets/Icons/crop-16x16.png Binary files differnew file mode 100644 index 0000000..225c344 --- /dev/null +++ b/UVtools.WPF/Assets/Icons/crop-16x16.png diff --git a/UVtools.WPF/Assets/Icons/crosshairs-16x16.png b/UVtools.WPF/Assets/Icons/crosshairs-16x16.png Binary files differnew file mode 100644 index 0000000..62e9eef --- /dev/null +++ b/UVtools.WPF/Assets/Icons/crosshairs-16x16.png diff --git a/UVtools.WPF/Assets/Icons/cursor-16x16.png b/UVtools.WPF/Assets/Icons/cursor-16x16.png Binary files differnew file mode 100644 index 0000000..b0eeaa0 --- /dev/null +++ b/UVtools.WPF/Assets/Icons/cursor-16x16.png diff --git a/UVtools.WPF/Assets/Icons/delete-16x16.png b/UVtools.WPF/Assets/Icons/delete-16x16.png Binary files differnew file mode 100644 index 0000000..b5842b7 --- /dev/null +++ b/UVtools.WPF/Assets/Icons/delete-16x16.png diff --git a/UVtools.WPF/Assets/Icons/exit-16x16.png b/UVtools.WPF/Assets/Icons/exit-16x16.png Binary files differnew file mode 100644 index 0000000..863566c --- /dev/null +++ b/UVtools.WPF/Assets/Icons/exit-16x16.png diff --git a/UVtools.WPF/Assets/Icons/expand-16x16.png b/UVtools.WPF/Assets/Icons/expand-16x16.png Binary files differnew file mode 100644 index 0000000..a8c87f4 --- /dev/null +++ b/UVtools.WPF/Assets/Icons/expand-16x16.png diff --git a/UVtools.WPF/Assets/Icons/expand-alt-16x16.png b/UVtools.WPF/Assets/Icons/expand-alt-16x16.png Binary files differnew file mode 100644 index 0000000..22b181f --- /dev/null +++ b/UVtools.WPF/Assets/Icons/expand-alt-16x16.png diff --git a/UVtools.WPF/Assets/Icons/extract-object-16x16.png b/UVtools.WPF/Assets/Icons/extract-object-16x16.png Binary files differnew file mode 100644 index 0000000..9bdb1d2 --- /dev/null +++ b/UVtools.WPF/Assets/Icons/extract-object-16x16.png diff --git a/UVtools.WPF/Assets/Icons/eye-16x16.png b/UVtools.WPF/Assets/Icons/eye-16x16.png Binary files differnew file mode 100644 index 0000000..4f3c7e2 --- /dev/null +++ b/UVtools.WPF/Assets/Icons/eye-16x16.png diff --git a/UVtools.WPF/Assets/Icons/eye-24x24.png b/UVtools.WPF/Assets/Icons/eye-24x24.png Binary files differnew file mode 100644 index 0000000..4f3c7e2 --- /dev/null +++ b/UVtools.WPF/Assets/Icons/eye-24x24.png diff --git a/UVtools.WPF/Assets/Icons/file-close-16x16.png b/UVtools.WPF/Assets/Icons/file-close-16x16.png Binary files differnew file mode 100644 index 0000000..ef36711 --- /dev/null +++ b/UVtools.WPF/Assets/Icons/file-close-16x16.png diff --git a/UVtools.WPF/Assets/Icons/file-image-16x16.png b/UVtools.WPF/Assets/Icons/file-image-16x16.png Binary files differnew file mode 100644 index 0000000..7e10379 --- /dev/null +++ b/UVtools.WPF/Assets/Icons/file-image-16x16.png diff --git a/UVtools.WPF/Assets/Icons/file-import-16x16.png b/UVtools.WPF/Assets/Icons/file-import-16x16.png Binary files differnew file mode 100644 index 0000000..1712317 --- /dev/null +++ b/UVtools.WPF/Assets/Icons/file-import-16x16.png diff --git a/UVtools.WPF/Assets/Icons/file-refresh-16x16.png b/UVtools.WPF/Assets/Icons/file-refresh-16x16.png Binary files differnew file mode 100644 index 0000000..39d6920 --- /dev/null +++ b/UVtools.WPF/Assets/Icons/file-refresh-16x16.png diff --git a/UVtools.WPF/Assets/Icons/filter-filled-16x16.png b/UVtools.WPF/Assets/Icons/filter-filled-16x16.png Binary files differnew file mode 100644 index 0000000..a19d124 --- /dev/null +++ b/UVtools.WPF/Assets/Icons/filter-filled-16x16.png diff --git a/UVtools.WPF/Assets/Icons/flip-16x16.png b/UVtools.WPF/Assets/Icons/flip-16x16.png Binary files differnew file mode 100644 index 0000000..138d97a --- /dev/null +++ b/UVtools.WPF/Assets/Icons/flip-16x16.png diff --git a/UVtools.WPF/Assets/Icons/internet-explorer-16x16.png b/UVtools.WPF/Assets/Icons/internet-explorer-16x16.png Binary files differnew file mode 100644 index 0000000..b5b3ea6 --- /dev/null +++ b/UVtools.WPF/Assets/Icons/internet-explorer-16x16.png diff --git a/UVtools.WPF/Assets/Icons/island-16x16.png b/UVtools.WPF/Assets/Icons/island-16x16.png Binary files differnew file mode 100644 index 0000000..d9b45d6 --- /dev/null +++ b/UVtools.WPF/Assets/Icons/island-16x16.png diff --git a/UVtools.WPF/Assets/Icons/ladder-16x16.png b/UVtools.WPF/Assets/Icons/ladder-16x16.png Binary files differnew file mode 100644 index 0000000..de76c84 --- /dev/null +++ b/UVtools.WPF/Assets/Icons/ladder-16x16.png diff --git a/UVtools.WPF/Assets/Icons/layers-16x16.png b/UVtools.WPF/Assets/Icons/layers-16x16.png Binary files differnew file mode 100644 index 0000000..b8f66f5 --- /dev/null +++ b/UVtools.WPF/Assets/Icons/layers-16x16.png diff --git a/UVtools.WPF/Assets/Icons/layers-alt-16x16.png b/UVtools.WPF/Assets/Icons/layers-alt-16x16.png Binary files differnew file mode 100644 index 0000000..230e11b --- /dev/null +++ b/UVtools.WPF/Assets/Icons/layers-alt-16x16.png diff --git a/UVtools.WPF/Assets/Icons/list-16x16.png b/UVtools.WPF/Assets/Icons/list-16x16.png Binary files differnew file mode 100644 index 0000000..85d6795 --- /dev/null +++ b/UVtools.WPF/Assets/Icons/list-16x16.png diff --git a/UVtools.WPF/Assets/Icons/log-16x16.png b/UVtools.WPF/Assets/Icons/log-16x16.png Binary files differnew file mode 100644 index 0000000..55d7785 --- /dev/null +++ b/UVtools.WPF/Assets/Icons/log-16x16.png diff --git a/UVtools.WPF/Assets/Icons/map-marker-16x16.png b/UVtools.WPF/Assets/Icons/map-marker-16x16.png Binary files differnew file mode 100644 index 0000000..a0523b2 --- /dev/null +++ b/UVtools.WPF/Assets/Icons/map-marker-16x16.png diff --git a/UVtools.WPF/Assets/Icons/mask-16x16.png b/UVtools.WPF/Assets/Icons/mask-16x16.png Binary files differnew file mode 100644 index 0000000..0a450a4 --- /dev/null +++ b/UVtools.WPF/Assets/Icons/mask-16x16.png diff --git a/UVtools.WPF/Assets/Icons/microchip_16x16.png b/UVtools.WPF/Assets/Icons/microchip_16x16.png Binary files differnew file mode 100644 index 0000000..ca399d8 --- /dev/null +++ b/UVtools.WPF/Assets/Icons/microchip_16x16.png diff --git a/UVtools.WPF/Assets/Icons/minus_16x16.png b/UVtools.WPF/Assets/Icons/minus_16x16.png Binary files differnew file mode 100644 index 0000000..4fd33f9 --- /dev/null +++ b/UVtools.WPF/Assets/Icons/minus_16x16.png diff --git a/UVtools.WPF/Assets/Icons/move-16x16.png b/UVtools.WPF/Assets/Icons/move-16x16.png Binary files differnew file mode 100644 index 0000000..a018770 --- /dev/null +++ b/UVtools.WPF/Assets/Icons/move-16x16.png diff --git a/UVtools.WPF/Assets/Icons/object-group-16x16.png b/UVtools.WPF/Assets/Icons/object-group-16x16.png Binary files differnew file mode 100644 index 0000000..e5cd1e9 --- /dev/null +++ b/UVtools.WPF/Assets/Icons/object-group-16x16.png diff --git a/UVtools.WPF/Assets/Icons/open-16x16.png b/UVtools.WPF/Assets/Icons/open-16x16.png Binary files differnew file mode 100644 index 0000000..40fcd9a --- /dev/null +++ b/UVtools.WPF/Assets/Icons/open-16x16.png diff --git a/UVtools.WPF/Assets/Icons/pattern-16x16.png b/UVtools.WPF/Assets/Icons/pattern-16x16.png Binary files differnew file mode 100644 index 0000000..714d8b5 --- /dev/null +++ b/UVtools.WPF/Assets/Icons/pattern-16x16.png diff --git a/UVtools.WPF/Assets/Icons/photo-16x16.png b/UVtools.WPF/Assets/Icons/photo-16x16.png Binary files differnew file mode 100644 index 0000000..af90fe0 --- /dev/null +++ b/UVtools.WPF/Assets/Icons/photo-16x16.png diff --git a/UVtools.WPF/Assets/Icons/pixel-16x16.png b/UVtools.WPF/Assets/Icons/pixel-16x16.png Binary files differnew file mode 100644 index 0000000..d7c46a7 --- /dev/null +++ b/UVtools.WPF/Assets/Icons/pixel-16x16.png diff --git a/UVtools.WPF/Assets/Icons/plus-16x16.png b/UVtools.WPF/Assets/Icons/plus-16x16.png Binary files differnew file mode 100644 index 0000000..7614e37 --- /dev/null +++ b/UVtools.WPF/Assets/Icons/plus-16x16.png diff --git a/UVtools.WPF/Assets/Icons/pointer-16x16.png b/UVtools.WPF/Assets/Icons/pointer-16x16.png Binary files differnew file mode 100644 index 0000000..fadbd93 --- /dev/null +++ b/UVtools.WPF/Assets/Icons/pointer-16x16.png diff --git a/UVtools.WPF/Assets/Icons/refresh-16x16.png b/UVtools.WPF/Assets/Icons/refresh-16x16.png Binary files differnew file mode 100644 index 0000000..c5f7827 --- /dev/null +++ b/UVtools.WPF/Assets/Icons/refresh-16x16.png diff --git a/UVtools.WPF/Assets/Icons/resize-16x16.png b/UVtools.WPF/Assets/Icons/resize-16x16.png Binary files differnew file mode 100644 index 0000000..3ba586c --- /dev/null +++ b/UVtools.WPF/Assets/Icons/resize-16x16.png diff --git a/UVtools.WPF/Assets/Icons/save-16x16.png b/UVtools.WPF/Assets/Icons/save-16x16.png Binary files differnew file mode 100644 index 0000000..38ce759 --- /dev/null +++ b/UVtools.WPF/Assets/Icons/save-16x16.png diff --git a/UVtools.WPF/Assets/Icons/save-as-16x16.png b/UVtools.WPF/Assets/Icons/save-as-16x16.png Binary files differnew file mode 100644 index 0000000..e22cce7 --- /dev/null +++ b/UVtools.WPF/Assets/Icons/save-as-16x16.png diff --git a/UVtools.WPF/Assets/Icons/search-16x16.png b/UVtools.WPF/Assets/Icons/search-16x16.png Binary files differnew file mode 100644 index 0000000..ea9d8e2 --- /dev/null +++ b/UVtools.WPF/Assets/Icons/search-16x16.png diff --git a/UVtools.WPF/Assets/Icons/settings-16x16.png b/UVtools.WPF/Assets/Icons/settings-16x16.png Binary files differnew file mode 100644 index 0000000..83e560c --- /dev/null +++ b/UVtools.WPF/Assets/Icons/settings-16x16.png diff --git a/UVtools.WPF/Assets/Icons/sort-alpha-up-16x16.png b/UVtools.WPF/Assets/Icons/sort-alpha-up-16x16.png Binary files differnew file mode 100644 index 0000000..765a4dd --- /dev/null +++ b/UVtools.WPF/Assets/Icons/sort-alpha-up-16x16.png diff --git a/UVtools.WPF/Assets/Icons/square-solid-16x16.png b/UVtools.WPF/Assets/Icons/square-solid-16x16.png Binary files differnew file mode 100644 index 0000000..d32f1a0 --- /dev/null +++ b/UVtools.WPF/Assets/Icons/square-solid-16x16.png diff --git a/UVtools.WPF/Assets/Icons/sync-16x16.png b/UVtools.WPF/Assets/Icons/sync-16x16.png Binary files differnew file mode 100644 index 0000000..c5f7827 --- /dev/null +++ b/UVtools.WPF/Assets/Icons/sync-16x16.png diff --git a/UVtools.WPF/Assets/Icons/th-16x16.png b/UVtools.WPF/Assets/Icons/th-16x16.png Binary files differnew file mode 100644 index 0000000..16bfb6d --- /dev/null +++ b/UVtools.WPF/Assets/Icons/th-16x16.png diff --git a/UVtools.WPF/Assets/Icons/toolbox-16x16.png b/UVtools.WPF/Assets/Icons/toolbox-16x16.png Binary files differnew file mode 100644 index 0000000..fda6150 --- /dev/null +++ b/UVtools.WPF/Assets/Icons/toolbox-16x16.png diff --git a/UVtools.WPF/Assets/Icons/trash-16x16.png b/UVtools.WPF/Assets/Icons/trash-16x16.png Binary files differnew file mode 100644 index 0000000..ef9d610 --- /dev/null +++ b/UVtools.WPF/Assets/Icons/trash-16x16.png diff --git a/UVtools.WPF/Assets/Icons/undo-16x16.png b/UVtools.WPF/Assets/Icons/undo-16x16.png Binary files differnew file mode 100644 index 0000000..a9b83da --- /dev/null +++ b/UVtools.WPF/Assets/Icons/undo-16x16.png diff --git a/UVtools.WPF/Assets/Icons/undo-alt-16x16.png b/UVtools.WPF/Assets/Icons/undo-alt-16x16.png Binary files differnew file mode 100644 index 0000000..55f04c6 --- /dev/null +++ b/UVtools.WPF/Assets/Icons/undo-alt-16x16.png diff --git a/UVtools.WPF/Assets/Icons/warning-16x16.png b/UVtools.WPF/Assets/Icons/warning-16x16.png Binary files differnew file mode 100644 index 0000000..d29b583 --- /dev/null +++ b/UVtools.WPF/Assets/Icons/warning-16x16.png diff --git a/UVtools.WPF/Controls/AdvancedImageBox.cs b/UVtools.WPF/Controls/AdvancedImageBox.cs index 047feac..98c6ba2 100644 --- a/UVtools.WPF/Controls/AdvancedImageBox.cs +++ b/UVtools.WPF/Controls/AdvancedImageBox.cs @@ -11,6 +11,8 @@ using Avalonia.Media; using Avalonia.Media.Imaging; using Avalonia.Skia; using Avalonia.Styling; +using Avalonia.Visuals.Media.Imaging; +using SkiaSharp; using UVtools.Core.Extensions; @@ -525,6 +527,45 @@ namespace UVtools.WPF.Controls public virtual bool IsActualSize => Zoom == 100; + private ISolidColorBrush _pixelGridColor = Brushes.DimGray; + /// <summary> + /// Gets or sets the color of the pixel grid. + /// </summary> + /// <value>The color of the pixel grid.</value> + public virtual ISolidColorBrush PixelGridColor + { + get => _pixelGridColor; + set + { + if (PixelGridColor != value) + { + _pixelGridColor = value; + + //this.OnPixelGridColorChanged(EventArgs.Empty); + } + } + } + + private int _pixelGridThreshold = 5; + /// <summary> + /// Gets or sets the minimum size of zoomed pixel's before the pixel grid will be drawn + /// </summary> + /// <value>The pixel grid threshold.</value> + + public virtual int PixelGridThreshold + { + get => _pixelGridThreshold; + set + { + if (PixelGridThreshold != value) + { + _pixelGridThreshold = value; + + //this.OnPixelGridThresholdChanged(EventArgs.Empty); + } + } + } + //Our render target we compile everything to and present to the user private RenderTargetBitmap RenderTarget; @@ -778,11 +819,13 @@ namespace UVtools.WPF.Controls /// <param name="relativeDisplayPoint">The relative display point to offset scrolling by.</param> public virtual void ScrollTo(Point imageLocation, Point relativeDisplayPoint) { - var x = HorizontalScrollBarMaximum - imageLocation.X * ZoomFactor + relativeDisplayPoint.X; - var y = VerticalScrollBarMaximum - imageLocation.Y * ZoomFactor + relativeDisplayPoint.Y; + var x = imageLocation.X * ZoomFactor - relativeDisplayPoint.X; + var y = imageLocation.Y * ZoomFactor - relativeDisplayPoint.Y; Offset = new Vector(x, y); - Debug.WriteLine($"{Offset} | {HorizontalScrollBarMaximum},{VerticalScrollBarMaximum} | {HorizontalScrollBarValue},{VerticalScrollBarValue}"); + Debug.WriteLine($"{Offset} | " + + $"{relativeDisplayPoint} | " + + $"{HorizontalScrollBarValue},{VerticalScrollBarValue}"); } /// <summary> @@ -989,6 +1032,7 @@ namespace UVtools.WPF.Controls public void LoadImage(string path) { Image = new Bitmap(path); + Image.Save("D:\\test2.png"); //ImageControl.Source = Image; //ImageControl.InvalidateVisual(); } @@ -997,6 +1041,8 @@ namespace UVtools.WPF.Controls { Debug.WriteLine($"Render: {DateTime.Now.Ticks}"); // base.Render(context); + + // Draw Grid if (ShowGrid) { // draw the background @@ -1021,22 +1067,33 @@ namespace UVtools.WPF.Controls } if (Image is null) return; - - context.DrawImage(Image, 1.0, + // Draw iamge + context.DrawImage(Image, GetSourceImageRegion(), GetImageViewPort() ); - /*using (var surface = SKSurface.Create(SkiaContext.GrContext, RenderTarget)) + //SkiaContext.SkCanvas.dr + // Draw pixel grid + var pixelSize = ZoomFactor; + if (pixelSize > PixelGridThreshold) + { + Rect viewport = GetImageViewPort(); + var offsetX = Offset.X % pixelSize; + var offsetY = Offset.Y % pixelSize; + + Pen pen = new Pen(PixelGridColor); + for (double x = viewport.X + pixelSize - offsetX; x < viewport.Right; x += pixelSize) + { + context.DrawLine(pen, new Point(x, viewport.X), new Point(x, viewport.Bottom)); + } + + for (double y = viewport.Y + pixelSize - offsetY; y < viewport.Bottom; y += pixelSize) { - surface.Canvas.DrawImage(Image, 0f, 0f); - surface.Canvas.Flush(); - var textureImage = surface.Snapshot(); //This should be texture backed - }*/ - - /*context.DrawImage(RenderTarget, 1.0, - new Rect(0, 0, RenderTarget.PixelSize.Width, RenderTarget.PixelSize.Height), - new Rect(0, 0, Width, Height) - );*/ + context.DrawLine(pen, new Point(viewport.Y, y), new Point(viewport.Right, y)); + } + + context.DrawRectangle(pen, viewport); + } } /// <summary> diff --git a/UVtools.WPF/Extensions/BitmapExtension.cs b/UVtools.WPF/Extensions/BitmapExtension.cs new file mode 100644 index 0000000..deee547 --- /dev/null +++ b/UVtools.WPF/Extensions/BitmapExtension.cs @@ -0,0 +1,116 @@ +using System; +using System.Diagnostics; +using System.Runtime.InteropServices; +using Avalonia; +using Avalonia.Media.Imaging; +using Avalonia.Platform; +using Emgu.CV; +using Emgu.CV.CvEnum; +using SkiaSharp; +using UVtools.Core.Extensions; + +namespace UVtools.WPF.Extensions +{ + /// <summary> + /// Provide extension method to convert IInputArray to and from Bitmap + /// </summary> + public static class BitmapExtension + { + public static SKBitmap ToSkBitmap(this Mat mat) + { + SKBitmap bitmap; + Mat target = mat; + SKColorType colorType; + switch (mat.NumberOfChannels) + { + case 1: + colorType = SKColorType.Gray8; + break; + case 2: + colorType = SKColorType.Rg1616; + break; + case 3: + CvInvoke.CvtColor(mat, target, ColorConversion.Bgr2Bgra); + colorType = SKColorType.Bgra8888; + break; + case 4: + colorType = SKColorType.Bgra8888; + break; + default: + throw new Exception("Unknown color type"); + } + + bitmap = new SKBitmap(new SKImageInfo(target.Width, target.Height, colorType)); + bitmap.SetPixels(target.DataPointer); + return bitmap; + } + + public static SKImage ToSkImage(this Mat mat) + { + var bitmap = mat.ToSkBitmap(); + if (bitmap is null) return null; + return SKImage.FromBitmap(bitmap); + } + + public static Bitmap ToBitmap(this Mat mat) + { + if (mat.NumberOfChannels == 1) + { + var writeableBitmap = new WriteableBitmap(new PixelSize(mat.Width, mat.Height), new Vector(72, 72), + PixelFormat.Rgba8888, AlphaFormat.Unpremul); + var span = mat.GetPixelSpan<byte>(); + var bytes = new[] {0, 0, 0, 255}; + using (var lockBuffer = writeableBitmap.Lock()) + { + for (var i = 1; i < span.Length; i++) + { + bytes[0] = bytes[1] = bytes[2] = span[i]; + Marshal.Copy(bytes, 0, + new IntPtr(lockBuffer.Address.ToInt64() + i * 4), bytes.Length); + } + } + + return writeableBitmap; + } + + return null; + } + /*PixelFormat targetPixelFormat = PixelFormat.Bgra8888; + + switch (mat.NumberOfChannels) + { + case 3: + targetPixelFormat = PixelFormat.Rgb565; + break; + case 4: + targetPixelFormat = PixelFormat.Bgra8888; + break; + default: + throw new Exception("Unknown color type"); + } + + + var writeableBitmap = new WriteableBitmap(new PixelSize(mat.Width, mat.Height), new Vector(72, 72), targetPixelFormat, AlphaFormat.Unpremul); + using var lockBuffer = writeableBitmap.Lock(); + var buffer = mat.GetBytes(); + for (var y = 0; y < mat.Height; y++) + { + Marshal.Copy(buffer, y * lockBuffer.RowBytes, new IntPtr(lockBuffer.Address.ToInt64() + y * lockBuffer.RowBytes), lockBuffer.RowBytes); + } + //Marshal.Copy(buffer, 0, lockBuffer.Address, buffer.Length); + + SKBitmap bitmap = new SKBitmap(new SKImageInfo(mat.Width, mat.Height, SKColorType.Gray8)); + bitmap.SetPixels(mat.DataPointer); + Debug.WriteLine(bitmap.Info.ColorType); + + bitmap = SKBitmap.Decode(buffer.AsSpan(), new SKImageInfo + { + Width = mat.Width, + Height = mat.Height, + ColorType = SKColorType.Gray8, + });*/ + + /*return writeableBitmap; + }*/ + } +}
\ No newline at end of file diff --git a/UVtools.WPF/Extensions/WindowExtensions.cs b/UVtools.WPF/Extensions/WindowExtensions.cs new file mode 100644 index 0000000..191ae84 --- /dev/null +++ b/UVtools.WPF/Extensions/WindowExtensions.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; +using Avalonia.Controls; +using MessageBox.Avalonia.DTO; +using MessageBox.Avalonia.Enums; +using MessageBox.Avalonia.Models; + +namespace UVtools.WPF.Extensions +{ + public static class WindowExtensions + { + public static async Task<ButtonResult> MessageBoxGeneric(this Window window, string message, string title = null, + ButtonEnum buttons = ButtonEnum.Ok, Icon icon = Icon.None, WindowStartupLocation location = WindowStartupLocation.CenterOwner, Style style = Style.None) + { + var messageBoxStandardWindow = MessageBox.Avalonia.MessageBoxManager.GetMessageBoxStandardWindow( + new MessageBoxStandardParams + { + ButtonDefinitions = buttons, + ContentTitle = title ?? window.Title, + ContentMessage = message, + Icon = icon, + Style = style, + WindowStartupLocation = location, + CanResize = false + }); + + return await messageBoxStandardWindow.ShowDialog(window); + } + + public static async Task<ButtonResult> MessageBoxInfo(this Window window, string message, string title = null, ButtonEnum buttons = ButtonEnum.Ok, Style style = Style.None) + => await window.MessageBoxGeneric(message, title ?? $"{window.Title} Information", buttons, Icon.Info, WindowStartupLocation.CenterOwner, style); + + public static async Task<ButtonResult> MessageBoxError(this Window window, string message, string title = null, ButtonEnum buttons = ButtonEnum.Ok, Style style = Style.None) + => await window.MessageBoxGeneric(message, title ?? $"{window.Title} Error", buttons, Icon.Error, WindowStartupLocation.CenterOwner, style); + + public static async Task<ButtonResult> MessageBoxQuestion(this Window window, string message, string title = null, ButtonEnum buttons = ButtonEnum.YesNo, Style style = Style.None) + => await window.MessageBoxGeneric(message, title ?? $"{window.Title} Question", buttons, Icon.Info, WindowStartupLocation.CenterOwner, style); + + } +} diff --git a/UVtools.WPF/MainWindow.axaml b/UVtools.WPF/MainWindow.axaml index 0e97bee..6a55a48 100644 --- a/UVtools.WPF/MainWindow.axaml +++ b/UVtools.WPF/MainWindow.axaml @@ -2,20 +2,175 @@ 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:manager="clr-namespace:Avalonia.ThemeManager;assembly=Avalonia.ThemeManager" xmlns:uc="clr-namespace:UVtools.WPF.Controls" + xmlns:idc="clr-namespace:Dock.Avalonia.Controls;assembly=Dock.Avalonia" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" x:Class="UVtools.WPF.MainWindow" Title="UVtools"> - + <DockPanel> - <StackPanel DockPanel.Dock="Top" Orientation="Horizontal"> + <Menu DockPanel.Dock="Top"> + <MenuItem Name="MainMenu.File" Header="_File"> + <MenuItem Name="MainMenu.File.Open" Header="_Open" InputGesture="Ctrl+O" Command="{Binding MenuFileOpenClicked}"> + <MenuItem.Icon> + <Image Source="\Assets\Icons\open-16x16.png"/> + </MenuItem.Icon> + </MenuItem> + <MenuItem Name="MainMenu.File.OpenNewWindow" Header="Open in _new window" InputGesture="Ctrl+Shift+O" Command="{Binding ButtonClicked}"> + <MenuItem.Icon> + <Image Source="\Assets\Icons\open-16x16.png"/> + </MenuItem.Icon> + </MenuItem> + <MenuItem Name="MainMenu.File.Reload" Header="_Reload" InputGesture="Ctrl+F5" IsEnabled="{Binding IsFileLoaded}"> + <MenuItem.Icon> + <Image Source="\Assets\Icons\file-refresh-16x16.png"/> + </MenuItem.Icon> + </MenuItem> + <MenuItem Name="MainMenu.File.Save" Header="_Save" InputGesture="Ctrl+S"> + <MenuItem.Icon> + <Image Source="\Assets\Icons\save-16x16.png"/> + </MenuItem.Icon> + </MenuItem> + <MenuItem Name="MainMenu.File.SaveAs" Header="Save _as" InputGesture="Ctrl+Shift+S" IsEnabled="{Binding IsFileLoaded}"> + <MenuItem.Icon> + <Image Source="\Assets\Icons\save-as-16x16.png"/> + </MenuItem.Icon> + </MenuItem> + <MenuItem Name="MainMenu.File.Close" Header="_Close" InputGesture="Ctrl+W" IsEnabled="{Binding IsFileLoaded}"> + <MenuItem.Icon> + <Image Source="\Assets\Icons\file-close-16x16.png"/> + </MenuItem.Icon> + </MenuItem> + + <Separator/> + + <MenuItem Name="MainMenu.File.Extract" Header="_Extract" InputGesture="Ctrl+E" IsEnabled="{Binding IsFileLoaded}"> + <MenuItem.Icon> + <Image Source="\Assets\Icons\extract-object-16x16.png"/> + </MenuItem.Icon> + </MenuItem> + + <MenuItem Name="MainMenu.File.Convert" Header="_Convert to" IsEnabled="{Binding IsFileLoaded}"> + <MenuItem.Icon> + <Image Source="\Assets\Icons\convert-16x16.png"/> + </MenuItem.Icon> + </MenuItem> + + <Separator/> + + <MenuItem Name="MainMenu.File.Exit" Header="_Exit Alt+F4" InputGesture="Alt+F4"> + <MenuItem.Icon> + <Image Source="\Assets\Icons\exit-16x16.png"/> + </MenuItem.Icon> + </MenuItem> + </MenuItem> + <MenuItem Header="_Edit"> + <MenuItem Header="Copy"/> + <MenuItem Header="Paste"/> + </MenuItem> + </Menu> + + <Menu DockPanel.Dock="Bottom"> + <MenuItem Header="_File"> + <MenuItem Header="_Open..."/> + <Separator/> + <MenuItem Header="_Exit"/> + </MenuItem> + <MenuItem Header="_Edit"> + <MenuItem Header="Copy"/> + <MenuItem Header="Paste"/> + </MenuItem> + </Menu> + + <TabControl DockPanel.Dock="Left" Width="300"> + <TabItem Header="Information" VerticalContentAlignment="Center"> + <TextBlock Text="I am in the circle page !" HorizontalAlignment="Left" VerticalAlignment="Center"/> + </TabItem> + <TabItem> + <TabItem.Header> + <TextBlock VerticalAlignment="Center">Issues</TextBlock> + </TabItem.Header> + <StackPanel> + <TextBlock Text="I am in the triangle page ! I'll put a button to show you that each page contains what you want." HorizontalAlignment="Left" VerticalAlignment="Center"/> + <Button>A button in the triangle page !</Button> + </StackPanel> + </TabItem> + <TabItem> + <TabItem.Header> + <TextBlock VerticalAlignment="Center">GCode</TextBlock> + </TabItem.Header> + <StackPanel Orientation="Horizontal"> + <TextBlock Text="Square : " HorizontalAlignment="Left" VerticalAlignment="Center"/> + <Rectangle Fill="Blue" Width="63" Height="41"/> + </StackPanel> + </TabItem> + <TabItem> + <TabItem.Header> + <TextBlock VerticalAlignment="Center">Log</TextBlock> + </TabItem.Header> + <StackPanel Orientation="Horizontal"> + <TextBlock Text="Square : " HorizontalAlignment="Left" VerticalAlignment="Center"/> + <Rectangle Fill="Blue" Width="63" Height="41"/> + </StackPanel> + </TabItem> + </TabControl> + + <Grid DockPanel.Dock="Right" ColumnDefinitions="100*,1.5*,4*" RowDefinitions="Auto,Auto,*,Auto,Auto,Auto" Margin="5"> + <TextBlock Margin="0,0,0,10" Text="???" HorizontalAlignment="Center" TextAlignment="Center" Grid.Row="0"/> + <RepeatButton Grid.Row="1">Up</RepeatButton> + <Slider Margin="0,5,0,5" HorizontalAlignment="Center" Orientation="Vertical" Grid.Row="2"/> + <RepeatButton Grid.Row="3">Down</RepeatButton> + <StackPanel Margin="0,10,0,10" Grid.Row="4" Orientation="Horizontal"> + <Button Content="asd"/> + <Button Margin="5,0,5,0" Content="asd"/> + <Button Content="asd"/> + </StackPanel> + <TextBlock Text="???" HorizontalAlignment="Center" TextAlignment="Center" Grid.Row="5"/> + </Grid> + + + <!--<StackPanel DockPanel.Dock="Top" Orientation="Horizontal"> <Button Name="zoomtofit">Zoom to fit</Button> <Button Name="center">Center image</Button> - </StackPanel> - - <uc:AdvancedImageBox + </StackPanel>--> + + <Grid ColumnDefinitions="*" RowDefinitions="Auto,*,Auto" Margin="5"> + <Menu Grid.Row="0"> + <MenuItem Header="_File"> + <MenuItem Header="_Open..."/> + <Separator/> + <MenuItem Header="_Exit"/> + </MenuItem> + <MenuItem Header="_Edit"> + <MenuItem Header="Copy"/> + <MenuItem Header="Paste"/> + </MenuItem> + </Menu> + + <uc:AdvancedImageBox + Grid.Row="1" GridCellSize="15" - Name="Layer.ImageOld" + Name="Layer.Image" /> + + <Menu Grid.Row="2"> + <MenuItem Header="_File"> + <MenuItem Header="_Open..."/> + <Separator/> + <MenuItem Header="_Exit"/> + </MenuItem> + <MenuItem Header="_Edit"> + <MenuItem Header="Copy"/> + <MenuItem Header="Paste"/> + </MenuItem> + </Menu> + + + </Grid> + + </DockPanel> + + </Window> diff --git a/UVtools.WPF/MainWindow.axaml.cs b/UVtools.WPF/MainWindow.axaml.cs index f4b19ff..01cc19c 100644 --- a/UVtools.WPF/MainWindow.axaml.cs +++ b/UVtools.WPF/MainWindow.axaml.cs @@ -1,30 +1,103 @@ -using Avalonia; +using System; +using System.ComponentModel; +using System.IO; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; using Avalonia.Controls; using Avalonia.Markup.Xaml; +using MessageBox.Avalonia.DTO; +using MessageBox.Avalonia.Enums; +using MessageBox.Avalonia.Models; +using SkiaSharp; +using UVtools.Core.FileFormats; using UVtools.WPF.Controls; +using UVtools.WPF.Extensions; +using UVtools.WPF.ViewModels; namespace UVtools.WPF { - public class MainWindow : Window + public class MainWindow : Window, 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> + 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; + eventHandler?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } + #endregion + + public MainWindowViewModel ViewModel { get; } + + + + + + public AdvancedImageBox LayerImage; public Button ZoomToFitButton; public Button CenterButton; + public MainWindow() { InitializeComponent(); #if DEBUG - this.AttachDevTools(); + //this.AttachDevTools(); #endif - LayerImage = this.FindControl<AdvancedImageBox>("Layer.ImageOld"); + App.Selector?.EnableThemes(this); + + ViewModel = new MainWindowViewModel(this); + DataContext = ViewModel; + + LayerImage = this.FindControl<AdvancedImageBox>("Layer.Image"); ZoomToFitButton = this.FindControl<Button>("zoomtofit"); CenterButton = this.FindControl<Button>("center"); - LayerImage.LoadImage(@"D:\Tiago\Desktop\UVtools\body_Tough0.1mm_SL1_5h16m_HOLLOW_DRAIN\body_Tough0.1mm_SL1_5h16m_HOLLOW_DRAIN00000.png"); + //LayerImage.LoadImage(@"D:\Test.png"); - ZoomToFitButton.Click += (sender, args) => LayerImage.ZoomToFit(); - CenterButton.Click += (sender, args) => LayerImage.CenterAt(1440/2,2560/2); + //ZoomToFitButton.Click += (sender, args) => LayerImage.ZoomToFit(); + //CenterButton.Click += (sender, args) => LayerImage.CenterAt(1440/2,2560/2); //var layerImage = this.FindControl<AdvancedPictureBox>("Layer.ImageOld"); - //layerImage.LoadImage(@"D:\Tiago\Desktop\UVtools\body_Tough0.1mm_SL1_5h16m_HOLLOW_DRAIN\body_Tough0.1mm_SL1_5h16m_HOLLOW_DRAIN00000.png"); + LayerImage.LoadImage(@"D:\Tiago\Desktop\UVtools\body_Tough0.1mm_SL1_5h16m_HOLLOW_DRAIN\body_Tough0.1mm_SL1_5h16m_HOLLOW_DRAIN00000.png"); } private void InitializeComponent() @@ -32,11 +105,85 @@ namespace UVtools.WPF AvaloniaXamlLoader.Load(this); } - public override void EndInit() + public void ProcessFiles(string[] files, bool openNewWindow = false) { - base.EndInit(); + if (files is null || files.Length == 0) return; + + for (int i = 0; i < files.Length; i++) + { + if (i == 0 && !openNewWindow) + { + ProcessFile(files[i]); + continue; + } + + + } + } + + void ReloadFile(uint actualLayer = 0) + { + if (App.SlicerFile is null) return; + ProcessFile(App.SlicerFile.FileFullPath, actualLayer); + } + + void ProcessFile(string fileName, uint actualLayer = 0) + { + var fileNameOnly = Path.GetFileName(fileName); + App.SlicerFile = FileFormat.FindByExtension(fileName, true, true); + if (App.SlicerFile is null) return; + + var task = Task.Factory.StartNew(() => + { + try + { + App.SlicerFile.Decode(fileName); + } + catch (OperationCanceledException) + { + App.SlicerFile.Clear(); + } + finally + { + /* Invoke((MethodInvoker)delegate + { + // Running on the UI thread + EnableGUI(true); + });*/ + } + }); + + task.Wait(); + + var mat = App.SlicerFile[0].LayerMat; + var matRgb = App.SlicerFile[0].BrgMat; + + var skbitmapGray = mat.ToSkBitmap(); + using (var image = SKImage.FromBitmap(skbitmapGray)) + using (var data = image.Encode(SKEncodedImageFormat.Png, 80)) + { + // save the data to a stream + using (var stream = File.OpenWrite("D:\\gray.png")) + { + data.SaveTo(stream); + } + } + - //layerImage.LoadImage(@"D:\Tiago\Desktop\UVtools\body_Tough0.1mm_SL1_5h16m_HOLLOW_DRAIN\body_Tough0.1mm_SL1_5h16m_HOLLOW_DRAIN00000.png"); + + var skbitmapRBG = matRgb.ToSkBitmap(); + using (var image = SKImage.FromBitmap(skbitmapRBG)) + using (var data = image.Encode(SKEncodedImageFormat.Png, 80)) + { + // save the data to a stream + using (var stream = File.OpenWrite("D:\\rgb.png")) + { + data.SaveTo(stream); + } + } + + //Avalonia.Skia.SkiaSharpExtensions. + //LayerImage.Image = bitmap; } } } diff --git a/UVtools.WPF/Program.cs b/UVtools.WPF/Program.cs index 2124998..ea81577 100644 --- a/UVtools.WPF/Program.cs +++ b/UVtools.WPF/Program.cs @@ -1,5 +1,4 @@ using Avalonia; -using Avalonia.Logging.Serilog; namespace UVtools.WPF { diff --git a/UVtools.WPF/Themes/UVtools.themes b/UVtools.WPF/Themes/UVtools.themes new file mode 100644 index 0000000..caf7d59 --- /dev/null +++ b/UVtools.WPF/Themes/UVtools.themes @@ -0,0 +1,58 @@ +[ + { + "Name": "UVtoolsLight", + "ThemeAccentColor": "#CC119EDA", + "ThemeAccentColor2": "#99119EDA", + "ThemeAccentColor3": "#66119EDA", + "ThemeAccentColor4": "#33119EDA", + "ThemeBackgroundColor": "#FFFFFFFF", + "ThemeBorderLowColor": "#FFAAAAAA", + "ThemeBorderMidColor": "#FF888888", + "ThemeBorderHighColor": "#FF333333", + "ThemeControlLowColor": "#FFFFFFFF", + "ThemeControlMidColor": "#FFAAAAAA", + "ThemeControlHighColor": "#FF888888", + "ThemeControlHighlightLowColor": "#FFF0F0F0", + "ThemeControlHighlightMidColor": "#FFD0D0D0", + "ThemeControlHighlightHighColor": "#FF808080", + "ThemeForegroundColor": "#FF000000", + "ThemeForegroundLowColor": "#FF808080", + "HighlightColor": "#FF086F9E", + "ErrorColor": "#FFFF0000", + "ErrorLowColor": "#10FF0000", + "ThemeBorderThickness": "1", + "ThemeDisabledOpacity": 0.5, + "FontSizeSmall": 12.0, + "FontSizeNormal": 14.0, + "FontSizeLarge": 18.0, + "ScrollBarThickness": 20.0 + }, + { + "Name": "UVtoolsDark", + "ThemeAccentColor": "#CC119EDA", + "ThemeAccentColor2": "#99119EDA", + "ThemeAccentColor3": "#66119EDA", + "ThemeAccentColor4": "#33119EDA", + "ThemeBackgroundColor": "#FF282828", + "ThemeBorderLowColor": "#FF505050", + "ThemeBorderMidColor": "#FF808080", + "ThemeBorderHighColor": "#FFA0A0A0", + "ThemeControlLowColor": "#FF282828", + "ThemeControlMidColor": "#FF505050", + "ThemeControlHighColor": "#FF808080", + "ThemeControlHighlightLowColor": "#FFA8A8A8", + "ThemeControlHighlightMidColor": "#FF828282", + "ThemeControlHighlightHighColor": "#FF505050", + "ThemeForegroundColor": "#FFDEDEDE", + "ThemeForegroundLowColor": "#FF808080", + "HighlightColor": "#FF119EDA", + "ErrorColor": "#FFFF0000", + "ErrorLowColor": "#10FF0000", + "ThemeBorderThickness": "11", + "ThemeDisabledOpacity": 0.5, + "FontSizeSmall": 12.0, + "FontSizeNormal": 14.0, + "FontSizeLarge": 18.0, + "ScrollBarThickness": 20.0 + } +]
\ No newline at end of file diff --git a/UVtools.WPF/Themes/UVtoolsDark.xaml b/UVtools.WPF/Themes/UVtoolsDark.xaml new file mode 100644 index 0000000..2c8dfc6 --- /dev/null +++ b/UVtools.WPF/Themes/UVtoolsDark.xaml @@ -0,0 +1,58 @@ +<Style xmlns="https://github.com/avaloniaui" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:sys="clr-namespace:System;assembly=mscorlib"> + <Style.Resources> + + <Color x:Key="ThemeAccentColor">#CC119EDA</Color> + <Color x:Key="ThemeAccentColor2">#99119EDA</Color> + <Color x:Key="ThemeAccentColor3">#66119EDA</Color> + <Color x:Key="ThemeAccentColor4">#33119EDA</Color> + + <Color x:Key="ThemeBackgroundColor">#FF282828</Color> + <Color x:Key="ThemeBorderLowColor">#FF505050</Color> + <Color x:Key="ThemeBorderMidColor">#FF808080</Color> + <Color x:Key="ThemeBorderHighColor">#FFA0A0A0</Color> + <Color x:Key="ThemeControlLowColor">#FF282828</Color> + <Color x:Key="ThemeControlMidColor">#FF505050</Color> + <Color x:Key="ThemeControlHighColor">#FF808080</Color> + <Color x:Key="ThemeControlHighlightLowColor">#FFA8A8A8</Color> + <Color x:Key="ThemeControlHighlightMidColor">#FF828282</Color> + <Color x:Key="ThemeControlHighlightHighColor">#FF505050</Color> + <Color x:Key="ThemeForegroundColor">#FFDEDEDE</Color> + <Color x:Key="ThemeForegroundLowColor">#FF808080</Color> + + <Color x:Key="HighlightColor">#FF119EDA</Color> + <Color x:Key="ErrorColor">#FFFF0000</Color> + <Color x:Key="ErrorLowColor">#10FF0000</Color> + + <SolidColorBrush x:Key="ThemeBackgroundBrush" Color="{DynamicResource ThemeBackgroundColor}"></SolidColorBrush> + <SolidColorBrush x:Key="ThemeBorderLowBrush" Color="{DynamicResource ThemeBorderLowColor}"></SolidColorBrush> + <SolidColorBrush x:Key="ThemeBorderMidBrush" Color="{DynamicResource ThemeBorderMidColor}"></SolidColorBrush> + <SolidColorBrush x:Key="ThemeBorderHighBrush" Color="{DynamicResource ThemeBorderHighColor}"></SolidColorBrush> + <SolidColorBrush x:Key="ThemeControlLowBrush" Color="{DynamicResource ThemeControlLowColor}"></SolidColorBrush> + <SolidColorBrush x:Key="ThemeControlMidBrush" Color="{DynamicResource ThemeControlMidColor}"></SolidColorBrush> + <SolidColorBrush x:Key="ThemeControlHighBrush" Color="{DynamicResource ThemeControlHighColor}"></SolidColorBrush> + <SolidColorBrush x:Key="ThemeControlHighlightLowBrush" Color="{DynamicResource ThemeControlHighlightLowColor}"></SolidColorBrush> + <SolidColorBrush x:Key="ThemeControlHighlightMidBrush" Color="{DynamicResource ThemeControlHighlightMidColor}"></SolidColorBrush> + <SolidColorBrush x:Key="ThemeControlHighlightHighBrush" Color="{DynamicResource ThemeControlHighlightHighColor}"></SolidColorBrush> + <SolidColorBrush x:Key="ThemeForegroundBrush" Color="{DynamicResource ThemeForegroundColor}"></SolidColorBrush> + <SolidColorBrush x:Key="ThemeForegroundLowBrush" Color="{DynamicResource ThemeForegroundLowColor}"></SolidColorBrush> + + <SolidColorBrush x:Key="HighlightBrush" Color="{DynamicResource HighlightColor}"></SolidColorBrush> + <SolidColorBrush x:Key="ThemeAccentBrush" Color="{DynamicResource ThemeAccentColor}"></SolidColorBrush> + <SolidColorBrush x:Key="ThemeAccentBrush2" Color="{DynamicResource ThemeAccentColor2}"></SolidColorBrush> + <SolidColorBrush x:Key="ThemeAccentBrush3" Color="{DynamicResource ThemeAccentColor3}"></SolidColorBrush> + <SolidColorBrush x:Key="ThemeAccentBrush4" Color="{DynamicResource ThemeAccentColor4}"></SolidColorBrush> + <SolidColorBrush x:Key="ErrorBrush" Color="{DynamicResource ErrorColor}"></SolidColorBrush> + <SolidColorBrush x:Key="ErrorLowBrush" Color="{DynamicResource ErrorLowColor}"></SolidColorBrush> + + <Thickness x:Key="ThemeBorderThickness">11</Thickness> + <sys:Double x:Key="ThemeDisabledOpacity">0.5</sys:Double> + + <sys:Double x:Key="FontSizeSmall">12</sys:Double> + <sys:Double x:Key="FontSizeNormal">14</sys:Double> + <sys:Double x:Key="FontSizeLarge">18</sys:Double> + + <sys:Double x:Key="ScrollBarThickness">20</sys:Double> + </Style.Resources> +</Style> diff --git a/UVtools.WPF/Themes/UVtoolsLight.xaml b/UVtools.WPF/Themes/UVtoolsLight.xaml new file mode 100644 index 0000000..3dadc1d --- /dev/null +++ b/UVtools.WPF/Themes/UVtoolsLight.xaml @@ -0,0 +1,58 @@ +<Style xmlns="https://github.com/avaloniaui" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:sys="clr-namespace:System;assembly=mscorlib"> + <Style.Resources> + + <Color x:Key="ThemeAccentColor">#CC119EDA</Color> + <Color x:Key="ThemeAccentColor2">#99119EDA</Color> + <Color x:Key="ThemeAccentColor3">#66119EDA</Color> + <Color x:Key="ThemeAccentColor4">#33119EDA</Color> + + <Color x:Key="ThemeBackgroundColor">#FFFFFFFF</Color> + <Color x:Key="ThemeBorderLowColor">#FFAAAAAA</Color> + <Color x:Key="ThemeBorderMidColor">#FF888888</Color> + <Color x:Key="ThemeBorderHighColor">#FF333333</Color> + <Color x:Key="ThemeControlLowColor">#FFFFFFFF</Color> + <Color x:Key="ThemeControlMidColor">#FFAAAAAA</Color> + <Color x:Key="ThemeControlHighColor">#FF888888</Color> + <Color x:Key="ThemeControlHighlightLowColor">#FFF0F0F0</Color> + <Color x:Key="ThemeControlHighlightMidColor">#FFD0D0D0</Color> + <Color x:Key="ThemeControlHighlightHighColor">#FF808080</Color> + <Color x:Key="ThemeForegroundColor">#FF000000</Color> + <Color x:Key="ThemeForegroundLowColor">#FF808080</Color> + + <Color x:Key="HighlightColor">#FF086F9E</Color> + <Color x:Key="ErrorColor">#FFFF0000</Color> + <Color x:Key="ErrorLowColor">#10FF0000</Color> + + <SolidColorBrush x:Key="ThemeBackgroundBrush" Color="{DynamicResource ThemeBackgroundColor}"></SolidColorBrush> + <SolidColorBrush x:Key="ThemeBorderLowBrush" Color="{DynamicResource ThemeBorderLowColor}"></SolidColorBrush> + <SolidColorBrush x:Key="ThemeBorderMidBrush" Color="{DynamicResource ThemeBorderMidColor}"></SolidColorBrush> + <SolidColorBrush x:Key="ThemeBorderHighBrush" Color="{DynamicResource ThemeBorderHighColor}"></SolidColorBrush> + <SolidColorBrush x:Key="ThemeControlLowBrush" Color="{DynamicResource ThemeControlLowColor}"></SolidColorBrush> + <SolidColorBrush x:Key="ThemeControlMidBrush" Color="{DynamicResource ThemeControlMidColor}"></SolidColorBrush> + <SolidColorBrush x:Key="ThemeControlHighBrush" Color="{DynamicResource ThemeControlHighColor}"></SolidColorBrush> + <SolidColorBrush x:Key="ThemeControlHighlightLowBrush" Color="{DynamicResource ThemeControlHighlightLowColor}"></SolidColorBrush> + <SolidColorBrush x:Key="ThemeControlHighlightMidBrush" Color="{DynamicResource ThemeControlHighlightMidColor}"></SolidColorBrush> + <SolidColorBrush x:Key="ThemeControlHighlightHighBrush" Color="{DynamicResource ThemeControlHighlightHighColor}"></SolidColorBrush> + <SolidColorBrush x:Key="ThemeForegroundBrush" Color="{DynamicResource ThemeForegroundColor}"></SolidColorBrush> + <SolidColorBrush x:Key="ThemeForegroundLowBrush" Color="{DynamicResource ThemeForegroundLowColor}"></SolidColorBrush> + + <SolidColorBrush x:Key="HighlightBrush" Color="{DynamicResource HighlightColor}"></SolidColorBrush> + <SolidColorBrush x:Key="ThemeAccentBrush" Color="{DynamicResource ThemeAccentColor}"></SolidColorBrush> + <SolidColorBrush x:Key="ThemeAccentBrush2" Color="{DynamicResource ThemeAccentColor2}"></SolidColorBrush> + <SolidColorBrush x:Key="ThemeAccentBrush3" Color="{DynamicResource ThemeAccentColor3}"></SolidColorBrush> + <SolidColorBrush x:Key="ThemeAccentBrush4" Color="{DynamicResource ThemeAccentColor4}"></SolidColorBrush> + <SolidColorBrush x:Key="ErrorBrush" Color="{DynamicResource ErrorColor}"></SolidColorBrush> + <SolidColorBrush x:Key="ErrorLowBrush" Color="{DynamicResource ErrorLowColor}"></SolidColorBrush> + + <Thickness x:Key="ThemeBorderThickness">1</Thickness> + <sys:Double x:Key="ThemeDisabledOpacity">0.5</sys:Double> + + <sys:Double x:Key="FontSizeSmall">12</sys:Double> + <sys:Double x:Key="FontSizeNormal">14</sys:Double> + <sys:Double x:Key="FontSizeLarge">18</sys:Double> + + <sys:Double x:Key="ScrollBarThickness">20</sys:Double> + </Style.Resources> +</Style> diff --git a/UVtools.WPF/UVtools.WPF.csproj b/UVtools.WPF/UVtools.WPF.csproj index 2f7542f..31d7731 100644 --- a/UVtools.WPF/UVtools.WPF.csproj +++ b/UVtools.WPF/UVtools.WPF.csproj @@ -6,11 +6,35 @@ <ApplicationIcon>UVtools.ico</ApplicationIcon> </PropertyGroup> <ItemGroup> - <PackageReference Include="Avalonia" Version="0.9.11" /> + <PackageReference Include="Avalonia" Version="0.10.0-preview5" /> <PackageReference Include="Avalonia.Angle.Windows.Natives" Version="2.1.0.2019013001" /> - <PackageReference Include="Avalonia.Desktop" Version="0.9.11" /> + <PackageReference Include="Avalonia.Desktop" Version="0.10.0-preview5" /> + <PackageReference Include="Avalonia.ThemeManager" Version="0.10.0-preview3" /> + <PackageReference Include="Dock.Avalonia" Version="0.10.0-preview5" /> + <PackageReference Include="Emgu.CV.runtime.windows" Version="4.4.0.4061" /> + <PackageReference Include="MessageBox.Avalonia" Version="0.10.0-prev2" /> </ItemGroup> <ItemGroup> <ProjectReference Include="..\UVtools.Core\UVtools.Core.csproj" /> </ItemGroup> + <ItemGroup> + <AvaloniaResource Include="Assets\Icons\*" /> + </ItemGroup> + <ItemGroup> + <None Update="Themes - Copy\UVtoolsDark.xaml"> + <Generator>MSBuild:Compile</Generator> + </None> + <None Update="Themes - Copy\UVtoolsLight.xaml"> + <Generator>MSBuild:Compile</Generator> + </None> + <None Update="Themes\UVtools.themes"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </None> + <None Update="Themes\UVtoolsDark.xaml"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </None> + <None Update="Themes\UVtoolsLight.xaml"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </None> + </ItemGroup> </Project> diff --git a/UVtools.WPF/ViewModels/MainWindowViewModel.cs b/UVtools.WPF/ViewModels/MainWindowViewModel.cs new file mode 100644 index 0000000..c69bf7f --- /dev/null +++ b/UVtools.WPF/ViewModels/MainWindowViewModel.cs @@ -0,0 +1,32 @@ +using System.Diagnostics; +using Avalonia.Controls; +using JetBrains.Annotations; +using MessageBox.Avalonia.DTO; +using MessageBox.Avalonia.Enums; +using MessageBox.Avalonia.Models; +using UVtools.Core.Objects; +using UVtools.WPF.Extensions; + +namespace UVtools.WPF.ViewModels +{ + public class MainWindowViewModel : BindableBase + { + private MainWindow Parent; + public bool IsFileLoaded => !ReferenceEquals(App.SlicerFile, null); + + public MainWindowViewModel(MainWindow parent) + { + Parent = parent; + } + + public async void MenuFileOpenClicked() + { + var dialog = new OpenFileDialog + { + AllowMultiple = false, + }; + var files = await dialog.ShowAsync(Parent); + Parent.ProcessFiles(files); + } + } +} |