Put in a first pass at a text size control.

This commit is contained in:
Lars Brubaker 2017-06-06 15:04:07 -07:00
parent 0c64f9ff30
commit 4b88969c4e
4 changed files with 85 additions and 0 deletions

View file

@ -84,6 +84,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage
mainContainer.AddChild(new HorizontalLine(50));
mainContainer.AddChild(GetDisplayControl());
mainContainer.AddChild(GetTextSizeControl());
mainContainer.AddChild(new HorizontalLine(50));
}
#endif
@ -190,6 +191,76 @@ namespace MatterHackers.MatterControl.ConfigurationPage
return buttonRow;
}
private FlowLayoutWidget GetTextSizeControl()
{
FlowLayoutWidget buttonRow = new FlowLayoutWidget();
buttonRow.HAnchor = HAnchor.ParentLeftRight;
buttonRow.Margin = new BorderDouble(top: 4);
TextWidget settingsLabel = new TextWidget("Text Size".Localize());
settingsLabel.AutoExpandBoundsToText = true;
settingsLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor;
settingsLabel.VAnchor = VAnchor.ParentTop;
Button textSizeControlRestartButton = textImageButtonFactory.Generate("Restart".Localize());
textSizeControlRestartButton.VAnchor = Agg.UI.VAnchor.ParentCenter;
textSizeControlRestartButton.Visible = false;
textSizeControlRestartButton.Margin = new BorderDouble(right: 6);
textSizeControlRestartButton.Click += (sender, e) =>
{
if (PrinterConnectionAndCommunication.Instance.PrinterIsPrinting)
{
StyledMessageBox.ShowMessageBox(null, cannotRestartWhilePrintIsActiveMessage, cannotRestartWhileActive);
}
else
{
RestartApplication();
}
};
FlowLayoutWidget optionsContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);
optionsContainer.Margin = new BorderDouble(bottom: 6);
DropDownList interfaceOptionsDropList = new DropDownList("Development", maxHeight: 200);
interfaceOptionsDropList.HAnchor = HAnchor.ParentLeftRight;
optionsContainer.AddChild(interfaceOptionsDropList);
optionsContainer.Width = 200;
interfaceOptionsDropList.AddItem(".8");
interfaceOptionsDropList.AddItem(".9");
interfaceOptionsDropList.AddItem("1.0");
interfaceOptionsDropList.AddItem("1.1");
interfaceOptionsDropList.AddItem("1.2");
interfaceOptionsDropList.AddItem("1.3");
interfaceOptionsDropList.AddItem("1.4");
List<string> acceptableUpdateFeedTypeValues = new List<string>() { ".8", ".9", "1.0", "1.1", "1.2", "1.3", "1.4" };
string currentTextModeType = UserSettings.Instance.get(UserSettingsKey.ApplicationTextSize);
if (acceptableUpdateFeedTypeValues.IndexOf(currentTextModeType) == -1)
{
currentTextModeType = "1.0";
}
interfaceOptionsDropList.SelectedValue = currentTextModeType;
interfaceOptionsDropList.SelectionChanged += (sender, e) =>
{
string textSizeMode = ((DropDownList)sender).SelectedValue;
if (textSizeMode != UserSettings.Instance.get(UserSettingsKey.ApplicationTextSize))
{
UserSettings.Instance.set(UserSettingsKey.ApplicationTextSize, textSizeMode);
textSizeControlRestartButton.Visible = true;
}
};
buttonRow.AddChild(settingsLabel);
buttonRow.AddChild(new HorizontalSpacer());
buttonRow.AddChild(textSizeControlRestartButton);
buttonRow.AddChild(optionsContainer);
return buttonRow;
}
private FlowLayoutWidget GetDisplayControl()
{
FlowLayoutWidget buttonRow = new FlowLayoutWidget();