Finish switch to new toggle controls
- Issue MatterHackers/MCCentral#3043 Remove current ToggleSwitch factory to resolve differing types
This commit is contained in:
parent
e33406aca0
commit
8dfeeac3cd
3 changed files with 13 additions and 60 deletions
|
|
@ -67,9 +67,12 @@ namespace MatterHackers.MatterControl.PrinterControls
|
||||||
autoLevelRow.AddChild(runWizardButton);
|
autoLevelRow.AddChild(runWizardButton);
|
||||||
|
|
||||||
// put in the switch
|
// put in the switch
|
||||||
CheckBox printLevelingSwitch = ImageButtonFactory.CreateToggleSwitch(printer.Settings.GetValue<bool>(SettingsKey.print_leveling_enabled));
|
var printLevelingSwitch = new RoundedToggleSwitch(theme)
|
||||||
printLevelingSwitch.VAnchor = VAnchor.Center;
|
{
|
||||||
printLevelingSwitch.Margin = new BorderDouble(left: 16);
|
VAnchor = VAnchor.Center,
|
||||||
|
Margin = new BorderDouble(left: 16),
|
||||||
|
Checked = printer.Settings.GetValue<bool>(SettingsKey.print_leveling_enabled)
|
||||||
|
};
|
||||||
printLevelingSwitch.CheckedStateChanged += (sender, e) =>
|
printLevelingSwitch.CheckedStateChanged += (sender, e) =>
|
||||||
{
|
{
|
||||||
printer.Settings.Helpers.DoPrintLeveling(printLevelingSwitch.Checked);
|
printer.Settings.Helpers.DoPrintLeveling(printLevelingSwitch.Checked);
|
||||||
|
|
|
||||||
|
|
@ -41,59 +41,6 @@ namespace MatterHackers.MatterControl
|
||||||
{
|
{
|
||||||
public bool InvertImageColor { get; set; } = true;
|
public bool InvertImageColor { get; set; } = true;
|
||||||
|
|
||||||
public static CheckBox CreateToggleSwitch(bool initialState)
|
|
||||||
{
|
|
||||||
return CreateToggleSwitch(initialState, ActiveTheme.Instance.PrimaryTextColor);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static CheckBox CreateToggleSwitch(bool initialState, Color textColor, bool useStandardLabels = true)
|
|
||||||
{
|
|
||||||
return CreateToggleSwitch(
|
|
||||||
initialState,
|
|
||||||
textColor,
|
|
||||||
60 * GuiWidget.DeviceScale,
|
|
||||||
24 * GuiWidget.DeviceScale,
|
|
||||||
useStandardLabels);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static CheckBox CreateToggleSwitch(bool initialState, Color textColor, double pixelWidth, double pixelHeight, bool useStandardLabels = true)
|
|
||||||
{
|
|
||||||
return CreateToggleSwitch(
|
|
||||||
initialState,
|
|
||||||
textColor,
|
|
||||||
new Color(textColor, 70),
|
|
||||||
pixelWidth,
|
|
||||||
pixelHeight,
|
|
||||||
useStandardLabels);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static CheckBox CreateToggleSwitch(bool initialState, Color textColor, Color borderColor, double pixelWidth, double pixelHeight, bool useStandardLabels = true)
|
|
||||||
{
|
|
||||||
string on = "On".Localize();
|
|
||||||
string off = "Off".Localize();
|
|
||||||
|
|
||||||
if (!useStandardLabels)
|
|
||||||
{
|
|
||||||
on = "";
|
|
||||||
off = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
return new CheckBox(
|
|
||||||
new ToggleSwitchView(
|
|
||||||
on,
|
|
||||||
off,
|
|
||||||
pixelWidth,
|
|
||||||
pixelHeight,
|
|
||||||
ActiveTheme.Instance.PrimaryBackgroundColor,
|
|
||||||
new Color(220, 220, 220),
|
|
||||||
ActiveTheme.Instance.PrimaryAccentColor,
|
|
||||||
textColor,
|
|
||||||
borderColor))
|
|
||||||
{
|
|
||||||
Checked = initialState,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public Button Generate(ImageBuffer normalImage, ImageBuffer hoverImage, ImageBuffer pressedImage = null, ImageBuffer disabledImage = null)
|
public Button Generate(ImageBuffer normalImage, ImageBuffer hoverImage, ImageBuffer pressedImage = null, ImageBuffer disabledImage = null)
|
||||||
{
|
{
|
||||||
if(hoverImage == null)
|
if(hoverImage == null)
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ namespace MatterHackers.MatterControl.PrinterControls
|
||||||
|
|
||||||
private EditableNumberDisplay fanSpeedDisplay;
|
private EditableNumberDisplay fanSpeedDisplay;
|
||||||
|
|
||||||
private CheckBox toggleSwitch;
|
private ICheckbox toggleSwitch;
|
||||||
|
|
||||||
private FanControls(PrinterConnection printerConnection, ThemeConfig theme)
|
private FanControls(PrinterConnection printerConnection, ThemeConfig theme)
|
||||||
: base(FlowDirection.TopToBottom)
|
: base(FlowDirection.TopToBottom)
|
||||||
|
|
@ -60,9 +60,12 @@ namespace MatterHackers.MatterControl.PrinterControls
|
||||||
bool fanActive = printerConnection.FanSpeed0To255 != 0;
|
bool fanActive = printerConnection.FanSpeed0To255 != 0;
|
||||||
|
|
||||||
Stopwatch timeSinceLastManualSend = new Stopwatch();
|
Stopwatch timeSinceLastManualSend = new Stopwatch();
|
||||||
toggleSwitch = ImageButtonFactory.CreateToggleSwitch(fanActive);
|
|
||||||
toggleSwitch.Margin = new BorderDouble(5, 0);
|
var toggleSwitch = new RoundedToggleSwitch(theme)
|
||||||
toggleSwitch.VAnchor = VAnchor.Center;
|
{
|
||||||
|
Margin = new BorderDouble(5, 0),
|
||||||
|
VAnchor = VAnchor.Center
|
||||||
|
};
|
||||||
toggleSwitch.CheckedStateChanged += (s, e) =>
|
toggleSwitch.CheckedStateChanged += (s, e) =>
|
||||||
{
|
{
|
||||||
if (!timeSinceLastManualSend.IsRunning
|
if (!timeSinceLastManualSend.IsRunning
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue