コード例 #1
0
		public ThemeColorSelectorWidget (GuiWidget colorToChangeTo)
		{	

			this.colorToChangeTo = colorToChangeTo;
			//TextWidget colorText = new TextWidget("Accent Color", color: RGBA_Bytes.White);
			//colorText.VAnchor = Agg.UI.VAnchor.ParentCenter;
			//this.AddChild(colorText);
			//Temporary theme changer button

			GuiWidget themeButtons = new GuiWidget(186, 42);

            int themeCount = ActiveTheme.Instance.AvailableThemes.Count;

			themeButtons.BackgroundColor = RGBA_Bytes.White;
			int index = 0;
            for (int x = 0; x < themeCount/2; x++)
			{
                Button buttonOne = getThemeButton(index, x, 0);
                Button buttonTwo = getThemeButton(index + themeCount/2, x, 1);

                themeButtons.AddChild(buttonOne);
                themeButtons.AddChild(buttonTwo);
                index++;
			}

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

            iconContainer.AddChild(notifyButton);
        }
コード例 #3
0
        public MeshViewerApplication(string meshFileToLoad = "")
            : base(800, 600)
        {
            BackgroundColor = RGBA_Bytes.White;
            MinimumSize = new VectorMath.Vector2(200, 200);
            Title = "MatterHackers MeshViewr";
            UseOpenGL = true;

            FlowLayoutWidget mainContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);
            mainContainer.AnchorAll();

            viewArea = new GuiWidget();

            viewArea.AnchorAll();

            Vector3 viewerVolume = new Vector3(200, 200, 200);
            double scale = 1;
            meshViewerWidget = new MeshViewerWidget(viewerVolume, scale, MeshViewerWidget.BedShape.Rectangular, "No Part Loaded");

            meshViewerWidget.AnchorAll();

            viewArea.AddChild(meshViewerWidget);

            mainContainer.AddChild(viewArea);

            FlowLayoutWidget buttonPanel = new FlowLayoutWidget(FlowDirection.LeftToRight);
            buttonPanel.HAnchor = HAnchor.ParentLeftRight;
            buttonPanel.Padding = new BorderDouble(3, 3);
            buttonPanel.BackgroundColor = RGBA_Bytes.DarkGray;

            if (meshFileToLoad != "")
            {
                meshViewerWidget.LoadMesh(meshFileToLoad);
            }
            else
            {
                openFileButton = new Button("Open 3D File", 0, 0);
                openFileButton.Click += new Button.ButtonEventHandler(openFileButton_ButtonClick);
                buttonPanel.AddChild(openFileButton);
            }

            bedCheckBox = new CheckBox("Bed");
            bedCheckBox.Checked = true;
            buttonPanel.AddChild(bedCheckBox);

            wireframeCheckBox = new CheckBox("Wireframe");
            buttonPanel.AddChild(wireframeCheckBox);

            GuiWidget leftRightSpacer = new GuiWidget();
            leftRightSpacer.HAnchor = HAnchor.ParentLeftRight;
            buttonPanel.AddChild(leftRightSpacer);

            mainContainer.AddChild(buttonPanel);

            this.AddChild(mainContainer);
            this.AnchorAll();

            AddHandlers();
        }
コード例 #4
0
		public ApplicationMenuRow()
			: base(FlowDirection.LeftToRight)
		{
			linkButtonFactory.textColor = ActiveTheme.Instance.PrimaryTextColor;
			linkButtonFactory.fontSize = 8;

			this.HAnchor = HAnchor.ParentLeftRight;
			this.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;

			// put in the file menu
			MenuOptionFile menuOptionFile = new MenuOptionFile();
			this.AddChild(menuOptionFile);

			MenuOptionSettings menuOptionSettings = new MenuOptionSettings();
			this.AddChild(menuOptionSettings);

			// put in the help menu
			MenuOptionHelp menuOptionHelp = new MenuOptionHelp();
			this.AddChild(menuOptionHelp);

			//linkButtonFactory.textColor = ActiveTheme.Instance.SecondaryAccentColor;
			linkButtonFactory.fontSize = 10;

			Button updateStatusMessage = linkButtonFactory.Generate("Update Available");
			UpdateControlData.Instance.UpdateStatusChanged.RegisterEvent(SetUpdateNotification, ref unregisterEvents);
			popUpAboutPage = new FlowLayoutWidget();
			popUpAboutPage.Margin = new BorderDouble(30, 0, 0, 0);
			popUpAboutPage.HAnchor = HAnchor.FitToChildren;
			popUpAboutPage.VAnchor = VAnchor.FitToChildren | VAnchor.ParentCenter;
			popUpAboutPage.AddChild(updateStatusMessage);
			updateStatusMessage.Click += (sender, e) =>
			{
				UiThread.RunOnIdle(CheckForUpdateWindow.Show);
			};
			this.AddChild(popUpAboutPage);
			SetUpdateNotification(this, null);

			// put in a spacer
			this.AddChild(new HorizontalSpacer());

			// make an object that can hold custom content on the right (like the sign in)
			rightElement = new FlowLayoutWidget(FlowDirection.LeftToRight);
			rightElement.Height = 24;
			rightElement.Margin = new BorderDouble(bottom: 4);
			this.AddChild(rightElement);

			this.Padding = new BorderDouble(0, 0, 6, 0);

			if (AddRightElement != null)
			{
				AddRightElement(rightElement);
			}

			// When the application is first started, plugins are loaded after the MainView control has been initialize,
			// and such they not around when this constructor executes. In that case, we run the AddRightElement 
			// delegate after the plugins get initialized via the PluginsLoaded event
			ApplicationController.Instance.PluginsLoaded.RegisterEvent(PluginsLoaded, ref unregisterEvents);
		}
コード例 #5
0
ファイル: Tab.cs プロジェクト: SkightTeam/agg-sharp
		private void AddText(string tabText, GuiWidget widgetState, RGBA_Bytes textColor, RGBA_Bytes backgroundColor, double pointSize)
		{
			tabTitle = new TextWidget(tabText, pointSize: pointSize, textColor: textColor);
			tabTitle.AutoExpandBoundsToText = true;
			widgetState.AddChild(tabTitle);
			widgetState.Selectable = false;
			widgetState.SetBoundsToEncloseChildren();
			widgetState.BackgroundColor = backgroundColor;
		}
コード例 #6
0
		public ApplicationMenuRow()
			: base(FlowDirection.LeftToRight)
		{
			linkButtonFactory.textColor = ActiveTheme.Instance.PrimaryTextColor;
			linkButtonFactory.fontSize = 8;

			Button signInLink = linkButtonFactory.Generate("(Sign Out)");
			signInLink.VAnchor = Agg.UI.VAnchor.ParentCenter;
			signInLink.Margin = new BorderDouble(top: 0);

			this.HAnchor = HAnchor.ParentLeftRight;
			this.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;

			// put in the file menu
			MenuOptionFile menuOptionFile = new MenuOptionFile();
			this.AddChild(menuOptionFile);

			MenuOptionSettings menuOptionSettings = new MenuOptionSettings();
			this.AddChild(menuOptionSettings);

			// put in the help menu
			MenuOptionHelp menuOptionHelp = new MenuOptionHelp();
			this.AddChild(menuOptionHelp);

			//linkButtonFactory.textColor = ActiveTheme.Instance.SecondaryAccentColor;
			linkButtonFactory.fontSize = 10;

			Button updateStatusMessage = linkButtonFactory.Generate("Update Available");
			UpdateControlData.Instance.UpdateStatusChanged.RegisterEvent(SetUpdateNotification, ref unregisterEvents);
			popUpAboutPage = new FlowLayoutWidget();
			popUpAboutPage.Margin = new BorderDouble(30, 0, 0, 0);
			popUpAboutPage.HAnchor = HAnchor.FitToChildren;
			popUpAboutPage.VAnchor = VAnchor.FitToChildren | VAnchor.ParentCenter;
			popUpAboutPage.AddChild(updateStatusMessage);
			updateStatusMessage.Click += (sender, e) =>
			{
				UiThread.RunOnIdle(AboutWindow.Show);
			};
			this.AddChild(popUpAboutPage);
			SetUpdateNotification(this, null);

			// put in a spacer
			this.AddChild(new HorizontalSpacer());

			// make an object that can hold custom content on the right (like the sign in)
			rightElement = new FlowLayoutWidget(FlowDirection.LeftToRight);
			rightElement.Height = 24;
			rightElement.Margin = new BorderDouble(bottom: 4);
			this.AddChild(rightElement);

			this.Padding = new BorderDouble(0, 0, 6, 0);

			if (privateAddRightElement != null)
			{
				privateAddRightElement(rightElement);
			}
		}
コード例 #7
0
		public void TopToBottomContainerAppliesExpectedMarginToToggleView()
		{
			TestContext.CurrentContext.SetCompatibleWorkingDirectory();

			int marginSize = 40;
			int dimensions = 300;

			GuiWidget outerContainer = new GuiWidget(dimensions, dimensions);

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

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

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

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

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

			var bounds = toggleBox.BoundsRelativeToParent;
			Assert.IsTrue(bounds.Left == marginSize, "Left margin is incorrect");
			Assert.IsTrue(bounds.Right == dimensions - marginSize, "Right margin is incorrect");
			Assert.IsTrue(bounds.Top == dimensions - marginSize, "Top margin is incorrect");
			Assert.IsTrue(bounds.Bottom == marginSize, "Bottom margin is incorrect");
		}
