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; }
private CheckBoxViewStates getCheckBoxButtonView(string label, ImageBuffer normalImage = null, ImageBuffer pressedImage = null, ImageBuffer normalToPressedImage = null, ImageBuffer pressedToNormalImage = null, string pressedLabel = null) { string pressedText = pressedLabel; if (pressedLabel == null) { pressedText = label; } if (normalImage != null) { if (!ActiveTheme.Instance.IsDarkTheme && AllowThemeToAdjustImage) { normalImage.InvertLightness(); } } if (pressedImage != null) { if (!ActiveTheme.Instance.IsDarkTheme && AllowThemeToAdjustImage) { pressedImage.InvertLightness(); } } if (normalToPressedImage != null) { if (!ActiveTheme.Instance.IsDarkTheme && AllowThemeToAdjustImage) { normalToPressedImage.InvertLightness(); } } if (pressedToNormalImage != null) { if (!ActiveTheme.Instance.IsDarkTheme && AllowThemeToAdjustImage) { pressedToNormalImage.InvertLightness(); } } 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; }
public RadioButton GenerateRadioButton(string label, ImageBuffer iconImage) { if (iconImage != null ) { iconImage.InvertLightness(); if (ActiveTheme.Instance.IsDarkTheme && AllowThemeToAdjustImage) { iconImage.InvertLightness(); } } 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, checkedBorderColor, hoverTextColor, borderWidth, internalMargin, iconImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight, width: this.FixedWidth, centerText: true); TextImageWidget checkedState = new TextImageWidget(label, pressedFillColor, checkedBorderColor, 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; }
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) { // make copies so we don't change source data normalImage = new ImageBuffer(normalImage); normalImage.InvertLightness(); } if (pressedImage != null) { pressedImage.InvertLightness(); pressedImage = new ImageBuffer(pressedImage); } if (hoverImage != null) { hoverImage = new ImageBuffer(hoverImage); hoverImage.InvertLightness(); } if (disabledImage != null) { disabledImage = new ImageBuffer(disabledImage); disabledImage.InvertLightness(); } } 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; }