private FlowLayoutWidget GetAutoLevelControl() { FlowLayoutWidget buttonRow = new FlowLayoutWidget(); buttonRow.HAnchor = HAnchor.ParentLeftRight; buttonRow.Margin = new BorderDouble(0, 4); TextWidget notificationSettingsLabel = new TextWidget("Software Print Leveling"); notificationSettingsLabel.AutoExpandBoundsToText = true; notificationSettingsLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor; notificationSettingsLabel.VAnchor = VAnchor.ParentCenter; Button editButton = textImageButtonFactory.GenerateEditButton(); editButton.VAnchor = Agg.UI.VAnchor.ParentCenter; editButton.Click += (sender, e) => { UiThread.RunOnIdle(() => { if (editLevelingSettingsWindow == null) { editLevelingSettingsWindow = new EditLevelingSettingsWindow(); editLevelingSettingsWindow.Closed += (sender2, e2) => { editLevelingSettingsWindow = null; }; } else { editLevelingSettingsWindow.BringToFront(); } }); }; Button runPrintLevelingButton = textImageButtonFactory.Generate("Configure".Localize().ToUpper()); runPrintLevelingButton.Margin = new BorderDouble(left: 6); runPrintLevelingButton.VAnchor = VAnchor.ParentCenter; runPrintLevelingButton.Click += (sender, e) => { UiThread.RunOnIdle(() => { LevelWizardBase.ShowPrintLevelWizard(LevelWizardBase.RuningState.UserRequestedCalibration); }); }; Agg.Image.ImageBuffer levelingImage = StaticData.Instance.LoadIcon(Path.Combine("PrintStatusControls", "leveling-24x24.png")); if (!ActiveTheme.Instance.IsDarkTheme) { InvertLightness.DoInvertLightness(levelingImage); } ImageWidget levelingIcon = new ImageWidget(levelingImage); levelingIcon.Margin = new BorderDouble(right: 6); CheckBox printLevelingSwitch = ImageButtonFactory.CreateToggleSwitch(ActiveSliceSettings.Instance.DoPrintLeveling); printLevelingSwitch.VAnchor = VAnchor.ParentCenter; printLevelingSwitch.Margin = new BorderDouble(left: 16); printLevelingSwitch.CheckedStateChanged += (sender, e) => { ActiveSliceSettings.Instance.DoPrintLeveling = printLevelingSwitch.Checked; }; printLevelingStatusLabel = new TextWidget(""); printLevelingStatusLabel.AutoExpandBoundsToText = true; printLevelingStatusLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor; printLevelingStatusLabel.VAnchor = VAnchor.ParentCenter; ActiveSliceSettings.Instance.DoPrintLevelingChanged.RegisterEvent((sender, e) => { SetPrintLevelButtonVisiblity(); printLevelingSwitch.Checked = ActiveSliceSettings.Instance.DoPrintLeveling; }, ref unregisterEvents); buttonRow.AddChild(levelingIcon); buttonRow.AddChild(printLevelingStatusLabel); buttonRow.AddChild(editButton); buttonRow.AddChild(new HorizontalSpacer()); buttonRow.AddChild(runPrintLevelingButton); // only show the switch if leveling can be turned off (it can't if it is required). if (!ActiveSliceSettings.Instance.LevelingRequiredToPrint) { buttonRow.AddChild(printLevelingSwitch); } SetPrintLevelButtonVisiblity(); return buttonRow; }
private FlowLayoutWidget GetAutoLevelControl() { FlowLayoutWidget buttonRow = new FlowLayoutWidget(); buttonRow.HAnchor = HAnchor.ParentLeftRight; buttonRow.Margin = new BorderDouble(0, 4); TextWidget notificationSettingsLabel = new TextWidget("Software Print Leveling"); notificationSettingsLabel.AutoExpandBoundsToText = true; notificationSettingsLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor; notificationSettingsLabel.VAnchor = VAnchor.ParentCenter; Button editButton = textImageButtonFactory.GenerateEditButton(); editButton.VAnchor = Agg.UI.VAnchor.ParentCenter; editButton.Click += (sender, e) => { UiThread.RunOnIdle(() => { if (editLevelingSettingsWindow == null) { editLevelingSettingsWindow = new EditLevelingSettingsWindow(); editLevelingSettingsWindow.Closed += (sender2, e2) => { editLevelingSettingsWindow = null; }; } else { editLevelingSettingsWindow.BringToFront(); } }); }; Button runPrintLevelingButton = textImageButtonFactory.Generate("Configure".Localize().ToUpper()); runPrintLevelingButton.Margin = new BorderDouble(left: 6); runPrintLevelingButton.VAnchor = VAnchor.ParentCenter; runPrintLevelingButton.Click += (sender, e) => { UiThread.RunOnIdle(() => { LevelWizardBase.ShowPrintLevelWizard(LevelWizardBase.RuningState.UserRequestedCalibration); }); }; Agg.Image.ImageBuffer levelingImage = StaticData.Instance.LoadIcon(Path.Combine("PrintStatusControls", "leveling-24x24.png")); if (!ActiveTheme.Instance.IsDarkTheme) { InvertLightness.DoInvertLightness(levelingImage); } ImageWidget levelingIcon = new ImageWidget(levelingImage); levelingIcon.Margin = new BorderDouble(right: 6); CheckBox printLevelingSwitch = ImageButtonFactory.CreateToggleSwitch(ActivePrinterProfile.Instance.DoPrintLeveling); printLevelingSwitch.VAnchor = VAnchor.ParentCenter; printLevelingSwitch.Margin = new BorderDouble(left: 16); printLevelingSwitch.CheckedStateChanged += (sender, e) => { ActivePrinterProfile.Instance.DoPrintLeveling = printLevelingSwitch.Checked; }; printLevelingStatusLabel = new TextWidget(""); printLevelingStatusLabel.AutoExpandBoundsToText = true; printLevelingStatusLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor; printLevelingStatusLabel.VAnchor = VAnchor.ParentCenter; GuiWidget hSpacer = new GuiWidget(); hSpacer.HAnchor = HAnchor.ParentLeftRight; ActivePrinterProfile.Instance.DoPrintLevelingChanged.RegisterEvent((sender, e) => { SetPrintLevelButtonVisiblity(); printLevelingSwitch.Checked = ActivePrinterProfile.Instance.DoPrintLeveling; }, ref unregisterEvents); buttonRow.AddChild(levelingIcon); buttonRow.AddChild(printLevelingStatusLabel); buttonRow.AddChild(editButton); buttonRow.AddChild(new HorizontalSpacer()); buttonRow.AddChild(runPrintLevelingButton); buttonRow.AddChild(printLevelingSwitch); SetPrintLevelButtonVisiblity(); return(buttonRow); }
private FlowLayoutWidget GetAutoLevelControl() { FlowLayoutWidget buttonRow = new FlowLayoutWidget(); buttonRow.Name = "AutoLevelRowItem"; buttonRow.HAnchor = HAnchor.ParentLeftRight; buttonRow.Margin = new BorderDouble(0, 4); ImageBuffer levelingImage = StaticData.Instance.LoadIcon("leveling_32x32.png", 24, 24).InvertLightness(); if (!ActiveTheme.Instance.IsDarkTheme) { levelingImage.InvertLightness(); } ImageWidget levelingIcon = new ImageWidget(levelingImage); levelingIcon.Margin = new BorderDouble(right: 6); buttonRow.AddChild(levelingIcon); // label printLevelingStatusLabel = new TextWidget("") { AutoExpandBoundsToText = true, TextColor = ActiveTheme.Instance.PrimaryTextColor, VAnchor = VAnchor.ParentCenter, Text = "Software Print Leveling".Localize() }; buttonRow.AddChild(printLevelingStatusLabel); // edit button Button editButton = TextImageButtonFactory.GetThemedEditButton(); editButton.Margin = new BorderDouble(2, 2, 2, 0); editButton.VAnchor = Agg.UI.VAnchor.ParentTop; editButton.VAnchor = VAnchor.ParentCenter; editButton.Click += (sender, e) => { UiThread.RunOnIdle(() => { if (editLevelingSettingsWindow == null) { editLevelingSettingsWindow = new EditLevelingSettingsWindow(); editLevelingSettingsWindow.Closed += (sender2, e2) => { editLevelingSettingsWindow = null; }; } else { editLevelingSettingsWindow.BringToFront(); } }); }; buttonRow.AddChild(editButton); buttonRow.AddChild(new HorizontalSpacer()); // configure button runPrintLevelingButton = textImageButtonFactory.Generate("Configure".Localize().ToUpper()); runPrintLevelingButton.Margin = new BorderDouble(left: 6); runPrintLevelingButton.VAnchor = VAnchor.ParentCenter; runPrintLevelingButton.Click += (sender, e) => { UiThread.RunOnIdle(() => LevelWizardBase.ShowPrintLevelWizard(LevelWizardBase.RuningState.UserRequestedCalibration)); }; buttonRow.AddChild(runPrintLevelingButton); // put in the switch CheckBox printLevelingSwitch = ImageButtonFactory.CreateToggleSwitch(ActiveSliceSettings.Instance.GetValue<bool>(SettingsKey.print_leveling_enabled)); printLevelingSwitch.VAnchor = VAnchor.ParentCenter; printLevelingSwitch.Margin = new BorderDouble(left: 16); printLevelingSwitch.CheckedStateChanged += (sender, e) => { ActiveSliceSettings.Instance.Helpers.DoPrintLeveling(printLevelingSwitch.Checked); }; PrinterSettings.PrintLevelingEnabledChanged.RegisterEvent((sender, e) => { printLevelingSwitch.Checked = ActiveSliceSettings.Instance.GetValue<bool>(SettingsKey.print_leveling_enabled); }, ref unregisterEvents); // only show the switch if leveling can be turned off (it can't if it is required). if (!ActiveSliceSettings.Instance.GetValue<bool>(SettingsKey.print_leveling_required_to_print)) { buttonRow.AddChild(printLevelingSwitch); } return buttonRow; }
private FlowLayoutWidget GetAutoLevelControl() { FlowLayoutWidget buttonRow = new FlowLayoutWidget(); buttonRow.Name = "AutoLevelRowItem"; buttonRow.HAnchor = HAnchor.ParentLeftRight; buttonRow.Margin = new BorderDouble(0, 4); ImageBuffer levelingImage = StaticData.Instance.LoadIcon("leveling_32x32.png", 24, 24).InvertLightness(); if (!ActiveTheme.Instance.IsDarkTheme) { levelingImage.InvertLightness(); } ImageWidget levelingIcon = new ImageWidget(levelingImage); levelingIcon.Margin = new BorderDouble(right: 6); buttonRow.AddChild(levelingIcon); // label printLevelingStatusLabel = new TextWidget("") { AutoExpandBoundsToText = true, TextColor = ActiveTheme.Instance.PrimaryTextColor, VAnchor = VAnchor.ParentCenter, Text = "Software Print Leveling".Localize() }; buttonRow.AddChild(printLevelingStatusLabel); // edit button Button editButton = TextImageButtonFactory.GetThemedEditButton(); editButton.Margin = new BorderDouble(2, 2, 2, 0); editButton.VAnchor = Agg.UI.VAnchor.ParentTop; editButton.VAnchor = VAnchor.ParentCenter; editButton.Click += (sender, e) => { UiThread.RunOnIdle(() => { if (editLevelingSettingsWindow == null) { editLevelingSettingsWindow = new EditLevelingSettingsWindow(); editLevelingSettingsWindow.Closed += (sender2, e2) => { editLevelingSettingsWindow = null; }; } else { editLevelingSettingsWindow.BringToFront(); } }); }; buttonRow.AddChild(editButton); buttonRow.AddChild(new HorizontalSpacer()); // configure button runPrintLevelingButton = textImageButtonFactory.Generate("Configure".Localize().ToUpper()); runPrintLevelingButton.Margin = new BorderDouble(left: 6); runPrintLevelingButton.VAnchor = VAnchor.ParentCenter; runPrintLevelingButton.Click += (sender, e) => { UiThread.RunOnIdle(() => LevelWizardBase.ShowPrintLevelWizard(LevelWizardBase.RuningState.UserRequestedCalibration)); }; buttonRow.AddChild(runPrintLevelingButton); // put in the switch CheckBox printLevelingSwitch = ImageButtonFactory.CreateToggleSwitch(ActiveSliceSettings.Instance.GetValue <bool>(SettingsKey.print_leveling_enabled)); printLevelingSwitch.VAnchor = VAnchor.ParentCenter; printLevelingSwitch.Margin = new BorderDouble(left: 16); printLevelingSwitch.CheckedStateChanged += (sender, e) => { ActiveSliceSettings.Instance.Helpers.DoPrintLeveling(printLevelingSwitch.Checked); }; PrinterSettings.PrintLevelingEnabledChanged.RegisterEvent((sender, e) => { printLevelingSwitch.Checked = ActiveSliceSettings.Instance.GetValue <bool>(SettingsKey.print_leveling_enabled); }, ref unregisterEvents); // only show the switch if leveling can be turned off (it can't if it is required). if (!ActiveSliceSettings.Instance.GetValue <bool>(SettingsKey.print_leveling_required_to_print)) { buttonRow.AddChild(printLevelingSwitch); } return(buttonRow); }