コード例 #8
0
		public ThemeColorSelectorWidget ()
		{	
			//TextWidget colorText = new TextWidget("Accent Color", color: RGBA_Bytes.White);
			//colorText.VAnchor = Agg.UI.VAnchor.ParentCenter;
			//this.AddChild(colorText);
			//Temporary theme changer button
			GuiWidget themeButtons = new GuiWidget(96, 42);
			themeButtons.BackgroundColor = RGBA_Bytes.White;
			int index = 0;
			for (int x = 0; x < 5; x++)
			{
				for (int y = 0; y < 2; y++)
				{
					GuiWidget normal = new GuiWidget(16, 16);
					normal.BackgroundColor = ActiveTheme.Instance.AvailableThemes[index].primaryAccentColor;
					GuiWidget hover = new GuiWidget(16, 16);
					hover.BackgroundColor = ActiveTheme.Instance.AvailableThemes[index].secondaryAccentColor;
					GuiWidget pressed = new GuiWidget(16, 16);
					pressed.BackgroundColor = ActiveTheme.Instance.AvailableThemes[index].secondaryAccentColor;
					GuiWidget disabled = new GuiWidget(16, 16);
					new GuiWidget(16, 16);
                    Button colorButton = new Button(4 + x * 18, 4 + y * 18, new ButtonViewStates(normal, hover, pressed, disabled));
					colorButton.Name = index.ToString();
					colorButton.Click += (sender, mouseEvent) => 
					{                                
						UserSettings.Instance.set("ActiveThemeIndex",((GuiWidget)sender).Name);
						ActiveTheme.Instance.LoadThemeSettings(int.Parse(((GuiWidget)sender).Name));
					};
					index++;
					themeButtons.AddChild(colorButton);
				}
			}
			themeButtons.Margin = new BorderDouble(5);
			this.AddChild(themeButtons);
            this.VAnchor = VAnchor.ParentCenter;
		}
コード例 #9
0
		protected void CreateGuiElements(string openButtonText)
		{
			this.Cursor = Cursors.Hand;

			linkButtonFactory.fontSize = 10;
			linkButtonFactory.textColor = RGBA_Bytes.White;

			WidgetTextColor = RGBA_Bytes.Black;
			WidgetBackgroundColor = RGBA_Bytes.White;

			TextInfo textInfo = new CultureInfo("en-US", false).TextInfo;

			SetDisplayAttributes();

			FlowLayoutWidget mainContainer = new FlowLayoutWidget(FlowDirection.LeftToRight);
			mainContainer.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
			mainContainer.VAnchor = VAnchor.ParentBottomTop;
			{
				GuiWidget primaryContainer = new GuiWidget();
				primaryContainer.HAnchor = HAnchor.ParentLeftRight;
				primaryContainer.VAnchor = VAnchor.ParentBottomTop;

				FlowLayoutWidget primaryFlow = new FlowLayoutWidget(FlowDirection.LeftToRight);
				primaryFlow.HAnchor = HAnchor.ParentLeftRight;
				primaryFlow.VAnchor = VAnchor.ParentBottomTop;

				GuiWidget middleColumn = new GuiWidget(0.0, 0.0);
				middleColumn.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
				middleColumn.VAnchor = Agg.UI.VAnchor.ParentBottomTop;
				middleColumn.Margin = new BorderDouble(10, 6);
				{
					partLabel = new TextWidget(this.ItemName.Replace('_', ' '), pointSize: 14);
					partLabel.Name = "Row Item " + partLabel.Text;
					partLabel.TextColor = WidgetTextColor;
					partLabel.MinimumSize = new Vector2(1, 18);
					partLabel.VAnchor = VAnchor.ParentCenter;
					middleColumn.AddChild(partLabel);
				}

				primaryFlow.AddChild(thumbnailWidget);
				primaryFlow.AddChild(middleColumn);

				primaryContainer.AddChild(primaryFlow);

				rightButtonOverlay = GetItemActionButtons(openButtonText);
				rightButtonOverlay.Visible = false;

				mainContainer.AddChild(primaryContainer);
				mainContainer.AddChild(rightButtonOverlay);
			}
			this.AddChild(mainContainer);

			AddHandlers();
		}
コード例 #10
0
		private void AddThemeControls(FlowLayoutWidget controlsTopToBottomLayout)
		{
			DisableableWidget container = new DisableableWidget();

			AltGroupBox themeControlsGroupBox = new AltGroupBox(LocalizedString.Get("Theme Settings"));
			themeControlsGroupBox.TextColor = ActiveTheme.Instance.PrimaryTextColor;
			themeControlsGroupBox.BorderColor = ActiveTheme.Instance.PrimaryTextColor;
			themeControlsGroupBox.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
			themeControlsGroupBox.VAnchor = Agg.UI.VAnchor.FitToChildren;
			themeControlsGroupBox.Height = 78;

			FlowLayoutWidget colorSelectorContainer = new FlowLayoutWidget(FlowDirection.LeftToRight);
			colorSelectorContainer.HAnchor = HAnchor.ParentLeftRight;

			GuiWidget currentColorThemeBorder = new GuiWidget();
			currentColorThemeBorder.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
			currentColorThemeBorder.VAnchor = VAnchor.ParentBottomTop;
			currentColorThemeBorder.Margin = new BorderDouble(top: 2, bottom: 2);
			currentColorThemeBorder.Padding = new BorderDouble(4);
			currentColorThemeBorder.BackgroundColor = RGBA_Bytes.White;

			GuiWidget currentColorTheme = new GuiWidget();
			currentColorTheme.HAnchor = HAnchor.ParentLeftRight;
			currentColorTheme.VAnchor = VAnchor.ParentBottomTop;
			currentColorTheme.BackgroundColor = ActiveTheme.Instance.PrimaryAccentColor;

			ThemeColorSelectorWidget themeSelector = new ThemeColorSelectorWidget(colorToChangeTo: currentColorTheme);
			themeSelector.Margin = new BorderDouble(right: 5);

			themeControlsGroupBox.AddChild(colorSelectorContainer);
			colorSelectorContainer.AddChild(themeSelector);
			colorSelectorContainer.AddChild(currentColorThemeBorder);
			currentColorThemeBorder.AddChild(currentColorTheme);
			container.AddChild(themeControlsGroupBox);
			controlsTopToBottomLayout.AddChild(container);
		}
コード例 #11
0
		private void AddText(string tabText, GuiWidget widgetState, RGBA_Bytes textColor, RGBA_Bytes backgroundColor, double pointSize)
		{
			leftToRight = new FlowLayoutWidget();
			tabTitle = new TextWidget(tabText, pointSize: pointSize, textColor: textColor);
			tabTitle.AutoExpandBoundsToText = true;
			leftToRight.AddChild(tabTitle);

			ImageBuffer popOutImageClick = StaticData.Instance.LoadIcon(Path.Combine("icon_pop_out_32x32.png"));
			if (ActiveTheme.Instance.IsDarkTheme)
			{
				InvertLightness.DoInvertLightness(popOutImageClick);
			}

			ImageBuffer popOutImage = new ImageBuffer(popOutImageClick);
			byte[] buffer = popOutImage.GetBuffer();
			for (int i = 0; i < buffer.Length; i++)
			{
				if ((i & 3) != 3)
				{
					buffer[i] = textColor.red;
				}
			}

			Button popOut = new Button(0, 0, new ButtonViewStates(new ImageWidget(popOutImage), new ImageWidget(popOutImage), new ImageWidget(popOutImageClick), new ImageWidget(popOutImageClick)));
			popOut.ToolTipText = "Pop This Tab out into its own Window".Localize();
			popOut.Click += (sender, e) =>
			{
				popOutManager.ShowContentInWindow();
			};
			popOut.Margin = new BorderDouble(3, 0);
			popOut.VAnchor = VAnchor.ParentTop;
			leftToRight.AddChild(popOut);

			widgetState.AddChild(leftToRight);
			widgetState.SetBoundsToEncloseChildren();
			widgetState.BackgroundColor = backgroundColor;
		}
