Пример #1
0
        private Button GetAutoLevelIndicator()
        {
            ImageButtonFactory imageButtonFactory = new ImageButtonFactory();

            imageButtonFactory.InvertImageColor = false;
            ImageBuffer levelingImage   = StaticData.Instance.LoadIcon("leveling_32x32.png", 16, 16).InvertLightness();
            Button      autoLevelButton = imageButtonFactory.Generate(levelingImage, levelingImage);

            autoLevelButton.Margin      = new Agg.BorderDouble(top: 3);
            autoLevelButton.ToolTipText = "Print leveling is enabled.".Localize();
            autoLevelButton.Cursor      = Cursors.Hand;
            autoLevelButton.Visible     = ActiveSliceSettings.Instance.GetValue <bool>("print_leveling_enabled");

            ActiveSliceSettings.ActivePrinterChanged.RegisterEvent((sender, e) =>
            {
                autoLevelButton.Visible = ActiveSliceSettings.Instance.GetValue <bool>("print_leveling_enabled");
            }, ref unregisterEvents);

            ActiveSliceSettings.Instance.DoPrintLevelingChanged.RegisterEvent((sender, e) =>
            {
                autoLevelButton.Visible = ActiveSliceSettings.Instance.GetValue <bool>("print_leveling_enabled");
            }, ref unregisterEvents);

            return(autoLevelButton);
        }
        private static void AddNotificationButton(GuiWidget iconContainer)
        {
            ImageButtonFactory imageButtonFactory = new ImageButtonFactory();
            imageButtonFactory.invertImageColor = false;
            string notifyIconPath = Path.Combine("PrintStatusControls", "notify.png");
            string notifyHoverIconPath = Path.Combine("PrintStatusControls", "notify-hover.png");
            Button notifyButton = imageButtonFactory.Generate(notifyIconPath, notifyHoverIconPath);
            notifyButton.Cursor = Cursors.Hand;
            notifyButton.Margin = new Agg.BorderDouble(top: 3);
            notifyButton.Click += (sender, mouseEvent) => { 
                UiThread.RunOnIdle((state) =>
                {
                    NotificationFormWindow.Open();
                });
            };
            notifyButton.MouseEnterBounds += (sender, mouseEvent) => {
                UiThread.RunOnIdle((state) =>
                {
                    HelpTextWidget.Instance.ShowHoverText("Edit notification settings");
                }); 
            };
            notifyButton.MouseLeaveBounds += (sender, mouseEvent) => {
                UiThread.RunOnIdle((state) =>
                {
                    HelpTextWidget.Instance.HideHoverText();
                }); 
            };

            iconContainer.AddChild(notifyButton);
        }
Пример #3
0
        private FlowLayoutWidget GetNotificationControls()
        {
            FlowLayoutWidget notificationSettingsContainer = new FlowLayoutWidget();

            notificationSettingsContainer.HAnchor |= HAnchor.ParentLeftRight;
            notificationSettingsContainer.VAnchor |= Agg.UI.VAnchor.ParentCenter;
            notificationSettingsContainer.Margin   = new BorderDouble(0, 0, 0, 0);
            notificationSettingsContainer.Padding  = new BorderDouble(0);

            this.textImageButtonFactory.FixedHeight = TallButtonHeight;

            ImageBuffer notifiImage = StaticData.Instance.LoadIcon("notify-24x24.png").InvertLightness();

            notifiImage.SetRecieveBlender(new BlenderPreMultBGRA());
            int iconSize = (int)(24 * GuiWidget.DeviceScale);

            if (!ActiveTheme.Instance.IsDarkTheme)
            {
                notifiImage.InvertLightness();
            }

            ImageWidget notificationSettingsIcon = new ImageWidget(notifiImage);

            notificationSettingsIcon.VAnchor = VAnchor.ParentCenter;
            notificationSettingsIcon.Margin  = new BorderDouble(right: 6, bottom: 6);

            configureNotificationSettingsButton         = textImageButtonFactory.Generate("Configure".Localize().ToUpper());
            configureNotificationSettingsButton.Name    = "Configure Notification Settings Button";
            configureNotificationSettingsButton.Margin  = new BorderDouble(left: 6);
            configureNotificationSettingsButton.VAnchor = VAnchor.ParentCenter;
            configureNotificationSettingsButton.Click  += new EventHandler(configureNotificationSettingsButton_Click);

            notificationSettingsLabel = new TextWidget(LocalizedString.Get("Notifications"));
            notificationSettingsLabel.AutoExpandBoundsToText = true;
            notificationSettingsLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor;
            notificationSettingsLabel.VAnchor   = VAnchor.ParentCenter;

            GuiWidget printNotificationsSwitchContainer = new FlowLayoutWidget();

            printNotificationsSwitchContainer.VAnchor = VAnchor.ParentCenter;
            printNotificationsSwitchContainer.Margin  = new BorderDouble(left: 16);

            CheckBox enablePrintNotificationsSwitch = ImageButtonFactory.CreateToggleSwitch(UserSettings.Instance.get("PrintNotificationsEnabled") == "true");

            enablePrintNotificationsSwitch.VAnchor              = VAnchor.ParentCenter;
            enablePrintNotificationsSwitch.CheckedStateChanged += (sender, e) =>
            {
                UserSettings.Instance.set("PrintNotificationsEnabled", enablePrintNotificationsSwitch.Checked ? "true" : "false");
            };
            printNotificationsSwitchContainer.AddChild(enablePrintNotificationsSwitch);
            printNotificationsSwitchContainer.SetBoundsToEncloseChildren();

            notificationSettingsContainer.AddChild(notificationSettingsIcon);
            notificationSettingsContainer.AddChild(notificationSettingsLabel);
            notificationSettingsContainer.AddChild(new HorizontalSpacer());
            notificationSettingsContainer.AddChild(configureNotificationSettingsButton);
            notificationSettingsContainer.AddChild(printNotificationsSwitchContainer);

            return(notificationSettingsContainer);
        }
Пример #4
0
        private Button GetAutoLevelIndicator()
        {
            ImageButtonFactory imageButtonFactory = new ImageButtonFactory();

            imageButtonFactory.invertImageColor = false;
            string notifyIconPath      = Path.Combine("PrintStatusControls", "leveling-16x16.png");
            string notifyHoverIconPath = Path.Combine("PrintStatusControls", "leveling-16x16.png");
            Button autoLevelButton     = imageButtonFactory.Generate(notifyIconPath, notifyHoverIconPath);

            autoLevelButton.Cursor            = Cursors.Hand;
            autoLevelButton.Margin            = new Agg.BorderDouble(top: 3);
            autoLevelButton.MouseEnterBounds += (sender, mouseEvent) => { HelpTextWidget.Instance.ShowHoverText("Print leveling is enabled."); };
            autoLevelButton.MouseLeaveBounds += (sender, mouseEvent) => { HelpTextWidget.Instance.HideHoverText(); };
            autoLevelButton.Visible           = ActivePrinterProfile.Instance.DoPrintLeveling;

            ActivePrinterProfile.Instance.ActivePrinterChanged.RegisterEvent((sender, e) =>
            {
                autoLevelButton.Visible = ActivePrinterProfile.Instance.DoPrintLeveling;
            }, ref unregisterEvents);

            ActivePrinterProfile.Instance.DoPrintLevelingChanged.RegisterEvent((sender, e) =>
            {
                autoLevelButton.Visible = ActivePrinterProfile.Instance.DoPrintLeveling;
            }, ref unregisterEvents);

            return(autoLevelButton);
        }
Пример #5
0
        protected override void AddChildElements()
        {
            AltGroupBox fanControlsGroupBox = new AltGroupBox(new TextWidget("ATX Power Control".Localize(), pointSize: 18, textColor: ActiveTheme.Instance.SecondaryAccentColor));

            fanControlsGroupBox.Margin      = new BorderDouble(0);
            fanControlsGroupBox.BorderColor = ActiveTheme.Instance.PrimaryTextColor;
            fanControlsGroupBox.HAnchor    |= Agg.UI.HAnchor.ParentLeftRight;
            this.AddChild(fanControlsGroupBox);

            atxPowertoggleSwitch        = ImageButtonFactory.CreateToggleSwitch(false);
            atxPowertoggleSwitch.Margin = new BorderDouble(6, 0, 6, 6);
            atxPowertoggleSwitch.CheckedStateChanged += (sender, e) =>
            {
                PrinterConnectionAndCommunication.Instance.AtxPowerEnabled = atxPowertoggleSwitch.Checked;
            };

            FlowLayoutWidget paddingContainer = new FlowLayoutWidget();

            paddingContainer.Padding = new BorderDouble(3, 5, 3, 0) * TextWidget.GlobalPointSizeScaleRatio;
            {
                paddingContainer.AddChild(atxPowertoggleSwitch);
            }
            fanControlsGroupBox.AddChild(paddingContainer);

            UpdateControlVisibility(null, null);
        }
