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);
|
||||
|
||||
// put in the switch
|
||||
CheckBox printLevelingSwitch = ImageButtonFactory.CreateToggleSwitch(printer.Settings.GetValue<bool>(SettingsKey.print_leveling_enabled));
|
||||
printLevelingSwitch.VAnchor = VAnchor.Center;
|
||||
printLevelingSwitch.Margin = new BorderDouble(left: 16);
|
||||
var printLevelingSwitch = new RoundedToggleSwitch(theme)
|
||||
{
|
||||
VAnchor = VAnchor.Center,
|
||||
Margin = new BorderDouble(left: 16),
|
||||
Checked = printer.Settings.GetValue<bool>(SettingsKey.print_leveling_enabled)
|
||||
};
|
||||
printLevelingSwitch.CheckedStateChanged += (sender, e) =>
|
||||
{
|
||||
printer.Settings.Helpers.DoPrintLeveling(printLevelingSwitch.Checked);
|
||||
|
|
|
|||
|
|
@ -41,59 +41,6 @@ namespace MatterHackers.MatterControl
|
|||
{
|
||||
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)
|
||||
{
|
||||
if(hoverImage == null)
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ namespace MatterHackers.MatterControl.PrinterControls
|
|||
|
||||
private EditableNumberDisplay fanSpeedDisplay;
|
||||
|
||||
private CheckBox toggleSwitch;
|
||||
private ICheckbox toggleSwitch;
|
||||
|
||||
private FanControls(PrinterConnection printerConnection, ThemeConfig theme)
|
||||
: base(FlowDirection.TopToBottom)
|
||||
|
|
@ -60,9 +60,12 @@ namespace MatterHackers.MatterControl.PrinterControls
|
|||
bool fanActive = printerConnection.FanSpeed0To255 != 0;
|
||||
|
||||
Stopwatch timeSinceLastManualSend = new Stopwatch();
|
||||
toggleSwitch = ImageButtonFactory.CreateToggleSwitch(fanActive);
|
||||
toggleSwitch.Margin = new BorderDouble(5, 0);
|
||||
toggleSwitch.VAnchor = VAnchor.Center;
|
||||
|
||||
var toggleSwitch = new RoundedToggleSwitch(theme)
|
||||
{
|
||||
Margin = new BorderDouble(5, 0),
|
||||
VAnchor = VAnchor.Center
|
||||
};
|
||||
toggleSwitch.CheckedStateChanged += (s, e) =>
|
||||
{
|
||||
if (!timeSinceLastManualSend.IsRunning
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue