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 new file mode 100644 index 0000000..c28c621 Binary files /dev/null and b/UVtools.WPF/Assets/Icons/Back-16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/Button-Info-16x16.png b/UVtools.WPF/Assets/Icons/Button-Info-16x16.png new file mode 100644 index 0000000..560873d Binary files /dev/null and b/UVtools.WPF/Assets/Icons/Button-Info-16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/CNCMachine-16x16.png b/UVtools.WPF/Assets/Icons/CNCMachine-16x16.png new file mode 100644 index 0000000..e2a5e4b Binary files /dev/null and b/UVtools.WPF/Assets/Icons/CNCMachine-16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/Cancel-24x24.png b/UVtools.WPF/Assets/Icons/Cancel-24x24.png new file mode 100644 index 0000000..74e4559 Binary files /dev/null and b/UVtools.WPF/Assets/Icons/Cancel-24x24.png differ diff --git a/UVtools.WPF/Assets/Icons/Cancel-32x32.png b/UVtools.WPF/Assets/Icons/Cancel-32x32.png new file mode 100644 index 0000000..a732caa Binary files /dev/null and b/UVtools.WPF/Assets/Icons/Cancel-32x32.png differ diff --git a/UVtools.WPF/Assets/Icons/DataList-16x16.png b/UVtools.WPF/Assets/Icons/DataList-16x16.png new file mode 100644 index 0000000..a4e784c Binary files /dev/null and b/UVtools.WPF/Assets/Icons/DataList-16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/Donate-16x16.png b/UVtools.WPF/Assets/Icons/Donate-16x16.png new file mode 100644 index 0000000..37378b3 Binary files /dev/null and b/UVtools.WPF/Assets/Icons/Donate-16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/GCode-16x16.png b/UVtools.WPF/Assets/Icons/GCode-16x16.png new file mode 100644 index 0000000..127cecc Binary files /dev/null and b/UVtools.WPF/Assets/Icons/GCode-16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/Geometry-16x16.png b/UVtools.WPF/Assets/Icons/Geometry-16x16.png new file mode 100644 index 0000000..da022c5 Binary files /dev/null and b/UVtools.WPF/Assets/Icons/Geometry-16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/Global-Network-icon-16x16.png b/UVtools.WPF/Assets/Icons/Global-Network-icon-16x16.png new file mode 100644 index 0000000..0c4e3be Binary files /dev/null and b/UVtools.WPF/Assets/Icons/Global-Network-icon-16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/Lock-16x16.png b/UVtools.WPF/Assets/Icons/Lock-16x16.png new file mode 100644 index 0000000..8af4d26 Binary files /dev/null and b/UVtools.WPF/Assets/Icons/Lock-16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/Next-16x16.png b/UVtools.WPF/Assets/Icons/Next-16x16.png new file mode 100644 index 0000000..9d8f5e4 Binary files /dev/null and b/UVtools.WPF/Assets/Icons/Next-16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/Ok-24x24.png b/UVtools.WPF/Assets/Icons/Ok-24x24.png new file mode 100644 index 0000000..e4cc79d Binary files /dev/null and b/UVtools.WPF/Assets/Icons/Ok-24x24.png differ diff --git a/UVtools.WPF/Assets/Icons/PhotoInfo-16x16.png b/UVtools.WPF/Assets/Icons/PhotoInfo-16x16.png new file mode 100644 index 0000000..f6a4c2f Binary files /dev/null and b/UVtools.WPF/Assets/Icons/PhotoInfo-16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/Wrench-16x16.png b/UVtools.WPF/Assets/Icons/Wrench-16x16.png new file mode 100644 index 0000000..2838a76 Binary files /dev/null and b/UVtools.WPF/Assets/Icons/Wrench-16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/accept-16x16.png b/UVtools.WPF/Assets/Icons/accept-16x16.png new file mode 100644 index 0000000..3b3abf8 Binary files /dev/null and b/UVtools.WPF/Assets/Icons/accept-16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/arrow-down-16x16.png b/UVtools.WPF/Assets/Icons/arrow-down-16x16.png new file mode 100644 index 0000000..9ce51bb Binary files /dev/null and b/UVtools.WPF/Assets/Icons/arrow-down-16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/arrow-down-double-16x16.png b/UVtools.WPF/Assets/Icons/arrow-down-double-16x16.png new file mode 100644 index 0000000..7393d68 Binary files /dev/null and b/UVtools.WPF/Assets/Icons/arrow-down-double-16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/arrow-end-16x16.png b/UVtools.WPF/Assets/Icons/arrow-end-16x16.png new file mode 100644 index 0000000..ce9d9c7 Binary files /dev/null and b/UVtools.WPF/Assets/Icons/arrow-end-16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/arrow-top-16x16.png b/UVtools.WPF/Assets/Icons/arrow-top-16x16.png new file mode 100644 index 0000000..8afa1a0 Binary files /dev/null and b/UVtools.WPF/Assets/Icons/arrow-top-16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/arrow-up-16x16.png b/UVtools.WPF/Assets/Icons/arrow-up-16x16.png new file mode 100644 index 0000000..585744a Binary files /dev/null and b/UVtools.WPF/Assets/Icons/arrow-up-16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/blur-16x16.png b/UVtools.WPF/Assets/Icons/blur-16x16.png new file mode 100644 index 0000000..8132066 Binary files /dev/null and b/UVtools.WPF/Assets/Icons/blur-16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/bowling-ball-16x16.png b/UVtools.WPF/Assets/Icons/bowling-ball-16x16.png new file mode 100644 index 0000000..f231665 Binary files /dev/null and b/UVtools.WPF/Assets/Icons/bowling-ball-16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/burn-16x16.png b/UVtools.WPF/Assets/Icons/burn-16x16.png new file mode 100644 index 0000000..217963c Binary files /dev/null and b/UVtools.WPF/Assets/Icons/burn-16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/checkbox-marked-16x16.png b/UVtools.WPF/Assets/Icons/checkbox-marked-16x16.png new file mode 100644 index 0000000..ab94ab3 Binary files /dev/null and b/UVtools.WPF/Assets/Icons/checkbox-marked-16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/checkbox-unmarked-16x16.png b/UVtools.WPF/Assets/Icons/checkbox-unmarked-16x16.png new file mode 100644 index 0000000..697bb74 Binary files /dev/null and b/UVtools.WPF/Assets/Icons/checkbox-unmarked-16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/chessboard-16x16.png b/UVtools.WPF/Assets/Icons/chessboard-16x16.png new file mode 100644 index 0000000..e12226e Binary files /dev/null and b/UVtools.WPF/Assets/Icons/chessboard-16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/clipboard-16x16.png b/UVtools.WPF/Assets/Icons/clipboard-16x16.png new file mode 100644 index 0000000..42f9370 Binary files /dev/null and b/UVtools.WPF/Assets/Icons/clipboard-16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/code-16x16.png b/UVtools.WPF/Assets/Icons/code-16x16.png new file mode 100644 index 0000000..6aa33a4 Binary files /dev/null and b/UVtools.WPF/Assets/Icons/code-16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/compress-alt-16x16.png b/UVtools.WPF/Assets/Icons/compress-alt-16x16.png new file mode 100644 index 0000000..a2129b8 Binary files /dev/null and b/UVtools.WPF/Assets/Icons/compress-alt-16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/convert-16x16.png b/UVtools.WPF/Assets/Icons/convert-16x16.png new file mode 100644 index 0000000..76cf3c4 Binary files /dev/null and b/UVtools.WPF/Assets/Icons/convert-16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/copy_16x16.png b/UVtools.WPF/Assets/Icons/copy_16x16.png new file mode 100644 index 0000000..562239a Binary files /dev/null and b/UVtools.WPF/Assets/Icons/copy_16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/crop-16x16.png b/UVtools.WPF/Assets/Icons/crop-16x16.png new file mode 100644 index 0000000..225c344 Binary files /dev/null and b/UVtools.WPF/Assets/Icons/crop-16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/crosshairs-16x16.png b/UVtools.WPF/Assets/Icons/crosshairs-16x16.png new file mode 100644 index 0000000..62e9eef Binary files /dev/null and b/UVtools.WPF/Assets/Icons/crosshairs-16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/cursor-16x16.png b/UVtools.WPF/Assets/Icons/cursor-16x16.png new file mode 100644 index 0000000..b0eeaa0 Binary files /dev/null and b/UVtools.WPF/Assets/Icons/cursor-16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/delete-16x16.png b/UVtools.WPF/Assets/Icons/delete-16x16.png new file mode 100644 index 0000000..b5842b7 Binary files /dev/null and b/UVtools.WPF/Assets/Icons/delete-16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/exit-16x16.png b/UVtools.WPF/Assets/Icons/exit-16x16.png new file mode 100644 index 0000000..863566c Binary files /dev/null and b/UVtools.WPF/Assets/Icons/exit-16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/expand-16x16.png b/UVtools.WPF/Assets/Icons/expand-16x16.png new file mode 100644 index 0000000..a8c87f4 Binary files /dev/null and b/UVtools.WPF/Assets/Icons/expand-16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/expand-alt-16x16.png b/UVtools.WPF/Assets/Icons/expand-alt-16x16.png new file mode 100644 index 0000000..22b181f Binary files /dev/null and b/UVtools.WPF/Assets/Icons/expand-alt-16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/extract-object-16x16.png b/UVtools.WPF/Assets/Icons/extract-object-16x16.png new file mode 100644 index 0000000..9bdb1d2 Binary files /dev/null and b/UVtools.WPF/Assets/Icons/extract-object-16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/eye-16x16.png b/UVtools.WPF/Assets/Icons/eye-16x16.png new file mode 100644 index 0000000..4f3c7e2 Binary files /dev/null and b/UVtools.WPF/Assets/Icons/eye-16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/eye-24x24.png b/UVtools.WPF/Assets/Icons/eye-24x24.png new file mode 100644 index 0000000..4f3c7e2 Binary files /dev/null and b/UVtools.WPF/Assets/Icons/eye-24x24.png differ diff --git a/UVtools.WPF/Assets/Icons/file-close-16x16.png b/UVtools.WPF/Assets/Icons/file-close-16x16.png new file mode 100644 index 0000000..ef36711 Binary files /dev/null and b/UVtools.WPF/Assets/Icons/file-close-16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/file-image-16x16.png b/UVtools.WPF/Assets/Icons/file-image-16x16.png new file mode 100644 index 0000000..7e10379 Binary files /dev/null and b/UVtools.WPF/Assets/Icons/file-image-16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/file-import-16x16.png b/UVtools.WPF/Assets/Icons/file-import-16x16.png new file mode 100644 index 0000000..1712317 Binary files /dev/null and b/UVtools.WPF/Assets/Icons/file-import-16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/file-refresh-16x16.png b/UVtools.WPF/Assets/Icons/file-refresh-16x16.png new file mode 100644 index 0000000..39d6920 Binary files /dev/null and b/UVtools.WPF/Assets/Icons/file-refresh-16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/filter-filled-16x16.png b/UVtools.WPF/Assets/Icons/filter-filled-16x16.png new file mode 100644 index 0000000..a19d124 Binary files /dev/null and b/UVtools.WPF/Assets/Icons/filter-filled-16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/flip-16x16.png b/UVtools.WPF/Assets/Icons/flip-16x16.png new file mode 100644 index 0000000..138d97a Binary files /dev/null and b/UVtools.WPF/Assets/Icons/flip-16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/internet-explorer-16x16.png b/UVtools.WPF/Assets/Icons/internet-explorer-16x16.png new file mode 100644 index 0000000..b5b3ea6 Binary files /dev/null and b/UVtools.WPF/Assets/Icons/internet-explorer-16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/island-16x16.png b/UVtools.WPF/Assets/Icons/island-16x16.png new file mode 100644 index 0000000..d9b45d6 Binary files /dev/null and b/UVtools.WPF/Assets/Icons/island-16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/ladder-16x16.png b/UVtools.WPF/Assets/Icons/ladder-16x16.png new file mode 100644 index 0000000..de76c84 Binary files /dev/null and b/UVtools.WPF/Assets/Icons/ladder-16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/layers-16x16.png b/UVtools.WPF/Assets/Icons/layers-16x16.png new file mode 100644 index 0000000..b8f66f5 Binary files /dev/null and b/UVtools.WPF/Assets/Icons/layers-16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/layers-alt-16x16.png b/UVtools.WPF/Assets/Icons/layers-alt-16x16.png new file mode 100644 index 0000000..230e11b Binary files /dev/null and b/UVtools.WPF/Assets/Icons/layers-alt-16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/list-16x16.png b/UVtools.WPF/Assets/Icons/list-16x16.png new file mode 100644 index 0000000..85d6795 Binary files /dev/null and b/UVtools.WPF/Assets/Icons/list-16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/log-16x16.png b/UVtools.WPF/Assets/Icons/log-16x16.png new file mode 100644 index 0000000..55d7785 Binary files /dev/null and b/UVtools.WPF/Assets/Icons/log-16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/map-marker-16x16.png b/UVtools.WPF/Assets/Icons/map-marker-16x16.png new file mode 100644 index 0000000..a0523b2 Binary files /dev/null and b/UVtools.WPF/Assets/Icons/map-marker-16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/mask-16x16.png b/UVtools.WPF/Assets/Icons/mask-16x16.png new file mode 100644 index 0000000..0a450a4 Binary files /dev/null and b/UVtools.WPF/Assets/Icons/mask-16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/microchip_16x16.png b/UVtools.WPF/Assets/Icons/microchip_16x16.png new file mode 100644 index 0000000..ca399d8 Binary files /dev/null and b/UVtools.WPF/Assets/Icons/microchip_16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/minus_16x16.png b/UVtools.WPF/Assets/Icons/minus_16x16.png new file mode 100644 index 0000000..4fd33f9 Binary files /dev/null and b/UVtools.WPF/Assets/Icons/minus_16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/move-16x16.png b/UVtools.WPF/Assets/Icons/move-16x16.png new file mode 100644 index 0000000..a018770 Binary files /dev/null and b/UVtools.WPF/Assets/Icons/move-16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/object-group-16x16.png b/UVtools.WPF/Assets/Icons/object-group-16x16.png new file mode 100644 index 0000000..e5cd1e9 Binary files /dev/null and b/UVtools.WPF/Assets/Icons/object-group-16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/open-16x16.png b/UVtools.WPF/Assets/Icons/open-16x16.png new file mode 100644 index 0000000..40fcd9a Binary files /dev/null and b/UVtools.WPF/Assets/Icons/open-16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/pattern-16x16.png b/UVtools.WPF/Assets/Icons/pattern-16x16.png new file mode 100644 index 0000000..714d8b5 Binary files /dev/null and b/UVtools.WPF/Assets/Icons/pattern-16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/photo-16x16.png b/UVtools.WPF/Assets/Icons/photo-16x16.png new file mode 100644 index 0000000..af90fe0 Binary files /dev/null and b/UVtools.WPF/Assets/Icons/photo-16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/pixel-16x16.png b/UVtools.WPF/Assets/Icons/pixel-16x16.png new file mode 100644 index 0000000..d7c46a7 Binary files /dev/null and b/UVtools.WPF/Assets/Icons/pixel-16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/plus-16x16.png b/UVtools.WPF/Assets/Icons/plus-16x16.png new file mode 100644 index 0000000..7614e37 Binary files /dev/null and b/UVtools.WPF/Assets/Icons/plus-16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/pointer-16x16.png b/UVtools.WPF/Assets/Icons/pointer-16x16.png new file mode 100644 index 0000000..fadbd93 Binary files /dev/null and b/UVtools.WPF/Assets/Icons/pointer-16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/refresh-16x16.png b/UVtools.WPF/Assets/Icons/refresh-16x16.png new file mode 100644 index 0000000..c5f7827 Binary files /dev/null and b/UVtools.WPF/Assets/Icons/refresh-16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/resize-16x16.png b/UVtools.WPF/Assets/Icons/resize-16x16.png new file mode 100644 index 0000000..3ba586c Binary files /dev/null and b/UVtools.WPF/Assets/Icons/resize-16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/save-16x16.png b/UVtools.WPF/Assets/Icons/save-16x16.png new file mode 100644 index 0000000..38ce759 Binary files /dev/null and b/UVtools.WPF/Assets/Icons/save-16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/save-as-16x16.png b/UVtools.WPF/Assets/Icons/save-as-16x16.png new file mode 100644 index 0000000..e22cce7 Binary files /dev/null and b/UVtools.WPF/Assets/Icons/save-as-16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/search-16x16.png b/UVtools.WPF/Assets/Icons/search-16x16.png new file mode 100644 index 0000000..ea9d8e2 Binary files /dev/null and b/UVtools.WPF/Assets/Icons/search-16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/settings-16x16.png b/UVtools.WPF/Assets/Icons/settings-16x16.png new file mode 100644 index 0000000..83e560c Binary files /dev/null and b/UVtools.WPF/Assets/Icons/settings-16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/sort-alpha-up-16x16.png b/UVtools.WPF/Assets/Icons/sort-alpha-up-16x16.png new file mode 100644 index 0000000..765a4dd Binary files /dev/null and b/UVtools.WPF/Assets/Icons/sort-alpha-up-16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/square-solid-16x16.png b/UVtools.WPF/Assets/Icons/square-solid-16x16.png new file mode 100644 index 0000000..d32f1a0 Binary files /dev/null and b/UVtools.WPF/Assets/Icons/square-solid-16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/sync-16x16.png b/UVtools.WPF/Assets/Icons/sync-16x16.png new file mode 100644 index 0000000..c5f7827 Binary files /dev/null and b/UVtools.WPF/Assets/Icons/sync-16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/th-16x16.png b/UVtools.WPF/Assets/Icons/th-16x16.png new file mode 100644 index 0000000..16bfb6d Binary files /dev/null and b/UVtools.WPF/Assets/Icons/th-16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/toolbox-16x16.png b/UVtools.WPF/Assets/Icons/toolbox-16x16.png new file mode 100644 index 0000000..fda6150 Binary files /dev/null and b/UVtools.WPF/Assets/Icons/toolbox-16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/trash-16x16.png b/UVtools.WPF/Assets/Icons/trash-16x16.png new file mode 100644 index 0000000..ef9d610 Binary files /dev/null and b/UVtools.WPF/Assets/Icons/trash-16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/undo-16x16.png b/UVtools.WPF/Assets/Icons/undo-16x16.png new file mode 100644 index 0000000..a9b83da Binary files /dev/null and b/UVtools.WPF/Assets/Icons/undo-16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/undo-alt-16x16.png b/UVtools.WPF/Assets/Icons/undo-alt-16x16.png new file mode 100644 index 0000000..55f04c6 Binary files /dev/null and b/UVtools.WPF/Assets/Icons/undo-alt-16x16.png differ diff --git a/UVtools.WPF/Assets/Icons/warning-16x16.png b/UVtools.WPF/Assets/Icons/warning-16x16.png new file mode 100644 index 0000000..d29b583 Binary files /dev/null and b/UVtools.WPF/Assets/Icons/warning-16x16.png differ 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; + /// + /// Gets or sets the color of the pixel grid. + /// + /// The color of the pixel grid. + public virtual ISolidColorBrush PixelGridColor + { + get => _pixelGridColor; + set + { + if (PixelGridColor != value) + { + _pixelGridColor = value; + + //this.OnPixelGridColorChanged(EventArgs.Empty); + } + } + } + + private int _pixelGridThreshold = 5; + /// + /// Gets or sets the minimum size of zoomed pixel's before the pixel grid will be drawn + /// + /// The pixel grid threshold. + + 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 /// The relative display point to offset scrolling by. 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}"); } /// @@ -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)) - { - surface.Canvas.DrawImage(Image, 0f, 0f); - surface.Canvas.Flush(); - var textureImage = surface.Snapshot(); //This should be texture backed - }*/ + //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; - /*context.DrawImage(RenderTarget, 1.0, - new Rect(0, 0, RenderTarget.PixelSize.Width, RenderTarget.PixelSize.Height), - new Rect(0, 0, Width, Height) - );*/ + 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) + { + context.DrawLine(pen, new Point(viewport.Y, y), new Point(viewport.Right, y)); + } + + context.DrawRectangle(pen, viewport); + } } /// 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 +{ + /// + /// Provide extension method to convert IInputArray to and from Bitmap + /// + 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(); + 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 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 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 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 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"> - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Issues + + + + + + + + + GCode + + + + + + + + + Log + + + + + + + + + + + Up + + Down + +