Пример #6
0
        public PowerControls()
        {
            AltGroupBox fanControlsGroupBox = new AltGroupBox(new TextWidget("ATX Power Control".Localize(), pointSize: 18, textColor: ActiveTheme.Instance.SecondaryAccentColor));

            fanControlsGroupBox.Margin      = new BorderDouble(0);
            fanControlsGroupBox.BorderColor = ActiveTheme.Instance.PrimaryTextColor;
            fanControlsGroupBox.HAnchor    |= Agg.UI.HAnchor.ParentLeftRight;
            this.AddChild(fanControlsGroupBox);

            atxPowertoggleSwitch        = ImageButtonFactory.CreateToggleSwitch(false);
            atxPowertoggleSwitch.Margin = new BorderDouble(6, 0, 6, 6);
            atxPowertoggleSwitch.CheckedStateChanged += (sender, e) =>
            {
                PrinterConnectionAndCommunication.Instance.AtxPowerEnabled = atxPowertoggleSwitch.Checked;
            };

            FlowLayoutWidget paddingContainer = new FlowLayoutWidget();

            paddingContainer.Padding = new BorderDouble(3, 5, 3, 0);
            {
                paddingContainer.AddChild(atxPowertoggleSwitch);
            }
            fanControlsGroupBox.AddChild(paddingContainer);

            UpdateControlVisibility(null, null);

            PrinterConnectionAndCommunication.Instance.CommunicationStateChanged.RegisterEvent(this.UpdateControlVisibility, ref unregisterEvents);
            PrinterConnectionAndCommunication.Instance.AtxPowerStateChanged.RegisterEvent(this.UpdatePowerSwitch, ref unregisterEvents);

            this.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
            this.HAnchor = HAnchor.ParentLeftRight;
            this.VAnchor = VAnchor.ParentBottomTop;
        }
Пример #7
0
        private Button GetAutoLevelIndicator()
        {
            ImageButtonFactory imageButtonFactory = new ImageButtonFactory();

            imageButtonFactory.InvertImageColor = false;
            string notifyIconPath      = Path.Combine("PrintStatusControls", "leveling-16x16.png");
            string notifyHoverIconPath = Path.Combine("PrintStatusControls", "leveling-16x16.png");
            Button autoLevelButton     = imageButtonFactory.Generate(notifyIconPath, notifyHoverIconPath);

            autoLevelButton.Cursor      = Cursors.Hand;
            autoLevelButton.Margin      = new Agg.BorderDouble(top: 3);
            autoLevelButton.ToolTipText = "Print leveling is enabled.".Localize();
            autoLevelButton.Visible     = ActivePrinterProfile.Instance.DoPrintLeveling;

            ActivePrinterProfile.Instance.ActivePrinterChanged.RegisterEvent((sender, e) =>
            {
                autoLevelButton.Visible = ActivePrinterProfile.Instance.DoPrintLeveling;
            }, ref unregisterEvents);

            ActivePrinterProfile.Instance.DoPrintLevelingChanged.RegisterEvent((sender, e) =>
            {
                autoLevelButton.Visible = ActivePrinterProfile.Instance.DoPrintLeveling;
            }, ref unregisterEvents);

            return(autoLevelButton);
        }
Пример #8
0
        private FlowLayoutWidget GetCameraControl()
        {
            FlowLayoutWidget buttonRow = new FlowLayoutWidget();

            buttonRow.HAnchor = HAnchor.ParentLeftRight;
            buttonRow.Margin  = new BorderDouble(0, 4);

            ImageBuffer cameraIconImage = StaticData.Instance.LoadIcon("camera-24x24.png", 24, 24).InvertLightness();

            cameraIconImage.SetRecieveBlender(new BlenderPreMultBGRA());
            int iconSize = (int)(24 * GuiWidget.DeviceScale);

            if (!ActiveTheme.Instance.IsDarkTheme)
            {
                cameraIconImage.InvertLightness();
            }

            ImageWidget cameraIcon = new ImageWidget(cameraIconImage);

            cameraIcon.Margin = new BorderDouble(right: 6);

            TextWidget cameraLabel = new TextWidget("Camera Monitoring".Localize());

            cameraLabel.AutoExpandBoundsToText = true;
            cameraLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor;
            cameraLabel.VAnchor   = VAnchor.ParentCenter;

            openCameraButton        = textImageButtonFactory.Generate("Preview".Localize().ToUpper());
            openCameraButton.Click += openCameraPreview_Click;
            openCameraButton.Margin = new BorderDouble(left: 6);

            buttonRow.AddChild(cameraIcon);
            buttonRow.AddChild(cameraLabel);
            buttonRow.AddChild(new HorizontalSpacer());
            buttonRow.AddChild(openCameraButton);

            if (ApplicationSettings.Instance.get(ApplicationSettingsKey.HardwareHasCamera) == "true")
            {
                GuiWidget publishImageSwitchContainer = new FlowLayoutWidget();
                publishImageSwitchContainer.VAnchor = VAnchor.ParentCenter;
                publishImageSwitchContainer.Margin  = new BorderDouble(left: 16);

                CheckBox toggleSwitch = ImageButtonFactory.CreateToggleSwitch(ActiveSliceSettings.Instance.GetValue <bool>(SettingsKey.publish_bed_image));
                toggleSwitch.CheckedStateChanged += (sender, e) =>
                {
                    CheckBox thisControl = sender as CheckBox;
                    ActiveSliceSettings.Instance.SetValue(SettingsKey.publish_bed_image, thisControl.Checked ? "1" : "0");
                };
                publishImageSwitchContainer.AddChild(toggleSwitch);

                publishImageSwitchContainer.SetBoundsToEncloseChildren();

                buttonRow.AddChild(publishImageSwitchContainer);
            }

            return(buttonRow);
        }
Пример #9
0
        private void AddChildElements()
        {
            FlowLayoutWidget tempWidgets = new FlowLayoutWidget();

            tempWidgets.VAnchor = VAnchor.ParentBottomTop;

            tempWidgets.Width = 120;

            extruderTemperatureWidget = new TemperatureWidgetExtruder();
            //extruderTemperatureWidget.Margin = new BorderDouble(right: 6);
            extruderTemperatureWidget.VAnchor = VAnchor.ParentTop;

            bedTemperatureWidget         = new TemperatureWidgetBed();
            bedTemperatureWidget.VAnchor = VAnchor.ParentTop;

            tempWidgets.AddChild(extruderTemperatureWidget);
            tempWidgets.AddChild(new GuiWidget(6, 6));
            if (ActiveSliceSettings.Instance.GetValue <bool>(SettingsKey.has_heated_bed))
            {
                tempWidgets.AddChild(bedTemperatureWidget);
            }
            tempWidgets.AddChild(new GuiWidget(6, 6));

            FlowLayoutWidget printStatusContainer = CreateActivePrinterInfoWidget();

            PrintActionRow printActionRow = new PrintActionRow(queueDataView);

            printActionRow.VAnchor = VAnchor.ParentTop;

            ImageButtonFactory factory = new ImageButtonFactory();

            factory.InvertImageColor = false;

            setupButton         = factory.Generate(StaticData.Instance.LoadIcon("icon_gear_dot.png").InvertLightness(), null);
            setupButton.Margin  = new BorderDouble(left: 6);
            setupButton.VAnchor = VAnchor.ParentCenter;
            setupButton.Click  += (sender, e) =>
            {
                WizardWindow.Show <SetupOptionsPage>("/SetupOptions", "Setup Wizard");
                //WizardWindow.Show(true);
            };

            this.AddChild(printStatusContainer);
            this.AddChild(printActionRow);
            this.AddChild(tempWidgets);
            this.AddChild(setupButton);
            this.Height = 80;

            UpdatePrintStatus();
            UpdatePrintItemName();
        }
Пример #10
0
        private FlowLayoutWidget GetCameraControl()
        {
            FlowLayoutWidget buttonRow = new FlowLayoutWidget();

            buttonRow.HAnchor = HAnchor.ParentLeftRight;
            buttonRow.Margin  = new BorderDouble(0, 4);

            Agg.Image.ImageBuffer cameraIconImage = StaticData.Instance.LoadIcon(Path.Combine("PrintStatusControls", "camera-24x24.png"));
            if (!ActiveTheme.Instance.IsDarkTheme)
            {
                InvertLightness.DoInvertLightness(cameraIconImage);
            }

            ImageWidget cameraIcon = new ImageWidget(cameraIconImage);

            cameraIcon.Margin = new BorderDouble(right: 6);

            TextWidget cameraLabel = new TextWidget("Camera Monitoring");

            cameraLabel.AutoExpandBoundsToText = true;
            cameraLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor;
            cameraLabel.VAnchor   = VAnchor.ParentCenter;

            openCameraButton        = textImageButtonFactory.Generate("Preview".Localize().ToUpper());
            openCameraButton.Click += new EventHandler(openCameraPreview_Click);
            openCameraButton.Margin = new BorderDouble(left: 6);

            buttonRow.AddChild(cameraIcon);
            buttonRow.AddChild(cameraLabel);
            buttonRow.AddChild(new HorizontalSpacer());
            buttonRow.AddChild(openCameraButton);
#if __ANDROID__
            GuiWidget publishImageSwitchContainer = new FlowLayoutWidget();
            publishImageSwitchContainer.VAnchor = VAnchor.ParentCenter;
            publishImageSwitchContainer.Margin  = new BorderDouble(left: 16);

            CheckBox toggleSwitch = ImageButtonFactory.CreateToggleSwitch(PrinterSettings.Instance.get("PublishBedImage") == "true");
            toggleSwitch.CheckedStateChanged += (sender, e) =>
            {
                CheckBox thisControl = sender as CheckBox;
                PrinterSettings.Instance.set("PublishBedImage", thisControl.Checked ? "true" : "false");
            };
            publishImageSwitchContainer.AddChild(toggleSwitch);

            publishImageSwitchContainer.SetBoundsToEncloseChildren();

            buttonRow.AddChild(publishImageSwitchContainer);
#endif

            return(buttonRow);
        }
Пример #11
0
        private FlowLayoutWidget GetNotificationControls()
        {
            FlowLayoutWidget buttonRow = new FlowLayoutWidget();

            buttonRow.HAnchor |= HAnchor.ParentLeftRight;
            buttonRow.VAnchor |= Agg.UI.VAnchor.ParentCenter;
            buttonRow.Margin   = new BorderDouble(0, 0, 0, 0);
            buttonRow.Padding  = new BorderDouble(0);

            this.textImageButtonFactory.FixedHeight = TallButtonHeight;

            Agg.Image.ImageBuffer notificationSettingsImage = StaticData.Instance.LoadIcon(Path.Combine("PrintStatusControls", "notify-24x24.png"));
            if (!ActiveTheme.Instance.IsDarkTheme)
            {
                InvertLightness.DoInvertLightness(notificationSettingsImage);
            }

            ImageWidget levelingIcon = new ImageWidget(notificationSettingsImage);

            levelingIcon.Margin = new BorderDouble(right: 6, bottom: 6);

            notificationSettingsLabel = new TextWidget(LocalizedString.Get("Notification Settings"));
            notificationSettingsLabel.AutoExpandBoundsToText = true;
            notificationSettingsLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor;
            notificationSettingsLabel.VAnchor   = VAnchor.ParentCenter;

            GuiWidget levelingSwitchContainer = new FlowLayoutWidget();

            levelingSwitchContainer.VAnchor = VAnchor.ParentCenter;
            levelingSwitchContainer.Margin  = new BorderDouble(left: 16);

            CheckBox enablePrintNotificationsSwitch = ImageButtonFactory.CreateToggleSwitch(UserSettings.Instance.get("PrintNotificationsEnabled") == "true");

            enablePrintNotificationsSwitch.VAnchor              = VAnchor.ParentCenter;
            enablePrintNotificationsSwitch.CheckedStateChanged += (sender, e) =>
            {
                UserSettings.Instance.set("PrintNotificationsEnabled", enablePrintNotificationsSwitch.Checked ? "true" : "false");
            };
            levelingSwitchContainer.AddChild(enablePrintNotificationsSwitch);
            levelingSwitchContainer.SetBoundsToEncloseChildren();

            buttonRow.AddChild(levelingIcon);
            buttonRow.AddChild(notificationSettingsLabel);
            buttonRow.AddChild(new HorizontalSpacer());
            buttonRow.AddChild(levelingSwitchContainer);

            return(buttonRow);
        }
Пример #12
0
        private GuiWidget CreateFanControls()
        {
            PrinterConnectionAndCommunication.Instance.FanSpeedSet.RegisterEvent(FanSpeedChanged_Event, ref unregisterEvents);

            FlowLayoutWidget leftToRight = new FlowLayoutWidget();

            leftToRight.Padding = new BorderDouble(3, 0, 0, 5);

            //Matt's test editing to add a on/off toggle switch
            bool fanActive = PrinterConnectionAndCommunication.Instance.FanSpeed0To255 != 0;

            toggleSwitch                      = ImageButtonFactory.CreateToggleSwitch(fanActive);
            toggleSwitch.VAnchor              = VAnchor.ParentCenter;
            toggleSwitch.CheckedStateChanged += new EventHandler(ToggleSwitch_Click);
            toggleSwitch.Margin               = new BorderDouble(5, 0);

            leftToRight.AddChild(toggleSwitch);

            return(leftToRight);
        }
Пример #13
0
        public void TopToBottomContainerAppliesExpectedMarginToToggleView()
        {
            int marginSize = 40;
            int dimensions = 300;

            GuiWidget outerContainer = new GuiWidget(dimensions, dimensions);

            FlowLayoutWidget topToBottomContainer = new FlowLayoutWidget(FlowDirection.TopToBottom)
            {
                HAnchor = HAnchor.ParentLeftRight,
                VAnchor = VAnchor.ParentBottomTop,
            };

            outerContainer.AddChild(topToBottomContainer);

            CheckBox toggleBox = ImageButtonFactory.CreateToggleSwitch(true);

            toggleBox.HAnchor         = HAnchor.ParentLeftRight;
            toggleBox.VAnchor         = VAnchor.ParentBottomTop;
            toggleBox.Margin          = new BorderDouble(marginSize);
            toggleBox.BackgroundColor = RGBA_Bytes.Red;
            toggleBox.DebugShowBounds = true;

            topToBottomContainer.AddChild(toggleBox);
            topToBottomContainer.AnchorAll();
            topToBottomContainer.PerformLayout();

            outerContainer.DoubleBuffer = true;
            outerContainer.BackBuffer.NewGraphics2D().Clear(RGBA_Bytes.White);
            outerContainer.OnDraw(outerContainer.NewGraphics2D());

            // For troubleshooting or visual validation
            OutputImages(outerContainer, outerContainer);

            var bounds = toggleBox.BoundsRelativeToParent;

            Assert.IsTrue(bounds.Left == marginSize, "Left margin is incorrect");
            Assert.IsTrue(bounds.Right == dimensions - marginSize, "Right margin is incorrect");
            Assert.IsTrue(bounds.Top == dimensions - marginSize, "Top margin is incorrect");
            Assert.IsTrue(bounds.Bottom == marginSize, "Bottom margin is incorrect");
        }
Пример #14
0
		private Button GetAutoLevelIndicator()
		{
			ImageButtonFactory imageButtonFactory = new ImageButtonFactory();
			imageButtonFactory.InvertImageColor = false;
			string notifyIconPath = Path.Combine("PrintStatusControls", "leveling-16x16.png");
			string notifyHoverIconPath = Path.Combine("PrintStatusControls", "leveling-16x16.png");
			Button autoLevelButton = imageButtonFactory.Generate(notifyIconPath, notifyHoverIconPath);
			autoLevelButton.Cursor = Cursors.Hand;
			autoLevelButton.Margin = new Agg.BorderDouble(top: 3);
			autoLevelButton.ToolTipText = "Print leveling is enabled.".Localize();
			autoLevelButton.Visible = ActiveSliceSettings.Instance.GetValue<bool>(SettingsKey.print_leveling_enabled);

			PrinterSettings.PrintLevelingEnabledChanged.RegisterEvent((sender, e) =>
			{
				autoLevelButton.Visible = ActiveSliceSettings.Instance.GetValue<bool>(SettingsKey.print_leveling_enabled);
			}, ref unregisterEvents);

			return autoLevelButton;
		}
Пример #15
0
		private void AddChildElements()
		{
			FlowLayoutWidget tempWidgets = new FlowLayoutWidget();
			tempWidgets.VAnchor = VAnchor.ParentBottomTop;

			tempWidgets.Width = 120;

			extruderTemperatureWidget = new TemperatureWidgetExtruder();
			//extruderTemperatureWidget.Margin = new BorderDouble(right: 6);
			extruderTemperatureWidget.VAnchor = VAnchor.ParentTop;

			bedTemperatureWidget = new TemperatureWidgetBed();
			bedTemperatureWidget.VAnchor = VAnchor.ParentTop;

			tempWidgets.AddChild(extruderTemperatureWidget);
			tempWidgets.AddChild(new GuiWidget(6, 6));
			if (ActiveSliceSettings.Instance.GetValue<bool>(SettingsKey.has_heated_bed))
			{
				tempWidgets.AddChild(bedTemperatureWidget);
			}
			tempWidgets.AddChild(new GuiWidget(6, 6));

			FlowLayoutWidget printStatusContainer = CreateActivePrinterInfoWidget();

			PrintActionRow printActionRow = new PrintActionRow(queueDataView);
			printActionRow.VAnchor = VAnchor.ParentTop;

			ImageButtonFactory factory = new ImageButtonFactory();
			factory.InvertImageColor = false;

			setupButton = factory.Generate(StaticData.Instance.LoadIcon("icon_gear_dot.png").InvertLightness(), null);
			setupButton.Margin = new BorderDouble(left: 6);
			setupButton.VAnchor = VAnchor.ParentCenter;
			setupButton.Click += (sender, e) =>
			{
				WizardWindow.Show<SetupOptionsPage>("/SetupOptions", "Setup Wizard");
				//WizardWindow.Show(true);
			};

			this.AddChild(printStatusContainer);
			this.AddChild(printActionRow);
			this.AddChild(tempWidgets);
			this.AddChild(setupButton);
			this.Height = 80;

			UpdatePrintStatus();
			UpdatePrintItemName();
		}
Пример #16
0
		private Button GetAutoLevelIndicator()
		{
			ImageButtonFactory imageButtonFactory = new ImageButtonFactory();
			imageButtonFactory.InvertImageColor = false;
			ImageBuffer levelingImage = StaticData.Instance.LoadIcon("leveling_32x32.png", 16, 16).InvertLightness();
			Button autoLevelButton = imageButtonFactory.Generate(levelingImage, levelingImage);
			autoLevelButton.Margin = new Agg.BorderDouble(top: 3);
			autoLevelButton.ToolTipText = "Print leveling is enabled.".Localize();
			autoLevelButton.Cursor = Cursors.Hand;
			autoLevelButton.Visible = ActiveSliceSettings.Instance.GetValue<bool>(SettingsKey.print_leveling_enabled);

			PrinterSettings.PrintLevelingEnabledChanged.RegisterEvent((sender, e) =>
			{
				autoLevelButton.Visible = ActiveSliceSettings.Instance.GetValue<bool>(SettingsKey.print_leveling_enabled);
			}, ref unregisterEvents);

			return autoLevelButton;
		}
        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);
        }
Пример #18
0
		private Button GetAutoLevelIndicator()
		{
			ImageButtonFactory imageButtonFactory = new ImageButtonFactory();
			imageButtonFactory.invertImageColor = false;
			string notifyIconPath = Path.Combine("PrintStatusControls", "leveling-16x16.png");
			string notifyHoverIconPath = Path.Combine("PrintStatusControls", "leveling-16x16.png");
			Button autoLevelButton = imageButtonFactory.Generate(notifyIconPath, notifyHoverIconPath);
			autoLevelButton.Cursor = Cursors.Hand;
			autoLevelButton.Margin = new Agg.BorderDouble(top: 3);
			autoLevelButton.MouseEnterBounds += (sender, mouseEvent) => { HelpTextWidget.Instance.ShowHoverText("Print leveling is enabled."); };
			autoLevelButton.MouseLeaveBounds += (sender, mouseEvent) => { HelpTextWidget.Instance.HideHoverText(); };
			autoLevelButton.Visible = ActivePrinterProfile.Instance.DoPrintLeveling;

			ActivePrinterProfile.Instance.ActivePrinterChanged.RegisterEvent((sender, e) =>
			{
				autoLevelButton.Visible = ActivePrinterProfile.Instance.DoPrintLeveling;
			}, ref unregisterEvents);

			ActivePrinterProfile.Instance.DoPrintLevelingChanged.RegisterEvent((sender, e) =>
			{
				autoLevelButton.Visible = ActivePrinterProfile.Instance.DoPrintLeveling;
			}, ref unregisterEvents);

			return autoLevelButton;
		}
Пример #19
0
        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);
        }