📄 qbutton.cs
字号:
}
else if (mouse) //Big Button
{
Rectangle _r = new Rectangle(x2 + 1, 1, this.Width - _splitdistance-1, this.Height - 1);
GraphicsPath p = new GraphicsPath();
int _rtemp = _radius; _radius = 4;
DrawArc(_r, p);
_radius = _rtemp;
gr.FillPath(btransp, p);
}
}
#endregion
#region Vertical
else if (_imagelocation == imagelocation.Top)
{
if (ymouse < this.Height - _splitdistance & mouse) //Small button
{
Rectangle _r = new Rectangle(1, y1 + 1, this.Width - 1, this.Height - 1);
GraphicsPath p = new GraphicsPath();
int _rtemp = _radius; _radius = 4;
DrawArc(_r, p);
_radius = _rtemp;
gr.FillPath(btransp, p);
}
else if (mouse) //Big Button
{
Rectangle _r = new Rectangle(1, y2 + 1, this.Width - 1, this.Height - _splitdistance - 1);
GraphicsPath p = new GraphicsPath();
int _rtemp = _radius; _radius = 4;
DrawArc(_r, p);
_radius = _rtemp;
gr.FillPath(btransp, p);
}
}
#endregion
btransp.Dispose();
}
#endregion
#region About Fading
private Timer timer1 = new Timer();
int i_factor = 35;
public int FadingSpeed
{
get { return i_factor; }
set
{
if (value > -1)
{
i_factor = value;
}
}
}
int i_fR = 1; int i_fG = 1; int i_fB = 1; int i_fA = 1;
void timer1_Tick(object sender, EventArgs e)
{
#region Entering
if (i_mode == 1)
{
if (System.Math.Abs(ColorOn.R - R0) > i_factor)
{ i_fR = i_factor; }
else { i_fR = 1; }
if (System.Math.Abs(ColorOn.G - G0) > i_factor)
{ i_fG = i_factor; }
else { i_fG = 1; }
if (System.Math.Abs(ColorOn.B - B0) > i_factor)
{ i_fB = i_factor; }
else { i_fB = 1; }
if (ColorOn.R < R0)
{
R0 -= i_fR;
}
else if (ColorOn.R > R0)
{
R0 += i_fR;
}
if (ColorOn.G < G0)
{
G0 -= i_fG;
}
else if (ColorOn.G > G0)
{
G0 += i_fG;
}
if (ColorOn.B < B0)
{
B0 -= i_fB;
}
else if (ColorOn.B > B0)
{
B0 += i_fB;
}
if (ColorOn == Color.FromArgb(R0, G0, B0))
{
timer1.Stop();
}
else
{
this.Refresh();
}
}
#endregion
#region Leaving
if (i_mode == 0)
{
if (System.Math.Abs(ColorBase.R - R0) < i_factor)
{ i_fR = 1; }
else { i_fR = i_factor; }
if (System.Math.Abs(ColorBase.G - G0) < i_factor)
{ i_fG = 1; }
else { i_fG = i_factor; }
if (System.Math.Abs(ColorBase.B - B0) < i_factor)
{ i_fB = 1; }
else { i_fB = i_factor; }
if (System.Math.Abs(ColorBase.A - A0) < i_factor)
{ i_fA = 1; }
else { i_fA = i_factor; }
if (ColorBase.R < R0)
{
R0 -= i_fR;
}
else if (ColorBase.R > R0)
{
R0 += i_fR;
}
if (ColorBase.G < G0)
{
G0 -= i_fG;
}
else if (ColorBase.G > G0)
{
G0 += i_fG;
}
if (ColorBase.B < B0)
{
B0 -= i_fB;
}
else if (ColorBase.B > B0)
{
B0 += i_fB;
}
if (ColorBase.A < A0)
{
A0 -= i_fA;
}
else if (ColorBase.A > A0)
{
A0 += i_fA;
}
if (ColorBase == Color.FromArgb(A0,R0, G0, B0))
{
timer1.Stop();
}
else
{
this.Refresh();
}
}
#endregion
this.Refresh();
}
#endregion
#region Mouse Events
private bool m_ClickShowContextMenu = false;
public bool clickShowContextMenu
{
get { return m_ClickShowContextMenu; }
set { m_ClickShowContextMenu = value; }
}
int i_mode = 0; //0 Entering, 1 Out,2 Press
int xmouse = 0, ymouse = 0; bool mouse = false;
protected override void OnMouseEnter(EventArgs e)
{
base.OnMouseEnter(e);
_colorStroke = ColorOnStroke;
_tempshowbase = _showbase;
_showbase = showbase.Yes;
i_mode = 1;
xmouse = PointToClient(Cursor.Position).X;
mouse = true;
A0 = 200;
if (i_factor == 0)
{
R0 = _onColor.R; G0 = _onColor.G; B0 = _onColor.B;
}
timer1.Start();
}
protected override void OnMouseLeave(EventArgs e)
{
base.OnMouseLeave(e);
_colorStroke = ColorBaseStroke;
//_showbase = _tempshowbase;
_showbase = _oldshowbase;
i_mode = 0;
mouse = false;
if (i_factor == 0)
{
R0 = _baseColor.R; G0 = _baseColor.G; B0 = _baseColor.B;
}
timer1.Stop();
timer1.Start();
}
protected override void OnMouseDown(MouseEventArgs mevent)
{
base.OnMouseDown(mevent);
R0 = ColorPress.R; G0 = ColorPress.G; B0 = ColorPress.B;
_colorStroke = ColorPressStroke;
_showbase = showbase.Yes;
i_mode = 2;
xmouse = PointToClient(Cursor.Position).X;
ymouse = PointToClient(Cursor.Position).Y;
mouse = true;
}
protected override void OnMouseUp(MouseEventArgs mevent)
{
R0 = ColorOn.R; G0 = ColorOn.G; B0 = ColorOn.B;
_colorStroke = ColorOnStroke;
_showbase = showbase.Yes;
i_mode = 1;
mouse = true;
#region ClickSplit
if (_imagelocation == imagelocation.Left & xmouse > this.Width - _splitdistance & _splitbutton == splitbutton.Yes)
{
if (_arrow == arrow.ToDown)
{
if (this.ContextMenuStrip != null)
this.ContextMenuStrip.Opacity = 1.0;
this.ContextMenuStrip.Show(this,0,this.Height);
}
else if (_arrow == arrow.ToRight)
{
if (this.ContextMenuStrip != null)
{
ContextMenuStrip menu = this.ContextMenuStrip;
this.ContextMenuStrip.Opacity = 1.0;
RibbonMenuShadow shadow = new RibbonMenuShadow();
shadow.Show();
//menu.Show(this, this.Width, -this.Height);
}
}
}
else if (_imagelocation == imagelocation.Top & ymouse > this.Height - _splitdistance & _splitbutton == splitbutton.Yes)
{
if (_arrow == arrow.ToDown)
{
if (this.ContextMenuStrip != null)
this.ContextMenuStrip.Show(this, 0, this.Height);
}
}
else
{
if (m_ClickShowContextMenu)
{
if (_arrow == arrow.ToDown)
{
if (this.ContextMenuStrip != null)
this.ContextMenuStrip.Opacity = 1.0;
this.ContextMenuStrip.Show(this,2, this.Height);
base.OnMouseUp(mevent);
}
else if (_arrow == arrow.ToRight)
{
if (this.ContextMenuStrip != null)
{
ContextMenuStrip menu = this.ContextMenuStrip;
this.ContextMenuStrip.Opacity = 1.0;
menu.Show(this,this.Width, 2);
}
}
}
else
{
base.OnMouseUp(mevent);
}
}
#endregion
}
protected override void OnMouseMove(MouseEventArgs mevent)
{
if (mouse)
{
xmouse = PointToClient(Cursor.Position).X;
ymouse = PointToClient(Cursor.Position).Y;
this.Refresh();
}
base.OnMouseMove(mevent);
}
#endregion
}
public class RibbonColor
{
#region Constructors
public RibbonColor(Color color)
{
rc = color.R;
gc = color.G;
bc = color.B;
ac = color.A;
HSV();
}
public RibbonColor(uint alpha, int hue, int saturation, int brightness)
{
hc = hue;
sc = saturation;
vc = brightness;
ac = alpha;
GetColor();
}
#endregion
#region Alpha
private uint ac = 0; //Alpha > -1
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -