コード例 #1
0
        public PanelSeparator()
            : base(4, 1)
        {
            AddHandlers();

            defaultBackgroundColor = new RGBA_Bytes(200, 200, 200);
            hoverBackgroundColor = new RGBA_Bytes(100, 100, 100);
            
            Agg.Image.ImageBuffer arrowImage = new Agg.Image.ImageBuffer();
            ImageIO.LoadImageData(Path.Combine(ApplicationDataStorage.Instance.ApplicationStaticDataPath, "Icons", "icon_arrow_left_16x16.png"), arrowImage);
            arrowIndicator = new ImageWidget(arrowImage);
            arrowIndicator.HAnchor = Agg.UI.HAnchor.ParentCenter;
            arrowIndicator.VAnchor = Agg.UI.VAnchor.ParentCenter;
            arrowIndicator.Visible = true;

            this.AddChild(arrowIndicator);

            this.Hidden = false;
            this.BackgroundColor = defaultBackgroundColor;
            this.VAnchor = VAnchor.ParentBottomTop;
            this.Margin = new BorderDouble(8, 0);
            this.Cursor = Cursors.Hand;

            SetDisplayState();
        }
コード例 #2
0
		private FlowLayoutWidget GetCloudSyncDashboardControls()
		{
			FlowLayoutWidget cloudSyncContainer = new FlowLayoutWidget();
			cloudSyncContainer.HAnchor |= HAnchor.ParentLeftRight;
			cloudSyncContainer.VAnchor |= Agg.UI.VAnchor.ParentCenter;
			cloudSyncContainer.Margin = new BorderDouble(0, 0, 0, 0);
			cloudSyncContainer.Padding = new BorderDouble(0);

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

            ImageWidget cloudSyncIcon = new ImageWidget(cloudMonitorImage);
            cloudSyncIcon.Margin = new BorderDouble(right: 6, bottom: 6);

            TextWidget cloudSyncLabel = new TextWidget(LocalizedString.Get("Cloud Sync"));
            cloudSyncLabel.AutoExpandBoundsToText = true;
            cloudSyncLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor;
            cloudSyncLabel.VAnchor = VAnchor.ParentCenter;

            linkButtonFactory.fontSize = 10;
            Button cloudSyncGoLink = linkButtonFactory.Generate("GO TO DASHBOARD");
            cloudSyncGoLink.ToolTipText = "Open cloud sync dashboard in web browser";
            cloudSyncGoLink.Click += new EventHandler(cloudSyncGoButton_Click);

            cloudSyncContainer.AddChild(cloudSyncIcon);
            cloudSyncContainer.AddChild(cloudSyncLabel);
            cloudSyncContainer.AddChild(new HorizontalSpacer());
            cloudSyncContainer.AddChild(cloudSyncGoLink);

			return cloudSyncContainer;
		}
コード例 #3
0
		public TextImageWidget(string label, RGBA_Bytes fillColor, RGBA_Bytes borderColor, RGBA_Bytes textColor, double borderWidth, BorderDouble margin, ImageBuffer image = null, double fontSize = 12, FlowDirection flowDirection = FlowDirection.LeftToRight, double height = 40, double width = 0, bool centerText = false, double imageSpacing = 0)
			: base()
		{
			this.image = image;
			this.fillColor = fillColor;
			this.borderColor = borderColor;
			this.borderWidth = borderWidth;
			this.Margin = new BorderDouble(0);
			this.Padding = new BorderDouble(0);

			TextWidget textWidget = new TextWidget(label, pointSize: fontSize);
			ImageWidget imageWidget;

			FlowLayoutWidget container = new FlowLayoutWidget(flowDirection);

			if (centerText)
			{
				// make sure the contents are centered
				GuiWidget leftSpace = new GuiWidget(0, 1);
				leftSpace.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
				container.AddChild(leftSpace);
			}

			if (image != null && image.Width > 0)
			{
				imageWidget = new ImageWidget(image);
				imageWidget.VAnchor = VAnchor.ParentCenter;
				imageWidget.Margin = new BorderDouble(right: imageSpacing);
				container.AddChild(imageWidget);
			}

			if (label != "")
			{
				textWidget.VAnchor = VAnchor.ParentCenter;
				textWidget.TextColor = textColor;
				textWidget.Padding = new BorderDouble(3, 0);
				container.AddChild(textWidget);
			}

			if (centerText)
			{
				GuiWidget rightSpace = new GuiWidget(0, 1);
				rightSpace.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
				container.AddChild(rightSpace);

				container.HAnchor = Agg.UI.HAnchor.ParentLeftRight | Agg.UI.HAnchor.FitToChildren;
			}
			container.VAnchor = Agg.UI.VAnchor.ParentCenter;

			container.MinimumSize = new Vector2(width, height);
			container.Margin = margin;
			this.AddChild(container);
			HAnchor = HAnchor.ParentLeftRight | HAnchor.FitToChildren;
			VAnchor = VAnchor.ParentCenter | Agg.UI.VAnchor.FitToChildren;
		}
コード例 #4
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 += 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;
		}
コード例 #5
0
		private void AddWatermark()
		{
			string imagePathAndFile = Path.Combine(ApplicationDataStorage.Instance.ApplicationStaticDataPath, "OEMSettings", "watermark.png");
            if (File.Exists(imagePathAndFile))
            {
                ImageBuffer wattermarkImage = new ImageBuffer();
                ImageBMPIO.LoadImageData(imagePathAndFile, wattermarkImage);
                GuiWidget watermarkWidget = new ImageWidget(wattermarkImage);
                watermarkWidget.VAnchor = Agg.UI.VAnchor.ParentCenter;
                watermarkWidget.HAnchor = Agg.UI.HAnchor.ParentCenter;
                this.AddChildToBackground(watermarkWidget);
            }
		}
コード例 #6
0
		private void AddWatermark()
		{
			string imagePathAndFile = Path.Combine("OEMSettings", "watermark.png");
			if (StaticData.Instance.FileExists(imagePathAndFile))
			{
				ImageBuffer wattermarkImage = new ImageBuffer();
				StaticData.Instance.LoadImage(imagePathAndFile, wattermarkImage);

				GuiWidget watermarkWidget = new ImageWidget(wattermarkImage);
				watermarkWidget.VAnchor = Agg.UI.VAnchor.ParentCenter;
				watermarkWidget.HAnchor = Agg.UI.HAnchor.ParentCenter;
				this.AddChildToBackground(watermarkWidget);
			}
		}
コード例 #7
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;
		}
コード例 #8
0
		private FlowLayoutWidget GetCloudSyncDashboardControls()
		{
			FlowLayoutWidget cloudSyncContainer = new FlowLayoutWidget();
			cloudSyncContainer.HAnchor |= HAnchor.ParentLeftRight;
			cloudSyncContainer.VAnchor |= Agg.UI.VAnchor.ParentCenter;
			cloudSyncContainer.Margin = new BorderDouble(0, 0, 0, 0);
			cloudSyncContainer.Padding = new BorderDouble(0);

			ImageBuffer cloudMonitorImage = StaticData.Instance.LoadIcon("cloud-24x24.png").InvertLightness();
			cloudMonitorImage.SetRecieveBlender(new BlenderPreMultBGRA());
			int iconSize = (int)(24 * GuiWidget.DeviceScale);
			if (!ActiveTheme.Instance.IsDarkTheme)
			{
				cloudMonitorImage.InvertLightness();
			}

            ImageWidget cloudSyncIcon = new ImageWidget(cloudMonitorImage);
            cloudSyncIcon.Margin = new BorderDouble(right: 6, bottom: 6);
			cloudSyncIcon.VAnchor = VAnchor.ParentCenter;

			TextWidget cloudSyncLabel = new TextWidget("Cloud Sync".Localize());
            cloudSyncLabel.AutoExpandBoundsToText = true;
            cloudSyncLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor;
            cloudSyncLabel.VAnchor = VAnchor.ParentCenter;

            linkButtonFactory.fontSize = 10;
            Button cloudSyncGoLink = linkButtonFactory.Generate("Go to Dashboard".Localize().ToUpper());
            cloudSyncGoLink.ToolTipText = "Open cloud sync dashboard in web browser";
            cloudSyncGoLink.Click += new EventHandler(cloudSyncGoButton_Click);
			cloudSyncGoLink.VAnchor = VAnchor.ParentCenter;


			cloudSyncContainer.AddChild(cloudSyncIcon);
            cloudSyncContainer.AddChild(cloudSyncLabel);
            cloudSyncContainer.AddChild(new HorizontalSpacer()
			{
				VAnchor = VAnchor.ParentCenter,
			});
            cloudSyncContainer.AddChild(cloudSyncGoLink);

			return cloudSyncContainer;
		}
コード例 #9
0
		public PrintProgressBar(bool widgetIsExtended = true)
		{
			MinimumSize = new Vector2(0, 24);

			HAnchor = HAnchor.ParentLeftRight;
			BackgroundColor = ActiveTheme.Instance.SecondaryAccentColor;
			Margin = new BorderDouble(0);

			FlowLayoutWidget container = new FlowLayoutWidget(FlowDirection.LeftToRight);
			container.AnchorAll();
			container.Padding = new BorderDouble(6, 0);

			printTimeElapsed = new TextWidget("", pointSize: 11);
			printTimeElapsed.Printer.DrawFromHintedCache = true;
			printTimeElapsed.AutoExpandBoundsToText = true;
			printTimeElapsed.VAnchor = VAnchor.ParentCenter;

			printTimeRemaining = new TextWidget("", pointSize: 11);
			printTimeRemaining.Printer.DrawFromHintedCache = true;
			printTimeRemaining.AutoExpandBoundsToText = true;
			printTimeRemaining.VAnchor = VAnchor.ParentCenter;

			container.AddChild(printTimeElapsed);
			container.AddChild(new HorizontalSpacer());
			container.AddChild(printTimeRemaining);

			AddChild(container);

			if (UserSettings.Instance.IsTouchScreen)
			{
				upImageBuffer = StaticData.Instance.LoadIcon("TouchScreen/arrow_up_32x24.png");
				downImageBuffer = StaticData.Instance.LoadIcon("TouchScreen/arrow_down_32x24.png");

				indicatorWidget = new ImageWidget(upImageBuffer);
				indicatorWidget.HAnchor = HAnchor.ParentCenter;
				indicatorWidget.VAnchor = VAnchor.ParentCenter;

				WidgetIsExtended = widgetIsExtended;

				GuiWidget indicatorOverlay = new GuiWidget();
				indicatorOverlay.AnchorAll();
				indicatorOverlay.AddChild(indicatorWidget);

				AddChild(indicatorOverlay);
			}

			var clickOverlay = new GuiWidget();
			clickOverlay.AnchorAll();
			clickOverlay.Click += (s, e) =>
			{
				// In touchscreen mode, expand or collapse the print status row when clicked
				ApplicationView mainView = ApplicationController.Instance.MainView;
				if(mainView is TouchscreenView)
				{
					((TouchscreenView)mainView).ToggleTopContainer();
				}
			};
			AddChild(clickOverlay);

			PrinterConnectionAndCommunication.Instance.ActivePrintItemChanged.RegisterEvent(Instance_PrintItemChanged, ref unregisterEvents);
			PrinterConnectionAndCommunication.Instance.CommunicationStateChanged.RegisterEvent(Instance_PrintItemChanged, ref unregisterEvents);

			SetThemedColors();
			UpdatePrintStatus();
			UiThread.RunOnIdle(OnIdle);
		}
コード例 #10
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;
		}
コード例 #11
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;
		}
コード例 #12
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(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;
		}
コード例 #13
0
		private FlowLayoutWidget GetHomeButtonBar()
		{
			FlowLayoutWidget homeButtonBar = new FlowLayoutWidget();
			homeButtonBar.HAnchor = HAnchor.ParentLeftRight;
			homeButtonBar.Margin = new BorderDouble(3, 0, 3, 6) * TextWidget.GlobalPointSizeScaleRatio;
			homeButtonBar.Padding = new BorderDouble(0);

			textImageButtonFactory.borderWidth = 1;
			textImageButtonFactory.normalBorderColor = new RGBA_Bytes(ActiveTheme.Instance.PrimaryTextColor, 200);
			textImageButtonFactory.hoverBorderColor = new RGBA_Bytes(ActiveTheme.Instance.PrimaryTextColor, 200);

			ImageBuffer helpIconImage = StaticData.Instance.LoadIcon("icon_home_white_24x24.png");
			ImageWidget homeIconImageWidget = new ImageWidget(helpIconImage);
			homeIconImageWidget.Margin = new BorderDouble(0, 0, 6, 0) * TextWidget.GlobalPointSizeScaleRatio;
			homeIconImageWidget.OriginRelativeParent += new Vector2(0, 2) * TextWidget.GlobalPointSizeScaleRatio;
			RGBA_Bytes oldColor = this.textImageButtonFactory.normalFillColor;
			textImageButtonFactory.normalFillColor = new RGBA_Bytes(180, 180, 180);
			homeAllButton = textImageButtonFactory.Generate(LocalizedString.Get("ALL"));
			this.textImageButtonFactory.normalFillColor = oldColor;
			homeAllButton.ToolTipText = "Home X, Y and Z";
			homeAllButton.Margin = new BorderDouble(0, 0, 6, 0) * TextWidget.GlobalPointSizeScaleRatio;
			homeAllButton.Click += new EventHandler(homeAll_Click);

			textImageButtonFactory.FixedWidth = (int)homeAllButton.Width * TextWidget.GlobalPointSizeScaleRatio;
			homeXButton = textImageButtonFactory.Generate("X", centerText: true);
			homeXButton.ToolTipText = "Home X";
			homeXButton.Margin = new BorderDouble(0, 0, 6, 0) * TextWidget.GlobalPointSizeScaleRatio;
			homeXButton.Click += new EventHandler(homeXButton_Click);

			homeYButton = textImageButtonFactory.Generate("Y", centerText: true);
			homeYButton.ToolTipText = "Home Y";
			homeYButton.Margin = new BorderDouble(0, 0, 6, 0) * TextWidget.GlobalPointSizeScaleRatio;
			homeYButton.Click += new EventHandler(homeYButton_Click);

			homeZButton = textImageButtonFactory.Generate("Z", centerText: true);
			homeZButton.ToolTipText = "Home Z";
			homeZButton.Margin = new BorderDouble(0, 0, 6, 0) * TextWidget.GlobalPointSizeScaleRatio;
			homeZButton.Click += new EventHandler(homeZButton_Click);

			textImageButtonFactory.normalFillColor = RGBA_Bytes.White;
			textImageButtonFactory.FixedWidth = 0;

			GuiWidget spacer = new GuiWidget();
			spacer.HAnchor = HAnchor.ParentLeftRight;

			disableMotors = textImageButtonFactory.Generate("Release".Localize().ToUpper());
			disableMotors.Margin = new BorderDouble(0);
			disableMotors.Click += new EventHandler(disableMotors_Click);

			this.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;

			GuiWidget spacerReleaseShow = new GuiWidget(10 * TextWidget.GlobalPointSizeScaleRatio, 0);

			homeButtonBar.AddChild(homeIconImageWidget);
			homeButtonBar.AddChild(homeAllButton);
			homeButtonBar.AddChild(homeXButton);
			homeButtonBar.AddChild(homeYButton);
			homeButtonBar.AddChild(homeZButton);
			homeButtonBar.AddChild(spacer);
			homeButtonBar.AddChild(disableMotors);
			homeButtonBar.AddChild(spacerReleaseShow);

			return homeButtonBar;
		}
コード例 #14
0
		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;
		}
コード例 #15
0
        private GuiWidget CreateTerminalControlsContainer()
        {
            GroupBox terminalControlsContainer;
			terminalControlsContainer = new GroupBox(new LocalizedString("Communications").Translated);

            terminalControlsContainer.Margin = new BorderDouble(0);
            terminalControlsContainer.TextColor = ActiveTheme.Instance.PrimaryTextColor;
            terminalControlsContainer.BorderColor = ActiveTheme.Instance.PrimaryTextColor;
            terminalControlsContainer.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
            terminalControlsContainer.Height = 68;

            OutputScrollWindow.HookupPrinterOutput();

            {
                FlowLayoutWidget buttonBar = new FlowLayoutWidget();
                buttonBar.HAnchor |= HAnchor.ParentLeftRight;
                buttonBar.VAnchor |= Agg.UI.VAnchor.ParentCenter;
				buttonBar.Margin = new BorderDouble(3, 0, 3, 6);
                buttonBar.Padding = new BorderDouble(0);

                this.textImageButtonFactory.FixedHeight = TallButtonHeight;

				Agg.Image.ImageBuffer terminalImage = new Agg.Image.ImageBuffer();
				ImageBMPIO.LoadImageData(Path.Combine(ApplicationDataStorage.Instance.ApplicationStaticDataPath,"Icons", "PrintStatusControls", "terminal-24x24.png"), terminalImage);
				ImageWidget terminalIcon = new ImageWidget(terminalImage);
				terminalIcon.Margin = new BorderDouble (right: 6);

				Button showTerminal = textImageButtonFactory.Generate(new LocalizedString("SHOW TERMINAL").Translated);
                showTerminal.Margin = new BorderDouble(0);
                showTerminal.Click += (sender, e) =>
                {
                    OutputScrollWindow.Show();
                };

				//buttonBar.AddChild(terminalIcon);
                buttonBar.AddChild(showTerminal);

                terminalControlsContainer.AddChild(buttonBar);
            }

            return terminalControlsContainer;
        }
コード例 #16
0
		public PrintProgressBar(bool widgetIsExtended = true)
		{
			MinimumSize = new Vector2(0, 24);

			HAnchor = HAnchor.ParentLeftRight;
			BackgroundColor = ActiveTheme.Instance.SecondaryAccentColor;
			Margin = new BorderDouble(0);

			FlowLayoutWidget container = new FlowLayoutWidget(FlowDirection.LeftToRight);
			container.AnchorAll();
			container.Padding = new BorderDouble(6, 0);

			printTimeElapsed = new TextWidget("", pointSize: 11);
			printTimeElapsed.Printer.DrawFromHintedCache = true;
			printTimeElapsed.AutoExpandBoundsToText = true;
			printTimeElapsed.VAnchor = Agg.UI.VAnchor.ParentCenter;

			printTimeRemaining = new TextWidget("", pointSize: 11);
			printTimeRemaining.Printer.DrawFromHintedCache = true;
			printTimeRemaining.AutoExpandBoundsToText = true;
			printTimeRemaining.VAnchor = Agg.UI.VAnchor.ParentCenter;

			GuiWidget spacer = new GuiWidget();
			spacer.HAnchor = Agg.UI.HAnchor.ParentLeftRight;

			container.AddChild(printTimeElapsed);
			container.AddChild(spacer);
			container.AddChild(printTimeRemaining);

			AddChild(container);

			if (ActiveTheme.Instance.IsTouchScreen)
			{
				upImageBuffer = StaticData.Instance.LoadIcon("TouchScreen/arrow_up_32x24.png");
				downImageBuffer = StaticData.Instance.LoadIcon("TouchScreen/arrow_down_32x24.png");

				indicatorWidget = new ImageWidget(upImageBuffer);
				indicatorWidget.HAnchor = HAnchor.ParentCenter;
				indicatorWidget.VAnchor = VAnchor.ParentCenter;

				WidgetIsExtended = widgetIsExtended;

				GuiWidget indicatorOverlay = new GuiWidget();
				indicatorOverlay.AnchorAll();
				indicatorOverlay.AddChild(indicatorWidget);

				AddChild(indicatorOverlay);
			}

			ClickWidget clickOverlay = new ClickWidget();
			clickOverlay.AnchorAll();
			clickOverlay.Click += onProgressBarClick;

			AddChild(clickOverlay);

			AddHandlers();
			SetThemedColors();
			UpdatePrintStatus();
			UiThread.RunOnIdle(OnIdle);
		}
コード例 #17
0
		private FlowLayoutWidget GetGcodeTerminalControl()
		{
			FlowLayoutWidget buttonRow = new FlowLayoutWidget();
			buttonRow.HAnchor = HAnchor.ParentLeftRight;
			buttonRow.Margin = new BorderDouble(0, 4);

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

			ImageWidget terminalIcon = new ImageWidget(terminalSettingsImage);
			terminalIcon.Margin = new BorderDouble(right: 6, bottom: 6);

			TextWidget gcodeTerminalLabel = new TextWidget("Gcode Terminal");
			gcodeTerminalLabel.AutoExpandBoundsToText = true;
			gcodeTerminalLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor;
			gcodeTerminalLabel.VAnchor = VAnchor.ParentCenter;

			openGcodeTerminalButton = textImageButtonFactory.Generate("Show Terminal".Localize().ToUpper());
			openGcodeTerminalButton.Click += new EventHandler(openGcodeTerminalButton_Click);

			buttonRow.AddChild(terminalIcon);
			buttonRow.AddChild(gcodeTerminalLabel);
			buttonRow.AddChild(new HorizontalSpacer());
			buttonRow.AddChild(openGcodeTerminalButton);

			return buttonRow;
		}
コード例 #18
0
        private void AddEePromControls(FlowLayoutWidget controlsTopToBottomLayout)
        {
            GroupBox eePromControlsGroupBox = new GroupBox(groupBoxTitle);
            
			eePromControlsGroupBox.Margin = new BorderDouble(0);
            eePromControlsGroupBox.TextColor = ActiveTheme.Instance.PrimaryTextColor;
            eePromControlsGroupBox.BorderColor = ActiveTheme.Instance.PrimaryTextColor;
            eePromControlsGroupBox.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
            eePromControlsGroupBox.VAnchor = Agg.UI.VAnchor.FitToChildren;
			eePromControlsGroupBox.Height = 68;
            {
				FlowLayoutWidget eePromControlsLayout = new FlowLayoutWidget();
                eePromControlsLayout.HAnchor |= HAnchor.ParentCenter;
				eePromControlsLayout.VAnchor |= Agg.UI.VAnchor.ParentCenter;
				eePromControlsLayout.Margin = new BorderDouble(3, 0, 3, 6);
				eePromControlsLayout.Padding = new BorderDouble(0);
                {
					Agg.Image.ImageBuffer eePromImage = new Agg.Image.ImageBuffer();
					ImageIO.LoadImageData(Path.Combine(ApplicationDataStorage.Instance.ApplicationStaticDataPath,"Icons", "PrintStatusControls", "leveling-24x24.png"), eePromImage);
					ImageWidget eePromIcon = new ImageWidget(eePromImage);
					eePromIcon.Margin = new BorderDouble (right: 6);

                    Button openEePromWindow = textImageButtonFactory.Generate("Configure".Localize().ToUpper());
                    openEePromWindow.Click += (sender, e) =>
                    {
#if false // This is to force the creation of the repetier window for testing when we don't have repetier firmware.
                        new MatterHackers.MatterControl.EeProm.EePromRepetierWidget();
#else
                        switch (PrinterConnectionAndCommunication.Instance.FirmwareType)
                        {
                            case PrinterConnectionAndCommunication.FirmwareTypes.Repetier:
                                if (openEePromRepetierWidget != null)
                                {
                                    openEePromRepetierWidget.BringToFront();
                                }
                                else
                                {
                                    openEePromRepetierWidget = new EePromRepetierWidget();
                                    openEePromRepetierWidget.Closed += (RepetierWidget, RepetierEvent) => 
                                    {
                                        openEePromRepetierWidget = null;
                                    };
                                }
                                break;

                            case PrinterConnectionAndCommunication.FirmwareTypes.Marlin:
                                if (openEePromMarlinWidget != null)
                                {
                                    openEePromMarlinWidget.BringToFront();
                                }
                                else
                                {
                                    openEePromMarlinWidget = new EePromMarlinWidget();
                                    openEePromMarlinWidget.Closed += (marlinWidget, marlinEvent) => 
                                    {
                                        openEePromMarlinWidget = null;
                                    };
                                }
                                break;

                            default:
                                UiThread.RunOnIdle((state) =>
                                {
                                    StyledMessageBox.ShowMessageBox(noEepromMappingMessage, noEepromMappingTitle, StyledMessageBox.MessageType.OK);
                                }
                                );
                                break;
                        }
#endif
                    };
					//eePromControlsLayout.AddChild(eePromIcon);
                    eePromControlsLayout.AddChild(openEePromWindow);
                }

                eePromControlsGroupBox.AddChild(eePromControlsLayout);
            }

            eePromControlsContainer = new DisableableWidget();
            eePromControlsContainer.AddChild(eePromControlsGroupBox);

            controlsTopToBottomLayout.AddChild(eePromControlsContainer);
        }
コード例 #19
0
		private void AddContent(HtmlParser htmlParser, string htmlContent)
		{
			ElementState elementState = htmlParser.CurrentElementState;
			htmlContent = replaceMultipleWhiteSpacesWithSingleWhitespaceRegex.Replace(htmlContent, " ");
			string decodedHtml = HtmlParser.UrlDecode(htmlContent);
			switch (elementState.TypeName)
			{
				case "a":
					{
						elementsUnderConstruction.Push(new FlowLayoutWidget());
						elementsUnderConstruction.Peek().Name = "a";

						if (decodedHtml != null && decodedHtml != "")
						{
							Button linkButton = linkButtonFactory.Generate(decodedHtml.Replace("\r\n", "\n"));
							StyledTypeFace styled = new StyledTypeFace(LiberationSansFont.Instance, elementState.PointSize);
							double descentInPixels = styled.DescentInPixels;
							linkButton.OriginRelativeParent = new VectorMath.Vector2(linkButton.OriginRelativeParent.x, linkButton.OriginRelativeParent.y + descentInPixels);
							linkButton.Click += (sender, mouseEvent) =>
							{
								MatterControlApplication.Instance.LaunchBrowser(elementState.Href);
							};
							elementsUnderConstruction.Peek().AddChild(linkButton);
						}
					}
					break;

				case "h1":
				case "p":
					{
						elementsUnderConstruction.Push(new FlowLayoutWidget());
						elementsUnderConstruction.Peek().Name = "p";
						elementsUnderConstruction.Peek().HAnchor = HAnchor.ParentLeftRight;

						if (decodedHtml != null && decodedHtml != "")
						{
							WrappingTextWidget content = new WrappingTextWidget(decodedHtml, pointSize: elementState.PointSize, textColor: ActiveTheme.Instance.PrimaryTextColor);
							//content.VAnchor = VAnchor.ParentTop;
							elementsUnderConstruction.Peek().AddChild(content);
						}
					}
					break;

				case "div":
					{
						elementsUnderConstruction.Push(new FlowLayoutWidget());
						elementsUnderConstruction.Peek().Name = "div";

						if (decodedHtml != null && decodedHtml != "")
						{
							TextWidget content = new TextWidget(decodedHtml, pointSize: elementState.PointSize, textColor: ActiveTheme.Instance.PrimaryTextColor);
							elementsUnderConstruction.Peek().AddChild(content);
						}
					}
					break;

				case "!DOCTYPE":
					break;

				case "body":
					break;

				case "html":
					break;

				case "img":
					{
						ImageBuffer image = new ImageBuffer(Math.Max(elementState.SizeFixed.x, 1), Math.Max(elementState.SizeFixed.y, 1));
						ImageWidget imageWidget = new ImageWidget(image);
						imageWidget.Load += (s, e) => StaticData.DownloadToImageAsync(image, elementState.src, elementState.SizeFixed.x == 0 ? true : false);
						// put the image into the widget when it is done downloading.

						if (elementsUnderConstruction.Peek().Name == "a")
						{
							Button linkButton = new Button(0, 0, imageWidget);
							linkButton.Cursor = Cursors.Hand;
							linkButton.Click += (sender, mouseEvent) =>
							{
								MatterControlApplication.Instance.LaunchBrowser(elementState.Href);
							};
							elementsUnderConstruction.Peek().AddChild(linkButton);
						}
						else
						{
							elementsUnderConstruction.Peek().AddChild(imageWidget);
						}
					}
					break;

				case "input":
					break;

				case "table":
					break;

				case "td":
				case "span":
					GuiWidget widgetToAdd;

					if (elementState.Classes.Contains("translate"))
					{
						decodedHtml = decodedHtml.Localize();
					}
					if (elementState.Classes.Contains("toUpper"))
					{
						decodedHtml = decodedHtml.ToUpper();
					}
					if (elementState.Classes.Contains("versionNumber"))
					{
						decodedHtml = VersionInfo.Instance.ReleaseVersion;
					}
					if (elementState.Classes.Contains("buildNumber"))
					{
						decodedHtml = VersionInfo.Instance.BuildVersion;
					}

					Button createdButton = null;
					if (elementState.Classes.Contains("centeredButton"))
					{
						createdButton = textImageButtonFactory.Generate(decodedHtml);
						widgetToAdd = createdButton;
					}
					else if (elementState.Classes.Contains("linkButton"))
					{
						double oldFontSize = linkButtonFactory.fontSize;
						linkButtonFactory.fontSize = elementState.PointSize;
						createdButton = linkButtonFactory.Generate(decodedHtml);
						StyledTypeFace styled = new StyledTypeFace(LiberationSansFont.Instance, elementState.PointSize);
						double descentInPixels = styled.DescentInPixels;
						createdButton.OriginRelativeParent = new VectorMath.Vector2(createdButton.OriginRelativeParent.x, createdButton.OriginRelativeParent.y + descentInPixels);
						widgetToAdd = createdButton;
						linkButtonFactory.fontSize = oldFontSize;
					}
					else
					{
						TextWidget content = new TextWidget(decodedHtml, pointSize: elementState.PointSize, textColor: ActiveTheme.Instance.PrimaryTextColor);
						widgetToAdd = content;
					}

					if (createdButton != null)
					{
						if (elementState.Id == "sendFeedback")
						{
							createdButton.Click += (s, e) =>  ContactFormWindow.Open();
						}
						else if (elementState.Id == "clearCache")
						{
							createdButton.Click += (s, e) => AboutWidget.DeleteCacheData(0);
						}
					}

					if (elementState.VerticalAlignment == ElementState.VerticalAlignType.top)
					{
						widgetToAdd.VAnchor = VAnchor.ParentTop;
					}

					elementsUnderConstruction.Peek().AddChild(widgetToAdd);
					break;

				case "tr":
					elementsUnderConstruction.Push(new FlowLayoutWidget());
					elementsUnderConstruction.Peek().Name = "tr";
					if (elementState.SizePercent.y == 100)
					{
						elementsUnderConstruction.Peek().VAnchor = VAnchor.ParentBottomTop;
					}
					if (elementState.Alignment == ElementState.AlignType.center)
					{
						elementsUnderConstruction.Peek().HAnchor |= HAnchor.ParentCenter;
					}
					break;

				default:
					throw new NotImplementedException("Don't know what to do with '{0}'".FormatWith(elementState.TypeName));
			}
		}
コード例 #20
0
        private void AddEePromControls(FlowLayoutWidget controlsTopToBottomLayout)
        {
            GroupBox eePromControlsGroupBox = new GroupBox(new LocalizedString("EEProm Settings").Translated);

			eePromControlsGroupBox.Margin = new BorderDouble(0);
            eePromControlsGroupBox.TextColor = ActiveTheme.Instance.PrimaryTextColor;
            eePromControlsGroupBox.BorderColor = ActiveTheme.Instance.PrimaryTextColor;
            eePromControlsGroupBox.HAnchor |= Agg.UI.HAnchor.ParentLeftRight;
            eePromControlsGroupBox.VAnchor = Agg.UI.VAnchor.FitToChildren;
			eePromControlsGroupBox.Height = 68;

            {
				FlowLayoutWidget eePromControlsLayout = new FlowLayoutWidget();
				eePromControlsLayout.HAnchor |= HAnchor.ParentLeftRight;
				eePromControlsLayout.VAnchor |= Agg.UI.VAnchor.ParentCenter;
				eePromControlsLayout.Margin = new BorderDouble(3, 0, 3, 6);
				eePromControlsLayout.Padding = new BorderDouble(0);
                {
					Agg.Image.ImageBuffer eePromImage = new Agg.Image.ImageBuffer();
					ImageBMPIO.LoadImageData(Path.Combine(ApplicationDataStorage.Instance.ApplicationStaticDataPath,"Icons", "PrintStatusControls", "leveling-24x24.png"), eePromImage);
					ImageWidget eePromIcon = new ImageWidget(eePromImage);
					eePromIcon.Margin = new BorderDouble (right: 6);

					Button openEePromWindow = textImageButtonFactory.Generate(new LocalizedString("CONFIGURE").Translated);
                    openEePromWindow.Click += (sender, e) =>
                    {
#if false // This is to force the creation of the repetier window for testing when we don't have repetier firmware.
                        new MatterHackers.MatterControl.EeProm.EePromRepetierWidget();
#else
						switch(PrinterCommunication.Instance.FirmwareType)
                        {
                            case PrinterCommunication.FirmwareTypes.Repetier:
                                new MatterHackers.MatterControl.EeProm.EePromRepetierWidget();
                            break;

                            case PrinterCommunication.FirmwareTypes.Marlin:
                                new MatterHackers.MatterControl.EeProm.EePromMarlinWidget();
                            break;

                            default:
                                UiThread.RunOnIdle((state) => 
                                {
									string message = new LocalizedString("Oops! There is no eeprom mapping for your printer's firmware.").Translated;
                                    StyledMessageBox.ShowMessageBox(message, "Warning no eeprom mapping", StyledMessageBox.MessageType.OK);
                                }
                                );
                            break;
                        }
#endif
                    };
					//eePromControlsLayout.AddChild(eePromIcon);
                    eePromControlsLayout.AddChild(openEePromWindow);
                }

                eePromControlsGroupBox.AddChild(eePromControlsLayout);
            }

            eePromControlsContainer = new DisableableWidget();
            eePromControlsContainer.AddChild(eePromControlsGroupBox);

            controlsTopToBottomLayout.AddChild(eePromControlsContainer);
        }
コード例 #21
0
        private GuiWidget CreatePrintLevelingControlsContainer()
        {
            GroupBox printLevelingControlsContainer;
			printLevelingControlsContainer = new GroupBox(new LocalizedString("Automatic Calibration").Translated);

            printLevelingControlsContainer.Margin = new BorderDouble(0);
            printLevelingControlsContainer.TextColor = ActiveTheme.Instance.PrimaryTextColor;
            printLevelingControlsContainer.BorderColor = ActiveTheme.Instance.PrimaryTextColor;
            printLevelingControlsContainer.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
            printLevelingControlsContainer.Height = 68;

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

                this.textImageButtonFactory.FixedHeight = TallButtonHeight;

				Button runPrintLevelingButton = textImageButtonFactory.Generate(new LocalizedString("CONFIGURE").Translated);
                runPrintLevelingButton.Margin = new BorderDouble(left:6);
                runPrintLevelingButton.VAnchor = VAnchor.ParentCenter;
                runPrintLevelingButton.Click += new ButtonBase.ButtonEventHandler(runPrintLeveling_Click);

                Agg.Image.ImageBuffer levelingImage = new Agg.Image.ImageBuffer();
				ImageBMPIO.LoadImageData(Path.Combine(ApplicationDataStorage.Instance.ApplicationStaticDataPath,"Icons", "PrintStatusControls", "leveling-24x24.png"), levelingImage);
                ImageWidget levelingIcon = new ImageWidget(levelingImage);
				levelingIcon.Margin = new BorderDouble (right: 6);

				enablePrintLevelingButton = textImageButtonFactory.Generate(new LocalizedString("ENABLE").Translated);
				enablePrintLevelingButton.Margin = new BorderDouble(left:6);
				enablePrintLevelingButton.VAnchor = VAnchor.ParentCenter;
				enablePrintLevelingButton.Click += new ButtonBase.ButtonEventHandler(enablePrintLeveling_Click);

				disablePrintLevelingButton = textImageButtonFactory.Generate(new LocalizedString("DISABLE").Translated);
				disablePrintLevelingButton.Margin = new BorderDouble(left:6);
				disablePrintLevelingButton.VAnchor = VAnchor.ParentCenter;
				disablePrintLevelingButton.Click += new ButtonBase.ButtonEventHandler(disablePrintLeveling_Click);

				CheckBox doLevelingCheckBox = new CheckBox(new LocalizedString("Enable Automatic Print Leveling").Translated);
                doLevelingCheckBox.Margin = new BorderDouble(left: 3);
                doLevelingCheckBox.TextColor = ActiveTheme.Instance.PrimaryTextColor;
                doLevelingCheckBox.VAnchor = VAnchor.ParentCenter;
                doLevelingCheckBox.Checked = ActivePrinterProfile.Instance.DoPrintLeveling;

				printLevelingStatusLabel = new TextWidget ("");
				printLevelingStatusLabel.AutoExpandBoundsToText = true;
				printLevelingStatusLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor;
				printLevelingStatusLabel.VAnchor = VAnchor.ParentCenter;

				GuiWidget hSpacer = new GuiWidget ();
				hSpacer.HAnchor = HAnchor.ParentLeftRight;

                buttonBar.AddChild(levelingIcon);
				//buttonBar.AddChild(doLevelingCheckBox);
				buttonBar.AddChild (printLevelingStatusLabel);
				buttonBar.AddChild (hSpacer);
				buttonBar.AddChild(enablePrintLevelingButton);
				buttonBar.AddChild(disablePrintLevelingButton);
                buttonBar.AddChild(runPrintLevelingButton);
                doLevelingCheckBox.CheckedStateChanged += (sender, e) =>
                {
                    ActivePrinterProfile.Instance.DoPrintLeveling = doLevelingCheckBox.Checked;
                };
                ActivePrinterProfile.Instance.DoPrintLevelingChanged.RegisterEvent((sender, e) =>
                {
					SetPrintLevelButtonVisiblity();

                }, ref unregisterEvents);

                printLevelingControlsContainer.AddChild(buttonBar);
            }
			SetPrintLevelButtonVisiblity ();
            return printLevelingControlsContainer;
        }
コード例 #22
0
        GuiWidget CreateOptionsMenu()
        {
            ImageBuffer gearImage = new ImageBuffer();
            string imagePathAndFile = Path.Combine(ApplicationDataStorage.Instance.ApplicationStaticDataPath, "gear_icon.png");
            ImageBMPIO.LoadImageData(imagePathAndFile, gearImage);

            FlowLayoutWidget leftToRight = new FlowLayoutWidget();
            leftToRight.Margin = new BorderDouble(5, 0);
            string optionsString = new LocalizedString("Options").Translated;
            TextWidget optionsText = new TextWidget(optionsString, textColor: RGBA_Bytes.White);
            optionsText.VAnchor = Agg.UI.VAnchor.ParentCenter;
            optionsText.Margin = new BorderDouble(0, 0, 3, 0);
            leftToRight.AddChild(optionsText);
            GuiWidget gearWidget = new ImageWidget(gearImage);
            gearWidget.VAnchor = Agg.UI.VAnchor.ParentCenter;
            leftToRight.AddChild(gearWidget);
            leftToRight.HAnchor = HAnchor.FitToChildren;
            leftToRight.VAnchor = VAnchor.FitToChildren;

            Menu optionMenu = new Menu(leftToRight);
            optionMenu.OpenOffset = new Vector2(-2, -10);
            optionMenu.VAnchor = Agg.UI.VAnchor.ParentCenter;
            optionMenu.MenuItems.Add(new MenuItem(new ThemeColorSelectorWidget()));

            return optionMenu;
        }
コード例 #23
0
        private FlowLayoutWidget GetHomeButtonBar()
        {
            FlowLayoutWidget homeButtonBar = new FlowLayoutWidget();
            homeButtonBar.HAnchor = HAnchor.ParentLeftRight;
            homeButtonBar.Margin = new BorderDouble(3, 0, 3, 6);
            homeButtonBar.Padding = new BorderDouble(0);

            string homeIconFile = "icon_home_white_24x24.png";
            string fileAndPath = Path.Combine(ApplicationDataStorage.Instance.ApplicationStaticDataPath, homeIconFile);
            ImageBuffer helpIconImage = new ImageBuffer();
            ImageBMPIO.LoadImageData(fileAndPath, helpIconImage);
            ImageWidget homeIconImageWidget = new ImageWidget(helpIconImage);
            homeIconImageWidget.Margin = new BorderDouble(0, 0, 6, 0);
            homeIconImageWidget.OriginRelativeParent += new Vector2(0, 2);
            RGBA_Bytes oldColor = this.textImageButtonFactory.normalFillColor;
            textImageButtonFactory.normalFillColor = new RGBA_Bytes(190, 190, 190);
			homeAllButton = textImageButtonFactory.Generate(new LocalizedString("ALL").Translated);
            this.textImageButtonFactory.normalFillColor = oldColor;
            homeAllButton.Margin = new BorderDouble(0, 0, 6, 0);
            homeAllButton.Click += new ButtonBase.ButtonEventHandler(homeAll_Click);

            textImageButtonFactory.FixedWidth = (int)homeAllButton.Width;
            homeXButton = textImageButtonFactory.Generate("X", centerText: true);
            homeXButton.Margin = new BorderDouble(0, 0, 6, 0);
            homeXButton.Click += new ButtonBase.ButtonEventHandler(homeXButton_Click);

            homeYButton = textImageButtonFactory.Generate("Y", centerText: true);
            homeYButton.Margin = new BorderDouble(0, 0, 6, 0);
            homeYButton.Click += new ButtonBase.ButtonEventHandler(homeYButton_Click);

            homeZButton = textImageButtonFactory.Generate("Z", centerText: true);
            homeZButton.Margin = new BorderDouble(0, 0, 6, 0);
            homeZButton.Click += new ButtonBase.ButtonEventHandler(homeZButton_Click);

            textImageButtonFactory.normalFillColor = RGBA_Bytes.White;
            textImageButtonFactory.FixedWidth = 0;

            GuiWidget spacer = new GuiWidget();
            spacer.HAnchor = HAnchor.ParentLeftRight;

			disableMotors = textImageButtonFactory.Generate(new LocalizedString("UNLOCK").Translated);
            disableMotors.Margin = new BorderDouble(0);
            disableMotors.Click += new ButtonBase.ButtonEventHandler(disableMotors_Click);

            GuiWidget spacerReleaseShow = new GuiWidget(10, 0);

            homeButtonBar.AddChild(homeIconImageWidget);
            homeButtonBar.AddChild(homeAllButton);
            homeButtonBar.AddChild(homeXButton);
            homeButtonBar.AddChild(homeYButton);
            homeButtonBar.AddChild(homeZButton);
            homeButtonBar.AddChild(spacer);
            homeButtonBar.AddChild(disableMotors);
            homeButtonBar.AddChild(spacerReleaseShow);

            return homeButtonBar;
        }
コード例 #24
0
		protected GuiWidget GetThumbnailWidget(LibraryProvider parentProvider, PrintItemCollection printItemCollection, ImageBuffer imageBuffer)
		{
			Vector2 expectedSize = new Vector2((int)(50 * TextWidget.GlobalPointSizeScaleRatio), (int)(50 * TextWidget.GlobalPointSizeScaleRatio));
			if (imageBuffer.Width != expectedSize.x)
			{
				ImageBuffer scaledImageBuffer = new ImageBuffer((int)expectedSize.x, (int)expectedSize.y, 32, new BlenderBGRA());
				scaledImageBuffer.NewGraphics2D().Render(imageBuffer, 0, 0, scaledImageBuffer.Width, scaledImageBuffer.Height);
				imageBuffer = scaledImageBuffer;
			}

			ImageWidget folderThumbnail = new ImageWidget(imageBuffer);
			folderThumbnail.BackgroundColor = ActiveTheme.Instance.PrimaryAccentColor;

			Button clickThumbnail = new Button(0, 0, folderThumbnail);

			PrintItemCollection localPrintItemCollection = printItemCollection;
			clickThumbnail.Click += (sender, e) =>
			{
				if (ActiveTheme.Instance.IsTouchScreen)
				{
					if (parentProvider == null)
					{
						this.CurrentLibraryProvider = this.CurrentLibraryProvider.GetProviderForCollection(localPrintItemCollection);
					}
					else
					{
						this.CurrentLibraryProvider = parentProvider;
					}
				}
				else
				{
					MouseEventArgs mouseEvent = e as MouseEventArgs;

					if (mouseEvent != null
						&& IsDoubleClick(mouseEvent))
					{
						if (parentProvider == null)
						{
							this.CurrentLibraryProvider = this.CurrentLibraryProvider.GetProviderForCollection(localPrintItemCollection);
						}
						else
						{
							this.CurrentLibraryProvider = parentProvider;
						}
					}
				}

				UiThread.RunOnIdle(RebuildView);
			};

			return clickThumbnail;
		}
コード例 #25
0
		protected GuiWidget GetThumbnailWidget(LibraryProvider parentProvider, PrintItemCollection printItemCollection, ImageBuffer imageBuffer)
		{
			Vector2 expectedSize = new Vector2((int)(50 * TextWidget.GlobalPointSizeScaleRatio), (int)(50 * TextWidget.GlobalPointSizeScaleRatio));
			if (imageBuffer.Width != expectedSize.x)
			{
				ImageBuffer scaledImageBuffer = new ImageBuffer((int)expectedSize.x, (int)expectedSize.y, 32, new BlenderBGRA());
				scaledImageBuffer.NewGraphics2D().Render(imageBuffer, 0, 0, scaledImageBuffer.Width, scaledImageBuffer.Height);
				imageBuffer = scaledImageBuffer;
			}

			ImageWidget folderThumbnail = new ImageWidget(imageBuffer);
			folderThumbnail.BackgroundColor = ActiveTheme.Instance.PrimaryAccentColor;

			Button clickThumbnail = new Button(0, 0, folderThumbnail);
			clickThumbnail.Cursor = Cursors.Hand;

			clickThumbnail.Click += (sender, e) =>
			{
				if (parentProvider == null)
				{
					this.CurrentLibraryProvider = this.CurrentLibraryProvider.GetProviderForCollection(printItemCollection);
				}
				else
				{
					this.CurrentLibraryProvider = parentProvider;
				}
			};

			return clickThumbnail;
		}
コード例 #26
0
        public PluginChooserWindow()
            : base(360, 300)
        {
			Title = new LocalizedString("Installed Plugins").Translated;

            FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom);
            topToBottom.AnchorAll();
            topToBottom.Padding = new BorderDouble(3, 0, 3, 5);

            FlowLayoutWidget headerRow = new FlowLayoutWidget(FlowDirection.LeftToRight);
            headerRow.HAnchor = HAnchor.ParentLeftRight;
            headerRow.Margin = new BorderDouble(0, 3, 0, 0);
            headerRow.Padding = new BorderDouble(0, 3, 0, 3);

            {
				string elementHeaderLblBeg = new LocalizedString("Select a Design Tool").Translated;
				string elementHeaderLblFull = string.Format("{0}:", elementHeaderLblBeg);
				string elementHeaderLbl = elementHeaderLblFull;
				TextWidget elementHeader = new TextWidget(string.Format(elementHeaderLbl), pointSize: 14);
                elementHeader.TextColor = ActiveTheme.Instance.PrimaryTextColor;
                elementHeader.HAnchor = HAnchor.ParentLeftRight;
                elementHeader.VAnchor = Agg.UI.VAnchor.ParentBottom;

                headerRow.AddChild(elementHeader);
            }

            topToBottom.AddChild(headerRow);

            GuiWidget presetsFormContainer = new GuiWidget();
            //ListBox printerListContainer = new ListBox();
            {
                presetsFormContainer.HAnchor = HAnchor.ParentLeftRight;
                presetsFormContainer.VAnchor = VAnchor.ParentBottomTop;
                presetsFormContainer.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;
            }

            FlowLayoutWidget pluginRowContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);
            pluginRowContainer.AnchorAll();
            presetsFormContainer.AddChild(pluginRowContainer);

            foreach(CreatorInformation creatorInfo in RegisteredCreators.Instance.Creators)
            {
                ClickWidget pluginRow = new ClickWidget();         
                pluginRow.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
                pluginRow.Height = 38;
			    pluginRow.BackgroundColor = RGBA_Bytes.White;
                pluginRow.Padding = new BorderDouble(3);
                pluginRow.Margin = new BorderDouble(6,0,6,6);                

                GuiWidget overlay = new GuiWidget();
                overlay.AnchorAll();
                overlay.Cursor = Cursors.Hand;
                
                FlowLayoutWidget macroRow = new FlowLayoutWidget();
                macroRow.AnchorAll();
                macroRow.BackgroundColor = RGBA_Bytes.White;

                if (creatorInfo.iconPath != "")
                {
                    ImageBuffer imageBuffer = LoadImage(creatorInfo.iconPath);
                    ImageWidget imageWidget = new ImageWidget(imageBuffer);
                    macroRow.AddChild(imageWidget);
                }

                TextWidget buttonLabel = new TextWidget(creatorInfo.description, pointSize: 14);

                buttonLabel.Margin = new BorderDouble(left: 10);
                buttonLabel.VAnchor = Agg.UI.VAnchor.ParentCenter;                
                macroRow.AddChild(buttonLabel);

                FlowLayoutWidget hSpacer = new FlowLayoutWidget();
                hSpacer.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
                macroRow.AddChild(hSpacer);

                CreatorInformation callCorrectFunctionHold = creatorInfo;
                pluginRow.Click += (sender, e) =>
                {
                    if (RegisteredCreators.Instance.Creators.Count > 0)
                    {
                        callCorrectFunctionHold.functionToLaunchCreator(null, null);
                    }
                    UiThread.RunOnIdle(CloseOnIdle);
                };
                pluginRow.AddChild(macroRow);
                pluginRow.AddChild(overlay);
                pluginRowContainer.AddChild(pluginRow);
            }

            topToBottom.AddChild(presetsFormContainer);
            BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;

            //ShowAsSystemWindow();

			Button cancelPresetsButton = textImageButtonFactory.Generate(new LocalizedString("Cancel").Translated);
            cancelPresetsButton.Click += (sender, e) => { Close(); };

            FlowLayoutWidget buttonRow = new FlowLayoutWidget();
            buttonRow.HAnchor = HAnchor.ParentLeftRight;
            buttonRow.Padding = new BorderDouble(0, 3);

            GuiWidget hButtonSpacer = new GuiWidget();
            hButtonSpacer.HAnchor = HAnchor.ParentLeftRight;
            
            buttonRow.AddChild(hButtonSpacer);
            buttonRow.AddChild(cancelPresetsButton);

            topToBottom.AddChild(buttonRow);

            AddChild(topToBottom);
        }
コード例 #27
0
		private FlowLayoutWidget GetEEPromControl()
		{
			FlowLayoutWidget buttonRow = new FlowLayoutWidget();
			buttonRow.HAnchor = HAnchor.ParentLeftRight;
			buttonRow.Margin = new BorderDouble(0, 4);

			TextWidget notificationSettingsLabel = new TextWidget("EEProm Settings".Localize());
			notificationSettingsLabel.AutoExpandBoundsToText = true;
			notificationSettingsLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor;
			notificationSettingsLabel.VAnchor = VAnchor.ParentCenter;

			Agg.Image.ImageBuffer eePromImage = StaticData.Instance.LoadIcon(Path.Combine("PrintStatusControls", "leveling-24x24.png"));
			if (!ActiveTheme.Instance.IsDarkTheme)
			{
				InvertLightness.DoInvertLightness(eePromImage);
			}
			ImageWidget eePromIcon = new ImageWidget(eePromImage);
			eePromIcon.Margin = new BorderDouble(right: 6);

			Button configureEePromButton = textImageButtonFactory.Generate("Configure".Localize().ToUpper());
			configureEePromButton.Click += new EventHandler(configureEePromButton_Click);

			//buttonRow.AddChild(eePromIcon);
			buttonRow.AddChild(notificationSettingsLabel);
			buttonRow.AddChild(new HorizontalSpacer());
			buttonRow.AddChild(configureEePromButton);

			return buttonRow;
		}
コード例 #28
0
		private FlowLayoutWidget GetHomeButtonBar()
		{
			FlowLayoutWidget homeButtonBar = new FlowLayoutWidget();
			homeButtonBar.HAnchor = HAnchor.ParentLeftRight;
			homeButtonBar.Margin = new BorderDouble(3, 0, 3, 6);
			homeButtonBar.Padding = new BorderDouble(0);

			textImageButtonFactory.borderWidth = 1;
			textImageButtonFactory.normalBorderColor = new RGBA_Bytes(ActiveTheme.Instance.PrimaryTextColor, 200);
			textImageButtonFactory.hoverBorderColor = new RGBA_Bytes(ActiveTheme.Instance.PrimaryTextColor, 200);

			ImageBuffer helpIconImage = StaticData.Instance.LoadIcon("icon_home_white_24x24.png", 24, 24);
			if (ActiveTheme.Instance.IsDarkTheme)
			{
				helpIconImage.InvertLightness();
			}
			ImageWidget homeIconImageWidget = new ImageWidget(helpIconImage);

			homeIconImageWidget.Margin = new BorderDouble(0, 0, 6, 0);
			homeIconImageWidget.OriginRelativeParent += new Vector2(0, 2) * GuiWidget.DeviceScale;
			RGBA_Bytes oldColor = this.textImageButtonFactory.normalFillColor;
			textImageButtonFactory.normalFillColor = new RGBA_Bytes(180, 180, 180);
			homeAllButton = textImageButtonFactory.Generate(LocalizedString.Get("ALL"));
			this.textImageButtonFactory.normalFillColor = oldColor;
			homeAllButton.ToolTipText = "Home X, Y and Z";
			homeAllButton.Margin = new BorderDouble(0, 0, 6, 0);
			homeAllButton.Click += new EventHandler(homeAll_Click);

			textImageButtonFactory.FixedWidth = (int)homeAllButton.Width * GuiWidget.DeviceScale;
			homeXButton = textImageButtonFactory.Generate("X", centerText: true);
			homeXButton.ToolTipText = "Home X";
			homeXButton.Margin = new BorderDouble(0, 0, 6, 0);
			homeXButton.Click += new EventHandler(homeXButton_Click);

			homeYButton = textImageButtonFactory.Generate("Y", centerText: true);
			homeYButton.ToolTipText = "Home Y";
			homeYButton.Margin = new BorderDouble(0, 0, 6, 0);
			homeYButton.Click += new EventHandler(homeYButton_Click);

			homeZButton = textImageButtonFactory.Generate("Z", centerText: true);
			homeZButton.ToolTipText = "Home Z";
			homeZButton.Margin = new BorderDouble(0, 0, 6, 0);
			homeZButton.Click += new EventHandler(homeZButton_Click);

			textImageButtonFactory.normalFillColor = RGBA_Bytes.White;
			textImageButtonFactory.FixedWidth = 0;

			disableMotors = textImageButtonFactory.Generate("Release".Localize().ToUpper());
			disableMotors.Margin = new BorderDouble(0);
			disableMotors.Click += new EventHandler(disableMotors_Click);
			this.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;

			GuiWidget spacerReleaseShow = new GuiWidget(10 * GuiWidget.DeviceScale, 0);

			homeButtonBar.AddChild(homeIconImageWidget);
			homeButtonBar.AddChild(homeAllButton);
			homeButtonBar.AddChild(homeXButton);
			homeButtonBar.AddChild(homeYButton);
			homeButtonBar.AddChild(homeZButton);

			offsetStreamLabel = new TextWidget("", textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize: 8);
			offsetStreamLabel.AutoExpandBoundsToText = true;
			offsetStreamLabel.VAnchor = VAnchor.ParentCenter;
			homeButtonBar.AddChild(offsetStreamLabel);

			homeButtonBar.AddChild(new HorizontalSpacer());
			homeButtonBar.AddChild(disableMotors);
			homeButtonBar.AddChild(spacerReleaseShow);

			PrinterConnectionAndCommunication.Instance.OffsetStreamChanged += OffsetStreamChanged;

			return homeButtonBar;
		}
コード例 #29
0
		public void AddElements()
		{
			Title = LocalizedString.Get("Design Add-ons");

			FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom);
			topToBottom.AnchorAll();
			topToBottom.Padding = new BorderDouble(3, 0, 3, 5);

			FlowLayoutWidget headerRow = new FlowLayoutWidget(FlowDirection.LeftToRight);
			headerRow.HAnchor = HAnchor.ParentLeftRight;
			headerRow.Margin = new BorderDouble(0, 3, 0, 0);
			headerRow.Padding = new BorderDouble(0, 3, 0, 3);
			{
				string elementHeaderLabelBeg = LocalizedString.Get("Select a Design Tool");
				string elementHeaderLabelFull = string.Format("{0}:", elementHeaderLabelBeg);
				string elementHeaderLabel = elementHeaderLabelFull;
				TextWidget elementHeader = new TextWidget(string.Format(elementHeaderLabel), pointSize: 14);
				elementHeader.TextColor = ActiveTheme.Instance.PrimaryTextColor;
				elementHeader.HAnchor = HAnchor.ParentLeftRight;
				elementHeader.VAnchor = Agg.UI.VAnchor.ParentBottom;

				headerRow.AddChild(elementHeader);
			}

			topToBottom.AddChild(headerRow);

			GuiWidget presetsFormContainer = new GuiWidget();
			{
				presetsFormContainer.HAnchor = HAnchor.ParentLeftRight;
				presetsFormContainer.VAnchor = VAnchor.ParentBottomTop;
				presetsFormContainer.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;
			}

			FlowLayoutWidget pluginRowContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);
			pluginRowContainer.AnchorAll();
			presetsFormContainer.AddChild(pluginRowContainer);

			unlockButtonFactory.Margin = new BorderDouble(10, 0);
			if (ActiveTheme.Instance.IsDarkTheme)
			{
				unlockButtonFactory.normalFillColor = new RGBA_Bytes(0, 0, 0, 100);
				unlockButtonFactory.normalBorderColor = new RGBA_Bytes(0, 0, 0, 100);
				unlockButtonFactory.hoverFillColor = new RGBA_Bytes(0, 0, 0, 50);
				unlockButtonFactory.hoverBorderColor = new RGBA_Bytes(0, 0, 0, 50);
			}
			else
			{
				unlockButtonFactory.normalFillColor = new RGBA_Bytes(0, 0, 0, 50);
				unlockButtonFactory.normalBorderColor = new RGBA_Bytes(0, 0, 0, 50);
				unlockButtonFactory.hoverFillColor = new RGBA_Bytes(0, 0, 0, 100);
				unlockButtonFactory.hoverBorderColor = new RGBA_Bytes(0, 0, 0, 100);
			}

			foreach (CreatorInformation creatorInfo in RegisteredCreators.Instance.Creators)
			{
				FlowLayoutWidget pluginListingContainer = new FlowLayoutWidget();
				pluginListingContainer.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
				pluginListingContainer.BackgroundColor = RGBA_Bytes.White;
				pluginListingContainer.Padding = new BorderDouble(0);
				pluginListingContainer.Margin = new BorderDouble(6, 0, 6, 6);

				ClickWidget pluginRow = new ClickWidget();
				pluginRow.Margin = new BorderDouble(6, 0, 6, 0);
				pluginRow.Height = 38;
				pluginRow.HAnchor = Agg.UI.HAnchor.ParentLeftRight;

				FlowLayoutWidget macroRow = new FlowLayoutWidget();
				macroRow.AnchorAll();
				macroRow.BackgroundColor = RGBA_Bytes.White;

				if (creatorInfo.iconPath != "")
				{
					ImageBuffer imageBuffer = LoadImage(creatorInfo.iconPath);
					ImageWidget imageWidget = new ImageWidget(imageBuffer);
					imageWidget.VAnchor = Agg.UI.VAnchor.ParentCenter;
					macroRow.AddChild(imageWidget);
				}

				bool userHasPermission;
				if (!creatorInfo.paidAddOnFlag)
				{
					userHasPermission = true;
				}
				else
				{
					userHasPermission = creatorInfo.permissionFunction();
				}

				string addOnDescription;
				addOnDescription = creatorInfo.description;
				TextWidget buttonLabel = new TextWidget(addOnDescription, pointSize: 14);
				buttonLabel.Margin = new BorderDouble(left: 10);
				buttonLabel.VAnchor = Agg.UI.VAnchor.ParentCenter;
				macroRow.AddChild(buttonLabel);

				if (!userHasPermission)
				{
					TextWidget demoLabel = new TextWidget("(demo)", pointSize: 10);

					demoLabel.Margin = new BorderDouble(left: 4);
					demoLabel.VAnchor = Agg.UI.VAnchor.ParentCenter;
					macroRow.AddChild(demoLabel);
				}

				FlowLayoutWidget hSpacer = new FlowLayoutWidget();
				hSpacer.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
				macroRow.AddChild(hSpacer);

				CreatorInformation callCorrectFunctionHold = creatorInfo;
				pluginRow.Click += (sender, e) =>
				{
					if (RegisteredCreators.Instance.Creators.Count > 0)
					{
						UiThread.RunOnIdle(CloseOnIdle, callCorrectFunctionHold);
					}
					else
					{
						UiThread.RunOnIdle(CloseOnIdle);
					}
				};

				pluginRow.Cursor = Cursors.Hand;
				macroRow.Selectable = false;
				pluginRow.AddChild(macroRow);

				pluginListingContainer.AddChild(pluginRow);

				if (!userHasPermission)
				{
					Button unlockButton = unlockButtonFactory.Generate("Unlock");
					unlockButton.Margin = new BorderDouble(0);
					unlockButton.Cursor = Cursors.Hand;
					unlockButton.Click += (sender, e) =>
					{
						callCorrectFunctionHold.unlockFunction();
					};
					pluginListingContainer.AddChild(unlockButton);
				}

				pluginRowContainer.AddChild(pluginListingContainer);
				if (callCorrectFunctionHold.unlockRegisterFunction != null)
				{
					callCorrectFunctionHold.unlockRegisterFunction(TriggerReload, ref unregisterEvents);
				}
			}

			topToBottom.AddChild(presetsFormContainer);
			BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;

			Button cancelPresetsButton = textImageButtonFactory.Generate(LocalizedString.Get("Cancel"));
			cancelPresetsButton.Click += (sender, e) =>
			{
				UiThread.RunOnIdle(CloseOnIdle);
			};

			FlowLayoutWidget buttonRow = new FlowLayoutWidget();
			buttonRow.HAnchor = HAnchor.ParentLeftRight;
			buttonRow.Padding = new BorderDouble(0, 3);

			GuiWidget hButtonSpacer = new GuiWidget();
			hButtonSpacer.HAnchor = HAnchor.ParentLeftRight;

			buttonRow.AddChild(hButtonSpacer);
			buttonRow.AddChild(cancelPresetsButton);

			topToBottom.AddChild(buttonRow);

			AddChild(topToBottom);
		}
コード例 #30
0
        private GuiWidget CreatePrintLevelingControlsContainer()
        {
            Button editButton;
            GroupBox printLevelingControlsContainer = new GroupBox(textImageButtonFactory.GenerateGroupBoxLabelWithEdit(LocalizedString.Get("Automatic Calibration"), out editButton));
            editButton.Click += (sender, e) =>
            {
                UiThread.RunOnIdle((state) =>
                {
                    if (editLevelingSettingsWindow == null)
                    {
                        editLevelingSettingsWindow = new EditLevelingSettingsWindow();
                        editLevelingSettingsWindow.Closed += (sender2, e2) =>
                        {
                            editLevelingSettingsWindow = null;
                        };
                    }
                    else
                    {
                        editLevelingSettingsWindow.BringToFront();
                    }
                });
            };

            printLevelingControlsContainer.Margin = new BorderDouble(0);
            printLevelingControlsContainer.TextColor = ActiveTheme.Instance.PrimaryTextColor;
            printLevelingControlsContainer.BorderColor = ActiveTheme.Instance.PrimaryTextColor;
            printLevelingControlsContainer.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
            printLevelingControlsContainer.Height = 68;

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

                this.textImageButtonFactory.FixedHeight = TallButtonHeight;

                Button runPrintLevelingButton = textImageButtonFactory.Generate("Configure".Localize().ToUpper());
                runPrintLevelingButton.Margin = new BorderDouble(left:6);
                runPrintLevelingButton.VAnchor = VAnchor.ParentCenter;
                runPrintLevelingButton.Click += (sender, e) =>
                {
                    UiThread.RunOnIdle((state) =>
                    {
                        LevelWizardBase.ShowPrintLevelWizard(LevelWizardBase.RuningState.UserRequestedCalibration);
                    });
                };

                Agg.Image.ImageBuffer levelingImage = new Agg.Image.ImageBuffer();
				ImageIO.LoadImageData(Path.Combine(ApplicationDataStorage.Instance.ApplicationStaticDataPath,"Icons", "PrintStatusControls", "leveling-24x24.png"), levelingImage);
                if (!ActiveTheme.Instance.IsDarkTheme)
                {
                    InvertLightness.DoInvertLightness(levelingImage);
                }
                
                ImageWidget levelingIcon = new ImageWidget(levelingImage);
				levelingIcon.Margin = new BorderDouble (right: 6);

                enablePrintLevelingButton = textImageButtonFactory.Generate("Enable".Localize().ToUpper());
				enablePrintLevelingButton.Margin = new BorderDouble(left:6);
				enablePrintLevelingButton.VAnchor = VAnchor.ParentCenter;
				enablePrintLevelingButton.Click += new ButtonBase.ButtonEventHandler(enablePrintLeveling_Click);

                disablePrintLevelingButton = textImageButtonFactory.Generate("Disable".Localize().ToUpper());
				disablePrintLevelingButton.Margin = new BorderDouble(left:6);
				disablePrintLevelingButton.VAnchor = VAnchor.ParentCenter;
				disablePrintLevelingButton.Click += new ButtonBase.ButtonEventHandler(disablePrintLeveling_Click);

				printLevelingStatusLabel = new TextWidget ("");
				printLevelingStatusLabel.AutoExpandBoundsToText = true;
				printLevelingStatusLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor;
				printLevelingStatusLabel.VAnchor = VAnchor.ParentCenter;

				GuiWidget hSpacer = new GuiWidget ();
				hSpacer.HAnchor = HAnchor.ParentLeftRight;

                buttonBar.AddChild(levelingIcon);
				buttonBar.AddChild (printLevelingStatusLabel);
				buttonBar.AddChild (hSpacer);
				buttonBar.AddChild(enablePrintLevelingButton);
				buttonBar.AddChild(disablePrintLevelingButton);
                buttonBar.AddChild(runPrintLevelingButton);
                ActivePrinterProfile.Instance.DoPrintLevelingChanged.RegisterEvent((sender, e) =>
                {
					SetPrintLevelButtonVisiblity();

                }, ref unregisterEvents);

                printLevelingControlsContainer.AddChild(buttonBar);
            }
			SetPrintLevelButtonVisiblity ();
            return printLevelingControlsContainer;
        }