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(); ImageIO.LoadImageData(this.GetImageLocation(normalImageName), normalImage); ImageIO.LoadImageData(this.GetImageLocation(pressedImageName), pressedImage); ImageIO.LoadImageData(this.GetImageLocation(hoverImageName), hoverImage); ImageIO.LoadImageData(this.GetImageLocation(disabledImageName), disabledImage); if (!ActiveTheme.Instance.IsDarkTheme && invertImageColor) { InvertLightness.DoInvertLightness(normalImage); InvertLightness.DoInvertLightness(pressedImage); InvertLightness.DoInvertLightness(hoverImage); InvertLightness.DoInvertLightness(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; }
private ButtonViewStates getButtonView(string label, ImageBuffer normalImage = null, ImageBuffer hoverImage = null, ImageBuffer pressedImage = null, ImageBuffer disabledImage = null, bool centerText = false) { if (hoverImage == null && normalImage != null) { hoverImage = new ImageBuffer(normalImage); } if (pressedImage == null && hoverImage != null) { pressedImage = new ImageBuffer(hoverImage); } if (disabledImage == null && normalImage != null) { disabledImage = new ImageBuffer(normalImage); } if (!ActiveTheme.Instance.IsDarkTheme && AllowThemeToAdjustImage) { if (normalImage != null) InvertLightness.DoInvertLightness(normalImage); if (pressedImage != null) InvertLightness.DoInvertLightness(pressedImage); if (hoverImage != null) InvertLightness.DoInvertLightness(hoverImage); if (disabledImage != null) InvertLightness.DoInvertLightness(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, imageSpacing: ImageSpacing), new TextImageWidget(label, hoverFillColor, hoverBorderColor, hoverTextColor, borderWidth, Margin, hoverImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight, centerText: centerText, imageSpacing: ImageSpacing), new TextImageWidget(label, pressedFillColor, pressedBorderColor, pressedTextColor, borderWidth, Margin, pressedImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight, centerText: centerText, imageSpacing: ImageSpacing), new TextImageWidget(label, disabledFillColor, disabledBorderColor, disabledTextColor, borderWidth, Margin, disabledImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight, centerText: centerText, imageSpacing: ImageSpacing) ); return buttonViewWidget; }
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 = StaticData.Instance.LoadIcon(normalImageName); Agg.Image.ImageBuffer pressedImage = StaticData.Instance.LoadIcon(pressedImageName); Agg.Image.ImageBuffer hoverImage = StaticData.Instance.LoadIcon(hoverImageName); Agg.Image.ImageBuffer disabledImage = StaticData.Instance.LoadIcon(disabledImageName); if (!ActiveTheme.Instance.IsDarkTheme && invertImageColor) { InvertLightness.DoInvertLightness(normalImage); InvertLightness.DoInvertLightness(pressedImage); InvertLightness.DoInvertLightness(hoverImage); InvertLightness.DoInvertLightness(disabledImage); } if (ActiveTheme.Instance.IsTouchScreen) { //normalImage.NewGraphics2D().Line(0, 0, normalImage.Width, normalImage.Height, RGBA_Bytes.Violet); RoundedRect rect = new RoundedRect(pressedImage.GetBounds(), 0); pressedImage.NewGraphics2D().Render(new Stroke(rect, 3), ActiveTheme.Instance.PrimaryTextColor); } 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; }
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; }
public Button Generate(string buttonText) { //Widgets to show during the four button states ControlButtonViewBase buttonWidgetPressed = getButtonWidgetPressed(buttonText); ControlButtonViewBase buttonWidgetHover = getButtonWidgetHover(buttonText); ControlButtonViewBase buttonWidgetNormal = getButtonWidgetNormal(buttonText); ControlButtonViewBase buttonWidgetDisabled = getButtonWidgetDisabled(buttonText); //Create container for the three state widgets for the button ButtonViewStates buttonViewWidget = new ButtonViewStates(buttonWidgetNormal, buttonWidgetHover, buttonWidgetPressed, buttonWidgetDisabled); //Create button based on view container widget Button controlButton = new Button(0, 0, buttonViewWidget); controlButton.Margin = margin; return controlButton; }
public PrinterSelectButton() { this.HAnchor = HAnchor.ParentLeftRight; //Widgets to show during the four button states PrinterSelectViewBase buttonWidgetPressed = getButtonWidgetNormal(); PrinterSelectViewBase buttonWidgetHover = getButtonWidgetHover(); PrinterSelectViewBase buttonWidgetNormal = getButtonWidgetNormal(); PrinterSelectViewBase buttonWidgetDisabled = getButtonWidgetNormal(); //Create container for the three state widgets for the button ButtonViewStates buttonView = new ButtonViewStates(buttonWidgetNormal, buttonWidgetHover, buttonWidgetPressed, buttonWidgetDisabled); buttonView.HAnchor = HAnchor.ParentLeftRight; Margin = DefaultMargin; OriginRelativeParent = new Vector2(0, 0); if (buttonView != null) { buttonView.Selectable = false; AddChild(buttonView); HAnchor = HAnchor.FitToChildren; VAnchor = VAnchor.FitToChildren; if (LocalBounds.Left != 0 || LocalBounds.Bottom != 0) { // let's make sure that a button has 0, 0 at the lower left // move the children so they will fit with 0, 0 at the lower left foreach (GuiWidget child in Children) { child.OriginRelativeParent = child.OriginRelativeParent + new Vector2(-LocalBounds.Left, -LocalBounds.Bottom); } HAnchor = HAnchor.FitToChildren; VAnchor = VAnchor.FitToChildren; } MinimumSize = new Vector2(Width, Height); } }
private ButtonViewStates getButtonView(string label) { //Create the multi-state button view ButtonViewStates buttonViewWidget = new ButtonViewStates( new MoveButtonWidget(label, normalFillColor, normalTextColor), new MoveButtonWidget(label, hoverFillColor, hoverTextColor), new MoveButtonWidget(label, pressedFillColor, pressedTextColor), new MoveButtonWidget(label, disabledFillColor, disabledTextColor) ); return buttonViewWidget; }
private ButtonViewStates CreateButtonViewStates(string label) { //Create the multi-state button view ButtonViewStates buttonViewWidget = new ButtonViewStates( new DropDownButtonBase(label, normalFillColor, normalBorderColor, normalTextColor, borderWidth, Margin, fontSize, FlowDirection.LeftToRight, FixedHeight), new DropDownButtonBase(label, hoverFillColor, hoverBorderColor, hoverTextColor, borderWidth, Margin, fontSize, FlowDirection.LeftToRight, FixedHeight), new DropDownButtonBase(label, pressedFillColor, pressedBorderColor, pressedTextColor, borderWidth, Margin, fontSize, FlowDirection.LeftToRight, FixedHeight), new DropDownButtonBase(label, disabledFillColor, disabledBorderColor, disabledTextColor, borderWidth, Margin, fontSize, FlowDirection.LeftToRight, FixedHeight) ); buttonViewWidget.Padding = new BorderDouble(0, 0); return buttonViewWidget; }
public Button Generate(ImageBuffer normalImage, ImageBuffer hoverImage, ImageBuffer pressedImage = null, ImageBuffer disabledImage = null) { if(hoverImage == null) { hoverImage = normalImage; } if (pressedImage == null) { pressedImage = hoverImage; } if (disabledImage == null) { disabledImage = normalImage; } if (!ActiveTheme.Instance.IsDarkTheme && InvertImageColor) { normalImage.InvertLightness(); pressedImage.InvertLightness(); hoverImage.InvertLightness(); disabledImage.InvertLightness(); } 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; }