Caller specified pointSize for DropDownLists

This commit is contained in:
John Lewin 2018-01-12 12:57:53 -08:00
parent 98aee75b26
commit 13cc147dfe
20 changed files with 57 additions and 54 deletions

View file

@ -35,7 +35,6 @@ using MatterHackers.Agg;
using MatterHackers.Agg.Platform;
using MatterHackers.Agg.UI;
using MatterHackers.Localizations;
using MatterHackers.MatterControl.CustomWidgets;
using MatterHackers.VectorMath;
namespace MatterHackers.MatterControl.SlicerConfiguration
@ -46,6 +45,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
private string defaultMenuItemText = "- none -".Localize();
private Button editButton;
private NamedSettingsLayers layerType;
private ThemeConfig theme;
private PrinterConfig printer;
private GuiWidget pullDownContainer;
private EventHandler unregisterEvents;
@ -55,9 +55,11 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
public PresetSelectorWidget(PrinterConfig printer, string label, Color accentColor, NamedSettingsLayers layerType, bool whiteBackground = false)
: base(FlowDirection.TopToBottom)
{
theme = ApplicationController.Instance.Theme;
this.printer = printer;
this.whiteBackground = whiteBackground;
Name = label;
this.Name = label;
ActiveSliceSettings.MaterialPresetChanged += ActiveSliceSettings_MaterialPresetChanged;
@ -75,7 +77,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
this.HAnchor = HAnchor.Stretch;
this.VAnchor = VAnchor.Fit;
this.BackgroundColor = ActiveTheme.Instance.TertiaryBackgroundColor;
this.BackgroundColor = theme.Colors.TertiaryBackgroundColor;
GuiWidget accentBar = new GuiWidget(7, 3)
{
@ -84,9 +86,9 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
};
// Section Label
this.AddChild(new TextWidget(label)
this.AddChild(new TextWidget(label, pointSize: theme.DefaultFontSize)
{
TextColor = whiteBackground ? Color.Black : ActiveTheme.Instance.PrimaryTextColor,
TextColor = whiteBackground ? Color.Black : theme.Colors.PrimaryTextColor,
HAnchor = HAnchor.Left,
Margin = new BorderDouble(12, 3, 0, 6)
});
@ -216,10 +218,8 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
public override void OnClosed(ClosedEventArgs e)
{
ActiveSliceSettings.MaterialPresetChanged -= ActiveSliceSettings_MaterialPresetChanged;
if (unregisterEvents != null)
{
unregisterEvents(this, null);
}
unregisterEvents?.Invoke(this, null);
base.OnClosed(e);
}
@ -230,11 +230,11 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
private DropDownList CreateDropdown()
{
var dropDownList = new DropDownList(defaultMenuItemText, ActiveTheme.Instance.PrimaryTextColor, maxHeight: 300, useLeftIcons: true)
var dropDownList = new DropDownList(defaultMenuItemText, theme.Colors.PrimaryTextColor, maxHeight: 300, useLeftIcons: true, pointSize: theme.DefaultFontSize)
{
HAnchor = HAnchor.Stretch,
MenuItemsPadding = new BorderDouble(10, 7, 7, 7),
TextColor = whiteBackground ? Color.Black : ActiveTheme.Instance.PrimaryTextColor,
TextColor = whiteBackground ? Color.Black : theme.Colors.PrimaryTextColor,
};
dropDownList.Name = layerType.ToString() + " DropDown List";

View file

@ -310,7 +310,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
&& settingShouldBeShown)
{
topToBottomSettings.AddChild(
CreateItemRow(settingData, ref tabIndexForItem));
CreateItemRow(settingData, ref tabIndexForItem, theme));
topToBottomSettings.AddChild(new HorizontalLine(20)
{
@ -430,12 +430,12 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
return dataArea;
}
internal GuiWidget CreateItemRow(SliceSettingData settingData, ref int tabIndexForItem)
internal GuiWidget CreateItemRow(SliceSettingData settingData, ref int tabIndexForItem, ThemeConfig theme)
{
return CreateItemRow(settingData, settingsContext, printer, ActiveTheme.Instance.PrimaryTextColor, ref tabIndexForItem, allUiFields);
return CreateItemRow(settingData, settingsContext, printer, theme.Colors.PrimaryTextColor, theme, ref tabIndexForItem, allUiFields);
}
public static GuiWidget CreateItemRow(SliceSettingData settingData, SettingsContext settingsContext, PrinterConfig printer, Color textColor, ref int tabIndexForItem, Dictionary<string, UIField> fieldCache = null)
public static GuiWidget CreateItemRow(SliceSettingData settingData, SettingsContext settingsContext, PrinterConfig printer, Color textColor, ThemeConfig theme, ref int tabIndexForItem, Dictionary<string, UIField> fieldCache = null)
{
string sliceSettingValue = settingsContext.GetValue(settingData.SlicerConfigName);
@ -536,7 +536,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
sliceSettingValue = printer.Settings.Helpers.ComPort();
uiField = new ComPortField(printer);
uiField = new ComPortField(printer, theme);
uiField.ValueChanged += (s, e) =>
{
if (e.UserInitiated)
@ -698,10 +698,12 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
public static GuiWidget CreateQuickMenu(SliceSettingData settingData, SettingsContext settingsContext, GuiWidget content, InternalTextEditWidget internalTextWidget)
{
var theme = ApplicationController.Instance.Theme;
string sliceSettingValue =settingsContext.GetValue(settingData.SlicerConfigName);
FlowLayoutWidget totalContent = new FlowLayoutWidget();
DropDownList selectableOptions = new DropDownList("Custom", ActiveTheme.Instance.PrimaryTextColor, maxHeight: 200);
DropDownList selectableOptions = new DropDownList("Custom", theme.Colors.PrimaryTextColor, maxHeight: 200, pointSize: theme.DefaultFontSize);
selectableOptions.Margin = new BorderDouble(0, 0, 10, 0);
foreach (QuickMenuNameValue nameValue in settingData.QuickMenuSettings)

View file

@ -39,11 +39,12 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
public class ComPortField : UIField
{
private DropDownList dropdownList;
private ThemeConfig theme;
private PrinterConfig printer;
public ComPortField(PrinterConfig printer)
public ComPortField(PrinterConfig printer, ThemeConfig theme)
{
this.theme = theme;
this.printer = printer;
}
@ -59,7 +60,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
// bind to a context that will place it in the SliceSetting view but it binds its values to a machine
// specific dictionary key that is not exposed in the UI. At runtime we lookup and store to '<machinename>_com_port'
// ensuring that a single printer can be shared across different devices and we'll select the correct com port in each case
dropdownList = new DropDownList("None".Localize(), ActiveTheme.Instance.PrimaryTextColor, maxHeight: 200)
dropdownList = new DropDownList("None".Localize(), ActiveTheme.Instance.PrimaryTextColor, maxHeight: 200, pointSize: theme.DefaultFontSize)
{
ToolTipText = this.HelpText,
Margin = new BorderDouble(),

View file

@ -61,7 +61,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
{
var totalContent = new FlowLayoutWidget();
var selectableOptions = new DropDownList("Custom", textColor, maxHeight: 200);
var selectableOptions = new DropDownList("Custom", textColor, maxHeight: 200, pointSize: ApplicationController.Instance.Theme.DefaultFontSize);
selectableOptions.Margin = new BorderDouble(0, 0, 10, 0);
foreach (QuickMenuNameValue nameValue in settingData.QuickMenuSettings)

View file

@ -30,19 +30,21 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
{
EventHandler unregisterEvents = null;
var theme = ApplicationController.Instance.Theme;
base.Initialize(tabIndex);
bool canChangeComPort = !printer.Connection.PrinterIsConnected && printer.Connection.CommunicationState != CommunicationStates.AttemptingToConnect;
//This setting defaults to Manual
var selectedMachine = printer.Settings.GetValue(SettingsKey.selector_ip_address);
dropdownList = new DropDownList(selectedMachine, ActiveTheme.Instance.PrimaryTextColor, maxHeight: 200)
dropdownList = new DropDownList(selectedMachine, theme.Colors.PrimaryTextColor, maxHeight: 200, pointSize: theme.DefaultFontSize)
{
ToolTipText = HelpText,
Margin = new BorderDouble(),
TabIndex = tabIndex,
Enabled = canChangeComPort,
TextColor = canChangeComPort ? ActiveTheme.Instance.PrimaryTextColor : new Color(ActiveTheme.Instance.PrimaryTextColor, 150),
BorderColor = canChangeComPort ? ActiveTheme.Instance.SecondaryTextColor : new Color(ActiveTheme.Instance.SecondaryTextColor, 150),
TextColor = canChangeComPort ? theme.Colors.PrimaryTextColor : new Color(theme.Colors.PrimaryTextColor, 150),
BorderColor = canChangeComPort ? theme.Colors.SecondaryTextColor : new Color(theme.Colors.SecondaryTextColor, 150),
};
@ -60,8 +62,8 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
{
canChangeComPort = !printer.Connection.PrinterIsConnected && printer.Connection.CommunicationState != CommunicationStates.AttemptingToConnect;
dropdownList.Enabled = canChangeComPort;
dropdownList.TextColor = canChangeComPort ? ActiveTheme.Instance.PrimaryTextColor : new Color(ActiveTheme.Instance.PrimaryTextColor, 150);
dropdownList.BorderColor = canChangeComPort ? ActiveTheme.Instance.SecondaryTextColor : new Color(ActiveTheme.Instance.SecondaryTextColor, 150);
dropdownList.TextColor = canChangeComPort ? theme.Colors.PrimaryTextColor : new Color(theme.Colors.PrimaryTextColor, 150);
dropdownList.BorderColor = canChangeComPort ? theme.Colors.SecondaryTextColor : new Color(theme.Colors.SecondaryTextColor, 150);
}, ref unregisterEvents);
// Release event listener on close

View file

@ -43,7 +43,8 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
public override void Initialize(int tabIndex)
{
dropdownList = new DropDownList("None".Localize(), ActiveTheme.Instance.PrimaryTextColor, maxHeight: 200)
var theme = ApplicationController.Instance.Theme;
dropdownList = new DropDownList("None".Localize(), theme.Colors.PrimaryTextColor, maxHeight: 200, pointSize: theme.DefaultFontSize)
{
ToolTipText = this.HelpText,
TabIndex = tabIndex,