コード例 #12
0
		protected void AddChildElements()
		{
			actionBarButtonFactory.invertImageLocation = false;
			actionBarButtonFactory.borderWidth = 1;
			if (ActiveTheme.Instance.IsDarkTheme)
			{
				actionBarButtonFactory.normalBorderColor = new RGBA_Bytes(77, 77, 77);
			}
			else
			{
				actionBarButtonFactory.normalBorderColor = new RGBA_Bytes(190, 190, 190);
			}
			actionBarButtonFactory.hoverBorderColor = new RGBA_Bytes(128, 128, 128);

			// connect and disconnect buttons
			{
				connectPrinterButton = actionBarButtonFactory.Generate("Connect".Localize().ToUpper(), "icon_power_32x32.png");
				connectPrinterButton.Name = "Connect to printer button";
				connectPrinterButton.ToolTipText = "Connect to the currently selected printer".Localize();
				connectPrinterButton.Margin = new BorderDouble(6, 0, 3, 3);

				connectPrinterButton.VAnchor = VAnchor.ParentTop;
				connectPrinterButton.Cursor = Cursors.Hand;
				connectPrinterButton.Click += (s, e) =>
				{
					Button buttonClicked = ((Button)s);
					if (buttonClicked.Enabled)
					{
						if (ActiveSliceSettings.Instance.PrinterSelected)
						{
							UserRequestedConnectToActivePrinter();
						}
					}
				};

				disconnectPrinterButton = actionBarButtonFactory.Generate("Disconnect".Localize().ToUpper(), "icon_power_32x32.png");
				disconnectPrinterButton.Name = "Disconnect from printer button";
				disconnectPrinterButton.ToolTipText = "Disconnect from current printer".Localize();
				disconnectPrinterButton.Margin = new BorderDouble(6, 0, 3, 3);
				disconnectPrinterButton.VAnchor = VAnchor.ParentTop;
				disconnectPrinterButton.Cursor = Cursors.Hand;
				disconnectPrinterButton.Click += (s, e) => UiThread.RunOnIdle(OnIdleDisconnect);

				actionBarButtonFactory.invertImageLocation = true;

				this.AddChild(connectPrinterButton);
				this.AddChild(disconnectPrinterButton);
			}

			// printer selector and edit button
			{
				GuiWidget container = new GuiWidget()
				{
					HAnchor = HAnchor.ParentLeftRight,
					VAnchor = VAnchor.FitToChildren,
				};

				FlowLayoutWidget printerSelectorAndEditButton = new FlowLayoutWidget()
				{
					HAnchor = HAnchor.ParentLeftRight,
				};

				printerSelector = new PrinterSelector()
				{
					HAnchor = HAnchor.ParentLeftRight,
					Cursor = Cursors.Hand,
					Margin = new BorderDouble(0, 6, 0, 3)
				};
				printerSelector.AddPrinter += (s, e) => WizardWindow.ShowPrinterSetup(true);
				// make sure the control can get smaller but maintains its height
				printerSelector.MinimumSize = new Vector2(0, connectPrinterButton.MinimumSize.y);
				printerSelectorAndEditButton.AddChild(printerSelector);

				editPrinterButton = TextImageButtonFactory.GetThemedEditButton();
				editPrinterButton.Name = "Edit Printer Button";
				editPrinterButton.VAnchor = VAnchor.ParentCenter;
				editPrinterButton.Click += UiNavigation.OpenEditPrinterWizard_Click;
				printerSelectorAndEditButton.AddChild(editPrinterButton);

				container.AddChild(printerSelectorAndEditButton);
				printerSelectorAndEditOverlay = new GuiWidget()
				{
					HAnchor = HAnchor.ParentLeftRight,
					VAnchor = VAnchor.ParentBottomTop,
					Selectable = false,
				};
				container.AddChild(printerSelectorAndEditOverlay);

				this.AddChild(container);
			}

			// reset connection button
			{
				string resetConnectionText = "Reset\nConnection".Localize().ToUpper();
				Button resetConnectionButton = actionBarButtonFactory.Generate(resetConnectionText, "e_stop4.png");
				resetConnectionButton.Margin = new BorderDouble(6, 0, 3, 3);
				this.AddChild(resetConnectionButton);

				resetConnectionButton.Click += new EventHandler((s,e) => PrinterConnectionAndCommunication.Instance.RebootBoard());
				resetConnectionButton.Visible = ActiveSliceSettings.Instance.GetValue<bool>(SettingsKey.show_reset_connection);

				ActiveSliceSettings.SettingChanged.RegisterEvent((sender, e) => 
				{
					StringEventArgs stringEvent = e as StringEventArgs;
					if (stringEvent != null)
					{
						if (stringEvent.Data == SettingsKey.show_reset_connection)
						{
							resetConnectionButton.Visible = ActiveSliceSettings.Instance.GetValue<bool>(SettingsKey.show_reset_connection);
						}
					}
				}, ref unregisterEvents);
			}

			// Bind connect button states to active printer state
			this.SetConnectionButtonVisibleState();

			PrinterConnectionAndCommunication.Instance.EnableChanged.RegisterEvent(onPrinterStatusChanged, ref unregisterEvents);
			PrinterConnectionAndCommunication.Instance.CommunicationStateChanged.RegisterEvent(onPrinterStatusChanged, ref unregisterEvents);
		}
コード例 #13
0
ファイル: DropDownList.cs プロジェクト: jeske/agg-sharp
        public MenuItem AddItem(string name, string value = null)
        {
            if (value == null)
            {
                value = name;
            }
            
            mainControlText.Margin = MenuItemsPadding;

            GuiWidget normalTextWithMargin = new GuiWidget();
            normalTextWithMargin.HAnchor = UI.HAnchor.ParentLeftRight | UI.HAnchor.FitToChildren;
            normalTextWithMargin.VAnchor = UI.VAnchor.FitToChildren;
            normalTextWithMargin.BackgroundColor = MenuItemsBackgroundColor;
            TextWidget normal = new TextWidget(name);
            normal.Margin = MenuItemsPadding;
            normal.TextColor = MenuItemsTextColor;
            normalTextWithMargin.AddChild(normal);

            GuiWidget hoverTextWithMargin = new GuiWidget();
            hoverTextWithMargin.HAnchor = UI.HAnchor.ParentLeftRight | UI.HAnchor.FitToChildren;
            hoverTextWithMargin.VAnchor = UI.VAnchor.FitToChildren;
            hoverTextWithMargin.BackgroundColor = MenuItemsBackgroundHoverColor;
            TextWidget hover = new TextWidget(name);
            hover.Margin = MenuItemsPadding;
            hover.TextColor = MenuItemsTextHoverColor;
            hoverTextWithMargin.AddChild(hover);

            MenuItem menuItem = new MenuItem(new MenuItemStatesView(normalTextWithMargin, hoverTextWithMargin), value);
            menuItem.Text = name;
            MenuItems.Add(menuItem);

            return menuItem;
        }
コード例 #14
0
		private GuiWidget CreateContentForEmptyControl()
		{
			GuiWidget allContent = new GuiWidget(HAnchor.ParentLeftRight, VAnchor.ParentBottomTop);
			allContent.Padding = new BorderDouble(5, 10, 5, 10);

			FlowLayoutWidget flowWidget = new FlowLayoutWidget();
			flowWidget.BackgroundColor = ActiveTheme.Instance.TransparentDarkOverlay;
			flowWidget.HAnchor = HAnchor.ParentLeftRight;
			flowWidget.VAnchor = VAnchor.ParentTop;
			flowWidget.Padding = new BorderDouble(10, 0);
			flowWidget.Height = 60;

			TextImageButtonFactory bringBackButtonFactory = new TextImageButtonFactory();
			bringBackButtonFactory.normalFillColor = RGBA_Bytes.Gray;
			bringBackButtonFactory.normalTextColor = ActiveTheme.Instance.PrimaryTextColor;

			Button bringBackToTabButton = bringBackButtonFactory.Generate(LocalizedString.Get("Restore"));
			bringBackToTabButton.ToolTipText = "Bring the Window back into this Tab".Localize();
			bringBackToTabButton.VAnchor = VAnchor.ParentCenter;
			bringBackToTabButton.Cursor = Cursors.Hand;
			bringBackToTabButton.Click += (sender, e) =>
			{
				UiThread.RunOnIdle(() =>
				{
					SaveWindowShouldStartClosed();
					SystemWindow temp = systemWindowWithPopContent;
					SystemWindow_Closing(null, null);
					temp.Close();
				});
			};

			TextWidget windowedModeMessage = new TextWidget(LocalizedString.Get("WINDOWED MODE: This tab has been moved to a separate window."),
				pointSize: 10, textColor: ActiveTheme.Instance.PrimaryTextColor);
			windowedModeMessage.VAnchor = VAnchor.ParentCenter;

			flowWidget.AddChild(windowedModeMessage);
			flowWidget.AddChild(new HorizontalSpacer());
			flowWidget.AddChild(bringBackToTabButton);

			allContent.AddChild(flowWidget);

			return allContent;
		}
コード例 #15
0
        private GuiWidget Create4FieldSet(string label,
            string field1Label, ref MHNumberEdit field1,
            string field2Label, ref MHNumberEdit field2,
            string field3Label, ref MHNumberEdit field3,
            string field4Label, ref MHNumberEdit field4)
        {
            FlowLayoutWidget row = new FlowLayoutWidget();
            row.Margin = new BorderDouble(3);
            row.HAnchor = Agg.UI.HAnchor.ParentLeftRight;

            TextWidget labelWidget = new TextWidget(LocalizedString.Get(label), textColor: ActiveTheme.Instance.PrimaryTextColor);
            labelWidget.VAnchor = VAnchor.ParentCenter;
            maxWidthOfLeftStuff = Math.Max(maxWidthOfLeftStuff, labelWidget.Width);
            GuiWidget holder = new GuiWidget(labelWidget.Width, labelWidget.Height);
            holder.Margin = new BorderDouble(3, 0);
            holder.AddChild(labelWidget);
            leftStuffToSize.Add(holder);
            row.AddChild(holder);

            {
                row.AddChild(CreateTextField(field1Label));
                GuiWidget nextTabIndex = CreateMHNumEdit(ref field1);
                nextTabIndex.TabIndex = GetNextTabIndex();
                row.AddChild(nextTabIndex);
            }

            if (field2Label != null)
            {
                row.AddChild(CreateTextField(field2Label));
                GuiWidget nextTabIndex = CreateMHNumEdit(ref field2);
                nextTabIndex.TabIndex = GetNextTabIndex();
                row.AddChild(nextTabIndex);
            }

            if (field3Label != null)
            {
                row.AddChild(CreateTextField(field3Label));
                GuiWidget nextTabIndex = CreateMHNumEdit(ref field3);
                nextTabIndex.TabIndex = GetNextTabIndex();
                row.AddChild(nextTabIndex);
            }

            if (field4Label != null)
            {
                row.AddChild(CreateTextField(field4Label));
                GuiWidget nextTabIndex = CreateMHNumEdit(ref field4);
                nextTabIndex.TabIndex = GetNextTabIndex();
                row.AddChild(nextTabIndex);
            }

            return row;
        }
コード例 #16
0
		protected GuiWidget GetSliderLabels()
		{
			GuiWidget sliderLabels = new GuiWidget();
			sliderLabels.HAnchor = HAnchor.ParentLeftRight;
			sliderLabels.Height = 20 * TextWidget.GlobalPointSizeScaleRatio;
			{
				double buttonOffset = -10 * TextWidget.GlobalPointSizeScaleRatio;
				var offPosition = buttonOffset;

				tempOffButton = textImageButtonFactory.Generate("Off");
				tempOffButton.OriginRelativeParent = new Vector2(offPosition, 0);

				//sliderLabels.AddChild(tempOffButton);

				SortedDictionary<double, string> labels = GetTemperaturePresetLabels();

				bool firstElement = true;
				double minButtonPosition = 0;
				foreach (KeyValuePair<double, string> keyValue in labels)
				{
					if (firstElement)
					{
						minButtonPosition = buttonOffset;
						firstElement = false;
					}
					else
					{
						double wantedButtonPosition = buttonOffset;
						minButtonPosition = Math.Max(minButtonPosition + textImageButtonFactory.FixedWidth + 3, wantedButtonPosition);
					}
					Button tempButton = textImageButtonFactory.Generate(keyValue.Value);
					tempButton.OriginRelativeParent = new Vector2(minButtonPosition, 0);

					sliderLabels.AddChild(tempButton);

					// We push the value into a temp double so that the function will not point to a shared keyValue instance.
					double temp = keyValue.Key;
					tempButton.Click += (sender, e) =>
					{
						SetTargetTemperature(temp);
						tempSliderContainer.Visible = false;
					};
				}
			}

			sliderLabels.HAnchor = HAnchor.FitToChildren;
			sliderLabels.VAnchor = VAnchor.FitToChildren;
			sliderLabels.MinimumSize = new Vector2(sliderLabels.Width, sliderLabels.Height);
			return sliderLabels;
		}
コード例 #17
0
        private void AddLibraryButtonElements()
		{
			textImageButtonFactory.normalTextColor = ActiveTheme.Instance.PrimaryTextColor;
			textImageButtonFactory.hoverTextColor = ActiveTheme.Instance.PrimaryTextColor;
			textImageButtonFactory.pressedTextColor = ActiveTheme.Instance.PrimaryTextColor;
			textImageButtonFactory.disabledTextColor = ActiveTheme.Instance.TabLabelUnselected;
			textImageButtonFactory.disabledFillColor = new RGBA_Bytes();
			buttonPanel.RemoveAllChildren();
			// the add button
			{
				addToLibraryButton = textImageButtonFactory.Generate(LocalizedString.Get("Add"), "icon_circle_plus.png");
				addToLibraryButton.Enabled = false; // The library selector (the first library selected) is protected so we can't add to it. 
				addToLibraryButton.ToolTipText = "Add an .stl, .amf, .gcode or .zip file to the Library".Localize();
				addToLibraryButton.Name = "Library Add Button";
				buttonPanel.AddChild(addToLibraryButton);
				addToLibraryButton.Margin = new BorderDouble(0, 0, 3, 0);
				addToLibraryButton.Click += (sender, e) => UiThread.RunOnIdle(importToLibraryloadFile_ClickOnIdle);
			}

			// the create folder button
			{
				createFolderButton = textImageButtonFactory.Generate(LocalizedString.Get("Create Folder"));
				createFolderButton.Enabled = false; // The library selector (the first library selected) is protected so we can't add to it.
				createFolderButton.Name = "Create Folder From Library Button";
				buttonPanel.AddChild(createFolderButton);
				createFolderButton.Margin = new BorderDouble(0, 0, 3, 0);
				createFolderButton.Click += (sender, e) =>
				{
					if (createFolderWindow == null)
					{
						createFolderWindow = new CreateFolderWindow((returnInfo) =>
						{
							this.libraryDataView.CurrentLibraryProvider.AddCollectionToLibrary(returnInfo.newName);
						});
						createFolderWindow.Closed += (sender2, e2) => { createFolderWindow = null; };
					}
					else
					{
						createFolderWindow.BringToFront();
					}
				};
			}

			// add in the message widget
			{
				providerMessageWidget = new TextWidget("")
				{
					PointSize = 8,
					HAnchor = HAnchor.ParentRight,
					VAnchor = VAnchor.ParentBottom,
					TextColor = ActiveTheme.Instance.SecondaryTextColor,
					Margin = new BorderDouble(6),
					AutoExpandBoundsToText = true,
				};

				providerMessageContainer = new GuiWidget()
				{
					VAnchor = VAnchor.FitToChildren | VAnchor.ParentTop,
					HAnchor = HAnchor.ParentLeftRight,
					Visible = false,
				};

				providerMessageContainer.AddChild(providerMessageWidget);
				buttonPanel.AddChild(providerMessageContainer, -1);
			}
		}
コード例 #18
0
		private GuiWidget CreateDetailInfo(string detailText)
		{
			var wrappedText = new WrappedTextWidget(detailText)
			{
				TextColor = ActiveTheme.Instance.PrimaryTextColor,
			};

			var container = new GuiWidget(HAnchor.ParentLeftRight, VAnchor.FitToChildren)
			{
				Margin = new BorderDouble(25, 15, 5, 5),
			};

			container.AddChild(wrappedText);

			return container;
		}
コード例 #19
0
		public ThemeSelectorWindow()
			:base(400, 200)
		{
			Title = LocalizedString.Get("Theme Selector").Localize();

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

			//Create Header
			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);

			//Create 'Theme Change' label and add it to Header
			string themeChangeHeader = LocalizedString.Get("Select Theme".Localize());
			TextWidget elementHeader = new TextWidget(string.Format("{0}:", themeChangeHeader), pointSize: 14);
			elementHeader.TextColor = ActiveTheme.Instance.PrimaryTextColor;
			elementHeader.HAnchor = HAnchor.ParentLeftRight;
			elementHeader.VAnchor = Agg.UI.VAnchor.ParentBottom;

			//Add label to header 
			headerRow.AddChild(elementHeader);
			//Add Header
			topToBottom.AddChild(headerRow);


			//Theme Selector widget container and add themeselector
			FlowLayoutWidget themeChangeWidgetContainer = new FlowLayoutWidget();
			themeChangeWidgetContainer.Padding = new BorderDouble(3);
			themeChangeWidgetContainer.HAnchor |= Agg.UI.HAnchor.ParentLeftRight;

			GuiWidget currentColorTheme = new GuiWidget();
			currentColorTheme.HAnchor = HAnchor.ParentLeftRight;
			currentColorTheme.VAnchor = VAnchor.ParentBottomTop;
			currentColorTheme.BackgroundColor = ActiveTheme.Instance.PrimaryAccentColor;


			ThemeColorSelectorWidget themeSelector = new ThemeColorSelectorWidget(colorToChangeTo: currentColorTheme);
			themeSelector.Margin = new BorderDouble(right: 5);
			themeChangeWidgetContainer.AddChild(themeSelector);


			//Create CurrentColorTheme GUI Widgets
			GuiWidget currentColorThemeBorder = new GuiWidget();
			currentColorThemeBorder.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
			currentColorThemeBorder.VAnchor = VAnchor.ParentBottomTop;
			currentColorThemeBorder.Margin = new BorderDouble (top: 2, bottom: 2);
			currentColorThemeBorder.Padding = new BorderDouble(4);
			currentColorThemeBorder.BackgroundColor = RGBA_Bytes.White;




			FlowLayoutWidget presetsFormContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);

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

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

			string currentColorThemeLabelText = LocalizedString.Get("Currently Selected Theme".Localize());
			TextWidget currentColorThemeHeader = new TextWidget(string.Format("{0}:", currentColorThemeLabelText), pointSize: 14);
			currentColorThemeHeader.TextColor = ActiveTheme.Instance.PrimaryTextColor;
			currentColorThemeHeader.HAnchor = HAnchor.ParentLeftRight;
			currentColorThemeHeader.VAnchor = Agg.UI.VAnchor.ParentBottom;
			currentColorLabelContainer.AddChild(currentColorThemeHeader);


			//
			FlowLayoutWidget currentColorContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);
			currentColorContainer.HAnchor = HAnchor.ParentLeftRight;
			currentColorContainer.VAnchor = VAnchor.ParentBottomTop;
			currentColorContainer.Padding = new BorderDouble(3);
			currentColorContainer.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;

			currentColorContainer.AddChild(currentColorThemeBorder);
			currentColorThemeBorder.AddChild(currentColorTheme);

		
			presetsFormContainer.AddChild(themeChangeWidgetContainer);
			topToBottom.AddChild(presetsFormContainer);
			topToBottom.AddChild(currentColorLabelContainer);

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

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

			closeButton = textImageButtonFactory.Generate("Close");
			closeButton.Click += (sender, e) =>
			{
				UiThread.RunOnIdle((state) =>
				{
						Close();
				});
			};

			saveButton = textImageButtonFactory.Generate("Save");
			saveButton.Click += (sender, e) =>
			{
					UserSettings.Instance.set("ActiveThemeIndex",((GuiWidget)sender).Name);
					ActiveTheme.Instance.LoadThemeSettings(int.Parse(((GuiWidget)sender).Name));//GUIWIDGET
			};


			buttonRow.AddChild(saveButton);
			buttonRow.AddChild(new HorizontalSpacer());
			buttonRow.AddChild(closeButton);
			topToBottom.AddChild(buttonRow);
			AddChild(topToBottom);


			ShowAsSystemWindow();
		}
コード例 #20
0
        private GuiWidget LabelGenerator(string labelText, int fontSize = 12, int height = 28)
        {
            GuiWidget labelContainer = new GuiWidget();
            labelContainer.HAnchor = HAnchor.ParentLeftRight;
            labelContainer.Height = height;

            TextWidget formLabel = new TextWidget(labelText, pointSize: fontSize);
            formLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor;
            formLabel.VAnchor = VAnchor.ParentBottom;
            formLabel.HAnchor = HAnchor.ParentLeft;
            formLabel.Margin = new BorderDouble(bottom: 2);

            labelContainer.AddChild(formLabel);

            return labelContainer;
        }
コード例 #21
0
        private void DoLayout(string subjectText, string bodyText)
        {
            FlowLayoutWidget mainContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);
            mainContainer.AnchorAll();

            GuiWidget labelContainer = new GuiWidget();
            labelContainer.HAnchor = HAnchor.ParentLeftRight;
            labelContainer.Height = 30;

            TextWidget formLabel = new TextWidget(LocalizedString.Get("How can we help?"), pointSize: 16);
            formLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor;
            formLabel.VAnchor = VAnchor.ParentTop;
            formLabel.HAnchor = HAnchor.ParentLeft;
            formLabel.Margin = new BorderDouble(6, 3,6,6);
            labelContainer.AddChild(formLabel);
            mainContainer.AddChild(labelContainer);

            centerContainer = new GuiWidget();
            centerContainer.AnchorAll();
            centerContainer.Padding = new BorderDouble(3,0,3,3);

            messageContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);
            messageContainer.AnchorAll();
            messageContainer.Visible = false;
            messageContainer.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;
            messageContainer.Padding = new BorderDouble(10);

            submissionStatus = new TextWidget(LocalizedString.Get("Submitting your information..."), pointSize: 13);
            submissionStatus.AutoExpandBoundsToText = true;
            submissionStatus.Margin = new BorderDouble(0, 5);
			submissionStatus.TextColor = ActiveTheme.Instance.PrimaryTextColor;
            submissionStatus.HAnchor = HAnchor.ParentLeft;

            messageContainer.AddChild(submissionStatus);

            formContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);
            formContainer.AnchorAll();
            formContainer.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;
            formContainer.Padding = new BorderDouble(10);

            formContainer.AddChild(LabelGenerator(LocalizedString.Get("Question*")));
            formContainer.AddChild(LabelGenerator(LocalizedString.Get("Briefly describe your question"), 9, 14));

            questionInput = new MHTextEditWidget(subjectText);
            questionInput.HAnchor = HAnchor.ParentLeftRight;
            formContainer.AddChild(questionInput);

            questionErrorMessage = ErrorMessageGenerator();
            formContainer.AddChild(questionErrorMessage);

            formContainer.AddChild(LabelGenerator(LocalizedString.Get("Details*")));
            formContainer.AddChild(LabelGenerator(LocalizedString.Get("Fill in the details here"), 9, 14));

            detailInput = new MHTextEditWidget(bodyText, pixelHeight: 120, multiLine: true);
            detailInput.HAnchor = HAnchor.ParentLeftRight;
            formContainer.AddChild(detailInput);

            detailErrorMessage = ErrorMessageGenerator();
            formContainer.AddChild(detailErrorMessage);

            formContainer.AddChild(LabelGenerator(LocalizedString.Get("Your Email Address*")));

            emailInput = new MHTextEditWidget();
            emailInput.HAnchor = HAnchor.ParentLeftRight;
            formContainer.AddChild(emailInput);

            emailErrorMessage = ErrorMessageGenerator();
            formContainer.AddChild(emailErrorMessage);

            formContainer.AddChild(LabelGenerator(LocalizedString.Get("Your Name*")));

            nameInput = new MHTextEditWidget();
            nameInput.HAnchor = HAnchor.ParentLeftRight;
            formContainer.AddChild(nameInput);

            nameErrorMessage = ErrorMessageGenerator();
            formContainer.AddChild(nameErrorMessage);           

            centerContainer.AddChild(formContainer);

            mainContainer.AddChild(centerContainer);
            
            FlowLayoutWidget buttonBottomPanel = GetButtonButtonPanel();
            buttonBottomPanel.AddChild(submitButton);
            buttonBottomPanel.AddChild(cancelButton);
            buttonBottomPanel.AddChild(doneButton);

            mainContainer.AddChild(buttonBottomPanel);

            this.AddChild(mainContainer);
        }
コード例 #22
0
		public SlicePresetsWindow(PresetsContext presetsContext)
				: base(641, 481)
		{
			this.presetsContext = presetsContext;
			this.AlwaysOnTopOfMain = true;
			this.Title = LocalizedString.Get("Slice Presets Editor");
			this.MinimumSize = new Vector2(640, 480);
			this.AnchorAll();

			var linkButtonFactory = new LinkButtonFactory()
			{
				fontSize = 8,
				textColor = ActiveTheme.Instance.SecondaryAccentColor
			};

			var buttonFactory = new TextImageButtonFactory()
			{
				normalTextColor = ActiveTheme.Instance.PrimaryTextColor,
				hoverTextColor = ActiveTheme.Instance.PrimaryTextColor,
				disabledTextColor = ActiveTheme.Instance.PrimaryTextColor,
				pressedTextColor = ActiveTheme.Instance.PrimaryTextColor,
				borderWidth = 0
			};

			FlowLayoutWidget mainContainer = new FlowLayoutWidget(FlowDirection.TopToBottom)
			{
				Padding = new BorderDouble(3)
			};
			mainContainer.AnchorAll();

			middleRow = new GuiWidget();
			middleRow.AnchorAll();
			middleRow.AddChild(CreateSliceSettingsWidget(presetsContext.PersistenceLayer));

			mainContainer.AddChild(GetTopRow());
			mainContainer.AddChild(middleRow);
			mainContainer.AddChild(GetBottomRow(buttonFactory));

			this.AddChild(mainContainer);

			BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
		}
コード例 #23
0
		private void CreateAndAddChildren()
		{
			TextImageButtonFactory textImageButtonFactory = new TextImageButtonFactory();
			textImageButtonFactory.normalTextColor = ActiveTheme.Instance.PrimaryTextColor;
			textImageButtonFactory.hoverTextColor = ActiveTheme.Instance.PrimaryTextColor;
			textImageButtonFactory.disabledTextColor = ActiveTheme.Instance.PrimaryTextColor;
			textImageButtonFactory.pressedTextColor = ActiveTheme.Instance.PrimaryTextColor;

			CloseAllChildren();
			gcodeViewWidget = null;
			gcodeProcessingStateInfoText = null;

			FlowLayoutWidget mainContainerTopToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom);
			mainContainerTopToBottom.HAnchor = Agg.UI.HAnchor.Max_FitToChildren_ParentWidth;
			mainContainerTopToBottom.VAnchor = Agg.UI.VAnchor.Max_FitToChildren_ParentHeight;

			buttonBottomPanel = new FlowLayoutWidget(FlowDirection.LeftToRight);
			buttonBottomPanel.HAnchor = HAnchor.ParentLeftRight;
			buttonBottomPanel.Padding = new BorderDouble(3, 3);
			buttonBottomPanel.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;

			generateGCodeButton = textImageButtonFactory.Generate(LocalizedString.Get("Generate"));
			generateGCodeButton.Click += new EventHandler(generateButton_Click);
			buttonBottomPanel.AddChild(generateGCodeButton);

			layerSelectionButtonsPanel = new FlowLayoutWidget(FlowDirection.RightToLeft);
			layerSelectionButtonsPanel.HAnchor = HAnchor.ParentLeftRight;
			layerSelectionButtonsPanel.Padding = new BorderDouble(0);

			GuiWidget holdPanelOpen = new GuiWidget(1, generateGCodeButton.Height);
			layerSelectionButtonsPanel.AddChild(holdPanelOpen);

			if (windowMode == WindowMode.StandAlone)
			{
				Button closeButton = textImageButtonFactory.Generate(LocalizedString.Get("Close"));
				layerSelectionButtonsPanel.AddChild(closeButton);
				closeButton.Click += (sender, e) =>
				{
					CloseOnIdle();
				};
			}

			FlowLayoutWidget centerPartPreviewAndControls = new FlowLayoutWidget(FlowDirection.LeftToRight);
			centerPartPreviewAndControls.AnchorAll();

			gcodeDisplayWidget = new GuiWidget(HAnchor.ParentLeftRight, Agg.UI.VAnchor.ParentBottomTop);
			string firstProcessingMessage = "Press 'Add' to select an item.".Localize();

			if (printItem != null)
			{
				firstProcessingMessage = "Loading G-Code...".Localize();
				if (Path.GetExtension(printItem.FileLocation).ToUpper() == ".GCODE")
				{
					gcodeDisplayWidget.AddChild(CreateGCodeViewWidget(printItem.FileLocation));
				}
				else
				{
					if (File.Exists(printItem.FileLocation))
					{
						string gcodePathAndFileName = printItem.GetGCodePathAndFileName();
						bool gcodeFileIsComplete = printItem.IsGCodeFileComplete(gcodePathAndFileName);

						if (printItem.SlicingHadError)
						{
							firstProcessingMessage = slicingErrorMessage;
						}
						else
						{
							firstProcessingMessage = pressGenerateMessage;
						}

						if (File.Exists(gcodePathAndFileName) && gcodeFileIsComplete)
						{
							gcodeDisplayWidget.AddChild(CreateGCodeViewWidget(gcodePathAndFileName));
						}

						// we only hook these up to make sure we can regenerate the gcode when we want
						printItem.SlicingOutputMessage += sliceItem_SlicingOutputMessage;
						printItem.SlicingDone += sliceItem_Done;
					}
					else
					{
						firstProcessingMessage = string.Format("{0}\n'{1}'", fileNotFoundMessage, printItem.Name);
					}
				}
			}
			else
			{
				generateGCodeButton.Visible = false;
			}

			SetProcessingMessage(firstProcessingMessage);
			centerPartPreviewAndControls.AddChild(gcodeDisplayWidget);

			buttonRightPanel = CreateRightButtonPanel();
			buttonRightPanel.Visible = false;
			centerPartPreviewAndControls.AddChild(buttonRightPanel);

			// add in a spacer
			layerSelectionButtonsPanel.AddChild(new GuiWidget(HAnchor.ParentLeftRight));
			buttonBottomPanel.AddChild(layerSelectionButtonsPanel);

			mainContainerTopToBottom.AddChild(centerPartPreviewAndControls);
			mainContainerTopToBottom.AddChild(buttonBottomPanel);
			this.AddChild(mainContainerTopToBottom);

			meshViewerWidget = new MeshViewerWidget(viewerVolume, bedCenter, bedShape, "".Localize());
			meshViewerWidget.AnchorAll();
			meshViewerWidget.AllowBedRenderingWhenEmpty = true;
			gcodeDisplayWidget.AddChild(meshViewerWidget);
			meshViewerWidget.Visible = false;
			meshViewerWidget.TrackballTumbleWidget.DrawGlContent += new EventHandler(TrackballTumbleWidget_DrawGlContent);

			viewControls2D = new ViewControls2D();
			AddChild(viewControls2D);

			viewControls2D.ResetView += (sender, e) =>
			{
				SetDefaultView2D();
			};

			viewControls3D = new ViewControls3D(meshViewerWidget);
			viewControls3D.PartSelectVisible = false;
			AddChild(viewControls3D);

			viewControls3D.ResetView += (sender, e) =>
			{
				SetDefaultView();
			};

			viewControls3D.ActiveButton = ViewControls3DButtons.Rotate;
			viewControls3D.Visible = false;

			viewControlsToggle = new ViewControlsToggle();
			viewControlsToggle.HAnchor = Agg.UI.HAnchor.ParentRight;
			AddChild(viewControlsToggle);
			viewControlsToggle.Visible = false;

			//viewControls3D.translateButton.ClickButton(null);

			SetDefaultView();

			viewControls2D.translateButton.Click += (sender, e) =>
			{
				gcodeViewWidget.TransformState = ViewGcodeWidget.ETransformState.Move;
			};
			viewControls2D.scaleButton.Click += (sender, e) =>
			{
				gcodeViewWidget.TransformState = ViewGcodeWidget.ETransformState.Scale;
			};

			AddHandlers();
		}
コード例 #24
0
 GuiWidget CreateTextField(string label)
 {
     GuiWidget textWidget = new TextWidget(label, textColor: ActiveTheme.Instance.PrimaryTextColor);
     textWidget.VAnchor = VAnchor.ParentCenter;
     textWidget.HAnchor = HAnchor.ParentRight;
     GuiWidget container = new GuiWidget(textWidget.Height, 24);
     container.AddChild(textWidget);
     return container;            
 }
コード例 #25
0
		private void SetProcessingMessage(string message)
		{
			if (gcodeProcessingStateInfoText == null)
			{
				gcodeProcessingStateInfoText = new TextWidget(message);
				gcodeProcessingStateInfoText.HAnchor = HAnchor.ParentCenter;
				gcodeProcessingStateInfoText.VAnchor = VAnchor.ParentCenter;
				gcodeProcessingStateInfoText.AutoExpandBoundsToText = true;

				GuiWidget labelContainer = new GuiWidget();
				labelContainer.AnchorAll();
				labelContainer.AddChild(gcodeProcessingStateInfoText);
				labelContainer.Selectable = false;

				gcodeDisplayWidget.AddChild(labelContainer);
			}

			if (message == "")
			{
				gcodeProcessingStateInfoText.BackgroundColor = new RGBA_Bytes();
			}
			else
			{
				gcodeProcessingStateInfoText.BackgroundColor = RGBA_Bytes.White;
			}

			gcodeProcessingStateInfoText.Text = message;
		}
コード例 #26
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);
		}
コード例 #27
0
		public View3DWidget(PrintItemWrapper printItemWrapper, Vector3 viewerVolume, Vector2 bedCenter, MeshViewerWidget.BedShape bedShape, WindowMode windowType, AutoRotate autoRotate, OpenMode openMode = OpenMode.Viewing)
		{
			this.openMode = openMode;
			this.windowType = windowType;
			allowAutoRotate = (autoRotate == AutoRotate.Enabled);
			autoRotating = allowAutoRotate;
			MeshGroupExtraData = new List<PlatingMeshGroupData>();
			MeshGroupExtraData.Add(new PlatingMeshGroupData());

			this.printItemWrapper = printItemWrapper;

			FlowLayoutWidget mainContainerTopToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom);
			mainContainerTopToBottom.HAnchor = Agg.UI.HAnchor.Max_FitToChildren_ParentWidth;
			mainContainerTopToBottom.VAnchor = Agg.UI.VAnchor.Max_FitToChildren_ParentHeight;

			FlowLayoutWidget centerPartPreviewAndControls = new FlowLayoutWidget(FlowDirection.LeftToRight);
			centerPartPreviewAndControls.Name = "centerPartPreviewAndControls";
			centerPartPreviewAndControls.AnchorAll();

			GuiWidget viewArea = new GuiWidget();
			viewArea.AnchorAll();
			{
				meshViewerWidget = new MeshViewerWidget(viewerVolume, bedCenter, bedShape, "Press 'Add' to select an item.".Localize());

				PutOemImageOnBed();

				meshViewerWidget.AnchorAll();
			}
			viewArea.AddChild(meshViewerWidget);

			centerPartPreviewAndControls.AddChild(viewArea);
			mainContainerTopToBottom.AddChild(centerPartPreviewAndControls);

			FlowLayoutWidget buttonBottomPanel = new FlowLayoutWidget(FlowDirection.LeftToRight);
			buttonBottomPanel.HAnchor = HAnchor.ParentLeftRight;
			buttonBottomPanel.Padding = new BorderDouble(3, 3);
			buttonBottomPanel.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;

			buttonRightPanel = CreateRightButtonPanel(viewerVolume.y);
			buttonRightPanel.Name = "buttonRightPanel";
			buttonRightPanel.Visible = false;

			CreateOptionsContent();

			// add in the plater tools
			{
				FlowLayoutWidget editToolBar = new FlowLayoutWidget();

				string progressFindPartsLabel = "Entering Editor".Localize();
				string progressFindPartsLabelFull = "{0}:".FormatWith(progressFindPartsLabel);

				processingProgressControl = new ProgressControl(progressFindPartsLabelFull, ActiveTheme.Instance.PrimaryTextColor, ActiveTheme.Instance.PrimaryAccentColor);
				processingProgressControl.VAnchor = Agg.UI.VAnchor.ParentCenter;
				editToolBar.AddChild(processingProgressControl);
				editToolBar.VAnchor |= Agg.UI.VAnchor.ParentCenter;
				processingProgressControl.Visible = false;

				// If the window is embeded (in the center pannel) and there is no item loaded then don't show the add button
				enterEditButtonsContainer = new FlowLayoutWidget();
				{
					Button addButton = textImageButtonFactory.Generate("Insert".Localize(), "icon_insert_32x32.png");
					addButton.ToolTipText = "Insert an .stl, .amf or .zip file".Localize();
					addButton.Margin = new BorderDouble(right: 0);
					enterEditButtonsContainer.AddChild(addButton);
					addButton.Click += (sender, e) =>
					{
						UiThread.RunOnIdle(() =>
						{
							DoAddFileAfterCreatingEditData = true;
							EnterEditAndCreateSelectionData();
						});
					};
					if (printItemWrapper != null 
						&& printItemWrapper.PrintItem.ReadOnly)
					{
						addButton.Enabled = false;
					}

					Button enterEdittingButton = textImageButtonFactory.Generate("Edit".Localize(), "icon_edit_32x32.png");
					enterEdittingButton.Margin = new BorderDouble(right: 4);
					enterEdittingButton.Click += (sender, e) =>
					{
						EnterEditAndCreateSelectionData();
					};
					
					if (printItemWrapper != null 
						&& printItemWrapper.PrintItem.ReadOnly)
					{
						enterEdittingButton.Enabled = false;
					}

					Button exportButton = textImageButtonFactory.Generate("Export...".Localize());
					if (printItemWrapper != null && 
						(printItemWrapper.PrintItem.Protected || printItemWrapper.PrintItem.ReadOnly))
					{
						exportButton.Enabled = false;
					}

					exportButton.Margin = new BorderDouble(right: 10);
					exportButton.Click += (sender, e) =>
					{
						UiThread.RunOnIdle(() =>
						{
							OpenExportWindow();
						});
					};

					enterEditButtonsContainer.AddChild(enterEdittingButton);
					enterEditButtonsContainer.AddChild(exportButton);
				}
				editToolBar.AddChild(enterEditButtonsContainer);

				doEdittingButtonsContainer = new FlowLayoutWidget();
				doEdittingButtonsContainer.Visible = false;

				{
					Button addButton = textImageButtonFactory.Generate("Insert".Localize(), "icon_insert_32x32.png");
					addButton.Margin = new BorderDouble(right: 10);
					doEdittingButtonsContainer.AddChild(addButton);
					addButton.Click += (sender, e) =>
					{
						UiThread.RunOnIdle(() =>
						{
							FileDialog.OpenFileDialog(
								new OpenFileDialogParams(ApplicationSettings.OpenDesignFileParams, multiSelect: true),
								(openParams) =>
								{
									LoadAndAddPartsToPlate(openParams.FileNames);
								});
						});
					};

					GuiWidget separator = new GuiWidget(1, 2);
					separator.BackgroundColor = ActiveTheme.Instance.PrimaryTextColor;
					separator.Margin = new BorderDouble(4, 2);
					separator.VAnchor = VAnchor.ParentBottomTop;
					doEdittingButtonsContainer.AddChild(separator);

					Button ungroupButton = textImageButtonFactory.Generate("Ungroup".Localize());
					doEdittingButtonsContainer.AddChild(ungroupButton);
					ungroupButton.Click += (sender, e) =>
					{
						UngroupSelectedMeshGroup();
					};

					Button groupButton = textImageButtonFactory.Generate("Group".Localize());
					doEdittingButtonsContainer.AddChild(groupButton);
					groupButton.Click += (sender, e) =>
					{
						GroupSelectedMeshs();
					};

					Button alignButton = textImageButtonFactory.Generate("Align".Localize());
					doEdittingButtonsContainer.AddChild(alignButton);
					alignButton.Click += (sender, e) =>
					{
						AlignToSelectedMeshGroup();
					};

					Button arrangeButton = textImageButtonFactory.Generate("Arrange".Localize());
					doEdittingButtonsContainer.AddChild(arrangeButton);
					arrangeButton.Click += (sender, e) =>
					{
						AutoArrangePartsInBackground();
					};

					GuiWidget separatorTwo = new GuiWidget(1, 2);
					separatorTwo.BackgroundColor = ActiveTheme.Instance.PrimaryTextColor;
					separatorTwo.Margin = new BorderDouble(4, 2);
					separatorTwo.VAnchor = VAnchor.ParentBottomTop;
					doEdittingButtonsContainer.AddChild(separatorTwo);

					Button copyButton = textImageButtonFactory.Generate("Copy".Localize());
					doEdittingButtonsContainer.AddChild(copyButton);
					copyButton.Click += (sender, e) =>
					{
						MakeCopyOfGroup();
					};

					Button deleteButton = textImageButtonFactory.Generate("Remove".Localize());
					doEdittingButtonsContainer.AddChild(deleteButton);
					deleteButton.Click += (sender, e) =>
					{
						DeleteSelectedMesh();
					};

					GuiWidget separatorThree = new GuiWidget(1, 2);
					separatorThree.BackgroundColor = ActiveTheme.Instance.PrimaryTextColor;
					separatorThree.Margin = new BorderDouble(4, 1);
					separatorThree.VAnchor = VAnchor.ParentBottomTop;
					doEdittingButtonsContainer.AddChild(separatorThree);

					Button leaveEditModeButton = textImageButtonFactory.Generate("Cancel".Localize(), centerText: true);
					leaveEditModeButton.Click += (sender, e) =>
					{
						UiThread.RunOnIdle(() =>
						{
							if (saveButtons.Visible)
							{
								StyledMessageBox.ShowMessageBox(ExitEditingAndSaveIfRequired, "Would you like to save your changes before exiting the editor?", "Save Changes", StyledMessageBox.MessageType.YES_NO);
							}
							else
							{
								if (partHasBeenEdited)
								{
									ExitEditingAndSaveIfRequired(false);
								}
								else
								{
									SwitchStateToNotEditing();
								}
							}
						});
					};
					doEdittingButtonsContainer.AddChild(leaveEditModeButton);

					// put in the save button
					AddSaveAndSaveAs(doEdittingButtonsContainer);
				}

				KeyDown += (sender, e) =>
				{
					KeyEventArgs keyEvent = e as KeyEventArgs;
					if (keyEvent != null && !keyEvent.Handled)
					{
						if (keyEvent.KeyCode == Keys.Delete || keyEvent.KeyCode == Keys.Back)
						{
							DeleteSelectedMesh();
						}

						if (keyEvent.KeyCode == Keys.Escape)
						{
							if (meshSelectInfo.downOnPart)
							{
								meshSelectInfo.downOnPart = false;

								ScaleRotateTranslate translated = SelectedMeshGroupTransform;
								translated.translation = transformOnMouseDown;
								SelectedMeshGroupTransform = translated;

								Invalidate();
							}
						}
					}
				};

				editToolBar.AddChild(doEdittingButtonsContainer);
				buttonBottomPanel.AddChild(editToolBar);
			}

			GuiWidget buttonRightPanelHolder = new GuiWidget(HAnchor.FitToChildren, VAnchor.ParentBottomTop);
			buttonRightPanelHolder.Name = "buttonRightPanelHolder";
			centerPartPreviewAndControls.AddChild(buttonRightPanelHolder);
			buttonRightPanelHolder.AddChild(buttonRightPanel);

			viewControls3D = new ViewControls3D(meshViewerWidget);

			buttonRightPanelDisabledCover = new Cover(HAnchor.ParentLeftRight, VAnchor.ParentBottomTop);
			buttonRightPanelDisabledCover.BackgroundColor = new RGBA_Bytes(ActiveTheme.Instance.PrimaryBackgroundColor, 150);
			buttonRightPanelHolder.AddChild(buttonRightPanelDisabledCover);

			viewControls3D.PartSelectVisible = false;
			LockEditControls();

			GuiWidget leftRightSpacer = new GuiWidget();
			leftRightSpacer.HAnchor = HAnchor.ParentLeftRight;
			buttonBottomPanel.AddChild(leftRightSpacer);

			if (windowType == WindowMode.StandAlone)
			{
				Button closeButton = textImageButtonFactory.Generate("Close".Localize());
				buttonBottomPanel.AddChild(closeButton);
				closeButton.Click += (sender, e) =>
				{
					CloseOnIdle();
				};
			}

			mainContainerTopToBottom.AddChild(buttonBottomPanel);

			this.AddChild(mainContainerTopToBottom);
			this.AnchorAll();

			meshViewerWidget.TrackballTumbleWidget.TransformState = TrackBallController.MouseDownType.Rotation;
			AddChild(viewControls3D);

			AddHandlers();

			UiThread.RunOnIdle(AutoSpin);

			if (printItemWrapper == null && windowType == WindowMode.Embeded)
			{
				enterEditButtonsContainer.Visible = false;
			}

			if (windowType == WindowMode.Embeded)
			{
				PrinterConnectionAndCommunication.Instance.CommunicationStateChanged.RegisterEvent(SetEditControlsBasedOnPrinterState, ref unregisterEvents);
				if (windowType == WindowMode.Embeded)
				{
					// make sure we lock the controls if we are printing or paused
					switch (PrinterConnectionAndCommunication.Instance.CommunicationState)
					{
						case PrinterConnectionAndCommunication.CommunicationStates.Printing:
						case PrinterConnectionAndCommunication.CommunicationStates.Paused:
							LockEditControls();
							break;
					}
				}
			}

			ActiveTheme.Instance.ThemeChanged.RegisterEvent(ThemeChanged, ref unregisterEvents);

			upArrow = new UpArrow3D(this);
			heightDisplay = new HeightValueDisplay(this);
			heightDisplay.Visible = false;
			meshViewerWidget.interactionVolumes.Add(upArrow);

			// make sure the colors are set correctl
			ThemeChanged(this, null);

			saveButtons.VisibleChanged += (sender, e) =>
			{
				partHasBeenEdited = true;
			};
		}
コード例 #28
0
		public LibraryDataView()
		{
			// let the application controler know about this window so it can use it to switch library providers if it needs to.
			ApplicationController.Instance.CurrentLibraryDataView = this;

			currentLibraryProvider = new LibraryProviderSelector(SetCurrentLibraryProvider);
			currentLibraryProvider.DataReloaded += LibraryDataReloaded;

			if (libraryDataViewInstance != null)
			{
				throw new Exception("There should only ever be one of these, Lars.");
			}
			libraryDataViewInstance = this;

			// set the display attributes
			{
				this.AnchorAll();
				this.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;
				this.ScrollArea.Padding = new BorderDouble(3, 3, 5, 3);
			}

			ScrollArea.HAnchor = HAnchor.ParentLeftRight;

			AutoScroll = true;
			topToBottomItemList = new FlowLayoutWidget(FlowDirection.TopToBottom);
			topToBottomItemList.HAnchor = HAnchor.ParentLeftRight;
			AddChild(topToBottomItemList);

			AddAllItems();

			providerMessageWidget = new TextWidget("")
			{
				PointSize = 8,
				HAnchor = HAnchor.ParentRight,
				VAnchor = VAnchor.ParentBottom,
				TextColor = ActiveTheme.Instance.SecondaryTextColor,
				Margin = new BorderDouble(6),
				AutoExpandBoundsToText = true,
			};

			providerMessageContainer = new GuiWidget()
			{
				VAnchor = VAnchor.FitToChildren,
				HAnchor = HAnchor.ParentLeftRight,
				BackgroundColor = new RGBA_Bytes(ActiveTheme.Instance.SecondaryBackgroundColor, 220),
				Visible = false,
			};

			providerMessageContainer.AddChild(providerMessageWidget);
			this.AddChildToBackground(providerMessageContainer, -1);
		}
