public PartThumbnailWidget(PrintItemWrapper item, string noThumbnailFileName, string buildingThumbnailFileName, Vector2 size) { this.PrintItem = item; // Set Display Attributes this.Margin = new BorderDouble(0); this.Padding = new BorderDouble(5); this.Width = size.x; this.Height = size.y; this.MinimumSize = size; this.BackgroundColor = normalBackgroundColor; this.Cursor = Cursors.Hand; // set background images if (noThumbnailImage.Width == 0) { ImageBMPIO.LoadImageData(this.GetImageLocation(noThumbnailFileName), noThumbnailImage); ImageBMPIO.LoadImageData(this.GetImageLocation(buildingThumbnailFileName), buildingThumbnailImage); } this.image = new ImageBuffer(buildingThumbnailImage); // Add Handlers this.Click += new ButtonEventHandler(onMouseClick); this.MouseEnterBounds += new EventHandler(onEnter); this.MouseLeaveBounds += new EventHandler(onExit); ActiveTheme.Instance.ThemeChanged.RegisterEvent(onThemeChanged, ref unregisterEvents); }
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); }
private double PrintTopOfPage(ImageBuffer plateInventoryImage, Graphics2D plateGraphics) { plateGraphics.Clear(RGBA_Bytes.White); double currentlyPrintingHeightPixels = plateInventoryImage.Height - PageMarginMM.Top * PixelPerMM; string logoPathAndFile = Path.Combine(ApplicationDataStorage.Instance.ApplicationStaticDataPath, "PartSheetLogo.png"); if (File.Exists(logoPathAndFile)) { ImageBuffer logoImage = new ImageBuffer(); ImageBMPIO.LoadImageData(logoPathAndFile, logoImage); currentlyPrintingHeightPixels -= logoImage.Height; plateGraphics.Render(logoImage, (plateInventoryImage.Width - logoImage.Width) / 2, currentlyPrintingHeightPixels); } currentlyPrintingHeightPixels -= PartPaddingPixels; double underlineHeightMM = 1; RectangleDouble lineBounds = new RectangleDouble(0, 0, plateInventoryImage.Width - PageMarginPixels.Left * 2, underlineHeightMM * PixelPerMM); lineBounds.Offset(PageMarginPixels.Left, currentlyPrintingHeightPixels - lineBounds.Height); plateGraphics.FillRectangle(lineBounds, RGBA_Bytes.Black); return(currentlyPrintingHeightPixels - (lineBounds.Height + PartPaddingPixels)); }
ImageBuffer LoadImage(string imageName) { string path = Path.Combine(ApplicationDataStorage.Instance.ApplicationStaticDataPath, imageName); ImageBuffer buffer = new ImageBuffer(10, 10, 32, new BlenderBGRA()); ImageBMPIO.LoadImageData(path, buffer); return(buffer); }
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); } }
public RadioButton GenerateRadioButton(string label, string iconImageName = null) { ImageBuffer iconImage = null; if (iconImageName != null) { iconImage = new ImageBuffer(); ImageBMPIO.LoadImageData(this.GetImageLocation(iconImageName), iconImage); } BorderDouble internalMargin = new BorderDouble(0); TextImageWidget nomalState = new TextImageWidget(label, normalFillColor, normalBorderColor, normalTextColor, borderWidth, internalMargin, iconImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight, width: this.FixedWidth, centerText: true); TextImageWidget hoverState = new TextImageWidget(label, hoverFillColor, hoverBorderColor, hoverTextColor, borderWidth, internalMargin, iconImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight, width: this.FixedWidth, centerText: true); TextImageWidget checkingState = new TextImageWidget(label, hoverFillColor, RGBA_Bytes.White, hoverTextColor, borderWidth, internalMargin, iconImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight, width: this.FixedWidth, centerText: true); TextImageWidget checkedState = new TextImageWidget(label, pressedFillColor, RGBA_Bytes.White, pressedTextColor, borderWidth, internalMargin, iconImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight, width: this.FixedWidth, centerText: true); TextImageWidget disabledState = new TextImageWidget(label, disabledFillColor, disabledBorderColor, disabledTextColor, borderWidth, internalMargin, iconImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight, width: this.FixedWidth, centerText: true); RadioButtonViewStates checkBoxButtonViewWidget = new RadioButtonViewStates(nomalState, hoverState, checkingState, checkedState, disabledState); RadioButton radioButton = new RadioButton(checkBoxButtonViewWidget); radioButton.Margin = Margin; return(radioButton); }
public Button Generate(string normalImageName, string hoverImageName, string pressedImageName = null, string disabledImageName = null) { if (pressedImageName == null) { pressedImageName = hoverImageName; } if (disabledImageName == null) { disabledImageName = normalImageName; } Agg.Image.ImageBuffer normalImage = new Agg.Image.ImageBuffer(); Agg.Image.ImageBuffer pressedImage = new Agg.Image.ImageBuffer(); Agg.Image.ImageBuffer hoverImage = new Agg.Image.ImageBuffer(); Agg.Image.ImageBuffer disabledImage = new Agg.Image.ImageBuffer(); ImageBMPIO.LoadImageData(this.GetImageLocation(normalImageName), normalImage); ImageBMPIO.LoadImageData(this.GetImageLocation(pressedImageName), pressedImage); ImageBMPIO.LoadImageData(this.GetImageLocation(hoverImageName), hoverImage); ImageBMPIO.LoadImageData(this.GetImageLocation(disabledImageName), disabledImage); //normalImage.NewGraphics2D().Line(0, 0, normalImage.Width, normalImage.Height, RGBA_Bytes.Violet); //pressedImage.NewGraphics2D().Line(0, 0, normalImage.Width, normalImage.Height, RGBA_Bytes.Violet); ButtonViewStates buttonViewWidget = new ButtonViewStates( new ImageWidget(normalImage), new ImageWidget(hoverImage), new ImageWidget(pressedImage), new ImageWidget(disabledImage) ); //Create button based on view container widget Button imageButton = new Button(0, 0, buttonViewWidget); imageButton.Margin = new BorderDouble(0); imageButton.Padding = new BorderDouble(0); return(imageButton); }
void CreateOnePage(int plateNumber, ref int nextPartToPrintIndex, PdfPage pdfPage) { ImageBuffer plateInventoryImage = new ImageBuffer((int)(300 * 8.5), 300 * 11, 32, new BlenderBGRA()); Graphics2D plateGraphics = plateInventoryImage.NewGraphics2D(); double currentlyPrintingHeightPixels = PrintTopOfPage(plateInventoryImage, plateGraphics); Vector2 offset = new Vector2(PageMarginPixels.Left, currentlyPrintingHeightPixels); double tallestHeight = 0; List <PartImage> partsOnLine = new List <PartImage>(); while (nextPartToPrintIndex < partImagesToPrint.Count) { ImageBuffer image = partImagesToPrint[nextPartToPrintIndex].image; tallestHeight = Math.Max(tallestHeight, image.Height); if (partsOnLine.Count > 0 && offset.x + image.Width > plateInventoryImage.Width - PageMarginPixels.Right) { if (partsOnLine.Count == 1) { plateGraphics.Render(partsOnLine[0].image, plateInventoryImage.Width / 2 - partsOnLine[0].image.Width / 2, offset.y - tallestHeight); } else { foreach (PartImage partToDraw in partsOnLine) { plateGraphics.Render(partToDraw.image, partToDraw.xOffset, offset.y - tallestHeight); } } offset.x = PageMarginPixels.Left; offset.y -= (tallestHeight + PartPaddingPixels * 2); tallestHeight = 0; partsOnLine.Clear(); if (offset.y - image.Height < PageMarginPixels.Bottom) { break; } } else { partImagesToPrint[nextPartToPrintIndex].xOffset = offset.x; partsOnLine.Add(partImagesToPrint[nextPartToPrintIndex]); //plateGraphics.Render(image, offset.x, offset.y - image.Height); offset.x += image.Width + PartPaddingPixels * 2; nextPartToPrintIndex++; } } // print the last line of parts foreach (PartImage partToDraw in partsOnLine) { plateGraphics.Render(partToDraw.image, partToDraw.xOffset, offset.y - tallestHeight); } TypeFacePrinter printer = new TypeFacePrinter(string.Format("{0}", Path.GetFileNameWithoutExtension(pathAndFileToSaveTo)), 32, justification: Justification.Center); printer.Origin = new Vector2(plateGraphics.DestImage.Width / 2, 110); plateGraphics.Render(printer, RGBA_Bytes.Black); printer = new TypeFacePrinter(string.Format("Page {0}", plateNumber), 28, justification: Justification.Center); printer.Origin = new Vector2(plateGraphics.DestImage.Width / 2, 60); plateGraphics.Render(printer, RGBA_Bytes.Black); string applicationUserDataPath = ApplicationDataStorage.Instance.ApplicationUserDataPath; string folderToSavePrintsTo = Path.Combine(applicationUserDataPath, "data", "temp", "plateImages"); string jpegFileName = System.IO.Path.Combine(folderToSavePrintsTo, plateNumber.ToString() + ".jpeg"); if (!Directory.Exists(folderToSavePrintsTo)) { Directory.CreateDirectory(folderToSavePrintsTo); } ImageBMPIO.SaveImageData(jpegFileName, plateInventoryImage); XGraphics gfx = XGraphics.FromPdfPage(pdfPage); XImage jpegImage = XImage.FromFile(jpegFileName); //double width = jpegImage.PixelWidth * 72 / jpegImage.HorizontalResolution; //double height = jpegImage.PixelHeight * 72 / jpegImage. .HorizontalResolution; gfx.DrawImage(jpegImage, 0, 0, pdfPage.Width, pdfPage.Height); }
private CheckBoxViewStates getCheckBoxButtonView(string label, string normalImageName = null, string normalToPressedImageName = null, string pressedImageName = null, string pressedToNormalImageName = null, string pressedLabel = null) { ImageBuffer normalImage = new ImageBuffer(); ImageBuffer pressedImage = new ImageBuffer(); ImageBuffer normalToPressedImage = new ImageBuffer(); ImageBuffer pressedToNormalImage = new ImageBuffer(); string pressedText = pressedLabel; if (pressedLabel == null) { pressedText = label; } if (normalImageName != null) { ImageBMPIO.LoadImageData(this.GetImageLocation(normalImageName), normalImage); } if (pressedImageName != null) { ImageBMPIO.LoadImageData(this.GetImageLocation(pressedImageName), pressedImage); } if (normalToPressedImageName != null) { ImageBMPIO.LoadImageData(this.GetImageLocation(normalToPressedImageName), normalToPressedImage); } if (pressedToNormalImageName != null) { ImageBMPIO.LoadImageData(this.GetImageLocation(pressedToNormalImageName), pressedToNormalImage); } if (normalToPressedImageName == null) { normalToPressedImage = pressedImage; } if (pressedImageName == null) { pressedImage = normalToPressedImage; } if (pressedToNormalImageName == null) { pressedToNormalImage = normalImage; } if (invertImageLocation) { flowDirection = FlowDirection.RightToLeft; } else { flowDirection = FlowDirection.LeftToRight; } //Create the multi-state button view GuiWidget normal = new TextImageWidget(label, normalFillColor, normalBorderColor, normalTextColor, borderWidth, Margin, normalImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight); GuiWidget normalHover = new TextImageWidget(label, hoverFillColor, normalBorderColor, hoverTextColor, borderWidth, Margin, normalImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight); GuiWidget switchNormalToPressed = new TextImageWidget(label, pressedFillColor, normalBorderColor, pressedTextColor, borderWidth, Margin, normalToPressedImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight); GuiWidget pressed = new TextImageWidget(pressedText, pressedFillColor, pressedBorderColor, pressedTextColor, borderWidth, Margin, pressedImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight); GuiWidget pressedHover = new TextImageWidget(label, hoverFillColor, pressedBorderColor, hoverTextColor, borderWidth, Margin, pressedImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight); GuiWidget switchPressedToNormal = new TextImageWidget(label, normalFillColor, pressedBorderColor, normalTextColor, borderWidth, Margin, pressedToNormalImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight); GuiWidget disabled = new TextImageWidget(label, disabledFillColor, disabledBorderColor, disabledTextColor, borderWidth, Margin, normalImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight); CheckBoxViewStates checkBoxButtonViewWidget = new CheckBoxViewStates(normal, normalHover, switchNormalToPressed, pressed, pressedHover, switchPressedToNormal, disabled); return(checkBoxButtonViewWidget); }
private ButtonViewStates getButtonView(string label, string normalImageName = null, string hoverImageName = null, string pressedImageName = null, string disabledImageName = null, bool centerText = false) { if (hoverImageName == null) { hoverImageName = normalImageName; } if (pressedImageName == null) { pressedImageName = hoverImageName; } if (disabledImageName == null) { disabledImageName = normalImageName; } ImageBuffer normalImage = new ImageBuffer(); ImageBuffer pressedImage = new ImageBuffer(); ImageBuffer hoverImage = new ImageBuffer(); ImageBuffer disabledImage = new ImageBuffer(); if (normalImageName != null) { ImageBMPIO.LoadImageData(this.GetImageLocation(normalImageName), normalImage); } if (hoverImageName != null) { ImageBMPIO.LoadImageData(this.GetImageLocation(pressedImageName), pressedImage); } if (pressedImageName != null) { ImageBMPIO.LoadImageData(this.GetImageLocation(hoverImageName), hoverImage); } if (disabledImageName != null) { ImageBMPIO.LoadImageData(this.GetImageLocation(disabledImageName), disabledImage); } if (invertImageLocation) { flowDirection = FlowDirection.RightToLeft; } else { flowDirection = FlowDirection.LeftToRight; } //Create the multi-state button view ButtonViewStates buttonViewWidget = new ButtonViewStates( new TextImageWidget(label, normalFillColor, normalBorderColor, normalTextColor, borderWidth, Margin, normalImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight, centerText: centerText), new TextImageWidget(label, hoverFillColor, hoverBorderColor, hoverTextColor, borderWidth, Margin, hoverImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight, centerText: centerText), new TextImageWidget(label, pressedFillColor, pressedBorderColor, pressedTextColor, borderWidth, Margin, pressedImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight, centerText: centerText), new TextImageWidget(label, disabledFillColor, disabledBorderColor, disabledTextColor, borderWidth, Margin, disabledImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight, centerText: centerText) ); return(buttonViewWidget); }
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); }