Commit c64e5714 顾剑亮

new version

1 个父辈 4feea31d
正在显示 291 个修改的文件 包含 1157 行增加3587 行删除
此文件的差异被折叠, 点击展开。
namespace Asa.Face
{
partial class SurButton
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region 组件设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.SuspendLayout();
//
// SurButton
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.BorderRect = new System.Drawing.Rectangle(1, 1, 78, 38);
this.Name = "SurButton";
this.Paint += new System.Windows.Forms.PaintEventHandler(this.SurButton_Paint);
this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.SurButton_MouseDown);
this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.SurButton_MouseMove);
this.MouseUp += new System.Windows.Forms.MouseEventHandler(this.SurButton_MouseUp);
this.ResumeLayout(false);
}
#endregion
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
namespace Asa.Face
{
/// <summary>
/// 按钮控件
/// </summary>
[DefaultProperty("Text")]
[DefaultEvent("Click")]
public partial class SurButton : BaseCtl
{
private bool _down = false;
private Bitmap _img = null;
private Size _imgSize = new Size();
private HorizontalAlignment _textAlign = HorizontalAlignment.Center;
private Color _color = Color.Empty;
private RectangleF _colorPoint = new RectangleF();
private RectangleF _imgRect = new RectangleF();
private RectangleF _textRect = new RectangleF();
private const int SPACE = 6; //图片与文字的间隔
/// <summary>
/// 按钮控件
/// </summary>
public SurButton()
{
InitializeComponent();
}
//==========事件==========
/// <summary>
/// 单击时发生
/// </summary>
[Browsable(true), Category(""), Description("单击时发生")]
public new event MyEvent.Click Click;
//==========属性==========
/// <summary>
/// 控件上显示的图像
/// </summary>
[Browsable(true), Category(""), Description("控件上显示的图像"), DefaultValue(null)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public Bitmap Image
{
set
{
_img = value;
if (_img == null)
{
ImageSize = new Size();
}
else
{
if (_imgSize.Width == 0 || _imgSize.Height == 0)
ImageSize = _img.Size;
else
{
CalcSize();
Refresh();
}
}
}
get
{
return _img;
}
}
/// <summary>
/// 显示的图像的大小
/// </summary>
[Browsable(true), Category(""), Description("显示的图像的大小")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public Size ImageSize
{
set
{
_imgSize = value;
CalcSize();
Refresh();
}
get
{
return _imgSize;
}
}
/// <summary>
/// 显示的文本的对齐方式
/// </summary>
[Browsable(true), Category(""), Description("显示的文本的对齐方式"), DefaultValue(HorizontalAlignment.Center)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public HorizontalAlignment TextAlign
{
set
{
_textAlign = value;
CalcSize();
Refresh();
}
get
{
return _textAlign;
}
}
/// <summary>
/// 控件内部间距
/// </summary>
[Browsable(true), Category(""), Description("控件内部间距")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public new Padding Padding
{
set
{
base.Padding = value;
CalcSize();
Refresh();
}
get => base.Padding;
}
/// <summary>
/// 状态颜色
/// </summary>
[Browsable(true), Category(""), Description("状态颜色")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public Color StateColor
{
set
{
_color = value;
Refresh();
}
get
{
return _color;
}
}
//==========私有==========
/// <summary>
/// 计算位置大小
/// </summary>
protected override void CalcSize()
{
base.CalcSize();
Graphics g = CreateGraphics();
SizeF sf = g.MeasureString(Text, Font);
_imgRect = new RectangleF(0, (Height - _imgSize.Height) / 2f, _imgSize.Width, _imgSize.Height);
_textRect = new RectangleF(0, (Height - sf.Height) / 2f, sf.Width, sf.Height);
_colorPoint = new RectangleF(BorderWidth + 4, BorderWidth + 4, 10, 10);
float x;
switch (_textAlign)
{
case HorizontalAlignment.Left:
x = BorderWidth + Padding.Left;
if (_img != null)
{
_imgRect.X = x;
x += _imgSize.Width + SPACE;
}
_textRect.X = x;
break;
case HorizontalAlignment.Center:
if (_img != null)
{
x = (Width - sf.Width - _imgSize.Width - SPACE) / 2f;
_imgRect.X = x;
x += _imgSize.Width + SPACE;
}
else
{
x = (Width - sf.Width) / 2f;
}
_textRect.X = x;
break;
case HorizontalAlignment.Right:
x = Width - BorderWidth - Padding.Right - sf.Width;
_textRect.X = x;
if (_img != null)
{
x = x - SPACE - _imgSize.Width;
_imgRect.X = x;
}
break;
}
}
private void SurButton_MouseDown(object sender, MouseEventArgs e)
{
if (!Enabled) return;
if (e.Button == MouseButtons.Left)
{
_down = true;
Refresh();
}
}
private void SurButton_MouseMove(object sender, MouseEventArgs e)
{
}
private void SurButton_MouseUp(object sender, MouseEventArgs e)
{
if (!Enabled) return;
if (e.Button == MouseButtons.Left)
{
_down = false;
Refresh();
Click?.Invoke(this);
}
}
private void SurButton_Paint(object sender, PaintEventArgs e)
{
BufferedGraphicsContext current = BufferedGraphicsManager.Current;
BufferedGraphics bg = current.Allocate(e.Graphics, e.ClipRectangle);
Graphics g = bg.Graphics;
g.SmoothingMode = SmoothingMode.HighQuality;
g.CompositingQuality = CompositingQuality.HighQuality;
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
g.Clear(Common.BACK_COLOR); //背景
//控件边框
if (Inside && Enabled)
{
if (_down)
g.FillRectangle(Common.BLUE_BRUSH, BorderRect);
else
g.FillRectangle(Common.OVER_BRUSH, BorderRect);
if (BorderWidth > 0)
g.DrawRectangle(BorderInsidePen, BorderRect);
}
else
{
if (BorderWidth > 0)
g.DrawRectangle(BorderOutsidePen, BorderRect);
}
//图标
if (_img != null)
g.DrawImage(_img, _imgRect, new RectangleF(0, 0, _img.Width, _img.Height), GraphicsUnit.Pixel);
//文字
if (Enabled)
g.DrawString(Text, Font, Common.FORE_BRUSH, _textRect);
else
g.DrawString(Text, Font, Common.BORDER_BRUSH, _textRect);
//状态点
if (_color != Color.Empty && Enabled)
g.FillEllipse(new SolidBrush(_color), _colorPoint);
bg.Render();
bg.Dispose();
}
}
}
namespace Asa.Face
{
partial class SurButtonOKCancel
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region 组件设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.SuspendLayout();
//
// SurButtonOKCancel
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.BorderRect = new System.Drawing.Rectangle(1, 1, 78, 38);
this.Name = "SurButtonOKCancel";
this.Paint += new System.Windows.Forms.PaintEventHandler(this.SurButton_Paint);
this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.SurButton_MouseDown);
this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.SurButton_MouseMove);
this.MouseUp += new System.Windows.Forms.MouseEventHandler(this.SurButton_MouseUp);
this.ResumeLayout(false);
}
#endregion
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
namespace Asa.Face
{
/// <summary>
/// OK/Cancel两个按钮
/// </summary>
[DefaultProperty("ButtonIndex")]
[DefaultEvent("Click")]
public partial class SurButtonOKCancel : BaseCtl
{
private int _down = -1;
private int _over = -1;
private RectangleF[] _textRect = new RectangleF[2];
private Rectangle[] _btnRect = new Rectangle[2];
private const int SPACE = 6;
private static readonly string[] TEXT = new string[] { "OK", "Cancel" };
/// <summary>
/// OK/Cancel两个按钮
/// </summary>
public SurButtonOKCancel()
{
InitializeComponent();
}
//==========事件==========
/// <summary>
/// 单击时发生
/// </summary>
[Browsable(true), Category(""), Description("单击时发生")]
public new event MyEvent.Click Click;
//==========属性==========
/// <summary>
/// 按钮的Index索引
/// </summary>
[Browsable(false), Category(""), Description("按钮的Index索引")]
public int ButtonIndex { set; get; } = -1;
//==========私有==========
/// <summary>
/// 计算位置大小
/// </summary>
protected override void CalcSize()
{
base.CalcSize();
int w = (Width - SPACE) / 2;
_btnRect[0] = new Rectangle(BorderWidth / 2, BorderWidth / 2, w - BorderWidth, Height - BorderWidth);
_btnRect[1] = new Rectangle(w + SPACE, BorderWidth / 2, w - BorderWidth, Height - BorderWidth);
Graphics g = CreateGraphics();
SizeF sf = g.MeasureString(TEXT[0], Font);
_textRect[0] = new RectangleF((w - sf.Width) / 2f, (Height - sf.Height) / 2f, sf.Width, sf.Height);
sf = g.MeasureString(TEXT[1], Font);
_textRect[1] = new RectangleF(w + (w - sf.Width) / 2f + SPACE, (Height - sf.Height) / 2f, sf.Width, sf.Height);
}
private void SurButton_MouseDown(object sender, MouseEventArgs e)
{
if (!Enabled) return;
if (e.Button == MouseButtons.Left)
{
if (_over > -1)
{
_down = _over;
Refresh();
}
}
}
private void SurButton_MouseMove(object sender, MouseEventArgs e)
{
if (!Enabled) return;
int move = -1;
for (int i = 0; i < _btnRect.Length; i++)
{
if (_btnRect[i].Contains(e.Location))
{
move = i;
break;
}
}
if (_over != move)
{
_over = move;
Refresh();
}
}
private void SurButton_MouseUp(object sender, MouseEventArgs e)
{
if (!Enabled) return;
if (e.Button == MouseButtons.Left)
{
if (_over > -1 && _down > -1)
{
ButtonIndex = _over;
_down = -1;
Refresh();
Click?.Invoke(this);
ButtonIndex = -1;
}
}
}
private void SurButton_Paint(object sender, PaintEventArgs e)
{
BufferedGraphicsContext current = BufferedGraphicsManager.Current;
BufferedGraphics bg = current.Allocate(e.Graphics, e.ClipRectangle);
Graphics g = bg.Graphics;
g.SmoothingMode = SmoothingMode.HighQuality;
g.CompositingQuality = CompositingQuality.HighQuality;
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
g.Clear(Common.BACK_COLOR); //背景
if (Enabled)
{
if (!Inside) _over = -1;
for (int i = 0; i < _btnRect.Length; i++)
{
if (i == _down)
{
g.FillRectangle(Common.BLUE_BRUSH, _btnRect[i]);
}
else if (i == _over)
{
g.FillRectangle(Common.OVER_BRUSH, _btnRect[i]);
if (BorderWidth > 0)
g.DrawRectangle(BorderInsidePen, _btnRect[i].X, _btnRect[i].Y, _btnRect[i].Width, _btnRect[i].Height);
}
else
{
g.DrawRectangle(BorderOutsidePen, _btnRect[i].X, _btnRect[i].Y, _btnRect[i].Width, _btnRect[i].Height);
}
g.DrawString(TEXT[i], Font, Common.FORE_BRUSH, _textRect[i]);
}
}
else
{
if (BorderWidth > 0)
{
g.DrawRectangle(BorderOutsidePen, _btnRect[0].X, _btnRect[0].Y, _btnRect[0].Width, _btnRect[0].Height);
g.DrawRectangle(BorderOutsidePen, _btnRect[1].X, _btnRect[1].Y, _btnRect[1].Width, _btnRect[1].Height);
}
g.DrawString(TEXT[0], Font, Common.BORDER_BRUSH, _textRect[0]);
g.DrawString(TEXT[1], Font, Common.BORDER_BRUSH, _textRect[1]);
}
bg.Render();
bg.Dispose();
}
}
}
namespace Asa.Face
{
partial class SurCheck
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region 组件设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.SuspendLayout();
//
// SurCheck
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.BorderRect = new System.Drawing.Rectangle(1, 1, 78, 38);
this.Name = "SurCheck";
this.Paint += new System.Windows.Forms.PaintEventHandler(this.FlatCheck_Paint);
this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.FlatCheck_MouseDown);
this.ResumeLayout(false);
}
#endregion
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
namespace Asa.Face
{
/// <summary>
/// 复选框控件
/// </summary>
[DefaultProperty("Checked")]
[DefaultEvent("CheckedChanged")]
public partial class SurCheck : BaseCtl
{
private bool _check;
private GraphicsPath _switchPath = new GraphicsPath();
private RectangleF _switchPoint = new RectangleF();
private RectangleF _textRect = new RectangleF();
private string _text = "";
private int _radius = 9;
private int _between = 20;
private static readonly Pen SWITCH_PEN = new Pen(Common.FORE_COLOR, 1);
/// <summary>
/// 复选框控件
/// </summary>
public SurCheck()
{
InitializeComponent();
}
//==========事件==========
/// <summary>
/// Check属性更改时发生
/// </summary>
[Browsable(true), Category(""), Description("Check属性更改时发生")]
public event MyEvent.Changed CheckedChanged;
//==========属性==========
/// <summary>
/// 组件是否处于选中状态
/// </summary>
[Browsable(true), Category(""), Description("组件是否处于选中状态"), DefaultValue(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public bool Checked
{
set
{
_check = value;
CalcSize();
Refresh();
CheckedChanged?.Invoke(this);
}
get
{
return _check;
}
}
/// <summary>
/// 左右半圆的半径
/// </summary>
[Browsable(true), Category(""), Description("左右半圆的半径"), DefaultValue(9)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public int Radius
{
get
{
return _radius;
}
set
{
_radius = value;
CalcSize();
Refresh();
}
}
/// <summary>
/// 左右半圆的圆心距离
/// </summary>
[Browsable(true), Category(""), Description("左右半圆的圆心距离"), DefaultValue(20)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public int CircleSpace
{
set
{
_between = value;
CalcSize();
Refresh();
}
get
{
return _between;
}
}
//==========私有==========
/// <summary>
/// 计算大小
/// </summary>
protected override void CalcSize()
{
base.CalcSize();
int diameter = _radius * 2; //直径
RectangleF rect1 = new RectangleF(6, (Height - diameter) / 2f, diameter, diameter);
RectangleF rect2 = new RectangleF(6 + _between, (Height - diameter) / 2f, diameter, diameter);
SizeF sf = CreateGraphics().MeasureString(Text, Font);
_textRect = new RectangleF(rect2.X + rect2.Width + 6, (Height - sf.Height) / 2f, sf.Width, sf.Height);
_switchPath = new GraphicsPath();
_switchPath.AddArc(rect1, 90, 180);
_switchPath.AddLine(rect1.X + _radius, rect1.Y, rect2.X + _radius, rect2.Y);
_switchPath.AddArc(rect2, -90, 180);
_switchPath.AddLine(rect2.X + _radius, rect2.Y + diameter, rect1.X + _radius, rect1.Y + diameter);
int d = _radius * 2 - 6;
if (_check)
_switchPoint = new RectangleF(rect2.X + _radius - d / 2f, rect2.Y + _radius - d / 2f, d, d);
else
_switchPoint = new RectangleF(rect1.X + _radius - d / 2f, rect1.Y + _radius - d / 2f, d, d);
_text = Text;
string[] arr = Text.Split(',');
if (arr.Length == 2)
_text = _check ? arr[1] : arr[0];
}
private void FlatCheck_Paint(object sender, PaintEventArgs e)
{
BufferedGraphicsContext current = BufferedGraphicsManager.Current;
BufferedGraphics bg = current.Allocate(e.Graphics, e.ClipRectangle);
Graphics g = bg.Graphics;
g.SmoothingMode = SmoothingMode.HighQuality;
g.CompositingQuality = CompositingQuality.HighQuality;
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
g.Clear(Common.BACK_COLOR); //背景
//边框
if (Inside && Enabled)
{
if (BorderWidth > 0)
g.DrawRectangle(BorderInsidePen, BorderRect);
}
else
{
if (BorderWidth > 0)
g.DrawRectangle(BorderOutsidePen, BorderRect);
}
//开关
if (_check && Enabled)
g.FillPath(Common.BLUE_BRUSH, _switchPath);
else
g.DrawPath(SWITCH_PEN, _switchPath);
//开关点
if (Enabled)
g.FillEllipse(Common.FORE_BRUSH, _switchPoint);
//文本
if (Enabled)
g.DrawString(_text, Font, Common.FORE_BRUSH, _textRect);
else
g.DrawString(_text, Font, Common.BORDER_BRUSH, _textRect);
bg.Render();
bg.Dispose();
}
private void FlatCheck_MouseDown(object sender, MouseEventArgs e)
{
if (!Enabled) return;
if (e.Button == MouseButtons.Left)
Checked = !Checked;
}
}
}
namespace Asa.Face
{
partial class SurChoose
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region 组件设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.SuspendLayout();
//
// SurChoose
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.BorderRect = new System.Drawing.Rectangle(1, 1, 78, 38);
this.Name = "SurChoose";
this.Load += new System.EventHandler(this.SurChoose_Load);
this.Paint += new System.Windows.Forms.PaintEventHandler(this.SurChoose_Paint);
this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.SurChoose_MouseDown);
this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.SurChoose_MouseMove);
this.MouseUp += new System.Windows.Forms.MouseEventHandler(this.SurChoose_MouseUp);
this.ResumeLayout(false);
}
#endregion
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
namespace Asa.Face
{
/// <summary>
/// 选择控件
/// </summary>
[DefaultProperty("Text")]
[DefaultEvent("SelectedIndexChanged")]
public partial class SurChoose : BaseCtl
{
private RectangleF[] _btnRect;
private string[] _btnText;
private RectangleF[] _btnTextRect;
private int _indexOver = -1;
private int _index = -1;
private const int SPACE = 3;
/// <summary>
/// 选择控件
/// </summary>
public SurChoose()
{
InitializeComponent();
}
//==========事件==========
/// <summary>
/// SelectedIndex属性更改时发生
/// </summary>
[Browsable(true), Category(""), Description("SelectedIndex属性更改时发生")]
public event MyEvent.Changed SelectedIndexChanged;
//==========属性==========
/// <summary>
/// 当前选定项从零开始的索引
/// </summary>
[Browsable(false), Category(""), Description("当前选定项从零开始的索引")]
public int SelectedIndex
{
set
{
_index = value;
Refresh();
if (Enabled)
SelectedIndexChanged?.Invoke(this);
}
get => _index;
}
/// <summary>
/// 当前选定项的文本
/// </summary>
[Browsable(false), Category(""), Description("当前选定项的文本")]
public string SelectedText
{
set
{
if (_btnText != null)
{
int idx = Array.FindIndex(_btnText, s => s == value);
if (idx > -1) SelectedIndex = idx;
}
}
get
{
if (_btnText == null)
return "";
else if (_index < 0)
return "";
else
return _btnText[_index];
}
}
//==========私有==========
/// <summary>
/// 计算位置大小
/// </summary>
protected override void CalcSize()
{
base.CalcSize();
_btnText = Text.Split(',');
int count = _btnText.Length;
_btnRect = new RectangleF[count];
_btnTextRect = new RectangleF[count];
float w = Width - BorderWidth - BorderWidth;
float h = Height - BorderWidth - BorderWidth;
float ww = (w - SPACE * (count + 1)) / count;
float hh = h - SPACE - SPACE;
Graphics g = CreateGraphics();
SizeF sf;
for (int i = 0; i < count; i++)
{
_btnRect[i] = new RectangleF(BorderWidth + SPACE * (i + 1) + ww * i, BorderWidth + SPACE, ww, hh);
sf = g.MeasureString(_btnText[i], Font);
_btnTextRect[i] = new RectangleF(_btnRect[i].X + (_btnRect[i].Width - sf.Width) / 2, _btnRect[i].Y + (_btnRect[i].Height - sf.Height) / 2, sf.Width, sf.Height);
}
}
private void SurChoose_Paint(object sender, PaintEventArgs e)
{
BufferedGraphicsContext current = BufferedGraphicsManager.Current;
BufferedGraphics bg = current.Allocate(e.Graphics, e.ClipRectangle);
Graphics g = bg.Graphics;
g.SmoothingMode = SmoothingMode.HighQuality;
g.CompositingQuality = CompositingQuality.HighQuality;
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
g.Clear(Common.BACK_COLOR); //背景
//控件边框
if (Inside && Enabled)
{
if (BorderWidth > 0)
g.DrawRectangle(BorderInsidePen, BorderRect);
}
else
{
_indexOver = -1; //避免移动太快没有执行MouseMove
if (BorderWidth > 0)
g.DrawRectangle(BorderOutsidePen, BorderRect);
}
for (int i = 0; i < _btnRect.Length; i++)
{
if (Enabled)
{
if (i == _index)
g.FillRectangle(Common.BLUE_BRUSH, _btnRect[i]);
else if (i == _indexOver)
g.FillRectangle(Common.OVER_BRUSH, _btnRect[i]);
g.DrawString(_btnText[i], Font, Common.FORE_BRUSH, _btnTextRect[i]);
}
else
{
g.DrawString(_btnText[i], Font, Common.BORDER_BRUSH, _btnTextRect[i]);
}
}
bg.Render();
bg.Dispose();
}
private void SurChoose_Load(object sender, EventArgs e)
{
_index = -1;
}
private void SurChoose_MouseMove(object sender, MouseEventArgs e)
{
if (!Enabled) return;
int move = -1;
for (int i = 0; i < _btnRect.Length; i++)
{
if (_btnRect[i].Contains(e.Location))
{
move = i;
break;
}
}
if (_indexOver != move)
{
_indexOver = move;
Refresh();
}
}
private void SurChoose_MouseDown(object sender, MouseEventArgs e)
{
if (!Enabled) return;
if (e.Button == MouseButtons.Left)
{
if (_indexOver > -1)
{
_index = _indexOver;
Refresh();
}
}
}
private void SurChoose_MouseUp(object sender, MouseEventArgs e)
{
if (!Enabled) return;
if (e.Button == MouseButtons.Left)
{
if (_indexOver > -1 && _index > -1)
{
SelectedIndexChanged?.Invoke(this);
}
}
}
}
}
namespace Asa.Face
{
partial class SurHScrollBar
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region 组件设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.SuspendLayout();
//
// SurHScrollBar
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.BorderRect = new System.Drawing.Rectangle(1, 1, 78, 18);
this.Name = "SurHScrollBar";
this.Size = new System.Drawing.Size(80, 20);
this.Load += new System.EventHandler(this.SurScrollBar_Load);
this.Paint += new System.Windows.Forms.PaintEventHandler(this.ScrollBar_Paint);
this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.ScrollBar_MouseDown);
this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.ScrollBar_MouseMove);
this.MouseUp += new System.Windows.Forms.MouseEventHandler(this.ScrollBar_MouseUp);
this.ResumeLayout(false);
}
#endregion
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
namespace Asa.Face
{
/// <summary>
/// 水平滚动条
/// </summary>
[DefaultProperty("Value")]
[DefaultEvent("ValueChanged")]
public partial class SurHScrollBar : BaseCtl
{
private Rectangle _button1 = new Rectangle();
private Rectangle _button2 = new Rectangle();
private RectangleF _slider = new RectangleF();
private GraphicsPath _btnShape1 = new GraphicsPath();
private GraphicsPath _btnShape2 = new GraphicsPath();
private int _over = -1;
private int _down = -1;
private int _oldX = -1;
private int _max = 100;
private int _min = 0;
private int _value = 0;
private float _step = SLIDER_STEP;
private const int BTN_SIZE = 25;
private const int SLIDER_MIN = 15;
private const int SLIDER_STEP = 2;
private static readonly Color BACK = Color.FromArgb(40, 40, 40);
private static readonly Brush BTN_BRUSH = new SolidBrush(Color.FromArgb(60, 60, 60));
private static readonly Brush SLIDER_BRUSH = new SolidBrush(Color.FromArgb(60, 60, 60));
private static readonly Brush SLIDER_OVER = new SolidBrush(Color.FromArgb(70, 70, 70));
/// <summary>
/// 水平滚动条
/// </summary>
public SurHScrollBar()
{
InitializeComponent();
BackColor = BACK;
}
//==========事件==========
/// <summary>
/// 在控件的值更改时发生
/// </summary>
[Browsable(true), Category(""), Description("在控件的值更改时发生")]
public event MyEvent.Changed ValueChanged;
//==========属性==========
/// <summary>
/// 可滚动范围的上限值
/// </summary>
[Browsable(true), Category(""), Description("可滚动范围的上限值"), DefaultValue(100)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public int Maximum
{
set
{
if (value < _min)
_max = _min + 1;
else
_max = value;
if (_value > _max)
_value = _max;
CalcSize();
Refresh();
}
get => _max;
}
/// <summary>
/// 可滚动范围的下限值
/// </summary>
[Browsable(true), Category(""), Description("可滚动范围的下限值"), DefaultValue(0)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public int Minimum
{
set
{
if (value >= _max)
_min = _max - 1;
else if (value < 0)
_min = 0;
else
_min = value;
if (_value < _min)
_value = _min;
CalcSize();
Refresh();
}
get => _min;
}
/// <summary>
/// 滚动框位置表示的值
/// </summary>
[Browsable(true), Category(""), Description("滚动框位置表示的值"), DefaultValue(0)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public int Value
{
set
{
if (value >= _min && value <= _max)
{
_value = value;
CalcSize();
Refresh();
ValueChanged?.Invoke(this);
}
}
get => _value;
}
//==========私有==========
/// <summary>
/// 计算位置大小
/// </summary>
protected override void CalcSize()
{
base.CalcSize();
_button1 = new Rectangle(0, 0, BTN_SIZE, Height);
_button2 = new Rectangle(Width - BTN_SIZE, 0, BTN_SIZE, Height);
_btnShape1 = Shape.ControlTriangle(_button1, 6, Direction.Left);
_btnShape2 = Shape.ControlTriangle(_button2, 6, Direction.Right);
int w = Width - BTN_SIZE - BTN_SIZE - _max * SLIDER_STEP;
if (w < SLIDER_MIN)
{
w = SLIDER_MIN;
_step = (Width - BTN_SIZE - BTN_SIZE - w) / (float)_max;
}
else
{
_step = SLIDER_STEP;
}
_slider = new RectangleF(BTN_SIZE + _value * _step, 0, w, Height);
}
private void ScrollBar_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
if (_over > -1)
{
_oldX = e.Y;
_down = _over;
Refresh();
}
}
}
private void ScrollBar_MouseUp(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
if (_down == 0)
{
if (_value > _min)
{
Value--;
ValueChanged?.Invoke(this);
}
}
else if (_down == 2)
{
if (_value < _max)
{
Value++;
ValueChanged?.Invoke(this);
}
}
_down = -1;
Refresh();
}
}
private void ScrollBar_MouseMove(object sender, MouseEventArgs e)
{
int n = -1;
if (e.Button == MouseButtons.Left)
{
if (_down != 1) return;
n = Convert.ToInt32((e.X - _oldX) / _step);
_oldX += Convert.ToInt32(n * _step);
Value += n;
ValueChanged?.Invoke(this);
}
else
{
if (_button1.Contains(e.Location))
n = 0;
else if (_slider.Contains(e.Location))
n = 1;
else if (_button2.Contains(e.Location))
n = 2;
if (_over != n)
{
_over = n;
Refresh();
}
}
}
private void ScrollBar_Paint(object sender, PaintEventArgs e)
{
BufferedGraphicsContext current = BufferedGraphicsManager.Current;
BufferedGraphics bg = current.Allocate(e.Graphics, e.ClipRectangle);
Graphics g = bg.Graphics;
g.SmoothingMode = SmoothingMode.HighQuality;
g.CompositingQuality = CompositingQuality.HighQuality;
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
g.Clear(BACK); //背景
if (!Inside)
{
_over = -1;
_down = -1;
}
if (_down == 0)
g.FillRectangle(Common.BLUE_BRUSH, _button1);
else if (_over == 0)
g.FillRectangle(BTN_BRUSH, _button1);
if (_down == 1)
g.FillRectangle(Common.BLUE_BRUSH, _slider);
else if (_over == 1)
g.FillRectangle(SLIDER_OVER, _slider);
else
g.FillRectangle(SLIDER_BRUSH, _slider);
if (_down == 2)
g.FillRectangle(Common.BLUE_BRUSH, _button2);
else if (_over == 2)
g.FillRectangle(BTN_BRUSH, _button2);
g.FillPath(Common.FORE_BRUSH, _btnShape1);
g.FillPath(Common.FORE_BRUSH, _btnShape2);
bg.Render();
bg.Dispose();
}
private void SurScrollBar_Load(object sender, EventArgs e)
{
BackColor = BACK;
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
namespace Asa.Face
{
/// <summary>
/// 标签控件
/// </summary>
[DefaultProperty("Text")]
[DefaultEvent("Click")]
public partial class SurLabel : BaseCtl
{
private bool _foreCus = false;
private RectangleF _textRect = new RectangleF();
private HorizontalAlignment _textAlign = HorizontalAlignment.Left;
/// <summary>
/// 标签控件
/// </summary>
public SurLabel()
{
InitializeComponent();
}
//==========属性==========
/// <summary>
/// 显示的文本的对齐方式
/// </summary>
[Browsable(true), Category(""), Description("显示的文本的对齐方式"), DefaultValue(HorizontalAlignment.Left)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public HorizontalAlignment TextAlign
{
set
{
_textAlign = value;
CalcSize();
Refresh();
}
get
{
return _textAlign;
}
}
/// <summary>
/// 前景色是否自定义,通过ForeColor指定
/// </summary>
[Browsable(true), Category(""), Description("前景色是否自定义,通过ForeColor指定"), DefaultValue(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public bool ForeColorCustom
{
set
{
_foreCus = value;
Refresh();
}
get
{
return _foreCus;
}
}
//==========私有==========
/// <summary>
/// 计算位置大小
/// </summary>
protected override void CalcSize()
{
base.CalcSize();
SizeF sf = CreateGraphics().MeasureString(Text, Font, Width);
switch (TextAlign)
{
case HorizontalAlignment.Left:
_textRect = new RectangleF(BorderWidth, (Height - sf.Height) / 2f, sf.Width, sf.Height);
break;
case HorizontalAlignment.Center:
_textRect = new RectangleF((Width - sf.Width) / 2f, (Height - sf.Height) / 2f, sf.Width, sf.Height);
break;
case HorizontalAlignment.Right:
_textRect = new RectangleF(Width - BorderWidth - sf.Width, (Height - sf.Height) / 2f, sf.Width, sf.Height);
break;
}
}
private void SurLabel_Paint(object sender, PaintEventArgs e)
{
BufferedGraphicsContext current = BufferedGraphicsManager.Current;
BufferedGraphics bg = current.Allocate(e.Graphics, e.ClipRectangle);
Graphics g = bg.Graphics;
g.SmoothingMode = SmoothingMode.HighQuality;
g.CompositingQuality = CompositingQuality.HighQuality;
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
g.Clear(Common.BACK_COLOR); //背景
if (Inside && Enabled)
{
if (BorderWidth > 0)
g.DrawRectangle(BorderInsidePen, BorderRect);
}
else
{
if (BorderWidth > 0)
g.DrawRectangle(BorderOutsidePen, BorderRect);
}
if (Enabled)
g.DrawString(Text, Font, _foreCus ? new SolidBrush(ForeColor) : Common.FORE_BRUSH, _textRect);
else
g.DrawString(Text, Font, Common.BORDER_BRUSH, _textRect);
bg.Render();
bg.Dispose();
}
}
}
namespace Asa.Face
{
partial class SurList
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region 组件设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.SuspendLayout();
//
// SurList
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.BorderRect = new System.Drawing.Rectangle(1, 1, 78, 38);
this.Name = "SurList";
this.Paint += new System.Windows.Forms.PaintEventHandler(this.SurList_Paint);
this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.SurList_MouseDown);
this.MouseLeave += new System.EventHandler(this.SurList_MouseLeave);
this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.SurList_MouseMove);
this.MouseUp += new System.Windows.Forms.MouseEventHandler(this.SurList_MouseUp);
this.ResumeLayout(false);
}
#endregion
}
}
namespace Asa.Face
{
partial class SurLoading
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region 组件设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.SuspendLayout();
//
// SurLoading
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.BorderRect = new System.Drawing.Rectangle(1, 1, 78, 62);
this.Name = "SurLoading";
this.Size = new System.Drawing.Size(80, 64);
this.Paint += new System.Windows.Forms.PaintEventHandler(this.FlatLoadingRing_Paint);
this.ResumeLayout(false);
}
#endregion
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
namespace Asa.Face
{
/// <summary>
/// 加载时的环形动画
/// </summary>
public partial class SurLoading : BaseCtl
{
private int _index = -1;
private PointF _center; //大圆中心
private int _circleRadius = 30; //大圆半径
private int _ringDiam = 10; //小圆直径
private int _count = 12; //小圆个数
private RectangleF[] _ringRect; //小圆大小
private System.Threading.Thread tRing;
/// <summary>
/// 加载时的环形动画
/// </summary>
public SurLoading()
{
InitializeComponent();
}
//==========属性==========
/// <summary>
/// 是否在转动
/// </summary>
[Browsable(false)]
public bool IsRun { get; set; }
/// <summary>
/// 转动的速度
/// </summary>
[Browsable(true), Category(""), Description("转动的速度"), DefaultValue(200)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public int Speed { set; get; } = 200;
/// <summary>
/// 小圈圈的个数,3-100个
/// </summary>
[Browsable(true), Category(""), Description("小圈圈的个数,3-100个"), DefaultValue(12)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public int RingCount
{
set
{
_count = value;
if (_count < 3)
_count = 3;
else if (_count > 100)
_count = 100;
CalcSize();
Refresh();
}
get
{
return _count;
}
}
/// <summary>
/// 小圈圈的半径
/// </summary>
[Browsable(true), Category(""), Description("小圈圈的半径"), DefaultValue(10)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public int RingDiameter
{
set
{
_ringDiam = value;
if (_ringDiam < 2)
_ringDiam = 2;
CalcSize();
Refresh();
}
get
{
return _ringDiam;
}
}
/// <summary>
/// 半径
/// </summary>
[Browsable(true), Category(""), Description("大圆形的半径"), DefaultValue(30)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public int CircleRadius
{
set
{
_circleRadius = value;
CalcSize();
Refresh();
}
get
{
return _circleRadius;
}
}
/// <summary>
/// 开始转动
/// </summary>
[Browsable(false)]
public void Start()
{
_index = 0;
tRing = new System.Threading.Thread(new System.Threading.ThreadStart(Process));
tRing.Start();
IsRun = true;
}
/// <summary>
/// 停止转动
/// </summary>
[Browsable(false)]
public void Stop()
{
IsRun = false;
_index = -1;
if (tRing != null)
{
tRing.Abort();
tRing = null;
}
Refresh();
}
//==========私有==========
/// <summary>
/// 计算大小
/// </summary>
protected override void CalcSize()
{
base.CalcSize();
_center = new PointF(Width / 2f, Height / 2f);
//_radius = Math.Min(_center.X, _center.Y) / 2f;
_ringRect = new RectangleF[_count];
float angle = 360f / _count;
for (int i = 0; i < _ringRect.Length; i++)
{
double radian = (i * angle) * Math.PI / 180;
float x = Convert.ToSingle(Math.Cos(radian) * _circleRadius);
float y = Convert.ToSingle(Math.Sin(radian) * _circleRadius);
PointF pt = new PointF(_center.X + x, _center.Y + y);
_ringRect[i] = new RectangleF(pt.X - _ringDiam / 2f, pt.Y - _ringDiam / 2f, _ringDiam, _ringDiam);
}
}
private void FlatLoadingRing_Paint(object sender, PaintEventArgs e)
{
BufferedGraphicsContext current = BufferedGraphicsManager.Current;
BufferedGraphics bg = current.Allocate(e.Graphics, e.ClipRectangle);
Graphics g = bg.Graphics;
g.SmoothingMode = SmoothingMode.HighQuality;
g.CompositingQuality = CompositingQuality.HighQuality;
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
g.Clear(Common.BACK_COLOR); //背景
if (Inside)
{
if (BorderWidth > 0)
g.DrawRectangle(BorderInsidePen, BorderRect);
}
else
{
if (BorderWidth > 0)
g.DrawRectangle(BorderOutsidePen, BorderRect);
}
for (int i = 0; i < _ringRect.Length; i++)
{
if (i == _index)
g.FillEllipse(Common.BLUE_BRUSH, _ringRect[i]);
else
g.DrawEllipse(Common.FORE_PEN, _ringRect[i]);
}
bg.Render();
bg.Dispose();
}
private void Process()
{
while (true)
{
Invoke(new Action(() => { Refresh(); }));
_index++;
if (_index == _ringRect.Length) _index = 0;
System.Threading.Thread.Sleep(Speed);
}
}
}
}
namespace Asa.Face
{
partial class SurMultiButton
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region 组件设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.SuspendLayout();
//
// SurMultiButton
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.BorderRect = new System.Drawing.Rectangle(1, 1, 78, 38);
this.Name = "SurMultiButton";
this.Paint += new System.Windows.Forms.PaintEventHandler(this.SurChoose_Paint);
this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.SurChoose_MouseDown);
this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.SurChoose_MouseMove);
this.MouseUp += new System.Windows.Forms.MouseEventHandler(this.SurChoose_MouseUp);
this.ResumeLayout(false);
}
#endregion
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
namespace Asa.Face
{
/// <summary>
/// 多个按钮控件
/// </summary>
[DefaultProperty("Text")]
[DefaultEvent("Click")]
public partial class SurMultiButton : BaseCtl
{
private RectangleF[] _btnRect;
private string[] _btnText;
private RectangleF[] _btnTextRect;
private int _over = -1;
private int _down = -1;
private const int SPACE = 3;
/// <summary>
/// 多个按钮控件
/// </summary>
public SurMultiButton()
{
InitializeComponent();
}
//==========事件==========
/// <summary>
/// 单击时发生
/// </summary>
[Browsable(true), Category(""), Description("单击时发生")]
public new event MyEvent.Click Click;
//==========属性==========
/// <summary>
/// 选中的按钮从零开始的索引
/// </summary>
[Browsable(false), Category(""), Description("选中的按钮从零开始的索引")]
public int Index { get; private set; }
//==========私有==========
/// <summary>
/// 计算位置大小
/// </summary>
protected override void CalcSize()
{
base.CalcSize();
_btnText = Text.Split(',');
int count = _btnText.Length;
_btnRect = new RectangleF[count];
_btnTextRect = new RectangleF[count];
float w = Width - BorderWidth - BorderWidth;
float h = Height - BorderWidth - BorderWidth;
float ww = (w - SPACE * (count + 1)) / count;
float hh = h - SPACE - SPACE;
Graphics g = CreateGraphics();
SizeF sf;
for (int i = 0; i < count; i++)
{
_btnRect[i] = new RectangleF(BorderWidth + SPACE * (i + 1) + ww * i, BorderWidth + SPACE, ww, hh);
sf = g.MeasureString(_btnText[i], Font);
_btnTextRect[i] = new RectangleF(_btnRect[i].X + (_btnRect[i].Width - sf.Width) / 2, _btnRect[i].Y + (_btnRect[i].Height - sf.Height) / 2, sf.Width, sf.Height);
}
}
private void SurChoose_Paint(object sender, PaintEventArgs e)
{
BufferedGraphicsContext current = BufferedGraphicsManager.Current;
BufferedGraphics bg = current.Allocate(e.Graphics, e.ClipRectangle);
Graphics g = bg.Graphics;
g.SmoothingMode = SmoothingMode.HighQuality;
g.CompositingQuality = CompositingQuality.HighQuality;
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
g.Clear(Common.BACK_COLOR); //背景
//控件边框
if (Inside && Enabled)
{
if (BorderWidth > 0)
g.DrawRectangle(BorderInsidePen, BorderRect);
}
else
{
_over = -1; //避免移动太快没有执行MouseMove
if (BorderWidth > 0)
g.DrawRectangle(BorderOutsidePen, BorderRect);
}
for (int i = 0; i < _btnRect.Length; i++)
{
if (Enabled)
{
if (i == _down)
g.FillRectangle(Common.BLUE_BRUSH, _btnRect[i]);
else if (i == _over)
g.FillRectangle(Common.OVER_BRUSH, _btnRect[i]);
g.DrawString(_btnText[i], Font, Common.FORE_BRUSH, _btnTextRect[i]);
}
else
{
g.DrawString(_btnText[i], Font, Common.BORDER_BRUSH, _btnTextRect[i]);
}
}
bg.Render();
bg.Dispose();
}
private void SurChoose_MouseMove(object sender, MouseEventArgs e)
{
if (!Enabled) return;
int move = -1;
for (int i = 0; i < _btnRect.Length; i++)
{
if (_btnRect[i].Contains(e.Location))
{
move = i;
break;
}
}
if (_over != move)
{
_over = move;
Refresh();
}
}
private void SurChoose_MouseDown(object sender, MouseEventArgs e)
{
if (!Enabled) return;
if (e.Button == MouseButtons.Left)
{
if (_over > -1)
{
Index = _over;
_down = _over;
Refresh();
}
}
}
private void SurChoose_MouseUp(object sender, MouseEventArgs e)
{
if (!Enabled) return;
if (e.Button == MouseButtons.Left)
{
if (_over > -1 && _down > -1)
{
_down = -1;
Refresh();
Click?.Invoke(this);
}
}
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
namespace Asa.Face
{
/// <summary>
/// 单选框控件
/// </summary>
[DefaultProperty("Checked")]
[DefaultEvent("CheckedChanged")]
public partial class SurRadio : BaseCtl
{
private bool _check;
private RectangleF _switchRect = new RectangleF();
private RectangleF _switchPoint = new RectangleF();
private RectangleF _textRect = new RectangleF();
private int _radius = 9; //半径
private int _diameter = 18; //直径
private string _text = "";
/// <summary>
/// 单选框控件
/// </summary>
public SurRadio()
{
InitializeComponent();
}
//==========事件==========
/// <summary>
/// Check属性更改时发生
/// </summary>
[Browsable(true), Category(""), Description("Check属性更改时发生")]
public event MyEvent.Changed CheckedChanged;
//==========属性==========
/// <summary>
/// 组件是否处于选中状态
/// </summary>
[Browsable(true), Category(""), Description("单选按钮是否已选中"), DefaultValue(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public bool Checked
{
set
{
_check = value;
CalcSize();
Refresh();
if (_check)
{
SetGroup();
CheckedChanged?.Invoke(this);
}
}
get
{
return _check;
}
}
/// <summary>
/// 相同的内容为一组
/// </summary>
[Browsable(true), Category(""), Description("相同的内容为一组,同一组的单选按钮只能选中一个。"), DefaultValue("")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public string Group { set; get; }
/// <summary>
/// 圆的直径
/// </summary>
[Browsable(true), Category(""), Description("圆的直径"), DefaultValue(18)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public int Diameter
{
get
{
return _diameter;
}
set
{
_diameter = value;
_radius = _diameter / 2;
CalcSize();
Refresh();
}
}
//==========私有==========
/// <summary>
/// 计算大小
/// </summary>
protected override void CalcSize()
{
base.CalcSize();
_switchRect = new RectangleF(6, (Height - _diameter) / 2f, _diameter, _diameter);
SizeF sf = CreateGraphics().MeasureString(Text, Font);
_textRect = new RectangleF(_switchRect.X + _switchRect.Width + 6, (Height - sf.Height) / 2f, sf.Width, sf.Height);
int d = _diameter - 6;
if (_check)
_switchPoint = new RectangleF(_switchRect.X + _radius - d / 2f, _switchRect.Y + _radius - d / 2f, d, d);
_text = Text;
string[] arr = Text.Split(',');
if (arr.Length == 2)
_text = _check ? arr[1] : arr[0];
}
private void SurRadio_Paint(object sender, PaintEventArgs e)
{
BufferedGraphicsContext current = BufferedGraphicsManager.Current;
BufferedGraphics bg = current.Allocate(e.Graphics, e.ClipRectangle);
Graphics g = bg.Graphics;
g.SmoothingMode = SmoothingMode.HighQuality;
g.CompositingQuality = CompositingQuality.HighQuality;
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
g.Clear(Common.BACK_COLOR); //背景
//控件边框
if (Inside && Enabled)
{
if (BorderWidth > 0)
g.DrawRectangle(BorderInsidePen, BorderRect);
g.DrawEllipse(Common.BLUE_PEN, _switchRect);
}
else
{
if (BorderWidth > 0)
g.DrawRectangle(BorderOutsidePen, BorderRect);
g.DrawEllipse(Common.FORE_PEN, _switchRect);
}
if (_check && Enabled)
g.FillEllipse(Common.BLUE_BRUSH, _switchPoint);
if (Enabled)
g.DrawString(_text, Font, Common.FORE_BRUSH, _textRect);
else
g.DrawString(_text, Font, Common.BORDER_BRUSH, _textRect);
bg.Render();
bg.Dispose();
}
private void SurRadio_MouseDown(object sender, MouseEventArgs e)
{
if (!Enabled) return;
Checked = true;
CalcSize();
Refresh();
CheckedChanged?.Invoke(this);
}
private void SurRadio_MouseUp(object sender, MouseEventArgs e)
{
}
private void SetGroup()
{
if (Parent == null) return;
foreach (Control ctl in Parent.Controls)
{
if (ctl is SurRadio)
{
SurRadio rdo = (SurRadio)ctl;
if (rdo == this) continue;
if (rdo.Group == Group)
{
if (rdo.Checked)
{
rdo.Checked = false;
break;
}
}
}
}
}
}
}
namespace Asa.Face
{
partial class SurTrack
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region 组件设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.SuspendLayout();
//
// SurTrack
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.BorderRect = new System.Drawing.Rectangle(1, 1, 91, 306);
this.Name = "SurTrack";
this.Size = new System.Drawing.Size(93, 308);
this.Paint += new System.Windows.Forms.PaintEventHandler(this.FlatTrack_Paint);
this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.FlatTrack_MouseDown);
this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.FlatTrack_MouseMove);
this.MouseUp += new System.Windows.Forms.MouseEventHandler(this.FlatTrack_MouseUp);
this.ResumeLayout(false);
}
#endregion
}
}
namespace Asa.Face
{
partial class SurVScrollBar
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region 组件设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.SuspendLayout();
//
// SurVScrollBar
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.BorderRect = new System.Drawing.Rectangle(1, 1, 18, 78);
this.Name = "SurVScrollBar";
this.Size = new System.Drawing.Size(20, 80);
this.Load += new System.EventHandler(this.SurScrollBar_Load);
this.Paint += new System.Windows.Forms.PaintEventHandler(this.ScrollBar_Paint);
this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.ScrollBar_MouseDown);
this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.ScrollBar_MouseMove);
this.MouseUp += new System.Windows.Forms.MouseEventHandler(this.ScrollBar_MouseUp);
this.ResumeLayout(false);
}
#endregion
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
namespace Asa.Face
{
/// <summary>
/// 垂直滚动条
/// </summary>
[DefaultProperty("Value")]
[DefaultEvent("ValueChanged")]
public partial class SurVScrollBar : BaseCtl
{
private Rectangle _button1 = new Rectangle();
private Rectangle _button2 = new Rectangle();
private RectangleF _slider = new RectangleF();
private GraphicsPath _btnShape1 = new GraphicsPath();
private GraphicsPath _btnShape2 = new GraphicsPath();
private int _over = -1;
private int _down = -1;
private int _oldY = -1;
private int _max = 100;
private int _min = 0;
private int _value = 0;
private float _step = SLIDER_STEP;
private const int BTN_SIZE = 25;
private const int SLIDER_MIN = 15;
private const int SLIDER_STEP = 2;
private static readonly Color BACK = Color.FromArgb(40, 40, 40);
private static readonly Brush BTN_BRUSH = new SolidBrush(Color.FromArgb(60, 60, 60));
private static readonly Brush SLIDER_BRUSH = new SolidBrush(Color.FromArgb(60, 60, 60));
private static readonly Brush SLIDER_OVER = new SolidBrush(Color.FromArgb(70, 70, 70));
/// <summary>
/// 垂直滚动条
/// </summary>
public SurVScrollBar()
{
InitializeComponent();
BackColor = BACK;
}
//==========事件==========
/// <summary>
/// 在控件的值更改时发生
/// </summary>
[Browsable(true), Category(""), Description("在控件的值更改时发生")]
public event MyEvent.Changed ValueChanged;
//==========属性==========
/// <summary>
/// 可滚动范围的上限值
/// </summary>
[Browsable(true), Category(""), Description("可滚动范围的上限值"), DefaultValue(100)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public int Maximum
{
set
{
if (value <= _min)
_max = _min + 1;
else
_max = value;
if (_value > _max)
_value = _max;
CalcSize();
Refresh();
}
get => _max;
}
/// <summary>
/// 可滚动范围的下限值
/// </summary>
[Browsable(true), Category(""), Description("可滚动范围的下限值"), DefaultValue(0)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public int Minimum
{
set
{
if (value >= _max)
_min = _max - 1;
else if (value < 0)
_min = 0;
else
_min = value;
if (_value < _min)
_value = _min;
CalcSize();
Refresh();
}
get => _min;
}
/// <summary>
/// 滚动框位置表示的值
/// </summary>
[Browsable(true), Category(""), Description("滚动框位置表示的值"), DefaultValue(0)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public int Value
{
set
{
if (value >= _min && value <= _max)
{
_value = value;
CalcSize();
Refresh();
ValueChanged?.Invoke(this);
}
}
get => _value;
}
//==========私有==========
/// <summary>
/// 计算位置大小
/// </summary>
protected override void CalcSize()
{
base.CalcSize();
_button1 = new Rectangle(0, 0, Width, BTN_SIZE);
_button2 = new Rectangle(0, Height - BTN_SIZE, Width, BTN_SIZE);
_btnShape1 = Shape.ControlTriangle(_button1, 6, Direction.Top);
_btnShape2 = Shape.ControlTriangle(_button2, 6, Direction.Bottom);
int h = Height - BTN_SIZE - BTN_SIZE - _max * SLIDER_STEP;
if (h < SLIDER_MIN)
{
h = SLIDER_MIN;
_step = (Height - BTN_SIZE - BTN_SIZE - h) / (float)_max;
}
else
{
_step = SLIDER_STEP;
}
_slider = new RectangleF(0, BTN_SIZE + _value * _step, Width, h);
}
private void ScrollBar_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
if (_over > -1)
{
_oldY = e.Y;
_down = _over;
Refresh();
}
}
}
private void ScrollBar_MouseUp(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
if (_down == 0)
{
if (_value > _min)
{
Value--;
ValueChanged?.Invoke(this);
}
}
else if (_down == 2)
{
if (_value < _max)
{
Value++;
ValueChanged?.Invoke(this);
}
}
_down = -1;
Refresh();
}
}
private void ScrollBar_MouseMove(object sender, MouseEventArgs e)
{
int n = -1;
if (e.Button == MouseButtons.Left)
{
if (_down != 1) return;
n = Convert.ToInt32((e.Y - _oldY) / _step);
_oldY += Convert.ToInt32(n * _step);
Value += n;
ValueChanged?.Invoke(this);
}
else
{
if (_button1.Contains(e.Location))
n = 0;
else if (_slider.Contains(e.Location))
n = 1;
else if (_button2.Contains(e.Location))
n = 2;
if (_over != n)
{
_over = n;
Refresh();
}
}
}
private void ScrollBar_Paint(object sender, PaintEventArgs e)
{
BufferedGraphicsContext current = BufferedGraphicsManager.Current;
BufferedGraphics bg = current.Allocate(e.Graphics, e.ClipRectangle);
Graphics g = bg.Graphics;
g.SmoothingMode = SmoothingMode.HighQuality;
g.CompositingQuality = CompositingQuality.HighQuality;
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
g.Clear(BACK); //背景
if (!Inside)
{
_over = -1;
_down = -1;
}
if (_down == 0)
g.FillRectangle(Common.BLUE_BRUSH, _button1);
else if (_over == 0)
g.FillRectangle(BTN_BRUSH, _button1);
if (_down == 1)
g.FillRectangle(Common.BLUE_BRUSH, _slider);
else if (_over == 1)
g.FillRectangle(SLIDER_OVER, _slider);
else
g.FillRectangle(SLIDER_BRUSH, _slider);
if (_down == 2)
g.FillRectangle(Common.BLUE_BRUSH, _button2);
else if (_over == 2)
g.FillRectangle(BTN_BRUSH, _button2);
g.FillPath(Common.FORE_BRUSH, _btnShape1);
g.FillPath(Common.FORE_BRUSH, _btnShape2);
bg.Render();
bg.Dispose();
}
private void SurScrollBar_Load(object sender, EventArgs e)
{
BackColor = BACK;
}
}
}
namespace Asa.Face
{
partial class SurInput
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.BtnOK = new Asa.Face.SurButton();
this.BtnCancel = new Asa.Face.SurButton();
this.surTextBox1 = new Asa.Face.SurTextBox();
this.surLabel1 = new Asa.Face.SurLabel();
this.SuspendLayout();
//
// BtnOK
//
this.BtnOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.BtnOK.BorderRect = new System.Drawing.Rectangle(1, 1, 78, 38);
this.BtnOK.Font = new System.Drawing.Font("宋体", 12F);
this.BtnOK.ImageSize = new System.Drawing.Size(0, 0);
this.BtnOK.Inside = false;
this.BtnOK.Location = new System.Drawing.Point(337, 201);
this.BtnOK.Margin = new System.Windows.Forms.Padding(4);
this.BtnOK.Name = "BtnOK";
this.BtnOK.Size = new System.Drawing.Size(80, 40);
this.BtnOK.StateColor = System.Drawing.Color.Empty;
this.BtnOK.TabIndex = 1;
this.BtnOK.Text = "OK";
this.BtnOK.Click += new Asa.Face.MyEvent.Click(this.BtnOK_Click);
//
// BtnCancel
//
this.BtnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.BtnCancel.BorderRect = new System.Drawing.Rectangle(1, 1, 78, 38);
this.BtnCancel.Font = new System.Drawing.Font("宋体", 12F);
this.BtnCancel.ImageSize = new System.Drawing.Size(0, 0);
this.BtnCancel.Inside = false;
this.BtnCancel.Location = new System.Drawing.Point(423, 201);
this.BtnCancel.Margin = new System.Windows.Forms.Padding(4);
this.BtnCancel.Name = "BtnCancel";
this.BtnCancel.Size = new System.Drawing.Size(80, 40);
this.BtnCancel.StateColor = System.Drawing.Color.Empty;
this.BtnCancel.TabIndex = 2;
this.BtnCancel.Text = "Cancel";
this.BtnCancel.Click += new Asa.Face.MyEvent.Click(this.BtnCancel_Click);
//
// surTextBox1
//
this.surTextBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.surTextBox1.BorderRect = new System.Drawing.Rectangle(1, 1, 487, 38);
this.surTextBox1.Font = new System.Drawing.Font("宋体", 12F);
this.surTextBox1.Inside = false;
this.surTextBox1.Location = new System.Drawing.Point(13, 120);
this.surTextBox1.Margin = new System.Windows.Forms.Padding(4);
this.surTextBox1.MaxLength = 32767;
this.surTextBox1.Name = "surTextBox1";
this.surTextBox1.SelectedText = "";
this.surTextBox1.SelectionLength = 0;
this.surTextBox1.SelectionStart = 0;
this.surTextBox1.Size = new System.Drawing.Size(489, 40);
this.surTextBox1.TabIndex = 0;
this.surTextBox1.Text = "surTextBox1";
this.surTextBox1.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.SurTextBox1_KeyPress);
//
// surLabel1
//
this.surLabel1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.surLabel1.BorderRect = new System.Drawing.Rectangle(0, 0, 489, 30);
this.surLabel1.BorderWidth = 0;
this.surLabel1.Font = new System.Drawing.Font("宋体", 12F);
this.surLabel1.Inside = false;
this.surLabel1.Location = new System.Drawing.Point(13, 82);
this.surLabel1.Margin = new System.Windows.Forms.Padding(4);
this.surLabel1.Name = "surLabel1";
this.surLabel1.Size = new System.Drawing.Size(489, 30);
this.surLabel1.TabIndex = 3;
this.surLabel1.Text = "surLabel1";
//
// SurInput
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.ChangeSize = false;
this.ClientSize = new System.Drawing.Size(515, 253);
this.Controls.Add(this.surLabel1);
this.Controls.Add(this.surTextBox1);
this.Controls.Add(this.BtnCancel);
this.Controls.Add(this.BtnOK);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Location = new System.Drawing.Point(0, 0);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "SurInput";
this.Padding = new System.Windows.Forms.Padding(9, 51, 9, 9);
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "SurInput";
this.TitleFont = new System.Drawing.Font("宋体", 16F);
this.TitleHeight = 42;
this.TopMost = true;
this.ResumeLayout(false);
}
#endregion
private SurButton BtnOK;
private SurButton BtnCancel;
private SurTextBox surTextBox1;
private SurLabel surLabel1;
}
}
\ No newline at end of file
namespace Asa.Face
{
partial class SurMessage
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.surLabel1 = new Asa.Face.SurLabel();
this.surButton1 = new Asa.Face.SurButton();
this.surButton2 = new Asa.Face.SurButton();
this.surButton3 = new Asa.Face.SurButton();
this.SuspendLayout();
//
// surLabel1
//
this.surLabel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.surLabel1.BorderRect = new System.Drawing.Rectangle(0, 0, 326, 78);
this.surLabel1.BorderWidth = 0;
this.surLabel1.Font = new System.Drawing.Font("宋体", 12F);
this.surLabel1.Inside = false;
this.surLabel1.Location = new System.Drawing.Point(12, 54);
this.surLabel1.Margin = new System.Windows.Forms.Padding(4);
this.surLabel1.Name = "surLabel1";
this.surLabel1.Size = new System.Drawing.Size(326, 78);
this.surLabel1.TabIndex = 0;
this.surLabel1.Text = "surLabel1";
this.surLabel1.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// surButton1
//
this.surButton1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.surButton1.BorderRect = new System.Drawing.Rectangle(1, 1, 78, 38);
this.surButton1.Font = new System.Drawing.Font("宋体", 12F);
this.surButton1.ImageSize = new System.Drawing.Size(0, 0);
this.surButton1.Inside = false;
this.surButton1.Location = new System.Drawing.Point(86, 138);
this.surButton1.Margin = new System.Windows.Forms.Padding(4);
this.surButton1.Name = "surButton1";
this.surButton1.Size = new System.Drawing.Size(80, 40);
this.surButton1.StateColor = System.Drawing.Color.Empty;
this.surButton1.TabIndex = 1;
this.surButton1.Text = "surButton1";
this.surButton1.Click += new Asa.Face.MyEvent.Click(this.SurButton1_Click);
//
// surButton2
//
this.surButton2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.surButton2.BorderRect = new System.Drawing.Rectangle(1, 1, 78, 38);
this.surButton2.Font = new System.Drawing.Font("宋体", 12F);
this.surButton2.ImageSize = new System.Drawing.Size(0, 0);
this.surButton2.Inside = false;
this.surButton2.Location = new System.Drawing.Point(172, 138);
this.surButton2.Margin = new System.Windows.Forms.Padding(4);
this.surButton2.Name = "surButton2";
this.surButton2.Size = new System.Drawing.Size(80, 40);
this.surButton2.StateColor = System.Drawing.Color.Empty;
this.surButton2.TabIndex = 2;
this.surButton2.Text = "surButton2";
this.surButton2.Click += new Asa.Face.MyEvent.Click(this.SurButton2_Click);
//
// surButton3
//
this.surButton3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.surButton3.BorderRect = new System.Drawing.Rectangle(1, 1, 78, 38);
this.surButton3.Font = new System.Drawing.Font("宋体", 12F);
this.surButton3.ImageSize = new System.Drawing.Size(0, 0);
this.surButton3.Inside = false;
this.surButton3.Location = new System.Drawing.Point(258, 138);
this.surButton3.Margin = new System.Windows.Forms.Padding(4);
this.surButton3.Name = "surButton3";
this.surButton3.Size = new System.Drawing.Size(80, 40);
this.surButton3.StateColor = System.Drawing.Color.Empty;
this.surButton3.TabIndex = 3;
this.surButton3.Text = "surButton3";
this.surButton3.Click += new Asa.Face.MyEvent.Click(this.SurButton3_Click);
//
// SurMessage
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.ClientSize = new System.Drawing.Size(350, 190);
this.Controls.Add(this.surButton3);
this.Controls.Add(this.surButton2);
this.Controls.Add(this.surButton1);
this.Controls.Add(this.surLabel1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Location = new System.Drawing.Point(0, 0);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "SurMessage";
this.Padding = new System.Windows.Forms.Padding(9, 51, 9, 9);
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "SurMessage";
this.TitleFont = new System.Drawing.Font("宋体", 16F);
this.TitleHeight = 42;
this.TopMost = true;
this.Load += new System.EventHandler(this.SurMessage_Load);
this.ResumeLayout(false);
}
#endregion
private SurLabel surLabel1;
private SurButton surButton1;
private SurButton surButton2;
private SurButton surButton3;
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Asa.Face
{
public partial class SurMessage : SurForm
{
private MessageBoxButtons _buttons = MessageBoxButtons.OKCancel;
private DialogResult[] _result = new DialogResult[3];
private const int MIN_W = 350;
private const int MIN_H = 190;
private readonly int MAX_W;
private readonly int MAX_H;
private readonly int tempX;
private readonly int tempY;
public SurMessage()
{
InitializeComponent();
MAX_W = Screen.FromControl(this).WorkingArea.Width / 2;
MAX_H = Screen.FromControl(this).WorkingArea.Height / 2;
tempX = Width - surLabel1.Width;
tempY = Height - surLabel1.Height;
}
/// <summary>
/// 对话框
/// </summary>
/// <param name="title">标题</param>
/// <param name="content">内容</param>
/// <param name="buttons">按钮</param>
public SurMessage(string title, string content, MessageBoxButtons buttons) : this()
{
Text = title;
surLabel1.Text = content;
_buttons = buttons;
Graphics g = CreateGraphics();
SizeF sf = g.MeasureString(content, surLabel1.Font, MAX_W);
if (sf.Width < MIN_W)
Width = MIN_W + tempX;
else
Width = Convert.ToInt32(sf.Width) + tempX;
if (sf.Height > MAX_H)
Height = MAX_H + tempY;
else if (sf.Height < MIN_H)
Height = MIN_H + tempY;
else
Height = Convert.ToInt32(sf.Height) + tempY;
}
private void SurMessage_Load(object sender, EventArgs e)
{
switch (_buttons)
{
case MessageBoxButtons.OK:
surButton1.Visible = false;
surButton2.Visible = false;
surButton3.Text = "OK";
_result[2] = DialogResult.OK;
break;
case MessageBoxButtons.OKCancel:
surButton1.Visible = false;
surButton2.Text = "OK";
surButton3.Text = "Cancel";
_result[1] = DialogResult.OK;
_result[2] = DialogResult.Cancel;
break;
case MessageBoxButtons.AbortRetryIgnore:
surButton1.Text = "Abort";
surButton2.Text = "Retry";
surButton3.Text = "Ignore";
_result[0] = DialogResult.Abort;
_result[1] = DialogResult.Retry;
_result[2] = DialogResult.Ignore;
break;
case MessageBoxButtons.YesNoCancel:
surButton1.Text = "Yes";
surButton2.Text = "No";
surButton3.Text = "Cancel";
_result[0] = DialogResult.Yes;
_result[1] = DialogResult.No;
_result[2] = DialogResult.Cancel;
break;
case MessageBoxButtons.YesNo:
surButton1.Visible = false;
surButton2.Text = "Yes";
surButton3.Text = "No";
_result[1] = DialogResult.Yes;
_result[2] = DialogResult.No;
break;
case MessageBoxButtons.RetryCancel:
surButton1.Visible = false;
surButton2.Text = "Retry";
surButton3.Text = "Cancel";
_result[1] = DialogResult.Retry;
_result[2] = DialogResult.Cancel;
break;
}
}
private void SurButton1_Click(object sender)
{
DialogResult = _result[0];
}
private void SurButton2_Click(object sender)
{
DialogResult = _result[1];
}
private void SurButton3_Click(object sender)
{
DialogResult = _result[2];
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="$this.TrayLargeIcon" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
</root>
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
namespace Asa.Face
{
public partial class SurPanel : BasePnl
{
private bool _showTitle = true;
private int _titleHeight = 24;
private HorizontalAlignment _textAlign = HorizontalAlignment.Center;
private Rectangle _titleRect = new Rectangle();
private RectangleF _textRect = new RectangleF();
private Font _titleFont = new Font("宋体", 12f);
public SurPanel()
{
InitializeComponent();
}
[Browsable(false)]
public override Font Font { get => base.Font; set => base.Font = value; }
/// <summary>
/// 显示标题
/// </summary>
[Browsable(true), Category(""), Description("显示标题"), DefaultValue(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public bool ShowTitle
{
set
{
_showTitle = value;
//if (_showTitle)
// Padding = new Padding(6, 6 + _titleHeight, 6, 6);
//else
// Padding = new Padding(6, 6, 6, 6);
CalcSize();
Refresh();
}
get
{
return _showTitle;
}
}
[Browsable(true)]
public Font TitleFont
{
get => _titleFont;
set
{
_titleFont = value;
CalcSize();
Refresh();
}
}
/// <summary>
/// 显示的文本的对齐方式
/// </summary>
[Browsable(true), Category(""), Description("显示的文本的对齐方式"), DefaultValue(HorizontalAlignment.Center)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public HorizontalAlignment TextAlign
{
set
{
_textAlign = value;
CalcSize();
Refresh();
}
get
{
return _textAlign;
}
}
/// <summary>
/// 显示的标题的高度
/// </summary>
[Browsable(true), Category(""), Description("显示的标题的高度"), DefaultValue(24)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public int TitleHeight
{
set
{
_titleHeight = value < 0 ? 0 : value;
//if (_showTitle)
// Padding = new Padding(6, 6 + _titleHeight, 6, 6);
CalcSize();
Refresh();
}
get
{
return _titleHeight;
}
}
protected override void CalcSize()
{
base.CalcSize();
_titleRect = new Rectangle(0, 0, Width, _titleHeight + BorderWidth);
if (_titleHeight == 0) return;
SizeF sf = CreateGraphics().MeasureString(Text, _titleFont);
_textRect = new RectangleF(0, (_titleRect.Height - sf.Height) / 2f, sf.Width, sf.Height);
switch (TextAlign)
{
case HorizontalAlignment.Left:
_textRect.X = BorderWidth;
break;
case HorizontalAlignment.Center:
_textRect.X = (Width - sf.Width) / 2f;
break;
case HorizontalAlignment.Right:
_textRect.X = Width - BorderWidth - sf.Width;
break;
}
}
private void SurPanel_Paint(object sender, PaintEventArgs e)
{
BufferedGraphicsContext current = BufferedGraphicsManager.Current;
BufferedGraphics bg = current.Allocate(e.Graphics, e.ClipRectangle);
Graphics g = bg.Graphics;
g.SmoothingMode = SmoothingMode.HighQuality;
g.CompositingQuality = CompositingQuality.HighQuality;
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
g.Clear(Common.BACK_COLOR); //背景
if (Inside)
{
if (BorderWidth > 0)
g.DrawRectangle(BorderInsidePen, BorderRect);
}
else
{
if (BorderWidth > 0)
g.DrawRectangle(BorderOutsidePen, BorderRect);
}
if (_showTitle && _titleHeight > 0)
{
g.FillRectangle(Common.BLUE_BRUSH, _titleRect);
g.DrawString(Text, _titleFont, Common.FORE_BRUSH, _textRect);
}
bg.Render();
bg.Dispose();
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="$this.TrayLargeIcon" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
</root>
\ No newline at end of file
此文件类型无法预览
此文件类型无法预览
此文件类型无法预览
此文件类型无法预览
C:\SMD\AccUI\Face\bin\Debug\Asa.Face.dll
C:\SMD\AccUI\Face\bin\Debug\Asa.Face.pdb
C:\SMD\AccUI\Face\obj\Debug\Face.csproj.GenerateResource.cache
C:\SMD\AccUI\Face\obj\Debug\Asa.Face.dll
C:\SMD\AccUI\Face\obj\Debug\Asa.Face.pdb
C:\SMD\AccUI\Face\obj\Debug\Asa.Face.BaseCtl.resources
C:\SMD\AccUI\Face\obj\Debug\Asa.Face.SurTextBox.resources
C:\SMD\AccUI\Face\obj\Debug\Asa.Face.SurLabel.resources
C:\SMD\AccUI\Face\obj\Debug\Asa.Face.SurChart.resources
C:\SMD\AccUI\Face\obj\Debug\Asa.Face.SurChoose.resources
C:\SMD\AccUI\Face\bin\Debug\Asa.Face.xml
C:\SMD\AccUI\Face\obj\Debug\Asa.Face.SurButton.resources
C:\SMD\AccUI\Face\obj\Debug\Asa.Face.SurDataGrid.resources
C:\SMD\AccUI\Face\obj\Debug\Asa.Face.SurHScrollBar.resources
C:\SMD\AccUI\Face\obj\Debug\Asa.Face.SurVScrollBar.resources
C:\SMD\AccUI\Face\obj\Debug\Asa.Face.SurNumeric.resources
C:\SMD\AccUI\Face\obj\Debug\Asa.Face.SurList.resources
C:\SMD\AccUI\Face\obj\Debug\Asa.Face.SurCombo.resources
C:\SMD\AccUI\Face\obj\Debug\Asa.Face.SurCheck.resources
C:\SMD\AccUI\Face\obj\Debug\Asa.Face.SurLoading.resources
C:\SMD\AccUI\Face\obj\Debug\Asa.Face.SurTrack.resources
C:\SMD\AccUI\Face\obj\Debug\Asa.Face.SurRadio.resources
C:\SMD\AccUI\Face\obj\Debug\Asa.Face.BasePnl.resources
C:\SMD\AccUI\Face\obj\Debug\Asa.Face.SurPanel.resources
C:\SMD\AccUI\Face\obj\Debug\Asa.Face.SurMultiButton.resources
C:\SMD\AccUI\Face\obj\Debug\Asa.Face.SurForm.resources
C:\SMD\AccUI\Face\obj\Debug\Asa.Face.SurInput.resources
C:\SMD\AccUI\Face\obj\Debug\Asa.Face.SurMessage.resources
C:\SMD\AccUI\Face\obj\Debug\Asa.Face.SurButtonOKCancel.resources
C:\SMD\AccUI\Face\obj\Debug\Asa.Face.SurImageShow.resources
C:\SMD\AccUI\Face\obj\Debug\Asa.Face.BaseCtls.resources

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.28922.388
VisualStudioVersion = 16.0.30523.141
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test", "Test\Test.csproj", "{9BE689F4-C027-41F6-9840-6C9E27D6D923}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FaceControl", "FaceControl\FaceControl.csproj", "{06F6C6E6-02F6-4134-945A-BE51BEEF58A4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Theme", "Theme\Theme.csproj", "{EE12FD42-35D4-4728-BD9B-E4F023266934}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Face", "Face\Face.csproj", "{FD36DD42-62EA-4C87-B230-797A0B47F00C}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test", "Test\Test.csproj", "{30CC76C8-F637-4323-BD65-EFE963DE17E8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
......@@ -15,23 +13,19 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{9BE689F4-C027-41F6-9840-6C9E27D6D923}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9BE689F4-C027-41F6-9840-6C9E27D6D923}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9BE689F4-C027-41F6-9840-6C9E27D6D923}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9BE689F4-C027-41F6-9840-6C9E27D6D923}.Release|Any CPU.Build.0 = Release|Any CPU
{EE12FD42-35D4-4728-BD9B-E4F023266934}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EE12FD42-35D4-4728-BD9B-E4F023266934}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EE12FD42-35D4-4728-BD9B-E4F023266934}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EE12FD42-35D4-4728-BD9B-E4F023266934}.Release|Any CPU.Build.0 = Release|Any CPU
{FD36DD42-62EA-4C87-B230-797A0B47F00C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FD36DD42-62EA-4C87-B230-797A0B47F00C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FD36DD42-62EA-4C87-B230-797A0B47F00C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FD36DD42-62EA-4C87-B230-797A0B47F00C}.Release|Any CPU.Build.0 = Release|Any CPU
{06F6C6E6-02F6-4134-945A-BE51BEEF58A4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{06F6C6E6-02F6-4134-945A-BE51BEEF58A4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{06F6C6E6-02F6-4134-945A-BE51BEEF58A4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{06F6C6E6-02F6-4134-945A-BE51BEEF58A4}.Release|Any CPU.Build.0 = Release|Any CPU
{30CC76C8-F637-4323-BD65-EFE963DE17E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{30CC76C8-F637-4323-BD65-EFE963DE17E8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{30CC76C8-F637-4323-BD65-EFE963DE17E8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{30CC76C8-F637-4323-BD65-EFE963DE17E8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B5CA13C6-3346-4D85-91AC-6213EF3592DE}
SolutionGuid = {B0C8A353-FACB-4930-9D25-C6ECB846F05A}
EndGlobalSection
EndGlobal
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace FaceControl
{
public static class API
{
[DllImport("user32")]
public static extern int ReleaseCapture();
[DllImport("user32")]
public static extern int SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);
[DllImport("user32")]
public extern static int GetCaretBlinkTime();
[DllImport("user32.dll")]
public extern static bool GetCursorPos(out Point pt);
[DllImport("gdi32.dll")]
public static extern bool BitBlt(IntPtr hdcDest, int xDest, int yDest, int wDest, int hDest, IntPtr hdcSource, int xSrc, int ySrc, CopyPixelOperation rop);
[DllImport("gdi32.dll")]
public static extern IntPtr DeleteDC(IntPtr hDc);
[DllImport("gdi32.dll")]
public static extern IntPtr DeleteObject(IntPtr hDc);
[DllImport("gdi32.dll")]
public static extern IntPtr CreateCompatibleBitmap(IntPtr hdc, int nWidth, int nHeight);
[DllImport("gdi32.dll")]
public static extern IntPtr CreateCompatibleDC(IntPtr hdc);
[DllImport("gdi32.dll")]
public static extern IntPtr SelectObject(IntPtr hdc, IntPtr bmp);
[DllImport("user32.dll")]
public static extern IntPtr GetDesktopWindow();
[DllImport("user32.dll")]
public static extern IntPtr GetWindowDC(IntPtr ptr);
[DllImport("user32.dll")]
public static extern bool PrintWindow(IntPtr hwnd, IntPtr hdcBlt, UInt32 nFlags);
[DllImport("user32.dll")]
public static extern bool ReleaseDC(IntPtr hWnd, IntPtr hDc);
public const int WM_SYSCOMMAND = 0x112;
public const int SC_MOVE = 0xF010;
public const int HTCAPTION = 0x2;
}
}
namespace Asa.Theme
namespace FaceControl
{
partial class FlatLabel
partial class ControlBase
{
/// <summary>
/// 必需的设计器变量。
......@@ -30,11 +30,16 @@
{
this.SuspendLayout();
//
// FlatLabel
// ControlBase
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.Name = "FlatLabel";
this.Paint += new System.Windows.Forms.PaintEventHandler(this.FlatLabel_Paint);
this.Name = "ControlBase";
this.Load += new System.EventHandler(this.ControlBase_Load);
this.Paint += new System.Windows.Forms.PaintEventHandler(this.ControlBase_Paint);
this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.ControlBase_MouseDown);
this.MouseEnter += new System.EventHandler(this.ControlBase_MouseEnter);
this.MouseLeave += new System.EventHandler(this.ControlBase_MouseLeave);
this.Resize += new System.EventHandler(this.ControlBase_Resize);
this.ResumeLayout(false);
}
......
......@@ -7,28 +7,52 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
namespace Asa.Face
namespace FaceControl
{
public partial class BaseCtl : UserControl
public partial class ControlBase : UserControl
{
private bool _inside = false;
private int _borderW = 2;
private HorizontalAlignment _textAlign = HorizontalAlignment.Center;
private Model.ButtonShape _shape = Model.ButtonShape.Rectangle;
public BaseCtl()
internal Theme.IFaceTheme theme;
internal RectangleF borderRect;
internal Pen borderInsidePen;
internal Pen borderOutsidePen;
public ControlBase()
{
InitializeComponent();
AutoScaleMode = AutoScaleMode.None;
Margin = new Padding(3);
theme = new Theme.DarkTheme();
BackColor = theme.BACK_COLOR;
ForeColor = theme.FORE_COLOR;
}
//[Browsable(true), Category("属性已更改"), Description("在控件上更改Text属性的值时引发的事件")]
//public new event EventHandler TextChanged;
#region 属性
[Browsable(false)]
public new AutoScaleMode AutoScaleMode { set => base.AutoScaleMode = value; get => base.AutoScaleMode; }
[Browsable(false)]
public override bool AutoSize { get => base.AutoSize; set => base.AutoSize = value; }
[Browsable(false)]
public new AutoSizeMode AutoSizeMode { get => base.AutoSizeMode; set => base.AutoSizeMode = value; }
/// <summary>
/// 鼠标焦点在控件里面
/// 鼠标光标在控件里面
/// </summary>
[Browsable(false)]
public bool Inside
public bool CursorInside
{
set
{
......@@ -48,15 +72,9 @@ namespace Asa.Face
}
[Browsable(false)]
public Rectangle BorderRect { set; get; }
[Browsable(false)]
public Pen BorderInsidePen { set; get; }
[Browsable(false)]
public Pen BorderOutsidePen { set; get; }
internal bool AllowHideDrop { set; get; } = true;
[Browsable(true), DefaultValue(2)]
[Browsable(true), Category("外观"), Description("控件周围的边框大小"), DefaultValue(2)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public int BorderWidth
{
......@@ -75,7 +93,7 @@ namespace Asa.Face
}
}
[Browsable(true)]
[Browsable(true), Category("外观"), Description("与控件关联的文本")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public override string Text
{
......@@ -85,10 +103,11 @@ namespace Asa.Face
base.Text = value;
CalcSize();
Refresh();
//TextChanged?.Invoke(this, new EventArgs());
}
}
[Browsable(true)]
[Browsable(true), Category("外观"), Description("用于显示控件中文本的字体")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public override Font Font
{
......@@ -101,22 +120,72 @@ namespace Asa.Face
}
}
[Browsable(true), DefaultValue(true)]
[Browsable(true), Category("行为"), Description("提示是否已启用该控件"), DefaultValue(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public new bool Enabled
{
get => base.Enabled;
set
{
base.Enabled = value;
Refresh();
}
get
}
[Browsable(true), Category("外观"), Description("组件的背景色"), DefaultValue(null)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public override Color BackColor
{
get => base.BackColor;
set
{
return base.Enabled;
base.BackColor = value;
Refresh();
}
}
[Browsable(false)]
[Browsable(true), Category("外观"), Description("组件的前景色,用于显示文本"), DefaultValue(null)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public override Color ForeColor
{
get => base.ForeColor;
set
{
base.ForeColor = value;
Refresh();
}
}
[Browsable(true), Category("外观"), Description("控件上显示的文本的对齐方式"), DefaultValue(HorizontalAlignment.Center)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public HorizontalAlignment TextAlign
{
get => _textAlign;
set
{
_textAlign = value;
CalcSize();
Refresh();
}
}
[Browsable(true), Category("外观"), Description("控件的显示形状"), DefaultValue(Model.ButtonShape.Rectangle)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public Model.ButtonShape FaceShape
{
get => _shape;
set
{
_shape = value;
CalcSize();
Refresh();
}
}
#endregion
public Bitmap ToImage()
{
IntPtr hSrce = API.GetWindowDC(Handle);
......@@ -137,51 +206,89 @@ namespace Asa.Face
protected virtual void CalcSize()
{
borderRect = new RectangleF(_borderW / 2f, _borderW / 2f, Width - _borderW - 1, Height - _borderW - 1);
borderInsidePen = new Pen(theme.BORDER_COLOR, _borderW);
borderOutsidePen = new Pen(theme.LOST_FOCUS_COLOR, _borderW);
}
protected virtual void DrawEnabled(Graphics g)
{
}
protected virtual void DrawDisabled(Graphics g)
{
/// <summary>
/// 计算大小
/// </summary>
protected virtual void CalcSize() {
BorderRect = new Rectangle(_borderW / 2, _borderW / 2, Width - _borderW, Height - _borderW);
BorderInsidePen = new Pen(Common.BLUE_COLOR, _borderW);
BorderOutsidePen = new Pen(Common.BORDER_COLOR, _borderW);
}
private void BaseCtl_Load(object sender, EventArgs e)
internal virtual void HideDrop()
{
}
protected override void WndProc(ref Message m)
{
if (m.Msg == 0x0014) // 禁掉清除背景消息
return;
//System.Diagnostics.Debug.Print("Message: " + m.Msg);
base.WndProc(ref m);
}
private void ControlBase_Load(object sender, EventArgs e)
{
AutoScaleMode = AutoScaleMode.None;
theme = new Theme.DarkTheme();
CalcSize();
Refresh();
}
private void BaseCtl_Resize(object sender, EventArgs e)
private void ControlBase_Resize(object sender, EventArgs e)
{
CalcSize();
Refresh();
}
protected override void WndProc(ref Message m)
private void ControlBase_Paint(object sender, PaintEventArgs e)
{
//if (DesignMode)
//{
// base.WndProc(ref m);
//}
//else
//{
// if (m.Msg == 0x0014) // 禁掉清除背景消息
// return;
// base.WndProc(ref m);
//}
BufferedGraphicsContext current = BufferedGraphicsManager.Current;
BufferedGraphics bg = current.Allocate(e.Graphics, e.ClipRectangle);
Graphics g = bg.Graphics;
g.SmoothingMode = SmoothingMode.HighQuality;
g.CompositingQuality = CompositingQuality.HighQuality;
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
g.Clear(theme.BACK_COLOR); //背景
if (Enabled)
DrawEnabled(g);
else
DrawDisabled(g);
bg.Render();
bg.Dispose();
}
if (m.Msg == 0x0014) // 禁掉清除背景消息
return;
base.WndProc(ref m);
private void ControlBase_MouseEnter(object sender, EventArgs e)
{
CursorInside = true;
}
private void ControlBase_MouseLeave(object sender, EventArgs e)
{
CursorInside = false;
}
private void ControlBase_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
if (!AllowHideDrop) return;
if (TopLevelControl is FormBase @base)
@base.HideDrop(Handle);
}
}
}
}
namespace Asa.Face

namespace FaceControl
{
partial class BasePnl
partial class PanelBase
{
/// <summary>
/// 必需的设计器变量。
......@@ -28,13 +29,7 @@
/// </summary>
private void InitializeComponent()
{
this.SuspendLayout();
//
// BasePnl
//
this.Resize += new System.EventHandler(this.BasePnl_Resize);
this.ResumeLayout(false);
components = new System.ComponentModel.Container();
}
#endregion
......
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
namespace Asa.Face
namespace FaceControl
{
public partial class BasePnl : Panel
public partial class PanelBase : Panel
{
private bool _inside = false;
private int _borderW = 2;
private HorizontalAlignment _textAlign = HorizontalAlignment.Center;
private Model.ButtonShape _shape = Model.ButtonShape.Rectangle;
private Font _font = new Font("宋体", 9f);
public BasePnl()
internal Theme.IFaceTheme theme;
internal RectangleF borderRect;
internal Pen borderInsidePen;
internal Pen borderOutsidePen;
public PanelBase()
{
InitializeComponent();
Padding = new Padding(6);
theme = new Theme.DarkTheme();
Resize += PanelBase_Resize;
Paint += PanelBase_Paint;
MouseDown += PanelBase_MouseDown;
MouseEnter += PanelBase_MouseEnter;
MouseLeave += PanelBase_MouseLeave;
theme = new Theme.DarkTheme();
BackColor = theme.BACK_COLOR;
ForeColor = theme.FORE_COLOR;
}
#region 属性
[Browsable(false)]
public override bool AutoSize { get => base.AutoSize; set => base.AutoSize = value; }
[Browsable(false)]
public new AutoSizeMode AutoSizeMode { get => base.AutoSizeMode; set => base.AutoSizeMode = value; }
[Browsable(false)]
public new BorderStyle BorderStyle { get => base.BorderStyle; set => base.BorderStyle = value; }
[Browsable(false)]
public override Font Font { get => base.Font; set => base.Font = value; }
/// <summary>
/// 鼠标焦点在控件里面
/// 鼠标光标在控件里面
/// </summary>
[Browsable(false)]
public bool Inside
public bool CursorInside
{
set
{
if (_inside != value)
{
_inside = value;
Refresh();
if (Enabled)
{
_inside = value;
Refresh();
}
}
}
get
......@@ -42,16 +76,8 @@ namespace Asa.Face
}
}
[Browsable(false)]
public Rectangle BorderRect { set; get; }
[Browsable(false)]
public Pen BorderInsidePen { set; get; }
[Browsable(false)]
public Pen BorderOutsidePen { set; get; }
[Browsable(true), DefaultValue(2)]
[Browsable(true), Category("外观"), Description("控件周围的边框大小"), DefaultValue(2)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public int BorderWidth
{
......@@ -70,7 +96,7 @@ namespace Asa.Face
}
}
[Browsable(true)]
[Browsable(true), Category("外观"), Description("与控件关联的文本")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public override string Text
{
......@@ -83,20 +109,85 @@ namespace Asa.Face
}
}
[Browsable(true)]
[Browsable(true), Category("外观"), Description("用于显示控件中文本的字体")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public override Font Font
public Font TitleFont
{
get => base.Font;
get => _font;
set
{
base.Font = value;
_font = value;
CalcSize();
Refresh();
}
}
[Browsable(false)]
[Browsable(true), Category("行为"), Description("提示是否已启用该控件"), DefaultValue(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public new bool Enabled
{
get => base.Enabled;
set
{
base.Enabled = value;
Refresh();
}
}
[Browsable(true), Category("外观"), Description("组件的背景色"), DefaultValue(null)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public override Color BackColor
{
get => base.BackColor;
set
{
base.BackColor = value;
Refresh();
}
}
[Browsable(true), Category("外观"), Description("组件的前景色,用于显示文本"), DefaultValue(null)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public override Color ForeColor
{
get => base.ForeColor;
set
{
base.ForeColor = value;
Refresh();
}
}
[Browsable(true), Category("外观"), Description("控件上显示的文本的对齐方式"), DefaultValue(HorizontalAlignment.Center)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public HorizontalAlignment TextAlign
{
get => _textAlign;
set
{
_textAlign = value;
CalcSize();
Refresh();
}
}
[Browsable(true), Category("外观"), Description("控件的显示形状"), DefaultValue(Model.ButtonShape.Rectangle)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public Model.ButtonShape FaceShape
{
get => _shape;
set
{
_shape = value;
CalcSize();
Refresh();
}
}
#endregion
public Bitmap ToImage()
{
IntPtr hSrce = API.GetWindowDC(Handle);
......@@ -117,35 +208,83 @@ namespace Asa.Face
protected virtual void CalcSize()
{
borderRect = new RectangleF(_borderW / 2f, _borderW / 2f, Width - _borderW - 1, Height - _borderW - 1);
borderInsidePen = new Pen(theme.BORDER_COLOR, _borderW);
borderOutsidePen = new Pen(theme.LOST_FOCUS_COLOR, _borderW);
}
protected virtual void DrawEnabled(Graphics g)
{
}
protected virtual void DrawDisabled(Graphics g)
{
}
/// <summary>
/// 计算大小
/// </summary>
protected virtual void CalcSize()
protected override void WndProc(ref Message m)
{
BorderRect = new Rectangle(_borderW / 2, _borderW / 2, Width - _borderW, Height - _borderW);
BorderInsidePen = new Pen(Common.BLUE_COLOR, _borderW);
BorderOutsidePen = new Pen(Common.BORDER_COLOR, _borderW);
if (m.Msg == 0x0014) // 禁掉清除背景消息
return;
base.WndProc(ref m);
}
private void BasePnl_Resize(object sender, EventArgs e)
//private void PanelBase_Load(object sender, EventArgs e)
//{
// theme = new Theme.DarkTheme();
// CalcSize();
// Refresh();
//}
private void PanelBase_Resize(object sender, EventArgs e)
{
CalcSize();
Refresh();
}
protected override void WndProc(ref Message m)
private void PanelBase_Paint(object sender, PaintEventArgs e)
{
if (m.Msg == 0x0014) // 禁掉清除背景消息
return;
base.WndProc(ref m);
BufferedGraphicsContext current = BufferedGraphicsManager.Current;
BufferedGraphics bg = current.Allocate(e.Graphics, e.ClipRectangle);
Graphics g = bg.Graphics;
g.SmoothingMode = SmoothingMode.HighQuality;
g.CompositingQuality = CompositingQuality.HighQuality;
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
g.Clear(theme.BACK_COLOR); //背景
if (Enabled)
DrawEnabled(g);
else
DrawDisabled(g);
bg.Render();
bg.Dispose();
}
private void PanelBase_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
if (TopLevelControl is FormBase @base)
{
@base.HideDrop(Handle);
}
}
}
private void PanelBase_MouseEnter(object sender, EventArgs e)
{
CursorInside = true;
}
private void PanelBase_MouseLeave(object sender, EventArgs e)
{
CursorInside = false;
}
}
}
namespace Asa.Face

namespace FaceControl
{
partial class SurNumeric
partial class FaceButton
{
/// <summary>
/// 必需的设计器变量。
......@@ -30,16 +31,15 @@
{
this.SuspendLayout();
//
// SurNumeric
// FaceButton
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.BorderRect = new System.Drawing.Rectangle(1, 1, 78, 38);
this.Name = "SurNumeric";
this.Load += new System.EventHandler(this.SurNumeric_Load);
this.Paint += new System.Windows.Forms.PaintEventHandler(this.SurNumeric_Paint);
this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.SurNumeric_MouseDown);
this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.SurNumeric_MouseMove);
this.MouseUp += new System.Windows.Forms.MouseEventHandler(this.SurNumeric_MouseUp);
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Name = "FaceButton";
this.Size = new System.Drawing.Size(85, 45);
this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.FaceButton_MouseDown);
this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.FaceButton_MouseMove);
this.MouseUp += new System.Windows.Forms.MouseEventHandler(this.FaceButton_MouseUp);
this.ResumeLayout(false);
}
......
namespace Asa.Theme

namespace FaceControl
{
partial class FlatTrack
partial class FaceButtonGroup
{
/// <summary>
/// 必需的设计器变量。
......@@ -30,16 +31,15 @@
{
this.SuspendLayout();
//
// FlatAdjuster
// FaceButtonGroup
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Name = "FlatAdjuster";
this.Size = new System.Drawing.Size(93, 308);
this.Paint += new System.Windows.Forms.PaintEventHandler(this.FlatTrack_Paint);
this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.FlatTrack_MouseDown);
this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.FlatTrack_MouseMove);
this.MouseUp += new System.Windows.Forms.MouseEventHandler(this.FlatTrack_MouseUp);
this.Name = "FaceButtonGroup";
this.Size = new System.Drawing.Size(85, 45);
this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.FaceButtonGroup_MouseDown);
this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.FaceButtonGroup_MouseMove);
this.MouseUp += new System.Windows.Forms.MouseEventHandler(this.FaceButtonGroup_MouseUp);
this.ResumeLayout(false);
}
......
using System;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
namespace FaceControl
{
[DefaultProperty("Text")]
[DefaultEvent("Click")]
public partial class FaceButtonGroup : ControlBase
{
private bool mouseDown = false;
private int buttonOverIndex = -1;
private RectangleF[] textRect;
private RectangleF[] buttonRect;
private GraphicsPath borderPath = new GraphicsPath();
public FaceButtonGroup()
{
InitializeComponent();
}
#region 事件
[Browsable(true), Category("操作"), Description("单击组件时发生")]
public new event EventHandler Click;
#endregion
#region 属性
[Browsable(false)]
public int SelectedIndex
{
get => buttonOverIndex;
set
{
if (value > -1 && value < buttonRect.Length)
{
buttonOverIndex = value;
Click?.Invoke(this, new EventArgs());
}
}
}
[Browsable(false)]
public string SelectedText
{
get
{
if (buttonOverIndex == -1) return "";
string[] s = Text.Split(',');
return s[buttonOverIndex];
}
}
#endregion
protected override void CalcSize()
{
base.CalcSize();
CalcTextLocation();
CalcShape();
}
protected override void DrawEnabled(Graphics g)
{
base.DrawEnabled(g);
//控件边框
if (CursorInside && buttonOverIndex > -1)
{
if (mouseDown)
g.FillRectangle(new SolidBrush(theme.DOWN_COLOR), buttonRect[buttonOverIndex]); //按下
else
g.FillRectangle(new SolidBrush(theme.OVER_COLOR), buttonRect[buttonOverIndex]); //经过
Region reg = new Region(new Rectangle(0, 0, Width, Height));
reg.Exclude(borderPath);
g.FillRegion(new SolidBrush(theme.BACK_COLOR), reg);
if (BorderWidth > 0)
g.DrawPath(borderInsidePen, borderPath);
}
else
{
buttonOverIndex = -1;
g.FillPath(new SolidBrush(BackColor), borderPath);
if (BorderWidth > 0)
g.DrawPath(borderOutsidePen, borderPath);
}
//文字
string[] s = Text.Split(',');
for (int i = 0; i < s.Length; i++)
g.DrawString(s[i], Font, new SolidBrush(ForeColor), textRect[i]);
}
protected override void DrawDisabled(Graphics g)
{
base.DrawDisabled(g);
//控件边框
if (BorderWidth > 0)
g.DrawPath(borderOutsidePen, borderPath);
//文字
string[] s = Text.Split(',');
for (int i = 0; i < s.Length; i++)
g.DrawString(s[i], Font, new SolidBrush(theme.LOST_FOCUS_COLOR), textRect[i]);
}
private void CalcShape()
{
borderPath = new GraphicsPath();
float n;
switch (FaceShape)
{
case Model.ButtonShape.Rectangle:
borderPath.AddRectangle(borderRect);
break;
case Model.ButtonShape.RoundRectangle:
n = borderRect.Height / 8f;
borderPath.AddLine(borderRect.X + n, borderRect.Y, borderRect.Right - n, borderRect.Y);
borderPath.AddArc(borderRect.Right - n - n, borderRect.Y, n + n, n + n, 270, 90);
borderPath.AddLine(borderRect.Right, borderRect.Y + n, borderRect.Right, borderRect.Bottom - n);
borderPath.AddArc(borderRect.Right - n - n, borderRect.Bottom - n - n, n + n, n + n, 0, 90);
borderPath.AddLine(borderRect.Right - n, borderRect.Bottom, borderRect.X + n, borderRect.Bottom);
borderPath.AddArc(borderRect.X, borderRect.Bottom - n - n, n + n, n + n, 90, 90);
borderPath.AddLine(borderRect.X, borderRect.Bottom - n, borderRect.X, borderRect.Y + n);
borderPath.AddArc(borderRect.X, borderRect.Y, n + n, n + n, 180, 90);
break;
case Model.ButtonShape.Ellipse:
borderPath.AddEllipse(borderRect);
break;
case Model.ButtonShape.EllipseRectangle:
n = borderRect.Height / 2f;
borderPath.AddLine(borderRect.X + n, borderRect.Y, borderRect.Right - n, borderRect.Y);
borderPath.AddArc(borderRect.Right - n - n, borderRect.Y, n + n, n + n, 270, 180);
borderPath.AddLine(borderRect.Right - n, borderRect.Bottom, borderRect.X + n, borderRect.Bottom);
borderPath.AddArc(borderRect.X, borderRect.Y, n + n, n + n, 90, 180);
break;
case Model.ButtonShape.Circle:
if (borderRect.Width > borderRect.Height)
borderPath.AddEllipse((borderRect.Width - borderRect.Height) / 2f, borderRect.Y, borderRect.Height, borderRect.Height);
else
borderPath.AddEllipse(borderRect.X, (borderRect.Height - borderRect.Width) / 2f, borderRect.Width, borderRect.Width);
break;
}
}
private void CalcTextLocation()
{
if (string.IsNullOrEmpty(Text)) return;
Graphics g = CreateGraphics();
string[] s = Text.Split(',');
buttonRect = new RectangleF[s.Length];
textRect = new RectangleF[s.Length];
float w = (Width - BorderWidth - BorderWidth) / (float)s.Length;
float h = Height - BorderWidth - BorderWidth;
for (int i = 0; i < s.Length; i++)
{
buttonRect[i] = new RectangleF(BorderWidth + w * i, BorderWidth, w, h);
SizeF sf = g.MeasureString(s[i], Font);
textRect[i] = new RectangleF(0, (h - sf.Height) / 2f, sf.Width, sf.Height);
switch (TextAlign)
{
case HorizontalAlignment.Left:
textRect[i].X = buttonRect[i].X;
break;
case HorizontalAlignment.Center:
textRect[i].X = buttonRect[i].X + (buttonRect[i].Width - sf.Width) / 2f;
break;
case HorizontalAlignment.Right:
textRect[i].X = buttonRect[i].X + buttonRect[i].Width - sf.Width;
break;
}
}
}
private void FaceButtonGroup_MouseDown(object sender, MouseEventArgs e)
{
if (!Enabled) return;
if (e.Button == MouseButtons.Left)
{
mouseDown = true;
Refresh();
}
}
private void FaceButtonGroup_MouseUp(object sender, MouseEventArgs e)
{
if (!Enabled) return;
if (e.Button == MouseButtons.Left)
{
mouseDown = false;
Refresh();
Click?.Invoke(this, new EventArgs());
}
}
private void FaceButtonGroup_MouseMove(object sender, MouseEventArgs e)
{
buttonOverIndex = -1;
for (int i = 0; i < buttonRect.Length; i++)
{
if (buttonRect[i].Contains(e.Location))
{
buttonOverIndex = i;
break;
}
}
Refresh();
}
}
}
namespace Asa.Theme

namespace FaceControl
{
partial class FlatCheck
partial class FaceCheck
{
/// <summary>
/// 必需的设计器变量。
......@@ -30,13 +31,14 @@
{
this.SuspendLayout();
//
// FlatCheck
// FaceCheck
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Name = "FlatCheck";
this.Paint += new System.Windows.Forms.PaintEventHandler(this.FlatCheck_Paint);
this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.FlatCheck_MouseDown);
this.Name = "FaceCheck";
this.Size = new System.Drawing.Size(85, 45);
this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.FaceCheck_MouseDown);
this.MouseUp += new System.Windows.Forms.MouseEventHandler(this.FaceCheck_MouseUp);
this.ResumeLayout(false);
}
......
using System;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
namespace FaceControl
{
[DefaultProperty("Text")]
[DefaultEvent("CheckedChanged")]
public partial class FaceCheck : ControlBase
{
private bool mouseDown = false;
private RectangleF checkOutRect = new RectangleF();
private RectangleF checkInRect = new RectangleF();
private RectangleF textRect = new RectangleF();
private GraphicsPath borderPath = new GraphicsPath();
private bool _check = false;
private int _checkWidth = 18;
private const int SPACE = 6; //图片与文字的间隔
public FaceCheck()
{
InitializeComponent();
}
#region 事件
[Browsable(true), Category("杂项"), Description("当checked属性更改值时发生")]
public event EventHandler CheckedChanged;
#endregion
#region 属性
[Browsable(true), Category("外观"), Description("控件上矩形开关的宽度"), DefaultValue(18)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public int CheckWidth
{
get => _checkWidth;
set
{
_checkWidth = value;
CalcSize();
Refresh();
}
}
[Browsable(true), Category(""), Description("单选按钮是否已选中"), DefaultValue(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public bool Checked
{
set
{
if (_check != value)
{
_check = value;
CalcSize();
Refresh();
}
CheckedChanged?.Invoke(this, new EventArgs());
}
get
{
return _check;
}
}
#endregion
protected override void CalcSize()
{
base.CalcSize();
CalcTextLocation();
CalcShape();
}
protected override void DrawEnabled(Graphics g)
{
base.DrawEnabled(g);
//控件边框
if (CursorInside)
{
if (_check)
{
if (mouseDown)
g.FillRectangle(new SolidBrush(theme.DOWN_COLOR), checkOutRect);
else
g.FillRectangle(new SolidBrush(ForeColor), checkOutRect);
}
else
{
if (mouseDown)
g.FillRectangle(new SolidBrush(ForeColor), checkOutRect);
else
g.FillRectangle(new SolidBrush(theme.DOWN_COLOR), checkOutRect);
}
g.FillRectangle(new SolidBrush(theme.BACK_COLOR), checkInRect);
if (BorderWidth > 0)
g.DrawPath(borderInsidePen, borderPath);
}
else
{
g.FillPath(new SolidBrush(BackColor), borderPath);
if (_check)
{
g.FillRectangle(new SolidBrush(theme.DOWN_COLOR), checkOutRect);
}
else
{
g.FillRectangle(new SolidBrush(ForeColor), checkOutRect);
}
g.FillRectangle(new SolidBrush(theme.BACK_COLOR), checkInRect);
if (BorderWidth > 0)
g.DrawPath(borderOutsidePen, borderPath);
}
//开关圆点
//if (_check)
// g.FillRectangle(new SolidBrush(ForeColor), checkPoint);
if (_check)
{
g.DrawLine(new Pen(ForeColor, 2), checkInRect.X, checkInRect.Y + checkInRect.Height / 2f,
checkInRect.X + checkInRect.Width / 3f, checkInRect.Bottom);
g.DrawLine(new Pen(ForeColor, 2), checkInRect.X + checkInRect.Width / 3f, checkInRect.Bottom,
checkInRect.Right, checkInRect.Y);
}
//文字
g.DrawString(Text, Font, new SolidBrush(ForeColor), textRect);
}
protected override void DrawDisabled(Graphics g)
{
base.DrawDisabled(g);
//控件边框
g.FillRectangle(new SolidBrush(theme.OVER_COLOR), checkOutRect);
g.FillRectangle(new SolidBrush(theme.BACK_COLOR), checkInRect);
if (BorderWidth > 0)
g.DrawPath(borderOutsidePen, borderPath);
//开关圆点
if (_check)
{
//g.FillRectangle(new SolidBrush(theme.OVER_COLOR), checkPoint);
g.DrawLine(new Pen(theme.OVER_COLOR, 2), checkInRect.X, checkInRect.Y + checkInRect.Height / 2f,
checkInRect.X + checkInRect.Width / 3f, checkInRect.Bottom);
g.DrawLine(new Pen(theme.OVER_COLOR, 2), checkInRect.X + checkInRect.Width / 3f, checkInRect.Bottom,
checkInRect.Right, checkInRect.Y);
}
//文字
g.DrawString(Text, Font, new SolidBrush(theme.LOST_FOCUS_COLOR), textRect);
}
private void CalcShape()
{
borderPath = new GraphicsPath();
float n;
switch (FaceShape)
{
case Model.ButtonShape.Rectangle:
borderPath.AddRectangle(borderRect);
break;
case Model.ButtonShape.RoundRectangle:
n = borderRect.Height / 8f;
borderPath.AddLine(borderRect.X + n, borderRect.Y, borderRect.Right - n, borderRect.Y);
borderPath.AddArc(borderRect.Right - n - n, borderRect.Y, n + n, n + n, 270, 90);
borderPath.AddLine(borderRect.Right, borderRect.Y + n, borderRect.Right, borderRect.Bottom - n);
borderPath.AddArc(borderRect.Right - n - n, borderRect.Bottom - n - n, n + n, n + n, 0, 90);
borderPath.AddLine(borderRect.Right - n, borderRect.Bottom, borderRect.X + n, borderRect.Bottom);
borderPath.AddArc(borderRect.X, borderRect.Bottom - n - n, n + n, n + n, 90, 90);
borderPath.AddLine(borderRect.X, borderRect.Bottom - n, borderRect.X, borderRect.Y + n);
borderPath.AddArc(borderRect.X, borderRect.Y, n + n, n + n, 180, 90);
break;
case Model.ButtonShape.Ellipse:
borderPath.AddEllipse(borderRect);
break;
case Model.ButtonShape.EllipseRectangle:
n = borderRect.Height / 2f;
borderPath.AddLine(borderRect.X + n, borderRect.Y, borderRect.Right - n, borderRect.Y);
borderPath.AddArc(borderRect.Right - n - n, borderRect.Y, n + n, n + n, 270, 180);
borderPath.AddLine(borderRect.Right - n, borderRect.Bottom, borderRect.X + n, borderRect.Bottom);
borderPath.AddArc(borderRect.X, borderRect.Y, n + n, n + n, 90, 180);
break;
case Model.ButtonShape.Circle:
if (borderRect.Width > borderRect.Height)
borderPath.AddEllipse((borderRect.Width - borderRect.Height) / 2f, borderRect.Y, borderRect.Height, borderRect.Height);
else
borderPath.AddEllipse(borderRect.X, (borderRect.Height - borderRect.Width) / 2f, borderRect.Width, borderRect.Width);
break;
}
}
private void CalcTextLocation()
{
if (string.IsNullOrEmpty(Text)) return;
Graphics g = CreateGraphics();
SizeF sf = g.MeasureString(Text, Font);
checkOutRect = new RectangleF(0, (Height - _checkWidth) / 2f, _checkWidth, _checkWidth);
textRect = new RectangleF(0, (Height - sf.Height) / 2f, sf.Width, sf.Height);
float x;
switch (TextAlign)
{
case HorizontalAlignment.Left:
x = BorderWidth;
checkOutRect.X = x;
x += _checkWidth + SPACE;
textRect.X = x;
break;
case HorizontalAlignment.Center:
x = (Width - sf.Width - _checkWidth - SPACE) / 2f;
checkOutRect.X = x;
x += _checkWidth + SPACE;
textRect.X = x;
break;
case HorizontalAlignment.Right:
x = Width - BorderWidth - sf.Width;
textRect.X = x;
x -= (SPACE + _checkWidth);
checkOutRect.X = x;
break;
}
float w = _checkWidth / 6f;
checkInRect = new RectangleF(checkOutRect.X + w, checkOutRect.Y + w, w * 4, w * 4);
//checkPoint = new RectangleF(checkOutRect.X + w * 2, checkOutRect.Y + w * 2, w * 2, w * 2);
}
private void FaceCheck_MouseDown(object sender, MouseEventArgs e)
{
if (!Enabled) return;
if (e.Button == MouseButtons.Left)
{
mouseDown = true;
_check = !_check;
Refresh();
}
}
private void FaceCheck_MouseUp(object sender, MouseEventArgs e)
{
if (!Enabled) return;
if (e.Button == MouseButtons.Left)
{
mouseDown = false;
Refresh();
CheckedChanged?.Invoke(this, new EventArgs());
}
}
}
}
namespace Asa.Face

namespace FaceControl
{
partial class SurTextBox
partial class FaceCheckGroup
{
/// <summary>
/// 必需的设计器变量。
......@@ -30,13 +31,15 @@
{
this.SuspendLayout();
//
// SurTextBox
// FaceCheckGroup
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.BorderRect = new System.Drawing.Rectangle(1, 1, 78, 38);
this.Name = "SurTextBox";
this.Paint += new System.Windows.Forms.PaintEventHandler(this.SurTextBox_Paint);
this.Resize += new System.EventHandler(this.SurTextBox_Resize);
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Name = "FaceCheckGroup";
this.Size = new System.Drawing.Size(85, 45);
this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.FaceRadioGroup_MouseDown);
this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.FaceRadioGroup_MouseMove);
this.MouseUp += new System.Windows.Forms.MouseEventHandler(this.FaceRadioGroup_MouseUp);
this.ResumeLayout(false);
}
......
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
namespace FaceControl
{
[DefaultProperty("SelectedIndex")]
[DefaultEvent("CheckedChanged")]
public partial class FaceCheckGroup : ControlBase
{
private int buttonOverIndex = -1;
private List<int> buttonDownIndex;
private RectangleF[] textRect;
private RectangleF[] buttonRect;
private GraphicsPath borderPath = new GraphicsPath();
public FaceCheckGroup()
{
InitializeComponent();
buttonDownIndex = new List<int>();
}
#region 事件
[Browsable(true), Category("杂项"), Description("当checked属性更改值时发生")]
public event EventHandler CheckedChanged;
#endregion
#region 属性
[Browsable(false)]
public int[] SelectedIndex { get { return buttonDownIndex.ToArray(); } }
[Browsable(false)]
public string[] SelectedText
{
get
{
string[] s = Text.Split(',');
string[] rtn = new string[buttonDownIndex.Count];
for (int i = 0; i < rtn.Length; i++)
rtn[i] = s[buttonDownIndex[i]];
return rtn;
}
}
#endregion
protected override void CalcSize()
{
base.CalcSize();
CalcTextLocation();
CalcShape();
}
protected override void DrawEnabled(Graphics g)
{
base.DrawEnabled(g);
//控件边框
if (CursorInside && buttonOverIndex > -1)
{
for (int i = 0; i < buttonDownIndex.Count; i++)
g.FillRectangle(new SolidBrush(theme.DOWN_COLOR), buttonRect[buttonDownIndex[i]]);
int index = buttonDownIndex.FindIndex(s => s == buttonOverIndex);
if (index == -1)
g.FillRectangle(new SolidBrush(theme.OVER_COLOR), buttonRect[buttonOverIndex]); //经过
Region reg = new Region(new Rectangle(0, 0, Width, Height));
reg.Exclude(borderPath);
g.FillRegion(new SolidBrush(theme.BACK_COLOR), reg);
if (BorderWidth > 0)
g.DrawPath(borderInsidePen, borderPath);
}
else
{
buttonOverIndex = -1;
g.FillPath(new SolidBrush(BackColor), borderPath);
for (int i = 0; i < buttonDownIndex.Count; i++)
g.FillRectangle(new SolidBrush(theme.DOWN_COLOR), buttonRect[buttonDownIndex[i]]);
Region reg = new Region(new Rectangle(0, 0, Width, Height));
reg.Exclude(borderPath);
g.FillRegion(new SolidBrush(theme.BACK_COLOR), reg);
if (BorderWidth > 0)
g.DrawPath(borderOutsidePen, borderPath);
}
//文字
string[] s = Text.Split(',');
for (int i = 0; i < s.Length; i++)
g.DrawString(s[i], Font, new SolidBrush(ForeColor), textRect[i]);
}
protected override void DrawDisabled(Graphics g)
{
base.DrawDisabled(g);
//控件边框
if (BorderWidth > 0)
g.DrawPath(borderOutsidePen, borderPath);
//文字
string[] s = Text.Split(',');
for (int i = 0; i < s.Length; i++)
g.DrawString(s[i], Font, new SolidBrush(theme.LOST_FOCUS_COLOR), textRect[i]);
}
private void CalcShape()
{
borderPath = new GraphicsPath();
float n;
switch (FaceShape)
{
case Model.ButtonShape.Rectangle:
borderPath.AddRectangle(borderRect);
break;
case Model.ButtonShape.RoundRectangle:
n = borderRect.Height / 8f;
borderPath.AddLine(borderRect.X + n, borderRect.Y, borderRect.Right - n, borderRect.Y);
borderPath.AddArc(borderRect.Right - n - n, borderRect.Y, n + n, n + n, 270, 90);
borderPath.AddLine(borderRect.Right, borderRect.Y + n, borderRect.Right, borderRect.Bottom - n);
borderPath.AddArc(borderRect.Right - n - n, borderRect.Bottom - n - n, n + n, n + n, 0, 90);
borderPath.AddLine(borderRect.Right - n, borderRect.Bottom, borderRect.X + n, borderRect.Bottom);
borderPath.AddArc(borderRect.X, borderRect.Bottom - n - n, n + n, n + n, 90, 90);
borderPath.AddLine(borderRect.X, borderRect.Bottom - n, borderRect.X, borderRect.Y + n);
borderPath.AddArc(borderRect.X, borderRect.Y, n + n, n + n, 180, 90);
break;
case Model.ButtonShape.Ellipse:
borderPath.AddEllipse(borderRect);
break;
case Model.ButtonShape.EllipseRectangle:
n = borderRect.Height / 2f;
borderPath.AddLine(borderRect.X + n, borderRect.Y, borderRect.Right - n, borderRect.Y);
borderPath.AddArc(borderRect.Right - n - n, borderRect.Y, n + n, n + n, 270, 180);
borderPath.AddLine(borderRect.Right - n, borderRect.Bottom, borderRect.X + n, borderRect.Bottom);
borderPath.AddArc(borderRect.X, borderRect.Y, n + n, n + n, 90, 180);
break;
case Model.ButtonShape.Circle:
if (borderRect.Width > borderRect.Height)
borderPath.AddEllipse((borderRect.Width - borderRect.Height) / 2f, borderRect.Y, borderRect.Height, borderRect.Height);
else
borderPath.AddEllipse(borderRect.X, (borderRect.Height - borderRect.Width) / 2f, borderRect.Width, borderRect.Width);
break;
}
}
private void CalcTextLocation()
{
if (string.IsNullOrEmpty(Text)) return;
Graphics g = CreateGraphics();
string[] s = Text.Split(',');
buttonRect = new RectangleF[s.Length];
textRect = new RectangleF[s.Length];
float w = (Width - BorderWidth - BorderWidth) / (float)s.Length;
float h = Height - BorderWidth - BorderWidth;
for (int i = 0; i < s.Length; i++)
{
buttonRect[i] = new RectangleF(BorderWidth + w * i, BorderWidth, w, h);
SizeF sf = g.MeasureString(s[i], Font);
textRect[i] = new RectangleF(0, (h - sf.Height) / 2f, sf.Width, sf.Height);
switch (TextAlign)
{
case HorizontalAlignment.Left:
textRect[i].X = buttonRect[i].X;
break;
case HorizontalAlignment.Center:
textRect[i].X = buttonRect[i].X + (buttonRect[i].Width - sf.Width) / 2f;
break;
case HorizontalAlignment.Right:
textRect[i].X = buttonRect[i].X + buttonRect[i].Width - sf.Width;
break;
}
}
}
private void FaceRadioGroup_MouseDown(object sender, MouseEventArgs e)
{
if (!Enabled) return;
if (e.Button == MouseButtons.Left)
{
int index = buttonDownIndex.FindIndex(s => s == buttonOverIndex);
if (index == -1)
buttonDownIndex.Add(buttonOverIndex);
else
buttonDownIndex.RemoveAt(index);
Refresh();
}
}
private void FaceRadioGroup_MouseUp(object sender, MouseEventArgs e)
{
if (!Enabled) return;
if (e.Button == MouseButtons.Left)
{
Refresh();
CheckedChanged?.Invoke(this, new EventArgs());
}
}
private void FaceRadioGroup_MouseMove(object sender, MouseEventArgs e)
{
buttonOverIndex = -1;
for (int i = 0; i < buttonRect.Length; i++)
{
if (buttonRect[i].Contains(e.Location))
{
buttonOverIndex = i;
break;
}
}
Refresh();
}
}
}
此文件的差异被折叠, 点击展开。
此文件的差异被折叠, 点击展开。
此文件类型无法预览
此文件类型无法预览
此文件类型无法预览
此文件类型无法预览
此文件的差异被折叠, 点击展开。
此文件的差异被折叠, 点击展开。
此文件类型无法预览
此文件类型无法预览
此文件类型无法预览
此文件类型无法预览
此文件类型无法预览
此文件类型无法预览
此文件的差异被折叠, 点击展开。
此文件类型无法预览
此文件类型无法预览
此文件类型无法预览
此文件类型无法预览
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!