コード例 #29
0
		protected void CreateGuiElements()
		{
			this.Cursor = Cursors.Hand;

			linkButtonFactory.fontSize = 10;
			linkButtonFactory.textColor = RGBA_Bytes.White;

			WidgetTextColor = RGBA_Bytes.Black;
			WidgetBackgroundColor = RGBA_Bytes.White;

			TextInfo textInfo = new CultureInfo("en-US", false).TextInfo;

			SetDisplayAttributes();

			FlowLayoutWidget mainContainer = new FlowLayoutWidget(FlowDirection.LeftToRight);
			mainContainer.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
			mainContainer.VAnchor = VAnchor.ParentBottomTop;
			{
				partLabel = new TextWidget(this.ItemName.Replace('_', ' '), pointSize: 14);

				GuiWidget primaryContainer = new GuiWidget();
				primaryContainer.HAnchor = HAnchor.ParentLeftRight;
				primaryContainer.VAnchor = VAnchor.ParentBottomTop;
				primaryContainer.Name = "Row Item " + partLabel.Text;

				FlowLayoutWidget primaryFlow = new FlowLayoutWidget(FlowDirection.LeftToRight);
				primaryFlow.HAnchor = HAnchor.ParentLeftRight;
				primaryFlow.VAnchor = VAnchor.ParentBottomTop;

				selectionCheckBoxContainer = new GuiWidget();
				selectionCheckBoxContainer.VAnchor = VAnchor.ParentBottomTop;
				selectionCheckBoxContainer.Width = 40;
				selectionCheckBoxContainer.Visible = false;
				selectionCheckBoxContainer.Margin = new BorderDouble(left: 6);
				selectionCheckBox = new CheckBox("");
				selectionCheckBox.Click += selectionCheckBox_Click;
				selectionCheckBox.Name = "Row Item Select Checkbox";
				selectionCheckBox.VAnchor = VAnchor.ParentCenter;
				selectionCheckBox.HAnchor = HAnchor.ParentCenter;
				selectionCheckBoxContainer.AddChild(selectionCheckBox);

				middleColumn = new GuiWidget(0.0, 0.0);
				middleColumn.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
				middleColumn.VAnchor = Agg.UI.VAnchor.ParentBottomTop;
				middleColumn.Margin = new BorderDouble(10, 3);
				{
					partLabel.TextColor = WidgetTextColor;
					partLabel.MinimumSize = new Vector2(1, 18);
					partLabel.VAnchor = VAnchor.ParentCenter;
					middleColumn.AddChild(partLabel);

					bool mouseDownOnMiddle = false;
					middleColumn.MouseDown += (sender, e) =>
					{
						// Abort normal processing for view helpers
						if (this.IsViewHelperItem)
						{
							return;
						}
						mouseDownOnMiddle = true;
					};

					middleColumn.MouseUp += (sender, e) =>
					{
						if (mouseDownOnMiddle &
						middleColumn.LocalBounds.Contains(e.Position))
						{
							if (this.libraryDataView.EditMode)
							{
								if (this.IsSelectedItem)
								{
									libraryDataView.SelectedItems.Remove(this);
								}
								else
								{
									libraryDataView.SelectedItems.Add(this);
								}
								Invalidate();
							}
							else
							{
								// we only have single selection
								if (this.IsSelectedItem)
								{
									// It is already selected, do nothing.
								}
								else
								{
									libraryDataView.ClearSelectedItems();
									libraryDataView.SelectedItems.Add(this);
									Invalidate();
								}
							}
						}

						mouseDownOnMiddle = false;
					};
				}
				primaryFlow.AddChild(selectionCheckBoxContainer);

				primaryFlow.AddChild(thumbnailWidget);
				primaryFlow.AddChild(middleColumn);

				primaryContainer.AddChild(primaryFlow);

				rightButtonOverlay = GetItemActionButtons();
				rightButtonOverlay.Visible = false;

				mainContainer.AddChild(primaryContainer);
				mainContainer.AddChild(rightButtonOverlay);
			}
			this.AddChild(mainContainer);

			AddHandlers();
		}
コード例 #30
0
		public EditTemperaturePresetsWindow(string windowTitle, string temperatureSettings, EventHandler functionToCallOnSave)
			: base(360, 300)
		{
			AlwaysOnTopOfMain = true;
			Title = LocalizedString.Get(windowTitle);

			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 tempShortcutPresetLabel = LocalizedString.Get("Temperature Shortcut Presets");
				string tempShortcutPresetLabelFull = string.Format("{0}:", tempShortcutPresetLabel);
				TextWidget elementHeader = new TextWidget(tempShortcutPresetLabelFull, pointSize: 14);
				elementHeader.TextColor = ActiveTheme.Instance.PrimaryTextColor;
				elementHeader.HAnchor = HAnchor.ParentLeftRight;
				elementHeader.VAnchor = Agg.UI.VAnchor.ParentBottom;

				headerRow.AddChild(elementHeader);
			}

			topToBottom.AddChild(headerRow);

			FlowLayoutWidget presetsFormContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);
			//ListBox printerListContainer = new ListBox();
			{
				presetsFormContainer.HAnchor = HAnchor.ParentLeftRight;
				presetsFormContainer.VAnchor = VAnchor.ParentBottomTop;
				presetsFormContainer.Padding = new BorderDouble(3);
				presetsFormContainer.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;
			}

			topToBottom.AddChild(presetsFormContainer);

			this.functionToCallOnSave = functionToCallOnSave;
			BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;

			double oldHeight = textImageButtonFactory.FixedHeight;
			textImageButtonFactory.FixedHeight = 30 * GuiWidget.DeviceScale;

			TextWidget tempTypeLabel = new TextWidget(windowTitle, textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize: 10);
			tempTypeLabel.Margin = new BorderDouble(3);
			tempTypeLabel.HAnchor = HAnchor.ParentLeft;
			presetsFormContainer.AddChild(tempTypeLabel);

			FlowLayoutWidget leftRightLabels = new FlowLayoutWidget();
			leftRightLabels.Padding = new BorderDouble(3, 6);
			leftRightLabels.HAnchor |= Agg.UI.HAnchor.ParentLeftRight;

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

			GuiWidget labelLabelContainer = new GuiWidget();
			labelLabelContainer.Width = 66;
			labelLabelContainer.Height = 16;
			labelLabelContainer.Margin = new BorderDouble(3, 0);

			string labelLabelTxt = LocalizedString.Get("Label");
			TextWidget labelLabel = new TextWidget(string.Format(labelLabelTxt), textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize: 10);
			labelLabel.HAnchor = HAnchor.ParentLeft;
			labelLabel.VAnchor = VAnchor.ParentCenter;

			labelLabelContainer.AddChild(labelLabel);

			GuiWidget tempLabelContainer = new GuiWidget();
			tempLabelContainer.Width = 66;
			tempLabelContainer.Height = 16;
			tempLabelContainer.Margin = new BorderDouble(3, 0);

			TextWidget tempLabel = new TextWidget(string.Format("Temp (C)"), textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize: 10);
			tempLabel.HAnchor = HAnchor.ParentLeft;
			tempLabel.VAnchor = VAnchor.ParentCenter;

			tempLabelContainer.AddChild(tempLabel);

			leftRightLabels.AddChild(hLabelSpacer);
			leftRightLabels.AddChild(labelLabelContainer);
			leftRightLabels.AddChild(tempLabelContainer);

			presetsFormContainer.AddChild(leftRightLabels);

			// put in the temperature edit controls
			string[] settingsArray = temperatureSettings.Split(',');
			int preset_count = 1;
			int tab_index = 0;
			for (int i = 0; i < settingsArray.Count() - 1; i += 2)
			{
				FlowLayoutWidget leftRightEdit = new FlowLayoutWidget();
				leftRightEdit.Padding = new BorderDouble(3);
				leftRightEdit.HAnchor |= Agg.UI.HAnchor.ParentLeftRight;
				string presetLabelTxt = LocalizedString.Get("Preset");
				TextWidget label = new TextWidget(string.Format("{1} {0}", preset_count, presetLabelTxt), textColor: ActiveTheme.Instance.PrimaryTextColor);
				label.VAnchor = VAnchor.ParentCenter;
				leftRightEdit.AddChild(label);

				leftRightEdit.AddChild(new HorizontalSpacer());

				MHTextEditWidget typeEdit = new MHTextEditWidget(settingsArray[i], pixelWidth: 60, tabIndex: tab_index++);

				typeEdit.Margin = new BorderDouble(3);
				leftRightEdit.AddChild(typeEdit);
				listWithValues.Add(typeEdit);

				double temperatureValue = 0;
				double.TryParse(settingsArray[i + 1], out temperatureValue);
				MHNumberEdit valueEdit = new MHNumberEdit(temperatureValue, minValue: 0, pixelWidth: 60, tabIndex: tab_index++);
				valueEdit.Margin = new BorderDouble(3);
				leftRightEdit.AddChild(valueEdit);
				listWithValues.Add(valueEdit);

				//leftRightEdit.AddChild(textImageButtonFactory.Generate("Delete"));
				presetsFormContainer.AddChild(leftRightEdit);
				preset_count += 1;
			}

			{
				FlowLayoutWidget leftRightEdit = new FlowLayoutWidget();
				leftRightEdit.Padding = new BorderDouble(3);
				leftRightEdit.HAnchor |= Agg.UI.HAnchor.ParentLeftRight;

				TextWidget maxWidgetLabel = new TextWidget(LocalizedString.Get("Max Temp"), textColor: ActiveTheme.Instance.PrimaryTextColor);
				maxWidgetLabel.VAnchor = VAnchor.ParentCenter;
				leftRightEdit.AddChild(maxWidgetLabel);
				leftRightEdit.AddChild(new HorizontalSpacer());

				double maxTemperature = 0;
				double.TryParse(settingsArray[settingsArray.Count() - 1], out maxTemperature);
				MHNumberEdit valueEdit = new MHNumberEdit(maxTemperature, minValue: 0, pixelWidth: 60, tabIndex: tab_index);
				valueEdit.Margin = new BorderDouble(3);
				leftRightEdit.AddChild(valueEdit);
				listWithValues.Add(valueEdit);

				presetsFormContainer.AddChild(leftRightEdit);
			}

			textImageButtonFactory.FixedHeight = oldHeight;

			ShowAsSystemWindow();
			MinimumSize = new Vector2(360, 300);

			Button savePresetsButton = textImageButtonFactory.Generate(LocalizedString.Get("Save"));
			savePresetsButton.Click += new EventHandler(save_Click);

			Button cancelPresetsButton = textImageButtonFactory.Generate(LocalizedString.Get("Cancel"));
			cancelPresetsButton.Click += (sender, e) => { 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(savePresetsButton);
			buttonRow.AddChild(hButtonSpacer);
			buttonRow.AddChild(cancelPresetsButton);

			topToBottom.AddChild(buttonRow);

			AddChild(topToBottom);
		}