From e550fdc2668177fd70ecc730bd70ad5e6003fa17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tiago=20Concei=C3=A7=C3=A3o?= Date: Sun, 21 Aug 2022 23:39:20 +0100 Subject: [PATCH] v3.6.2 - (Add) Debug sub menu to test some behaviours (Only when compiled in debug mode, not visible on public release) - (Add) Utility method `LayerExists` to the file formats to know if specific layer index exists in the collection - (Improvement) Add loaded file information to the crash dialog message - (Fix) Message dialog height do not expand with text (#537) - (Fix) Crash when all layers get removed and UI attempt to show a layer (#538) --- CHANGELOG.md | 8 ++ CREDITS.md | 3 +- RELEASE_NOTES.md | 7 +- UVtools.Cmd/UVtools.Cmd.csproj | 2 +- UVtools.Core/FileFormats/FileFormat.cs | 20 +++- UVtools.Core/UVtools.Core.csproj | 2 +- UVtools.InstallerMM/UVtools.InstallerMM.wxs | 59 +--------- UVtools.WPF/App.axaml.cs | 92 ++++++++++------ UVtools.WPF/Assets/Styles/Styles.xaml | 36 ++++++- .../Tools/ToolCalculatorControl.axaml | 6 +- UVtools.WPF/Controls/WindowEx.cs | 2 + UVtools.WPF/MainWindow.LayerPreview.cs | 14 ++- UVtools.WPF/MainWindow.axaml | 19 +++- UVtools.WPF/MainWindow.axaml.cs | 10 ++ UVtools.WPF/Program.cs | 7 +- UVtools.WPF/UVtools.WPF.csproj | 4 +- UVtools.WPF/Windows/AboutWindow.axaml | 42 +++----- UVtools.WPF/Windows/BenchmarkWindow.axaml | 2 +- UVtools.WPF/Windows/CantRunWindow.axaml | 102 ------------------ UVtools.WPF/Windows/CantRunWindow.axaml.cs | 38 ------- .../Windows/MaterialManagerWindow.axaml | 12 +-- UVtools.WPF/Windows/MessageWindow.axaml | 4 +- UVtools.WPF/Windows/MessageWindow.axaml.cs | 88 ++++++++++++--- .../Windows/MissingInformationWindow.axaml | 2 +- .../Windows/SuggestionSettingsWindow.axaml | 2 +- UVtools.WPF/Windows/ToolWindow.axaml | 2 +- UVtools.WPF/Windows/ToolWindow.axaml.cs | 4 +- 27 files changed, 278 insertions(+), 311 deletions(-) delete mode 100644 UVtools.WPF/Windows/CantRunWindow.axaml delete mode 100644 UVtools.WPF/Windows/CantRunWindow.axaml.cs diff --git a/CHANGELOG.md b/CHANGELOG.md index 36aa75a6..c258400f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 21/08/2022 - v3.6.2 + +- (Add) Debug sub menu to test some behaviours (Only when compiled in debug mode, not visible on public release) +- (Add) Utility method `LayerExists` to the file formats to know if specific layer index exists in the collection +- (Improvement) Add loaded file information to the crash dialog message +- (Fix) Message dialog height do not expand with text (#537) +- (Fix) Crash when all layers get removed and UI attempt to show a layer (#538) + ## 19/08/2022 - v3.6.1 - (Fix) GCode: Improve the regex for parsing layer index from comments, also fixes chitubox zip format layer parsing diff --git a/CREDITS.md b/CREDITS.md index 3f78f2dd..07ad5c05 100644 --- a/CREDITS.md +++ b/CREDITS.md @@ -72,4 +72,5 @@ - Ed Wagaman - Marcin Chomiczuk - Patrick Hofmann -- Ajilus \ No newline at end of file +- Ajilus +- James F Hammond \ No newline at end of file diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index f84e0338..1d470b97 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,3 +1,6 @@ -- (Fix) GCode: Improve the regex for parsing layer index from comments, also fixes chitubox zip format layer parsing -- (Fix) MacOS: Auto updater was not copying the files to the right location, leading to not upgrade the program. However this version still need to update manually +- (Add) Debug sub menu to test some behaviours (Only when compiled in debug mode, not visible on public release) +- (Add) Utility method `LayerExists` to the file formats to know if specific layer index exists in the collection +- (Improvement) Add loaded file information to the crash dialog message +- (Fix) Message dialog height do not expand with text (#537) +- (Fix) Crash when all layers get removed and UI attempt to show a layer (#538) diff --git a/UVtools.Cmd/UVtools.Cmd.csproj b/UVtools.Cmd/UVtools.Cmd.csproj index 448c116b..6889d5e2 100644 --- a/UVtools.Cmd/UVtools.Cmd.csproj +++ b/UVtools.Cmd/UVtools.Cmd.csproj @@ -21,7 +21,7 @@ - + diff --git a/UVtools.Core/FileFormats/FileFormat.cs b/UVtools.Core/FileFormats/FileFormat.cs index d1796be7..fd7481d3 100644 --- a/UVtools.Core/FileFormats/FileFormat.cs +++ b/UVtools.Core/FileFormats/FileFormat.cs @@ -1294,7 +1294,7 @@ public Layer[] Layers /// /// Gets the last layer index /// - public uint LastLayerIndex => LayerCount - 1; + public uint LastLayerIndex => LayerCount > 0 ? LayerCount - 1 : 0; /// /// Gets the first layer @@ -5415,7 +5415,25 @@ public Layer[] AllocateAndSetFromMat(Mat[] mats, OperationProgress? progress = n return layers; } + /// + /// Checks if a layer index exists in the collection + /// + /// Layer index to check + /// + public bool LayerExists(int layerIndex) + { + return layerIndex >= 0 && layerIndex < LayerCount; + } + /// + /// Checks if a layer index exists in the collection + /// + /// Layer index to check + /// + public bool LayerExists(uint layerIndex) + { + return layerIndex < LayerCount; + } #endregion #region Layer methods diff --git a/UVtools.Core/UVtools.Core.csproj b/UVtools.Core/UVtools.Core.csproj index 11f6740a..ad1e2e36 100644 --- a/UVtools.Core/UVtools.Core.csproj +++ b/UVtools.Core/UVtools.Core.csproj @@ -10,7 +10,7 @@ https://github.com/sn4k3/UVtools https://github.com/sn4k3/UVtools MSLA/DLP, file analysis, calibration, repair, conversion and manipulation - 3.6.1 + 3.6.2 Copyright © 2020 PTRTECH UVtools.png AnyCPU;x64 diff --git a/UVtools.InstallerMM/UVtools.InstallerMM.wxs b/UVtools.InstallerMM/UVtools.InstallerMM.wxs index 8203d5ca..8807e58a 100644 --- a/UVtools.InstallerMM/UVtools.InstallerMM.wxs +++ b/UVtools.InstallerMM/UVtools.InstallerMM.wxs @@ -2,7 +2,7 @@ - + @@ -1286,9 +1286,6 @@ - - - @@ -1303,9 +1300,6 @@ - - - @@ -1320,9 +1314,6 @@ - - - @@ -1337,9 +1328,6 @@ - - - @@ -1354,9 +1342,6 @@ - - - @@ -1371,9 +1356,6 @@ - - - @@ -1388,9 +1370,6 @@ - - - @@ -1405,9 +1384,6 @@ - - - @@ -1422,9 +1398,6 @@ - - - @@ -1439,9 +1412,6 @@ - - - @@ -1456,9 +1426,6 @@ - - - @@ -1473,9 +1440,6 @@ - - - @@ -1490,9 +1454,6 @@ - - - @@ -1536,24 +1497,6 @@ - - - - - - - - - - - - - - - - - - diff --git a/UVtools.WPF/App.axaml.cs b/UVtools.WPF/App.axaml.cs index d959c170..674362a0 100644 --- a/UVtools.WPF/App.axaml.cs +++ b/UVtools.WPF/App.axaml.cs @@ -48,6 +48,19 @@ public enum ApplicationTheme [Description("Default dark")] DefaultDark } + + public static bool IsDebug + { + get + { +#if DEBUG + return true; +#else + return false; +#endif + } + } + //public static ThemeSelector ThemeSelector { get; set; } public static MainWindow MainWindow = null!; public static FileFormat? SlicerFile = null; @@ -207,10 +220,15 @@ public override void OnFrameworkInitializationCompleted() if (Program.IsCrashReport) { //Program.Args = new[] {"--crash-report", "Debug", "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum." }; + if (Program.Args.Length < 3) return; if (string.IsNullOrWhiteSpace(Program.Args[1])) return; - if(string.IsNullOrWhiteSpace(Program.Args[2])) return; + if (string.IsNullOrWhiteSpace(Program.Args[2])) return; var category = Program.Args[1]; var message = $"{Program.Args[2]}\nCategory: {category}"; + if (Program.Args.Length >= 4 && !string.IsNullOrWhiteSpace(Program.Args[3])) + { + message += $"\nFile: {Program.Args[3]}"; + } var bugReportMessageMk = $"# Report\n```\n{message}\n```"; @@ -227,7 +245,7 @@ public override void OnFrameworkInitializationCompleted() var append2 = $"\n\nMachine date time: {DateTime.Now}\n UTC date time: {DateTime.UtcNow}"; message += append2; - bugReportMessageMk += $"{append2}\n\n# Additional information and Workflow\nComplete with additional information and the workflow that caused this crash."; + bugReportMessageMk += $"{append2}\n\n# Additional information and Workflow\nComplete with additional information and the workflow that caused this crash with the file as well."; try { @@ -237,40 +255,18 @@ public override void OnFrameworkInitializationCompleted() { // ignored } + - - var reportButton = MessageWindow.CreateButton("Report", "fa-solid fa-bug"); - reportButton.Click += (sender, e) => - { - Current?.Clipboard?.SetTextAsync(bugReportMessageMk); - using var reader = new StringReader(message); - SystemAware.OpenBrowser($"https://github.com/sn4k3/UVtools/issues/new?assignees=sn4k3&labels=&template=bug_report.md&title={HttpUtility.UrlEncode($"[Crash] {reader.ReadLine()}")}&body={HttpUtility.UrlEncode("")}"); - e.Handled = true; - }; - - var helpButton = MessageWindow.CreateButton("Help", "fa-solid fa-question"); - helpButton.Click += (sender, e) => - { - Current?.Clipboard?.SetTextAsync(bugReportMessageMk); - SystemAware.OpenBrowser("https://github.com/sn4k3/UVtools/discussions/categories/q-a"); - e.Handled = true; - }; - - var restartButton = MessageWindow.CreateButton("Restart", "fa-solid fa-redo-alt"); - restartButton.Click += (sender, e) => - { - SystemAware.StartThisApplication(); - }; - + using var reader = new StringReader(message); desktop.MainWindow = new MessageWindow($"{About.SoftwareWithVersion} - Crash report", "fa-regular fa-frown", $"{About.Software} crashed due an unexpected {category.ToLowerInvariant()} error.\nYou can report this error if you find necessary.\nFind more details below:\n", message, new[] { - reportButton, - helpButton, - restartButton, + MessageWindow.CreateLinkButtonAction("Report", "fa-solid fa-bug", $"https://github.com/sn4k3/UVtools/issues/new?assignees=sn4k3&labels=&template=bug_report.md&title={HttpUtility.UrlEncode($"[Crash] {reader.ReadLine()}")}&body={HttpUtility.UrlEncode("")}", () => Current?.Clipboard?.SetTextAsync(bugReportMessageMk)), + MessageWindow.CreateLinkButtonAction("Help", "fa-solid fa-question", "https://github.com/sn4k3/UVtools/discussions/categories/q-a", () => Current?.Clipboard?.SetTextAsync(bugReportMessageMk)), + MessageWindow.CreateButtonAction("Restart", "fa-solid fa-redo-alt", () => SystemAware.StartThisApplication()), MessageWindow.CreateCloseButton("fa-solid fa-sign-out-alt") }); } @@ -280,12 +276,38 @@ public override void OnFrameworkInitializationCompleted() { if (!CvInvoke.Init()) { - desktop.MainWindow = new CantRunWindow(); + desktop.MainWindow = new MessageWindow($"{About.SoftwareWithVersion} is unable to run", + "fa-regular fa-frown", + $"{About.SoftwareWithVersionArch} [{SystemAware.OperatingSystemName}]\nUnable to run due one or more missing dependencies.\nTriggered by: libcvextern (OpenCV)", + "Your system doesn't have the required dependencies in order to run.\n" + + "Those dependencies are required at libcvextern/OpenCV library.\n" + + "UVtools is built on top of the OpenCV and therefore cannot run.\n\n" + + "Please install or build the dependencies in order to run the software.\n" + + "Check the manual page at 'Requirements' section for help.", + new[] + { + MessageWindow.CreateLinkButton("Open manual", "fa-brands fa-edge", "https://github.com/sn4k3/UVtools#requirements"), + MessageWindow.CreateLinkButton("Ask for help", "fa-solid fa-question", "https://github.com/sn4k3/UVtools/discussions/categories/q-a"), + MessageWindow.CreateCloseButton("fa-solid fa-sign-out-alt") + }); } } catch (Exception e) { - desktop.MainWindow = new CantRunWindow(); + desktop.MainWindow = new MessageWindow($"{About.SoftwareWithVersion} is unable to run", + "fa-regular fa-frown", + $"{About.SoftwareWithVersionArch} [{SystemAware.OperatingSystemName}]\nUnable to run due one or more missing dependencies.\nTriggered by: libcvextern (OpenCV)", + "Your system doesn't have the required dependencies in order to run.\n" + + "Those dependencies are required at libcvextern/OpenCV library.\n" + + "UVtools is built on top of the OpenCV and therefore cannot run.\n\n" + + "Please install or build the dependencies in order to run the software.\n" + + "Check the manual page at 'Requirements' section for help.", + new[] + { + MessageWindow.CreateLinkButton("Open manual", "fa-brands fa-edge", "https://github.com/sn4k3/UVtools#requirements"), + MessageWindow.CreateLinkButton("Ask for help", "fa-solid fa-question", "https://github.com/sn4k3/UVtools/discussions/categories/q-a"), + MessageWindow.CreateCloseButton("fa-solid fa-sign-out-alt") + }); Console.WriteLine(e.ToString()); } @@ -321,7 +343,7 @@ public override void OnFrameworkInitializationCompleted() base.OnFrameworkInitializationCompleted(); } - #region Utilities +#region Utilities public static string ApplicationPath => AppContext.BaseDirectory; public static readonly string AppExecutable = Environment.ProcessPath!; public static readonly string AppExecutableQuoted = $"\"{AppExecutable}\""; @@ -403,9 +425,9 @@ public static Stream GetAsset(string url) return null; } - #endregion +#endregion - #region Assembly properties +#region Assembly properties public static Assembly WpfAssembly => Assembly.GetExecutingAssembly(); public static string AssemblyVersion => WpfAssembly.GetName().Version?.ToString()!; @@ -471,5 +493,5 @@ public static string AssemblyCompany return attributes.Length == 0 ? string.Empty : ((AssemblyCompanyAttribute)attributes[0]).Company; } } - #endregion +#endregion } \ No newline at end of file diff --git a/UVtools.WPF/Assets/Styles/Styles.xaml b/UVtools.WPF/Assets/Styles/Styles.xaml index 144009a1..d74492ad 100644 --- a/UVtools.WPF/Assets/Styles/Styles.xaml +++ b/UVtools.WPF/Assets/Styles/Styles.xaml @@ -42,13 +42,47 @@ + + + + + + + + +