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

@ -88,7 +88,7 @@ namespace MatterHackers.MatterControl.AboutPage
UserSettings.Instance.set(UserSettingsKey.UpdateFeedType, "release");
}
var releaseOptionsDropList = new DropDownList("Development", theme.Colors.PrimaryTextColor, maxHeight: 200)
var releaseOptionsDropList = new DropDownList("Development", theme.Colors.PrimaryTextColor, maxHeight: 200, pointSize: theme.DefaultFontSize)
{
HAnchor = HAnchor.Fit
};

View file

@ -42,7 +42,8 @@ namespace MatterHackers.MatterControl
private EventHandler unregisterEvents;
int lastSelectedIndex = -1;
public PrinterSelector() : base("Printers".Localize() + "... ", ActiveTheme.Instance.PrimaryTextColor)
public PrinterSelector(ThemeConfig theme)
: base("Printers".Localize() + "... ", theme.Colors.PrimaryTextColor, pointSize: theme.DefaultFontSize)
{
Rebuild();

View file

@ -111,7 +111,7 @@ namespace MatterHackers.MatterControl.ActionBar
var settingsContext = new SettingsContext(printer, null, NamedSettingsLayers.All);
var settingsData = SliceSettingsOrganizer.Instance.GetSettingsData(SettingsKey.bed_temperature);
var row = SliceSettingsWidget.CreateItemRow(settingsData, settingsContext, printer, Color.Black, ref tabIndex);
var row = SliceSettingsWidget.CreateItemRow(settingsData, settingsContext, printer, Color.Black, ApplicationController.Instance.Theme, ref tabIndex);
container.AddChild(row);
// add in the temp graph

View file

@ -246,7 +246,7 @@ namespace MatterHackers.MatterControl.ActionBar
var settingsContext = new SettingsContext(printer, null, NamedSettingsLayers.All);
// TODO: make this be for the correct extruder
var settingsData = SliceSettingsOrganizer.Instance.GetSettingsData(TemperatureKey);
var row = SliceSettingsWidget.CreateItemRow(settingsData, settingsContext, printer, Color.Black, ref tabIndex);
var row = SliceSettingsWidget.CreateItemRow(settingsData, settingsContext, printer, Color.Black, ApplicationController.Instance.Theme, ref tabIndex);
container.AddChild(row);

View file

@ -161,7 +161,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage
#if !__ANDROID__
{
// ThumbnailRendering
var thumbnailsModeDropList = new DropDownList("", ActiveTheme.Instance.PrimaryTextColor, maxHeight: 200)
var thumbnailsModeDropList = new DropDownList("", ActiveTheme.Instance.PrimaryTextColor, maxHeight: 200, pointSize: ApplicationController.Instance.Theme.DefaultFontSize)
{
TextColor = menuTextColor,
};

View file

@ -43,7 +43,7 @@ namespace MatterHackers.MatterControl
: base(FlowDirection.TopToBottom)
{
int tabIndex = 0;
var rowItem = sliceSettingsWidget.CreateItemRow(SliceSettingsOrganizer.SettingsData["printer_name"], ref tabIndex);
var rowItem = sliceSettingsWidget.CreateItemRow(SliceSettingsOrganizer.SettingsData["printer_name"],ref tabIndex, theme);
var firstChild = rowItem.Children.FirstOrDefault();
firstChild.HAnchor = HAnchor.Absolute;

View file

@ -134,7 +134,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.PlusTab
var existingPrinterSection = CreateSection(leftContent, "Open Existing".Localize() + ":");
var printerSelector = new PrinterSelector()
var printerSelector = new PrinterSelector(theme)
{
Margin = new BorderDouble(left: 15)
};

View file

@ -57,7 +57,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
{ 5, "5" },
};
var dropDownList = new DropDownList("Custom", ActiveTheme.Instance.PrimaryTextColor, Direction.Down)
var dropDownList = new DropDownList("Custom", ActiveTheme.Instance.PrimaryTextColor, Direction.Down, ApplicationController.Instance.Theme.DefaultFontSize)
{
TextColor = Color.Black,
Margin = new BorderDouble(35, 15, 35, 5),

View file

@ -84,7 +84,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
foreach (var key in new[] { "layer_height", "fill_density", "support_material", "create_raft", "spiral_vase", "layer_to_pause" })
{
var settingsData = SliceSettingsOrganizer.Instance.GetSettingsData(key);
var row = SliceSettingsWidget.CreateItemRow(settingsData, settingsContext, printer, Color.Black, ref tabIndex);
var row = SliceSettingsWidget.CreateItemRow(settingsData, settingsContext, printer, Color.Black, theme, ref tabIndex);
optionsPanel.AddChild(row);
}

View file

@ -207,7 +207,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
{ 10, "cm to mm (10)"},
};
var dropDownList = new DropDownList("Scale".Localize(), theme.Colors.PrimaryTextColor, Direction.Down)
var dropDownList = new DropDownList("Scale".Localize(), theme.Colors.PrimaryTextColor, Direction.Down, pointSize: theme.DefaultFontSize)
{
HAnchor = HAnchor.Left
};

View file

@ -46,6 +46,8 @@ namespace MatterHackers.MatterControl
public MacroDetailPage(GCodeMacro gcodeMacro, PrinterSettings printerSettings)
{
var theme = ApplicationController.Instance.Theme;
// Form validation fields
MHTextEditWidget macroNameInput;
MHTextEditWidget macroCommandInput;
@ -61,7 +63,7 @@ namespace MatterHackers.MatterControl
contentRow.AddChild(new TextWidget("Macro Name".Localize() + ":", 0, 0, 12)
{
TextColor = ActiveTheme.Instance.PrimaryTextColor,
TextColor = theme.Colors.PrimaryTextColor,
HAnchor = HAnchor.Stretch,
Margin = new BorderDouble(0, 0, 0, 1)
});
@ -73,14 +75,14 @@ namespace MatterHackers.MatterControl
contentRow.AddChild(macroNameError = new TextWidget("Give the macro a name".Localize() + ".", 0, 0, 10)
{
TextColor = ActiveTheme.Instance.PrimaryTextColor,
TextColor = theme.Colors.PrimaryTextColor,
HAnchor = HAnchor.Stretch,
Margin = elementMargin
});
contentRow.AddChild(new TextWidget("Macro Commands".Localize() + ":", 0, 0, 12)
{
TextColor = ActiveTheme.Instance.PrimaryTextColor,
TextColor = theme.Colors.PrimaryTextColor,
HAnchor = HAnchor.Stretch,
Margin = new BorderDouble(0, 0, 0, 1)
});
@ -96,7 +98,7 @@ namespace MatterHackers.MatterControl
contentRow.AddChild(macroCommandError = new TextWidget("This should be in 'G-Code'".Localize() + ".", 0, 0, 10)
{
TextColor = ActiveTheme.Instance.PrimaryTextColor,
TextColor = theme.Colors.PrimaryTextColor,
HAnchor = HAnchor.Stretch,
Margin = elementMargin
});
@ -109,13 +111,13 @@ namespace MatterHackers.MatterControl
container.AddChild(new TextWidget("Where to show this macro:")
{
TextColor = ActiveTheme.Instance.PrimaryTextColor,
TextColor = theme.Colors.PrimaryTextColor,
VAnchor = VAnchor.Center
});
var macroUiLocation = new DropDownList("Default", ActiveTheme.Instance.PrimaryTextColor, Direction.Up)
var macroUiLocation = new DropDownList("Default", theme.Colors.PrimaryTextColor, Direction.Up, pointSize: theme.DefaultFontSize)
{
TextColor = ActiveTheme.Instance.PrimaryTextColor,
TextColor = theme.Colors.PrimaryTextColor,
Margin = new BorderDouble(5, 0),
VAnchor = VAnchor.Center
};

View file

@ -27,15 +27,9 @@ of the authors and should not be interpreted as representing official policies,
either expressed or implied, of the FreeBSD Project.
*/
using MatterHackers.Agg.Platform;
using MatterHackers.Agg.UI;
using MatterHackers.Localizations;
using System.Collections.Generic;
using MatterHackers.MatterControl.SettingsManagement;
using System.IO;
using System.Linq;
using MatterHackers.Agg;
using System;
using MatterHackers.Agg.UI;
namespace MatterHackers.MatterControl
{
@ -44,7 +38,7 @@ namespace MatterHackers.MatterControl
private List<KeyValuePair<string, string>> listSource;
public BoundDropList(string noSelectionString, int maxHeight = 0)
: base(noSelectionString, ActiveTheme.Instance.PrimaryTextColor, maxHeight: maxHeight)
: base(noSelectionString, ActiveTheme.Instance.PrimaryTextColor, maxHeight: maxHeight, pointSize: ApplicationController.Instance.Theme.DefaultFontSize)
{
}

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,

@ -1 +1 @@
Subproject commit c42218762da3a066c82049de13a496b1af5c4166
Subproject commit f3461d6760b2f460c25d6ef924d5f87f83835876

View file

@ -277,7 +277,7 @@ namespace MatterControl.Tests.MatterControl
AggContext.StaticData = new FileSystemStaticData(TestContext.CurrentContext.ResolveProjectPath(4, "StaticData"));
MatterControlUtilities.OverrideAppDataLocation(TestContext.CurrentContext.ResolveProjectPath(4));
var field = new ComPortField(new PrinterConfig(PrinterSettings.Empty));
var field = new ComPortField(new PrinterConfig(PrinterSettings.Empty), new ThemeConfig());
await ValidateAgainstValueMap(
field,