Add support for themed text/number edit fields
This commit is contained in:
parent
151e753db2
commit
34708054ee
44 changed files with 598 additions and 108 deletions
|
|
@ -41,7 +41,8 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
|
||||
private SettingsContext settingsContext;
|
||||
|
||||
public BoundDoubleField(SettingsContext settingsContext, SliceSettingData settingData)
|
||||
public BoundDoubleField(SettingsContext settingsContext, SliceSettingData settingData, ThemeConfig theme)
|
||||
: base (theme)
|
||||
{
|
||||
this.settingsContext = settingsContext;
|
||||
this.settingData = settingData;
|
||||
|
|
|
|||
|
|
@ -35,10 +35,16 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
public class CharField : UIField
|
||||
{
|
||||
protected MHTextEditWidget textEditWidget;
|
||||
private ThemeConfig theme;
|
||||
|
||||
public CharField(ThemeConfig theme)
|
||||
{
|
||||
this.theme = theme;
|
||||
}
|
||||
|
||||
public override void Initialize(int tabIndex)
|
||||
{
|
||||
textEditWidget = new MHTextEditWidget("", pixelWidth: ControlWidth, tabIndex: tabIndex)
|
||||
textEditWidget = new MHTextEditWidget("", theme, pixelWidth: ControlWidth, tabIndex: tabIndex)
|
||||
{
|
||||
ToolTipText = this.HelpText,
|
||||
SelectAllOnFocus = true,
|
||||
|
|
|
|||
|
|
@ -37,6 +37,11 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
{
|
||||
private double _doubleValue;
|
||||
|
||||
public DoubleField(ThemeConfig theme)
|
||||
: base (theme)
|
||||
{
|
||||
}
|
||||
|
||||
public double DoubleValue
|
||||
{
|
||||
get { return _doubleValue; }
|
||||
|
|
|
|||
|
|
@ -34,7 +34,8 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
{
|
||||
public class DoubleOrPercentField : ValueOrUnitsField
|
||||
{
|
||||
public DoubleOrPercentField()
|
||||
public DoubleOrPercentField(ThemeConfig theme)
|
||||
: base (theme)
|
||||
{
|
||||
unitsToken = "%";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,15 +40,17 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
{
|
||||
private SettingsContext settingsContext;
|
||||
private Color textColor;
|
||||
private ThemeConfig theme;
|
||||
private string slicerConfigName;
|
||||
|
||||
private List<Vector2Field> childFields;
|
||||
|
||||
public ExtruderOffsetField(SettingsContext settingsContext, string slicerConfigName, Color textColor)
|
||||
public ExtruderOffsetField(SettingsContext settingsContext, string slicerConfigName, Color textColor, ThemeConfig theme)
|
||||
{
|
||||
this.slicerConfigName = slicerConfigName;
|
||||
this.settingsContext = settingsContext;
|
||||
this.textColor = textColor;
|
||||
this.theme = theme;
|
||||
|
||||
//SaveCommaSeparatedIndexSetting(extruderOffset.ExtruderIndex, settingsContext, slicerConfigName, extruderOffset.Value.Replace(",", "x"));
|
||||
}
|
||||
|
|
@ -89,7 +91,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
labelWidget.Margin = new BorderDouble(right: 60);
|
||||
row.AddChild(labelWidget);
|
||||
|
||||
var field = new Vector2Field();
|
||||
var field = new Vector2Field(theme);
|
||||
field.Initialize(tabIndex++);
|
||||
field.Content.Margin = new BorderDouble(right: 55);
|
||||
field.Content.VAnchor = VAnchor.Center;
|
||||
|
|
|
|||
|
|
@ -36,6 +36,11 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
{
|
||||
public class IntField : NumberField
|
||||
{
|
||||
public IntField(ThemeConfig theme)
|
||||
: base (theme)
|
||||
{
|
||||
}
|
||||
|
||||
int _intValue;
|
||||
public int IntValue
|
||||
{
|
||||
|
|
|
|||
|
|
@ -34,7 +34,8 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
{
|
||||
public class IntOrMmField : ValueOrUnitsField
|
||||
{
|
||||
public IntOrMmField()
|
||||
public IntOrMmField(ThemeConfig theme)
|
||||
: base (theme)
|
||||
{
|
||||
this.unitsToken = "mm";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,10 +35,16 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
public class MultilineStringField : UIField
|
||||
{
|
||||
private MHTextEditWidget editWidget;
|
||||
private ThemeConfig theme;
|
||||
|
||||
public MultilineStringField(ThemeConfig theme)
|
||||
{
|
||||
this.theme = theme;
|
||||
}
|
||||
|
||||
public override void Initialize(int tabIndex)
|
||||
{
|
||||
editWidget = new MHTextEditWidget("", pixelWidth: 320, multiLine: true, tabIndex: tabIndex, typeFace: ApplicationController.GetTypeFace(NamedTypeFace.Liberation_Mono))
|
||||
editWidget = new MHTextEditWidget("", theme, pixelWidth: 320, multiLine: true, tabIndex: tabIndex, typeFace: ApplicationController.GetTypeFace(NamedTypeFace.Liberation_Mono))
|
||||
{
|
||||
HAnchor = HAnchor.Stretch,
|
||||
VAnchor = VAnchor.Fit,
|
||||
|
|
|
|||
|
|
@ -34,13 +34,19 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
public abstract class NumberField : UIField
|
||||
{
|
||||
protected MHNumberEdit numberEdit;
|
||||
private ThemeConfig theme;
|
||||
|
||||
protected bool AllowNegatives { get; set; } = true;
|
||||
protected bool AllowDecimals { get; set; } = true;
|
||||
|
||||
public NumberField(ThemeConfig theme)
|
||||
{
|
||||
this.theme = theme;
|
||||
}
|
||||
|
||||
public override void Initialize(int tabIndex)
|
||||
{
|
||||
numberEdit = new MHNumberEdit(0, pixelWidth: ControlWidth, allowDecimals: this.AllowDecimals, allowNegatives: this.AllowNegatives, tabIndex: tabIndex)
|
||||
numberEdit = new MHNumberEdit(0, theme, pixelWidth: ControlWidth, allowDecimals: this.AllowDecimals, allowNegatives: this.AllowNegatives, tabIndex: tabIndex)
|
||||
{
|
||||
ToolTipText = this.HelpText,
|
||||
SelectAllOnFocus = true,
|
||||
|
|
|
|||
|
|
@ -34,7 +34,8 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
{
|
||||
public class PositiveDoubleField : DoubleField
|
||||
{
|
||||
public PositiveDoubleField()
|
||||
public PositiveDoubleField(ThemeConfig theme)
|
||||
: base(theme)
|
||||
{
|
||||
this.AllowNegatives = false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
BackgroundColor = theme.ActiveTabColor
|
||||
};
|
||||
|
||||
editWidget = new MHTextEditWidget("", multiLine: true)
|
||||
editWidget = new MHTextEditWidget("", theme, multiLine: true)
|
||||
{
|
||||
HAnchor = HAnchor.Stretch,
|
||||
Name = this.Name
|
||||
|
|
|
|||
|
|
@ -34,10 +34,16 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
public class TextField : UIField
|
||||
{
|
||||
protected MHTextEditWidget textEditWidget;
|
||||
private ThemeConfig theme;
|
||||
|
||||
public TextField(ThemeConfig theme)
|
||||
{
|
||||
this.theme = theme;
|
||||
}
|
||||
|
||||
public override void Initialize(int tabIndex)
|
||||
{
|
||||
textEditWidget = new MHTextEditWidget("", pixelWidth: ControlWidth, tabIndex: tabIndex)
|
||||
textEditWidget = new MHTextEditWidget("", theme, pixelWidth: ControlWidth, tabIndex: tabIndex)
|
||||
{
|
||||
ToolTipText = this.HelpText,
|
||||
SelectAllOnFocus = true,
|
||||
|
|
|
|||
|
|
@ -34,6 +34,11 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
{
|
||||
protected string unitsToken = "units-token";
|
||||
|
||||
public ValueOrUnitsField(ThemeConfig theme)
|
||||
: base (theme)
|
||||
{
|
||||
}
|
||||
|
||||
public override void Initialize(int tabIndex)
|
||||
{
|
||||
base.Initialize(tabIndex);
|
||||
|
|
|
|||
|
|
@ -40,6 +40,12 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
private MHNumberEdit yEditWidget;
|
||||
|
||||
private MHNumberEdit xEditWidget;
|
||||
private ThemeConfig theme;
|
||||
|
||||
public Vector2Field(ThemeConfig theme)
|
||||
{
|
||||
this.theme = theme;
|
||||
}
|
||||
|
||||
public Vector2 Vector2
|
||||
{
|
||||
|
|
@ -60,7 +66,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
var container = new FlowLayoutWidget();
|
||||
|
||||
string[] xyValueStrings = this.Value?.Split(',');
|
||||
if (xyValueStrings == null
|
||||
if (xyValueStrings == null
|
||||
|| xyValueStrings.Length != 2)
|
||||
{
|
||||
xyValueStrings = new string[] { "0", "0" };
|
||||
|
|
@ -68,7 +74,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
|
||||
double.TryParse(xyValueStrings[0], out double currentXValue);
|
||||
|
||||
xEditWidget = new MHNumberEdit(currentXValue, allowNegatives: true, allowDecimals: true, pixelWidth: VectorXYEditWidth, tabIndex: tabIndex)
|
||||
xEditWidget = new MHNumberEdit(currentXValue, theme, allowNegatives: true, allowDecimals: true, pixelWidth: VectorXYEditWidth, tabIndex: tabIndex)
|
||||
{
|
||||
ToolTipText = this.HelpText,
|
||||
TabIndex = tabIndex,
|
||||
|
|
@ -90,7 +96,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
|
||||
double.TryParse(xyValueStrings[1], out double currentYValue);
|
||||
|
||||
yEditWidget = new MHNumberEdit(currentYValue, allowNegatives: true, allowDecimals: true, pixelWidth: VectorXYEditWidth, tabIndex: tabIndex)
|
||||
yEditWidget = new MHNumberEdit(currentYValue, theme, allowNegatives: true, allowDecimals: true, pixelWidth: VectorXYEditWidth, tabIndex: tabIndex)
|
||||
{
|
||||
ToolTipText = this.HelpText,
|
||||
TabIndex = tabIndex + 1,
|
||||
|
|
|
|||
|
|
@ -40,6 +40,12 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
private MHNumberEdit xEditWidget;
|
||||
private MHNumberEdit yEditWidget;
|
||||
private MHNumberEdit zEditWidget;
|
||||
private ThemeConfig theme;
|
||||
|
||||
public Vector3Field(ThemeConfig theme)
|
||||
{
|
||||
this.theme = theme;
|
||||
}
|
||||
|
||||
public Vector3 Vector3
|
||||
{
|
||||
|
|
@ -61,7 +67,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
var container = new FlowLayoutWidget();
|
||||
|
||||
string[] xyzValueStrings = this.Value?.Split(',');
|
||||
if (xyzValueStrings == null
|
||||
if (xyzValueStrings == null
|
||||
|| xyzValueStrings.Length != 3)
|
||||
{
|
||||
xyzValueStrings = new string[] { "0", "0", "0" };
|
||||
|
|
@ -69,7 +75,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
|
||||
double.TryParse(xyzValueStrings[0], out double currentXValue);
|
||||
|
||||
xEditWidget = new MHNumberEdit(currentXValue, allowNegatives: true, allowDecimals: true, pixelWidth: VectorXYZEditWidth, tabIndex: tabIndex)
|
||||
xEditWidget = new MHNumberEdit(currentXValue, theme, allowNegatives: true, allowDecimals: true, pixelWidth: VectorXYZEditWidth, tabIndex: tabIndex)
|
||||
{
|
||||
ToolTipText = this.HelpText,
|
||||
TabIndex = tabIndex,
|
||||
|
|
@ -78,7 +84,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
xEditWidget.ActuallNumberEdit.EditComplete += (sender, e) =>
|
||||
{
|
||||
this.SetValue(
|
||||
string.Format("{0},{1},{2}",
|
||||
string.Format("{0},{1},{2}",
|
||||
xEditWidget.ActuallNumberEdit.Value.ToString(),
|
||||
yEditWidget.ActuallNumberEdit.Value.ToString(),
|
||||
zEditWidget.ActuallNumberEdit.Value.ToString()),
|
||||
|
|
@ -94,7 +100,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
|
||||
double.TryParse(xyzValueStrings[1], out double currentYValue);
|
||||
|
||||
yEditWidget = new MHNumberEdit(currentYValue, allowNegatives: true, allowDecimals: true, pixelWidth: VectorXYZEditWidth, tabIndex: tabIndex)
|
||||
yEditWidget = new MHNumberEdit(currentYValue, theme, allowNegatives: true, allowDecimals: true, pixelWidth: VectorXYZEditWidth, tabIndex: tabIndex)
|
||||
{
|
||||
ToolTipText = this.HelpText,
|
||||
TabIndex = tabIndex + 1,
|
||||
|
|
@ -103,7 +109,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
yEditWidget.ActuallNumberEdit.EditComplete += (sender, e) =>
|
||||
{
|
||||
this.SetValue(
|
||||
string.Format("{0},{1},{2}",
|
||||
string.Format("{0},{1},{2}",
|
||||
xEditWidget.ActuallNumberEdit.Value.ToString(),
|
||||
yEditWidget.ActuallNumberEdit.Value.ToString(),
|
||||
zEditWidget.ActuallNumberEdit.Value.ToString()),
|
||||
|
|
@ -119,7 +125,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
|
||||
double.TryParse(xyzValueStrings[2], out double currentZValue);
|
||||
|
||||
zEditWidget = new MHNumberEdit(currentZValue, allowNegatives: true, allowDecimals: true, pixelWidth: VectorXYZEditWidth, tabIndex: tabIndex)
|
||||
zEditWidget = new MHNumberEdit(currentZValue, theme, allowNegatives: true, allowDecimals: true, pixelWidth: VectorXYZEditWidth, tabIndex: tabIndex)
|
||||
{
|
||||
ToolTipText = this.HelpText,
|
||||
TabIndex = tabIndex + 1,
|
||||
|
|
@ -128,7 +134,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
zEditWidget.ActuallNumberEdit.EditComplete += (sender, e) =>
|
||||
{
|
||||
this.SetValue(
|
||||
string.Format("{0},{1},{2}",
|
||||
string.Format("{0},{1},{2}",
|
||||
xEditWidget.ActuallNumberEdit.Value.ToString(),
|
||||
yEditWidget.ActuallNumberEdit.Value.ToString(),
|
||||
zEditWidget.ActuallNumberEdit.Value.ToString()),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue