Example #1
0
        public MessageBox(String message, string windowTitle, MessageType messageType, double width, double height)
            : base(width, height)
        {
            BackgroundColor = new RGBA_Bytes(50, 50, 50, 240);
            FlowLayoutWidget topToBottomFlow = new FlowLayoutWidget(FlowDirection.TopToBottom);

            topToBottomFlow.HAnchor = Agg.UI.HAnchor.ParentCenter;
            topToBottomFlow.VAnchor = Agg.UI.VAnchor.ParentCenter;
            topToBottomFlow.AddChild(new TextWidget(message, textColor: RGBA_Bytes.White));

            Title = windowTitle;

            // add a spacer
            topToBottomFlow.AddChild(new GuiWidget(10, 10));

            switch (messageType)
            {
            case MessageType.YES_NO:
            {
                FlowLayoutWidget yesNoButtonsFlow = new FlowLayoutWidget();

                Button yesButton = new Button("Yes");
                yesButton.Click += new EventHandler(okButton_Click);
                yesNoButtonsFlow.AddChild(yesButton);

                Button noButton = new Button("No");
                noButton.Click += new EventHandler(noButton_Click);
                yesNoButtonsFlow.AddChild(noButton);

                topToBottomFlow.AddChild(yesNoButtonsFlow);
            }
            break;

            case MessageType.OK:
            {
                Button okButton = new Button("Ok");
                okButton.Click += new EventHandler(okButton_Click);
                topToBottomFlow.AddChild(okButton);
            }
            break;

            default:
                throw new NotImplementedException();
            }

            topToBottomFlow.SetBoundsToEncloseChildren();

            AddChild(topToBottomFlow);

            IsModal = true;
        }
Example #2
0
        public MessageBox(String message, string windowTitle, MessageType messageType, double width, double height)
            : base(width, height)
        {
            BackgroundColor = new RGBA_Bytes(50, 50, 50, 240);
            FlowLayoutWidget topToBottomFlow = new FlowLayoutWidget(FlowDirection.TopToBottom);
            topToBottomFlow.HAnchor = Agg.UI.HAnchor.ParentCenter;
            topToBottomFlow.VAnchor = Agg.UI.VAnchor.ParentCenter;
            topToBottomFlow.AddChild(new TextWidget(message, textColor: RGBA_Bytes.White));

            Title = windowTitle;

            // add a spacer
            topToBottomFlow.AddChild(new GuiWidget(10, 10));

            switch (messageType)
            {
                case MessageType.YES_NO:
                    {
                        FlowLayoutWidget yesNoButtonsFlow = new FlowLayoutWidget();

                        Button yesButton = new Button("Yes");
                        yesButton.Click += new ButtonBase.ButtonEventHandler(okButton_Click);
                        yesNoButtonsFlow.AddChild(yesButton);

                        Button noButton = new Button("No");
                        noButton.Click += new ButtonBase.ButtonEventHandler(noButton_Click);
                        yesNoButtonsFlow.AddChild(noButton);

                        topToBottomFlow.AddChild(yesNoButtonsFlow);
                    }
                    break;

                case MessageType.OK:
                    {
                        Button okButton = new Button("Ok");
                        okButton.Click += new ButtonBase.ButtonEventHandler(okButton_Click);
                        topToBottomFlow.AddChild(okButton);
                    }
                    break;

                default:
                    throw new NotImplementedException();
            }

            topToBottomFlow.SetBoundsToEncloseChildren();

            AddChild(topToBottomFlow);

            IsModal = true;
        }
		public ButtonsPage()
			: base("Radio and Check Buttons")
		{
			FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom);
			topToBottom.AddChild(new CheckBox("Simple Check Box"));

			CheckBoxViewStates fourStates = new CheckBoxViewStates(new TextWidget("normal"), new TextWidget("normal"),
				new TextWidget("switch n->p"),
				new TextWidget("pressed"), new TextWidget("pressed"),
				new TextWidget("switch p->n"),
				new TextWidget("disabled"));
			topToBottom.AddChild(new CheckBox(fourStates));

			GuiWidget normalPressed = new TextWidget("0 4state");
			normalPressed.BackgroundColor = RGBA_Bytes.Gray;
			GuiWidget downPressed = new TextWidget("1 4state");
			downPressed.BackgroundColor = RGBA_Bytes.Gray;

			GuiWidget normalHover = new TextWidget("0 4state");
			normalHover.BackgroundColor = RGBA_Bytes.Yellow;
			GuiWidget downHover = new TextWidget("1 4state");
			downHover.BackgroundColor = RGBA_Bytes.Yellow;

			CheckBoxViewStates fourStates2 = new CheckBoxViewStates(new TextWidget("0 4state"), normalHover, normalPressed, new TextWidget("1 4state"), downHover, downPressed, new TextWidget("disabled"));
			topToBottom.AddChild(new CheckBox(fourStates2));

			topToBottom.AddChild(new RadioButton("Simple Radio Button 1"));
			topToBottom.AddChild(new RadioButton("Simple Radio Button 2"));
			topToBottom.AddChild(new RadioButton(new RadioButtonViewText("Simple Radio Button 3")));
			topToBottom.AddChild(new RadioButton(new RadioButtonViewStates(new TextWidget("O - unchecked"), new TextWidget("O - unchecked hover"), new TextWidget("O - checking"), new TextWidget("X - checked"), new TextWidget("disabled"))));

			groupBox = new GroupBox("Radio Group");
			//groupBox.LocalBounds = new RectangleDouble(0, 0, 300, 150);
			groupBox.OriginRelativeParent = new Vector2(200, 350);
			FlowLayoutWidget topToBottomRadios = new FlowLayoutWidget(FlowDirection.TopToBottom);
			topToBottomRadios.AnchorAll();
			topToBottomRadios.AddChild(new RadioButton("Simple Radio Button 1"));
			topToBottomRadios.AddChild(new RadioButton("Simple Radio Button 2"));
			topToBottomRadios.AddChild(new RadioButton("Simple Radio Button 3"));
			topToBottomRadios.SetBoundsToEncloseChildren();
			groupBox.AddChild(topToBottomRadios);
			topToBottom.AddChild(groupBox);

			AddChild(topToBottom);

			topToBottom.VAnchor = UI.VAnchor.ParentTop;
		}
		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;

#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;
		}
		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;
		}
		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;
		}
		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 += new EventHandler(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;
		}