Improve DI, use constructor injection
This commit is contained in:
parent
7853d1b612
commit
bbabf95c93
52 changed files with 244 additions and 245 deletions
|
|
@ -140,7 +140,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
},
|
||||
presetsContext.LayerType);
|
||||
|
||||
return new SliceSettingsWidget(printer, settingsContext, ApplicationController.Instance.Theme)
|
||||
return new SliceSettingsWidget(printer, settingsContext, theme)
|
||||
{
|
||||
ShowControlBar = false
|
||||
};
|
||||
|
|
|
|||
|
|
@ -202,7 +202,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
|
||||
this.TabBar.Padding = this.TabBar.Margin.Clone(right: theme.ToolbarPadding.Right);
|
||||
|
||||
searchPanel = new SearchInputBox()
|
||||
searchPanel = new SearchInputBox(theme)
|
||||
{
|
||||
Visible = false,
|
||||
BackgroundColor = theme.TabBarBackground,
|
||||
|
|
@ -788,7 +788,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
break;
|
||||
|
||||
case SliceSettingData.DataEditTypes.LIST:
|
||||
uiField = new ListField()
|
||||
uiField = new ListField(theme)
|
||||
{
|
||||
ListItems = settingData.ListValues.Split(',').ToList()
|
||||
};
|
||||
|
|
@ -808,7 +808,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
break;
|
||||
#if !__ANDROID__
|
||||
case SliceSettingData.DataEditTypes.IP_LIST:
|
||||
uiField = new IpAddessField(printer);
|
||||
uiField = new IpAddessField(printer, theme);
|
||||
break;
|
||||
#endif
|
||||
|
||||
|
|
@ -857,7 +857,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
if (settingData.QuickMenuSettings.Count > 0
|
||||
&& settingData.SlicerConfigName == "baud_rate")
|
||||
{
|
||||
var dropMenu = new DropMenuWrappedField(uiField, settingData, theme.Colors.PrimaryTextColor);
|
||||
var dropMenu = new DropMenuWrappedField(uiField, settingData, theme.Colors.PrimaryTextColor, theme);
|
||||
dropMenu.Initialize(tabIndexForItem);
|
||||
|
||||
settingsRow.AddContent(dropMenu.Content);
|
||||
|
|
|
|||
|
|
@ -38,11 +38,15 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
public class DirectionVectorField : UIField
|
||||
{
|
||||
private DropDownList dropDownList;
|
||||
private ThemeConfig theme;
|
||||
|
||||
public DirectionVectorField(ThemeConfig theme)
|
||||
{
|
||||
this.theme = theme;
|
||||
}
|
||||
|
||||
public override void Initialize(int tabIndex)
|
||||
{
|
||||
var theme = ApplicationController.Instance.Theme;
|
||||
|
||||
dropDownList = new DropDownList("Name".Localize(), theme.Colors.PrimaryTextColor, Direction.Down, pointSize: theme.DefaultFontSize)
|
||||
{
|
||||
BorderColor = theme.GetBorderColor(75)
|
||||
|
|
|
|||
|
|
@ -37,13 +37,15 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
{
|
||||
private UIField uiField;
|
||||
private Color textColor;
|
||||
private ThemeConfig theme;
|
||||
private SliceSettingData settingData;
|
||||
|
||||
public DropMenuWrappedField(UIField uiField, SliceSettingData settingData, Color textColor)
|
||||
public DropMenuWrappedField(UIField uiField, SliceSettingData settingData, Color textColor, ThemeConfig theme)
|
||||
{
|
||||
this.settingData = settingData;
|
||||
this.uiField = uiField;
|
||||
this.textColor = textColor;
|
||||
this.theme = theme;
|
||||
}
|
||||
|
||||
public void SetValue(string newValue, bool userInitiated)
|
||||
|
|
@ -60,7 +62,6 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
public void Initialize(int tabIndex)
|
||||
{
|
||||
var totalContent = new FlowLayoutWidget();
|
||||
var theme = ApplicationController.Instance.Theme;
|
||||
|
||||
var selectableOptions = new DropDownList("Custom", textColor, maxHeight: 200, pointSize: theme.DefaultFontSize)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -38,17 +38,17 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
public class EnumField : UIField
|
||||
{
|
||||
private EditableProperty property;
|
||||
private ThemeConfig theme;
|
||||
private DropDownList dropDownList;
|
||||
|
||||
public EnumField(EditableProperty property)
|
||||
public EnumField(EditableProperty property, ThemeConfig theme)
|
||||
{
|
||||
this.property = property;
|
||||
this.theme = theme;
|
||||
}
|
||||
|
||||
public override void Initialize(int tabIndex)
|
||||
{
|
||||
var theme = ApplicationController.Instance.Theme;
|
||||
|
||||
// Enum keyed on name to friendly name
|
||||
var enumItems = Enum.GetNames(property.PropertyType).Select(enumName =>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -43,11 +43,13 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
{
|
||||
private EditableProperty property;
|
||||
private IconsAttribute iconsAttribute;
|
||||
private ThemeConfig theme;
|
||||
|
||||
public IconEnumField(EditableProperty property, IconsAttribute iconsAttribute)
|
||||
public IconEnumField(EditableProperty property, IconsAttribute iconsAttribute, ThemeConfig theme)
|
||||
{
|
||||
this.property = property;
|
||||
this.iconsAttribute = iconsAttribute;
|
||||
this.theme = theme;
|
||||
}
|
||||
|
||||
// TODO: Violates UIField norms but consistent with past behavior - state is only correct at construction time, often reconstructed
|
||||
|
|
@ -55,8 +57,6 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
|
||||
public override void Initialize(int tabIndex)
|
||||
{
|
||||
var theme = ApplicationController.Instance.Theme;
|
||||
|
||||
// Enum keyed on name to friendly name
|
||||
var enumItems = Enum.GetNames(property.PropertyType).Select(enumName =>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -20,18 +20,18 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
private IconButton refreshButton;
|
||||
|
||||
private PrinterConfig printer;
|
||||
private ThemeConfig theme;
|
||||
|
||||
public IpAddessField(PrinterConfig printer)
|
||||
public IpAddessField(PrinterConfig printer, ThemeConfig theme)
|
||||
{
|
||||
this.printer = printer;
|
||||
this.theme = theme;
|
||||
}
|
||||
|
||||
public override void Initialize(int tabIndex)
|
||||
{
|
||||
EventHandler unregisterEvents = null;
|
||||
|
||||
var theme = ApplicationController.Instance.Theme;
|
||||
|
||||
base.Initialize(tabIndex);
|
||||
bool canChangeComPort = !printer.Connection.IsConnected && printer.Connection.CommunicationState != CommunicationStates.AttemptingToConnect;
|
||||
//This setting defaults to Manual
|
||||
|
|
@ -72,7 +72,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
|
||||
var widget = new FlowLayoutWidget();
|
||||
widget.AddChild(dropdownList);
|
||||
refreshButton = new IconButton(AggContext.StaticData.LoadIcon("fa-refresh_14.png", theme.InvertIcons), ApplicationController.Instance.Theme)
|
||||
refreshButton = new IconButton(AggContext.StaticData.LoadIcon("fa-refresh_14.png", theme.InvertIcons), theme)
|
||||
{
|
||||
Margin = new BorderDouble(left: 5)
|
||||
};
|
||||
|
|
|
|||
|
|
@ -38,12 +38,17 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
public class ListField : UIField
|
||||
{
|
||||
private DropDownList dropdownList;
|
||||
private ThemeConfig theme;
|
||||
|
||||
public List<string> ListItems { get; set; }
|
||||
|
||||
public ListField(ThemeConfig theme)
|
||||
{
|
||||
this.theme = theme;
|
||||
}
|
||||
|
||||
public override void Initialize(int tabIndex)
|
||||
{
|
||||
var theme = ApplicationController.Instance.Theme;
|
||||
dropdownList = new DropDownList("None".Localize(), theme.Colors.PrimaryTextColor, maxHeight: 200, pointSize: theme.DefaultFontSize)
|
||||
{
|
||||
ToolTipText = this.HelpText,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue