From 14194900f799dc2c4051a0e2fff71ed4d0c201f0 Mon Sep 17 00:00:00 2001 From: John Lewin Date: Sat, 10 Mar 2018 23:01:28 -0800 Subject: [PATCH] Revise About page - Swtich from html to GuiWidgets for layout - Simplify with DialogPage - remove AboutWindow, AboutWidget - Remove AboutPage namespace --- AboutPage/AboutPage.cs | 119 +++++++++++++++++ AboutPage/AboutWidget.cs | 120 ------------------ AboutPage/AboutWindow.cs | 75 ----------- AboutPage/CheckForUpdatesPage.cs | 2 +- AboutPage/UpdateControlData.cs | 1 - .../ApplicationSettingsView.cs | 3 +- MatterControl.csproj | 3 +- PartPreviewWindow/PartPreviewContent.cs | 1 - SetupWizard/DialogPage.cs | 2 +- SetupWizard/PublishPartToMatterHackers.cs | 2 +- 10 files changed, 124 insertions(+), 204 deletions(-) create mode 100644 AboutPage/AboutPage.cs delete mode 100644 AboutPage/AboutWidget.cs delete mode 100644 AboutPage/AboutWindow.cs diff --git a/AboutPage/AboutPage.cs b/AboutPage/AboutPage.cs new file mode 100644 index 000000000..c03b1e8db --- /dev/null +++ b/AboutPage/AboutPage.cs @@ -0,0 +1,119 @@ +/* +Copyright (c) 2017, Lars Brubaker, John Lewin +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +The views and conclusions contained in the software and documentation are those +of the authors and should not be interpreted as representing official policies, +either expressed or implied, of the FreeBSD Project. +*/ + +using System.IO; +using MatterHackers.Agg; +using MatterHackers.Agg.Platform; +using MatterHackers.Agg.UI; +using MatterHackers.Localizations; +using MatterHackers.MatterControl.ContactForm; +using MatterHackers.MatterControl.CustomWidgets; +using MatterHackers.VectorMath; + +namespace MatterHackers.MatterControl +{ + public class AboutPage : DialogPage + { + public AboutPage() + : base("Close".Localize()) + { + this.WindowTitle = "About".Localize() + " " + ApplicationController.Instance.ProductName; + + var theme = ApplicationController.Instance.Theme; + + this.WindowSize = new Vector2(500 * GuiWidget.DeviceScale, 550 * GuiWidget.DeviceScale); + + headerRow.CloseAllChildren(); + + headerRow.HAnchor = HAnchor.Center | HAnchor.Fit; + headerRow.AddChild(new TextWidget("MatterControl".Localize(), pointSize: 20) { Margin = new BorderDouble(right: 3) }); + headerRow.AddChild(new TextWidget("TM".Localize(), pointSize: 7) { VAnchor = VAnchor.Top }); + + contentRow.AddChild( + new TextWidget("Version".Localize() + " " + VersionInfo.Instance.BuildVersion, pointSize: theme.DefaultFontSize) + { + HAnchor = HAnchor.Center + }); + + contentRow.AddChild( + new TextWidget("Developed By".Localize() + ": " + "MatterHackers", pointSize: theme.DefaultFontSize) + { + HAnchor = HAnchor.Center + }); + + contentRow.AddChild( + new ImageWidget( + AggContext.StaticData.LoadIcon(Path.Combine("..", "Images", "mh-logo.png"), 250, 250)) + { + HAnchor = HAnchor.Center, + Margin = new BorderDouble(0, 25) + }); + + contentRow.AddChild(new VerticalSpacer()); + + var button = new TextButton("Send Feedback", theme) + { + HAnchor = HAnchor.Center, + VAnchor = VAnchor.Absolute, + BackgroundColor = theme.MinimalShade, + Margin = new BorderDouble(bottom: 20) + }; + button.Click += (s, e) => UiThread.RunOnIdle(() => + { + ContactFormWindow.Open(); + }); + + contentRow.AddChild(button); + + var siteLink = theme.LinkButtonFactory.Generate("www.matterhackers.com"); + siteLink.HAnchor = HAnchor.Center; + siteLink.Cursor = Cursors.Hand; + siteLink.Click += (s, e) => UiThread.RunOnIdle(() => + { + ApplicationController.Instance.LaunchBrowser("http://www.matterhackers.com"); + }); + contentRow.AddChild(siteLink); + + contentRow.AddChild( + new TextWidget("Copyright © 2018 MatterHackers, Inc.", pointSize: theme.DefaultFontSize) + { + HAnchor = HAnchor.Center, + }); + + var clearCacheLink = theme.LinkButtonFactory.Generate("Clear Cache".Localize()); + clearCacheLink.HAnchor = HAnchor.Center; + clearCacheLink.Cursor = Cursors.Hand; + clearCacheLink.Click += (s, e) => UiThread.RunOnIdle(() => + { + AboutWidget.DeleteCacheData(0); + }); + contentRow.AddChild(clearCacheLink); + } + } +} \ No newline at end of file diff --git a/AboutPage/AboutWidget.cs b/AboutPage/AboutWidget.cs deleted file mode 100644 index 7d5a73b4c..000000000 --- a/AboutPage/AboutWidget.cs +++ /dev/null @@ -1,120 +0,0 @@ -/* -Copyright (c) 2018, Lars Brubaker, John Lewin -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -The views and conclusions contained in the software and documentation are those -of the authors and should not be interpreted as representing official policies, -either expressed or implied, of the FreeBSD Project. -*/ - -using System; -using System.IO; -using MatterHackers.Agg; -using MatterHackers.Agg.Platform; -using MatterHackers.Agg.UI; - -namespace MatterHackers.MatterControl -{ - public class AboutWidget : GuiWidget - { - public AboutWidget() - { - this.HAnchor = HAnchor.Stretch; - this.VAnchor = VAnchor.Top; - - this.Padding = new BorderDouble(5); - this.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; - - FlowLayoutWidget customInfoTopToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom); - customInfoTopToBottom.Name = "AboutPageCustomInfo"; - customInfoTopToBottom.HAnchor = HAnchor.Stretch; - customInfoTopToBottom.VAnchor = VAnchor.MaxFitOrStretch; - customInfoTopToBottom.Padding = new BorderDouble(5, 10, 5, 0); - - if (UserSettings.Instance.IsTouchScreen) - { - customInfoTopToBottom.AddChild(new UpdateControlView(ApplicationController.Instance.Theme)); - } - - //AddMatterHackersInfo(customInfoTopToBottom); - customInfoTopToBottom.AddChild(new GuiWidget(1, 10)); - - string aboutHtmlFile = Path.Combine("OEMSettings", "AboutPage.html"); - string htmlContent = AggContext.StaticData.ReadAllText(aboutHtmlFile); - -#if false // test - { - SystemWindow releaseNotes = new SystemWindow(640, 480); - string releaseNotesFile = Path.Combine("OEMSettings", "ReleaseNotes.html"); - string releaseNotesContent = AggContext.StaticData.ReadAllText(releaseNotesFile); - HtmlWidget content = new HtmlWidget(releaseNotesContent, Color.Black); - content.AddChild(new GuiWidget(HAnchor.AbsolutePosition, VAnchor.Stretch)); - content.VAnchor |= VAnchor.Top; - content.BackgroundColor = Color.White; - releaseNotes.AddChild(content); - releaseNotes.BackgroundColor = Color.Cyan; - UiThread.RunOnIdle((state) => - { - releaseNotes.ShowAsSystemWindow(); - }, 1); - } -#endif - - HtmlWidget htmlWidget = new HtmlWidget(htmlContent, ActiveTheme.Instance.PrimaryTextColor); - - customInfoTopToBottom.AddChild(htmlWidget); - - this.AddChild(customInfoTopToBottom); - } - - public string CreateCenteredButton(string content) - { - throw new NotImplementedException(); - } - - public string CreateLinkButton(string content) - { - throw new NotImplementedException(); - } - - public string DoToUpper(string content) - { - throw new NotImplementedException(); - } - - public string DoTranslate(string content) - { - throw new NotImplementedException(); - } - - public string GetBuildString(string content) - { - return VersionInfo.Instance.BuildVersion; - } - - public string GetVersionString(string content) - { - return VersionInfo.Instance.ReleaseVersion; - } - } -} \ No newline at end of file diff --git a/AboutPage/AboutWindow.cs b/AboutPage/AboutWindow.cs deleted file mode 100644 index 93738d885..000000000 --- a/AboutPage/AboutWindow.cs +++ /dev/null @@ -1,75 +0,0 @@ -/* -Copyright (c) 2017, Lars Brubaker, John Lewin -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -The views and conclusions contained in the software and documentation are those -of the authors and should not be interpreted as representing official policies, -either expressed or implied, of the FreeBSD Project. -*/ - -using MatterHackers.Agg.UI; -using MatterHackers.Localizations; - -namespace MatterHackers.MatterControl -{ - public class AboutWindow : SystemWindow - { - private static AboutWindow aboutWindow = null; - - public AboutWindow(TextImageButtonFactory textImageButtonFactory) - : base(500, 640) - { - GuiWidget aboutPage = new AboutWidget(); - aboutPage.AnchorAll(); - this.AddChild(aboutPage); - - Button cancelButton = textImageButtonFactory.Generate("Close".Localize()); - cancelButton.Click += (s, e) => - { - UiThread.RunOnIdle(aboutWindow.Close); - }; - cancelButton.HAnchor = HAnchor.Right; - this.AddChild(cancelButton); - - this.Title = "About".Localize() + " " + ApplicationController.Instance.ProductName; - this.AlwaysOnTopOfMain = true; - this.ShowAsSystemWindow(); - } - - public static void Show() - { - if (aboutWindow == null) - { - aboutWindow = new AboutWindow(ApplicationController.Instance.Theme.ButtonFactory); - aboutWindow.Closed += (parentSender, e) => - { - aboutWindow = null; - }; - } - else - { - aboutWindow.BringToFront(); - } - } - } -} \ No newline at end of file diff --git a/AboutPage/CheckForUpdatesPage.cs b/AboutPage/CheckForUpdatesPage.cs index 5812cfd58..5c14abcbd 100644 --- a/AboutPage/CheckForUpdatesPage.cs +++ b/AboutPage/CheckForUpdatesPage.cs @@ -5,7 +5,7 @@ using MatterHackers.Agg.UI; using MatterHackers.Localizations; using MatterHackers.MatterControl.CustomWidgets; -namespace MatterHackers.MatterControl.AboutPage +namespace MatterHackers.MatterControl { public class CheckForUpdatesPage : DialogPage { diff --git a/AboutPage/UpdateControlData.cs b/AboutPage/UpdateControlData.cs index 10ee1a2d9..33dc4bae7 100644 --- a/AboutPage/UpdateControlData.cs +++ b/AboutPage/UpdateControlData.cs @@ -38,7 +38,6 @@ using MatterHackers.Agg; using MatterHackers.Agg.Platform; using MatterHackers.Agg.UI; using MatterHackers.Localizations; -using MatterHackers.MatterControl.AboutPage; using MatterHackers.MatterControl.DataStorage; using MatterHackers.MatterControl.SettingsManagement; using MatterHackers.MatterControl.VersionManagement; diff --git a/ConfigurationPage/ApplicationSettings/ApplicationSettingsView.cs b/ConfigurationPage/ApplicationSettings/ApplicationSettingsView.cs index 1391c922d..27a8d8299 100644 --- a/ConfigurationPage/ApplicationSettings/ApplicationSettingsView.cs +++ b/ConfigurationPage/ApplicationSettings/ApplicationSettingsView.cs @@ -36,7 +36,6 @@ using MatterHackers.Agg; using MatterHackers.Agg.Platform; using MatterHackers.Agg.UI; using MatterHackers.Localizations; -using MatterHackers.MatterControl.AboutPage; using MatterHackers.MatterControl.CustomWidgets; using MatterHackers.MatterControl.SlicerConfiguration; using MatterHackers.VectorMath; @@ -336,7 +335,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage } aboutMatterControl.Click += (s, e) => { - UiThread.RunOnIdle(AboutWindow.Show); + UiThread.RunOnIdle(() => DialogWindow.Show()); }; this.AddSettingsRow(aboutMatterControl); } diff --git a/MatterControl.csproj b/MatterControl.csproj index a52d1e6ce..7c865998a 100644 --- a/MatterControl.csproj +++ b/MatterControl.csproj @@ -71,7 +71,7 @@ - + @@ -460,7 +460,6 @@ - diff --git a/PartPreviewWindow/PartPreviewContent.cs b/PartPreviewWindow/PartPreviewContent.cs index 080b8a8e8..936d2a80e 100644 --- a/PartPreviewWindow/PartPreviewContent.cs +++ b/PartPreviewWindow/PartPreviewContent.cs @@ -34,7 +34,6 @@ using MatterHackers.Agg; using MatterHackers.Agg.Platform; using MatterHackers.Agg.UI; using MatterHackers.Localizations; -using MatterHackers.MatterControl.AboutPage; using MatterHackers.MatterControl.CustomWidgets; using MatterHackers.MatterControl.PartPreviewWindow.PlusTab; using MatterHackers.MatterControl.SettingsManagement; diff --git a/SetupWizard/DialogPage.cs b/SetupWizard/DialogPage.cs index 3b6a69335..fc578f018 100644 --- a/SetupWizard/DialogPage.cs +++ b/SetupWizard/DialogPage.cs @@ -38,7 +38,7 @@ namespace MatterHackers.MatterControl { public class DialogPage : GuiWidget { - private FlowLayoutWidget headerRow; + protected FlowLayoutWidget headerRow; protected FlowLayoutWidget contentRow; private FlowLayoutWidget footerRow; diff --git a/SetupWizard/PublishPartToMatterHackers.cs b/SetupWizard/PublishPartToMatterHackers.cs index 89d1ddd8e..ad617963d 100644 --- a/SetupWizard/PublishPartToMatterHackers.cs +++ b/SetupWizard/PublishPartToMatterHackers.cs @@ -39,7 +39,7 @@ namespace MatterHackers.MatterControl public class PublishPartToMatterHackers : DialogPage { string publishMessage = "Publish a copy of this part to MatterHackers.".Localize(); - string publicPublish = "\n\nThis copy will be made availble under the terms of the 'Creative Commons Attribution 4.0 International Public License', click the link below for details.".Localize(); + string publicPublish = "\n\nThis copy will be made available under the terms of the 'Creative Commons Attribution 4.0 International Public License', click the link below for details.".Localize(); List iAgreeCheckbox = new List();