Revise About page

- Swtich from html to GuiWidgets for layout
- Simplify with DialogPage - remove AboutWindow, AboutWidget
- Remove AboutPage namespace
This commit is contained in:
John Lewin 2018-03-10 23:01:28 -08:00
parent 90ea31cd71
commit 14194900f7
10 changed files with 124 additions and 204 deletions

119
AboutPage/AboutPage.cs Normal file
View file

@ -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);
}
}
}

View file

@ -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;
}
}
}

View file

@ -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();
}
}
}
}

View file

@ -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
{

View file

@ -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;

View file

@ -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<AboutPage>());
};
this.AddSettingsRow(aboutMatterControl);
}

View file

@ -71,7 +71,7 @@
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<Compile Include="AboutPage\AboutWindow.cs" />
<Compile Include="AboutPage\AboutPage.cs" />
<Compile Include="AboutPage\CacheDirectory.cs" />
<Compile Include="AboutPage\CheckForUpdatesPage.cs" />
<Compile Include="ConfigurationPage\CalibrationSettings\CalibrationControls.cs" />
@ -460,7 +460,6 @@
<Compile Include="VersionManagement\ClientTokenRequest.cs" />
<Compile Include="VersionManagement\WebRequestHandler.cs" />
<Compile Include="VersionManagement\VersionFileHandler.cs" />
<Compile Include="AboutPage\AboutWidget.cs" />
<Compile Include="CustomWidgets\ThemeColorSelectorWidget.cs" />
<Compile Include="ControlElements\TextImageButtonFactory.cs" />
<Compile Include="EeProm\EePromMarlinWindow.cs" />

View file

@ -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;

View file

@ -38,7 +38,7 @@ namespace MatterHackers.MatterControl
{
public class DialogPage : GuiWidget
{
private FlowLayoutWidget headerRow;
protected FlowLayoutWidget headerRow;
protected FlowLayoutWidget contentRow;
private FlowLayoutWidget footerRow;

View file

@ -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<CheckBox> iAgreeCheckbox = new List<CheckBox>();