Consolidate ButtonFactory - CheckForUpdateWindow

This commit is contained in:
John Lewin 2017-06-20 05:33:49 -07:00
parent 10f9b522f2
commit 322aac1bad
2 changed files with 162 additions and 207 deletions

View file

@ -1,34 +1,15 @@
using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MatterHackers.Agg;
using MatterHackers.Agg.Font;
using MatterHackers.Agg.Image;
using MatterHackers.Agg.PlatformAbstract;
using MatterHackers.Agg.UI;
using MatterHackers.Localizations;
using MatterHackers.MatterControl.ContactForm;
using MatterHackers.MatterControl.CustomWidgets;
using MatterHackers.MatterControl.ConfigurationPage;
using MatterHackers.MatterControl.HtmlParsing;
using MatterHackers.MatterControl.PrintLibrary;
using MatterHackers.MatterControl.PrintQueue;
using System.IO;
using System.Net;
namespace MatterHackers.MatterControl.AboutPage
{
public class CheckForUpdateWindow : SystemWindow
{
private static CheckForUpdateWindow checkUpdate = null;
TextImageButtonFactory textImageButtonFactory = new TextImageButtonFactory();
LinkButtonFactory linkButtonFactory = new LinkButtonFactory();
DropDownList releaseOptionsDropList;
TextWidget stableInfoLabel;
TextWidget alphaInfoLabel;
@ -36,12 +17,9 @@ namespace MatterHackers.MatterControl.AboutPage
TextWidget updateChannelLabel;
TextWidget currentBuildInfo;
public CheckForUpdateWindow()
: base (540, 350)
public CheckForUpdateWindow(ThemeConfig theme)
: base(540, 350)
{
linkButtonFactory.fontSize = 10;
linkButtonFactory.textColor = ActiveTheme.Instance.SecondaryAccentColor;
FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom);
topToBottom.AnchorAll();
topToBottom.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;
@ -55,7 +33,7 @@ namespace MatterHackers.MatterControl.AboutPage
FlowLayoutWidget currentFeedAndDropDownContainer = new FlowLayoutWidget(FlowDirection.LeftToRight);
currentFeedAndDropDownContainer.VAnchor = VAnchor.FitToChildren;
currentFeedAndDropDownContainer.HAnchor = HAnchor.ParentLeftRight;
currentFeedAndDropDownContainer.Margin = new BorderDouble(0,5,0,0);
currentFeedAndDropDownContainer.Margin = new BorderDouble(0, 5, 0, 0);
currentFeedAndDropDownContainer.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;
TextWidget checkUpdateLabel = new TextWidget("Check for Update".Localize(), pointSize: 20);
@ -69,8 +47,7 @@ namespace MatterHackers.MatterControl.AboutPage
UpdateControlView updateStatusWidget = new UpdateControlView();
String fullCurrentFeedLabel = "Update Channel".Localize();
TextWidget feedLabel = new TextWidget(fullCurrentFeedLabel, pointSize: 12);
TextWidget feedLabel = new TextWidget("Update Channel".Localize(), pointSize: 12);
feedLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor;
feedLabel.VAnchor = VAnchor.ParentCenter;
feedLabel.Margin = new BorderDouble(left: 5);
@ -102,10 +79,9 @@ namespace MatterHackers.MatterControl.AboutPage
string currentBuildInfoLabel = String.Format("Current Build : {0}", currentBuildNo);
currentBuildInfo = new TextWidget(currentBuildInfoLabel.Localize());
currentBuildInfo.HAnchor = HAnchor.ParentLeftRight;
currentBuildInfo.Margin = new BorderDouble(left: 5,bottom: 15, top: 20);
currentBuildInfo.Margin = new BorderDouble(left: 5, bottom: 15, top: 20);
currentBuildInfo.TextColor = ActiveTheme.Instance.PrimaryTextColor;
FlowLayoutWidget additionalInfoContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);
additionalInfoContainer.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;
additionalInfoContainer.HAnchor = HAnchor.ParentLeftRight;
@ -118,12 +94,11 @@ namespace MatterHackers.MatterControl.AboutPage
updateChannelLabel.Margin = new BorderDouble(bottom: 20);
additionalInfoContainer.AddChild(updateChannelLabel);
string stableFeedInfoText = "Stable: The current release version of MatterControl (recommended).".Localize();
stableInfoLabel = new TextWidget(stableFeedInfoText);
stableInfoLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor;
stableInfoLabel.HAnchor = HAnchor.ParentLeftRight;
stableInfoLabel.Margin = new BorderDouble(bottom:10);
stableInfoLabel.Margin = new BorderDouble(bottom: 10);
additionalInfoContainer.AddChild(stableInfoLabel);
string betaFeedInfoText = "Beta: The release candidate version of MatterControl.".Localize();
@ -144,13 +119,13 @@ namespace MatterHackers.MatterControl.AboutPage
buttonContainer.HAnchor = HAnchor.ParentLeftRight;
buttonContainer.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
Button closeButton = textImageButtonFactory.Generate("Close".Localize(), centerText: true);
Button closeButton = theme.textImageButtonFactory.Generate("Close".Localize(), centerText: true);
closeButton.Click += (sender, e) =>
{
CloseOnIdle();
};
Button whatsThisLink = linkButtonFactory.Generate("What's this?".Localize());
Button whatsThisLink = theme.HelpLinkFactory.Generate("What's this?".Localize());
whatsThisLink.VAnchor = VAnchor.ParentCenter;
whatsThisLink.Margin = new BorderDouble(left: 6);
whatsThisLink.Click += (sender, e) =>
@ -168,7 +143,6 @@ namespace MatterHackers.MatterControl.AboutPage
});
};
mainLabelContainer.AddChild(checkUpdateLabel);
topToBottom.AddChild(mainLabelContainer);
topToBottom.AddChild(updateStatusWidget);
@ -198,14 +172,13 @@ namespace MatterHackers.MatterControl.AboutPage
this.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
this.ShowAsSystemWindow();
this.AlwaysOnTopOfMain = true;
}
public static void Show()
{
if (checkUpdate == null)
{
checkUpdate = new CheckForUpdateWindow();
checkUpdate = new CheckForUpdateWindow(ApplicationController.Instance.Theme);
checkUpdate.Closed += (parentSender, e) =>
{
checkUpdate = null;
@ -233,31 +206,5 @@ namespace MatterHackers.MatterControl.AboutPage
{
UpdateControlData.Instance.CheckForUpdateUserRequested();
}
/*private void getAdditionalFeedInfo()
{
if (releaseOptionsDropList.SelectedLabel == "release")
{
stableInfoLabel.Visible = true;
betaInfoLabel.Visible = false;
alphaInfoLabel.Visible = false;
}
else if (releaseOptionsDropList.SelectedLabel == "pre-release")
{
stableInfoLabel.Visible = false;
betaInfoLabel.Visible = true;
alphaInfoLabel.Visible = false;
}
else
{
stableInfoLabel.Visible = false;
betaInfoLabel.Visible = false;
alphaInfoLabel.Visible = true;
}
}*/
}
}

View file

@ -45,15 +45,17 @@ namespace MatterHackers.MatterControl
private static ImageBuffer restorePressed;
private readonly int fizedHeightA = (int)(25 * GuiWidget.DeviceScale + .5);
private readonly int fontSizeA = 11;
private readonly double fizedHeightB = 52 * GuiWidget.DeviceScale;
private readonly int fontSizeB = 14;
private readonly int fontSize10 = 10;
private readonly int fontSize11 = 11;
private readonly int fontSize14 = 14;
private int shortButtonHeight = 25;
private int sideBarButtonWidth;
public LinkButtonFactory LinkButtonFactory { get; private set; }
public LinkButtonFactory HelpLinkFactory { get; private set; }
public TextImageButtonFactory textImageButtonFactory;
private TextImageButtonFactory checkboxButtonFactory;
@ -120,7 +122,7 @@ namespace MatterHackers.MatterControl
disabledBorderColor = new RGBA_Bytes(theme.PrimaryTextColor, 100),
disabledTextColor = new RGBA_Bytes(theme.PrimaryTextColor, 100),
FixedHeight = fizedHeightA,
fontSize = fontSizeA,
fontSize = fontSize11,
borderWidth = borderWidth
};
@ -133,7 +135,7 @@ namespace MatterHackers.MatterControl
AllowThemeToAdjustImage = false,
borderWidth = borderWidth,
FixedHeight = fizedHeightB,
fontSize = fontSizeB,
fontSize = fontSize14,
normalBorderColor = new RGBA_Bytes(255, 255, 255, 100),
hoverBorderColor = new RGBA_Bytes(255, 255, 255, 100)
};
@ -311,11 +313,17 @@ namespace MatterHackers.MatterControl
};
#endregion
LinkButtonFactory = new LinkButtonFactory()
this.LinkButtonFactory = new LinkButtonFactory()
{
fontSize = fontSizeA,
fontSize = fontSize11,
textColor = ActiveTheme.Instance.PrimaryTextColor
};
this.HelpLinkFactory = new LinkButtonFactory()
{
fontSize = fontSize10,
textColor = ActiveTheme.Instance.SecondaryAccentColor
};
}
internal TabControl CreateTabControl()