📄 elementbuttonstyle.cs
字号:
namespace Imps.Client.Pc
{
using Imps.Client.Pc.Theme;
using Imps.Client.Utils;
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Xml;
public class ElementButtonStyle : EStyleBase
{
private System.Windows.Forms.Cursor _cursor;
public Bitmap _disable_image;
public Bitmap _down_image;
public Color _fontDisableColor;
public Color _fontDownColor;
public string _fontFamily;
public Color _fontHoverColor;
public Color _fontNormalColor;
public int _fontPaddingLeft;
public int _fontPaddingTop;
public int _fontSize;
public string _fontStyle;
public Bitmap _hover_image;
public Image _icon;
public EAlignment _icon_hor_alignment;
public EStretch _icon_stretch;
public EAlignment _icon_ver_alignment;
public System.Drawing.Point _location;
public Bitmap _normal_image;
public Size _size;
public string _string;
public EAlignment _text_hor_alignment;
public EAlignment _text_ver_alignment;
private RGB _transParentColor;
public EAlignment _xAlignment;
public EAlignment _yAlignment;
public override void ChangeColor(int hue, double sat, double lum)
{
if (this.TransParentColor != null)
{
HSLFilter.ChangeImageColor(ref this._normal_image, hue, sat, lum, this.TransParentColor);
HSLFilter.ChangeImageColor(ref this._down_image, hue, sat, lum, this.TransParentColor);
HSLFilter.ChangeImageColor(ref this._hover_image, hue, sat, lum, this.TransParentColor);
HSLFilter.ChangeImageColor(ref this._disable_image, hue, sat, lum, this.TransParentColor);
base.ChangeColor(hue, sat, lum);
}
}
public override void Clone(EStyleBase sty)
{
base.Clone(sty);
ElementButtonStyle style = sty as ElementButtonStyle;
if (style != null)
{
if (style._normal_image != null)
{
this._normal_image = (Bitmap) style._normal_image.Clone();
}
if (style._down_image != null)
{
this._down_image = (Bitmap) style._down_image.Clone();
}
if (style._hover_image != null)
{
this._hover_image = (Bitmap) style._hover_image.Clone();
}
if (style._disable_image != null)
{
this._disable_image = (Bitmap) style._disable_image.Clone();
}
this._location = new System.Drawing.Point(style._location.X, style._location.Y);
this._size = new Size(style._size.Width, style._size.Height);
this._xAlignment = style._xAlignment;
this._yAlignment = style._yAlignment;
this._transParentColor = style._transParentColor;
if (style._icon != null)
{
this._icon = (Image) style._icon.Clone();
}
this._icon_hor_alignment = style._icon_hor_alignment;
this._icon_ver_alignment = style._icon_ver_alignment;
this._icon_stretch = style._icon_stretch;
if (null != style._cursor)
{
this._cursor = new System.Windows.Forms.Cursor(style._cursor.Handle);
}
}
}
public override void Dispose()
{
base.Dispose();
this._normal_image = null;
this._down_image = null;
this._hover_image = null;
this._disable_image = null;
this._location = System.Drawing.Point.Empty;
this._size = Size.Empty;
this._xAlignment = EAlignment.left;
this._yAlignment = EAlignment.top;
this._transParentColor = null;
this._icon = null;
this._icon_hor_alignment = EAlignment.left;
this._icon_ver_alignment = EAlignment.top;
this._icon_stretch = EStretch.none;
this._cursor = null;
this._fontFamily = null;
this._fontSize = 0;
this._fontStyle = null;
this._fontPaddingLeft = 0;
this._fontPaddingTop = 0;
this._fontNormalColor = Color.Empty;
this._fontDownColor = Color.Empty;
this._fontHoverColor = Color.Empty;
this._fontDisableColor = Color.Empty;
this._text_hor_alignment = EAlignment.center;
this._text_ver_alignment = EAlignment.center;
}
protected override void LoadStyle(XmlElement elem)
{
base.LoadStyle(elem);
this._location.X = base.GetIntegerAttribute(elem, "left");
this._location.Y = base.GetIntegerAttribute(elem, "top");
this._size.Width = base.GetIntegerAttribute(elem, "width");
this._size.Height = base.GetIntegerAttribute(elem, "height");
this._xAlignment = EStyleBase.AlignmentStringToValue(base.GetStringAttribute(elem, "xAlignment"), EAlignment.left);
this._yAlignment = EStyleBase.AlignmentStringToValue(base.GetStringAttribute(elem, "yAlignment"), EAlignment.top);
this._normal_image = base.GetImageAttribute(elem, "normalImage");
this._down_image = base.GetImageAttribute(elem, "downImage");
this._hover_image = base.GetImageAttribute(elem, "hoverImage");
this._disable_image = base.GetImageAttribute(elem, "disableImage");
this.TransParentColor = base.GetRGBAttribute(elem, "transColor");
this.Cursor = EStyleBase.NameToCursor(base.GetStringAttribute(elem, "cursor"));
foreach (XmlNode node in elem.ChildNodes)
{
XmlElement element = node as XmlElement;
if (element.Name == "Icon")
{
string fileName = base.GetStringAttribute(element, "ico");
if (!string.IsNullOrEmpty(fileName))
{
this._icon = Image.FromFile(ThemeManager.GetImagePath(fileName));
}
this._icon_hor_alignment = EStyleBase.AlignmentStringToValue(base.GetStringAttribute(element, "horizontalAlignment"), EAlignment.left);
this._icon_ver_alignment = EStyleBase.AlignmentStringToValue(base.GetStringAttribute(element, "virticalAlignment"), EAlignment.top);
this._icon_stretch = EStyleBase.StretchStringToValue(base.GetStringAttribute(element, "stretch"), EStretch.none);
continue;
}
if (element.Name == "Text")
{
this._string = base.GetStringAttribute(element, "string");
this._fontFamily = base.GetStringAttribute(element, "fontFamily");
this._fontSize = base.GetIntegerAttribute(element, "fontSize");
this._fontStyle = base.GetStringAttribute(element, "fontStyle");
this._fontPaddingLeft = base.GetIntegerAttribute(element, "paddingLeft");
this._fontPaddingTop = base.GetIntegerAttribute(element, "paddingTop");
this._fontNormalColor = base.GetColorAttribute(element, "color");
this._fontDownColor = base.GetColorAttribute(element, "downColor");
this._fontHoverColor = base.GetColorAttribute(element, "hoverColor");
this._fontDisableColor = base.GetColorAttribute(element, "disableColor");
this._text_hor_alignment = EStyleBase.AlignmentStringToValue(base.GetStringAttribute(element, "horizontalAlignment"), EAlignment.center);
this._text_ver_alignment = EStyleBase.AlignmentStringToValue(base.GetStringAttribute(element, "virticalAlignment"), EAlignment.center);
}
}
}
public System.Windows.Forms.Cursor Cursor
{
get
{
return this._cursor;
}
set
{
this._cursor = value;
}
}
public RGB TransParentColor
{
get
{
return this._transParentColor;
}
set
{
this._transParentColor = value;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -