UIForm:标题栏增加扩展按钮
This commit is contained in:
parent
afa860948d
commit
9f5631af92
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
35
SunnyUI.Demo/FMain.Designer.cs
generated
35
SunnyUI.Demo/FMain.Designer.cs
generated
@ -37,7 +37,11 @@
|
|||||||
this.uiLogo1 = new Sunny.UI.UILogo();
|
this.uiLogo1 = new Sunny.UI.UILogo();
|
||||||
this.uiAvatar = new Sunny.UI.UIAvatar();
|
this.uiAvatar = new Sunny.UI.UIAvatar();
|
||||||
this.StyleManager = new Sunny.UI.UIStyleManager(this.components);
|
this.StyleManager = new Sunny.UI.UIStyleManager(this.components);
|
||||||
|
this.uiContextMenuStrip1 = new Sunny.UI.UIContextMenuStrip();
|
||||||
|
this.关于ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.关于ToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.Header.SuspendLayout();
|
this.Header.SuspendLayout();
|
||||||
|
this.uiContextMenuStrip1.SuspendLayout();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// Aside
|
// Aside
|
||||||
@ -99,11 +103,36 @@
|
|||||||
this.uiAvatar.TabIndex = 4;
|
this.uiAvatar.TabIndex = 4;
|
||||||
this.uiAvatar.Text = "uiAvatar1";
|
this.uiAvatar.Text = "uiAvatar1";
|
||||||
//
|
//
|
||||||
|
// uiContextMenuStrip1
|
||||||
|
//
|
||||||
|
this.uiContextMenuStrip1.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||||
|
this.uiContextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
|
this.关于ToolStripMenuItem,
|
||||||
|
this.关于ToolStripMenuItem1});
|
||||||
|
this.uiContextMenuStrip1.Name = "uiContextMenuStrip1";
|
||||||
|
this.uiContextMenuStrip1.Size = new System.Drawing.Size(181, 78);
|
||||||
|
//
|
||||||
|
// 关于ToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.关于ToolStripMenuItem.Name = "关于ToolStripMenuItem";
|
||||||
|
this.关于ToolStripMenuItem.Size = new System.Drawing.Size(180, 26);
|
||||||
|
this.关于ToolStripMenuItem.Text = "主页";
|
||||||
|
this.关于ToolStripMenuItem.Click += new System.EventHandler(this.关于ToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
|
// 关于ToolStripMenuItem1
|
||||||
|
//
|
||||||
|
this.关于ToolStripMenuItem1.Name = "关于ToolStripMenuItem1";
|
||||||
|
this.关于ToolStripMenuItem1.Size = new System.Drawing.Size(180, 26);
|
||||||
|
this.关于ToolStripMenuItem1.Text = "关于";
|
||||||
|
this.关于ToolStripMenuItem1.Click += new System.EventHandler(this.关于ToolStripMenuItem1_Click);
|
||||||
|
//
|
||||||
// FMain
|
// FMain
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 21F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 21F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(1024, 720);
|
this.ClientSize = new System.Drawing.Size(1024, 720);
|
||||||
|
this.ExtendBox = true;
|
||||||
|
this.ExtendMenu = this.uiContextMenuStrip1;
|
||||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||||
this.MinimumSize = new System.Drawing.Size(1024, 720);
|
this.MinimumSize = new System.Drawing.Size(1024, 720);
|
||||||
this.Name = "FMain";
|
this.Name = "FMain";
|
||||||
@ -114,7 +143,10 @@
|
|||||||
this.ShowShadow = true;
|
this.ShowShadow = true;
|
||||||
this.Text = "SunnyUI.Net";
|
this.Text = "SunnyUI.Net";
|
||||||
this.Selecting += new Sunny.UI.UIMainFrame.OnSelecting(this.FMain_Selecting);
|
this.Selecting += new Sunny.UI.UIMainFrame.OnSelecting(this.FMain_Selecting);
|
||||||
|
this.Controls.SetChildIndex(this.Header, 0);
|
||||||
|
this.Controls.SetChildIndex(this.Aside, 0);
|
||||||
this.Header.ResumeLayout(false);
|
this.Header.ResumeLayout(false);
|
||||||
|
this.uiContextMenuStrip1.ResumeLayout(false);
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -124,5 +156,8 @@
|
|||||||
private UILogo uiLogo1;
|
private UILogo uiLogo1;
|
||||||
private UIAvatar uiAvatar;
|
private UIAvatar uiAvatar;
|
||||||
private UIStyleManager StyleManager;
|
private UIStyleManager StyleManager;
|
||||||
|
private UIContextMenuStrip uiContextMenuStrip1;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem 关于ToolStripMenuItem;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem 关于ToolStripMenuItem1;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -89,5 +89,15 @@ namespace Sunny.UI.Demo
|
|||||||
{
|
{
|
||||||
page?.Text.ConsoleWriteLine();
|
page?.Text.ConsoleWriteLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void 关于ToolStripMenuItem1_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
UIMessageBox.Show("SunnyUI.Net V3.0", "关于", Style, UIMessageBoxButtons.OK, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void 关于ToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
System.Diagnostics.Process.Start("https://gitee.com/yhuse/SunnyUI");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -120,6 +120,9 @@
|
|||||||
<metadata name="StyleManager.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
<metadata name="StyleManager.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
<value>17, 17</value>
|
<value>17, 17</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
|
<metadata name="uiContextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>150, 17</value>
|
||||||
|
</metadata>
|
||||||
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||||
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
<value>
|
<value>
|
||||||
|
@ -22,12 +22,14 @@
|
|||||||
* 2020-07-05: V2.2.6 更新窗体控制按钮圆角和跟随窗体圆角变化。
|
* 2020-07-05: V2.2.6 更新窗体控制按钮圆角和跟随窗体圆角变化。
|
||||||
* 2020-09-17: V2.2.7 重写WindowState相关代码
|
* 2020-09-17: V2.2.7 重写WindowState相关代码
|
||||||
* 2020-09-17: V2.2.7 增加了窗体可拉拽调整大小ShowDragStretch属性
|
* 2020-09-17: V2.2.7 增加了窗体可拉拽调整大小ShowDragStretch属性
|
||||||
|
* 2021-02-04: V3.0.1 标题栏增加扩展按钮
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
using System.Drawing.Design;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace Sunny.UI
|
namespace Sunny.UI
|
||||||
@ -57,10 +59,76 @@ namespace Sunny.UI
|
|||||||
UpdateStyles();
|
UpdateStyles();
|
||||||
|
|
||||||
Version = UIGlobal.Version;
|
Version = UIGlobal.Version;
|
||||||
|
extendSymbol = 0;
|
||||||
FormBorderStyle = FormBorderStyle.None;
|
FormBorderStyle = FormBorderStyle.None;
|
||||||
m_aeroEnabled = false;
|
m_aeroEnabled = false;
|
||||||
|
showTitleIcon = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool extendBox;
|
||||||
|
|
||||||
|
[DefaultValue(false)]
|
||||||
|
[Description("显示扩展按钮"), Category("SunnyUI")]
|
||||||
|
public bool ExtendBox
|
||||||
|
{
|
||||||
|
get => extendBox;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
extendBox = value;
|
||||||
|
CalcSystemBoxPos();
|
||||||
|
Invalidate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private int extendSymbol;
|
||||||
|
|
||||||
|
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
|
||||||
|
[Editor(typeof(UIImagePropertyEditor), typeof(UITypeEditor))]
|
||||||
|
[DefaultValue(0)]
|
||||||
|
[Description("扩展按钮字体图标"), Category("SunnyUI")]
|
||||||
|
public int ExtendSymbol
|
||||||
|
{
|
||||||
|
get => extendSymbol;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
extendSymbol = value;
|
||||||
|
Invalidate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private int _symbolSize = 24;
|
||||||
|
|
||||||
|
[DefaultValue(24)]
|
||||||
|
[Description("扩展按钮字体图标大小"), Category("SunnyUI")]
|
||||||
|
public int ExtendSymbolSize
|
||||||
|
{
|
||||||
|
get => _symbolSize;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_symbolSize = Math.Max(value, 16);
|
||||||
|
_symbolSize = Math.Min(value, 64);
|
||||||
|
Invalidate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Point extendSymbolOffset = new Point(0, 0);
|
||||||
|
|
||||||
|
[DefaultValue(typeof(Point), "0, 0")]
|
||||||
|
[Description("扩展按钮字体图标偏移量"), Category("SunnyUI")]
|
||||||
|
public Point ExtendSymbolOffset
|
||||||
|
{
|
||||||
|
get => extendSymbolOffset;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
extendSymbolOffset = value;
|
||||||
|
Invalidate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[DefaultValue(null)]
|
||||||
|
[Description("扩展按钮菜单"), Category("SunnyUI")]
|
||||||
|
public UIContextMenuStrip ExtendMenu { get; set; }
|
||||||
|
|
||||||
//不显示FormBorderStyle属性
|
//不显示FormBorderStyle属性
|
||||||
[Browsable(false)]
|
[Browsable(false)]
|
||||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||||
@ -321,6 +389,8 @@ namespace Sunny.UI
|
|||||||
|
|
||||||
private Rectangle MinimizeBoxRect;
|
private Rectangle MinimizeBoxRect;
|
||||||
|
|
||||||
|
private Rectangle ExtendBoxRect;
|
||||||
|
|
||||||
private int ControlBoxLeft;
|
private int ControlBoxLeft;
|
||||||
|
|
||||||
private void CalcSystemBoxPos()
|
private void CalcSystemBoxPos()
|
||||||
@ -351,10 +421,22 @@ namespace Sunny.UI
|
|||||||
{
|
{
|
||||||
MinimizeBoxRect = new Rectangle(Width + 1, Height + 1, 1, 1);
|
MinimizeBoxRect = new Rectangle(Width + 1, Height + 1, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ExtendBox)
|
||||||
|
{
|
||||||
|
if (MinimizeBox)
|
||||||
|
{
|
||||||
|
ExtendBoxRect = new Rectangle(MinimizeBoxRect.Left - 28 - 2, ControlBoxRect.Top, 28, 28);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MaximizeBoxRect = MinimizeBoxRect = ControlBoxRect = new Rectangle(Width + 1, Height + 1, 1, 1);
|
ExtendBoxRect = new Rectangle(ControlBoxRect.Left - 28 - 2, ControlBoxRect.Top, 28, 28);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ExtendBoxRect = MaximizeBoxRect = MinimizeBoxRect = ControlBoxRect = new Rectangle(Width + 1, Height + 1, 1, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -435,8 +517,23 @@ namespace Sunny.UI
|
|||||||
InMaxBox = false;
|
InMaxBox = false;
|
||||||
ShowMaximize();
|
ShowMaximize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (InExtendBox)
|
||||||
|
{
|
||||||
|
InExtendBox = false;
|
||||||
|
if (ExtendMenu != null)
|
||||||
|
{
|
||||||
|
this.ShowContextMenuStrip(ExtendMenu, ExtendBoxRect.Left, TitleHeight - 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ExtendBoxClick?.Invoke(this, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public event EventHandler ExtendBoxClick;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 窗体最大化前的大小
|
/// 窗体最大化前的大小
|
||||||
@ -500,7 +597,7 @@ namespace Sunny.UI
|
|||||||
{
|
{
|
||||||
base.OnMouseDown(e);
|
base.OnMouseDown(e);
|
||||||
|
|
||||||
if (InControlBox || InMaxBox || InMinBox) return;
|
if (InControlBox || InMaxBox || InMinBox || InExtendBox) return;
|
||||||
if (!ShowTitle) return;
|
if (!ShowTitle) return;
|
||||||
if (e.Y > Padding.Top) return;
|
if (e.Y > Padding.Top) return;
|
||||||
|
|
||||||
@ -517,7 +614,7 @@ namespace Sunny.UI
|
|||||||
base.OnMouseDoubleClick(e);
|
base.OnMouseDoubleClick(e);
|
||||||
|
|
||||||
if (!MaximizeBox) return;
|
if (!MaximizeBox) return;
|
||||||
if (InControlBox || InMaxBox || InMinBox) return;
|
if (InControlBox || InMaxBox || InMinBox || InExtendBox) return;
|
||||||
if (!ShowTitle) return;
|
if (!ShowTitle) return;
|
||||||
if (e.Y > Padding.Top) return;
|
if (e.Y > Padding.Top) return;
|
||||||
|
|
||||||
@ -623,6 +720,7 @@ namespace Sunny.UI
|
|||||||
bool inControlBox = e.Location.InRect(ControlBoxRect);
|
bool inControlBox = e.Location.InRect(ControlBoxRect);
|
||||||
bool inMaxBox = e.Location.InRect(MaximizeBoxRect);
|
bool inMaxBox = e.Location.InRect(MaximizeBoxRect);
|
||||||
bool inMinBox = e.Location.InRect(MinimizeBoxRect);
|
bool inMinBox = e.Location.InRect(MinimizeBoxRect);
|
||||||
|
bool inExtendBox = e.Location.InRect(ExtendBoxRect);
|
||||||
bool isChange = false;
|
bool isChange = false;
|
||||||
|
|
||||||
if (inControlBox != InControlBox)
|
if (inControlBox != InControlBox)
|
||||||
@ -643,6 +741,12 @@ namespace Sunny.UI
|
|||||||
isChange = true;
|
isChange = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (inExtendBox != InExtendBox)
|
||||||
|
{
|
||||||
|
InExtendBox = inExtendBox;
|
||||||
|
isChange = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (isChange)
|
if (isChange)
|
||||||
{
|
{
|
||||||
Invalidate();
|
Invalidate();
|
||||||
@ -650,7 +754,7 @@ namespace Sunny.UI
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
InControlBox = InMaxBox = InMinBox = false;
|
InExtendBox = InControlBox = InMaxBox = InMinBox = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -660,11 +764,11 @@ namespace Sunny.UI
|
|||||||
protected override void OnMouseLeave(EventArgs e)
|
protected override void OnMouseLeave(EventArgs e)
|
||||||
{
|
{
|
||||||
base.OnMouseLeave(e);
|
base.OnMouseLeave(e);
|
||||||
InControlBox = InMaxBox = InMinBox = false;
|
InExtendBox = InControlBox = InMaxBox = InMinBox = false;
|
||||||
Invalidate();
|
Invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool InControlBox, InMaxBox, InMinBox;
|
private bool InControlBox, InMaxBox, InMinBox, InExtendBox;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否屏蔽Alt+F4
|
/// 是否屏蔽Alt+F4
|
||||||
@ -854,11 +958,41 @@ namespace Sunny.UI
|
|||||||
e.Graphics.DrawLine(Color.White,
|
e.Graphics.DrawLine(Color.White,
|
||||||
MinimizeBoxRect.Left + MinimizeBoxRect.Width / 2 - 6,
|
MinimizeBoxRect.Left + MinimizeBoxRect.Width / 2 - 6,
|
||||||
MinimizeBoxRect.Top + MinimizeBoxRect.Height / 2,
|
MinimizeBoxRect.Top + MinimizeBoxRect.Height / 2,
|
||||||
MinimizeBoxRect.Left + MinimizeBoxRect.Width / 2 + 6,
|
MinimizeBoxRect.Left + MinimizeBoxRect.Width / 2 + 5,
|
||||||
MinimizeBoxRect.Top + MinimizeBoxRect.Height / 2);
|
MinimizeBoxRect.Top + MinimizeBoxRect.Height / 2);
|
||||||
//e.Graphics.DrawFontImage(62161, 24, Color.White, MinimizeBoxRect, 1);
|
//e.Graphics.DrawFontImage(62161, 24, Color.White, MinimizeBoxRect, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ExtendBox)
|
||||||
|
{
|
||||||
|
if (InExtendBox)
|
||||||
|
{
|
||||||
|
if (ShowRadius)
|
||||||
|
e.Graphics.FillRoundRectangle(btn.FillHoverColor, ExtendBoxRect, 5);
|
||||||
|
else
|
||||||
|
e.Graphics.FillRectangle(btn.FillHoverColor, ExtendBoxRect);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ExtendSymbol == 0)
|
||||||
|
{
|
||||||
|
e.Graphics.DrawLine(Color.White,
|
||||||
|
ExtendBoxRect.Left + ExtendBoxRect.Width / 2 - 5 - 1,
|
||||||
|
ExtendBoxRect.Top + ExtendBoxRect.Height / 2 - 2,
|
||||||
|
ExtendBoxRect.Left + ExtendBoxRect.Width / 2 - 1,
|
||||||
|
ExtendBoxRect.Top + ExtendBoxRect.Height / 2 + 3);
|
||||||
|
|
||||||
|
e.Graphics.DrawLine(Color.White,
|
||||||
|
ExtendBoxRect.Left + ExtendBoxRect.Width / 2 + 5 - 1,
|
||||||
|
ExtendBoxRect.Top + ExtendBoxRect.Height / 2 - 2,
|
||||||
|
ExtendBoxRect.Left + ExtendBoxRect.Width / 2 - 1,
|
||||||
|
ExtendBoxRect.Top + ExtendBoxRect.Height / 2 + 3);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
e.Graphics.DrawFontImage(extendSymbol, ExtendSymbolSize, Color.White, ExtendBoxRect, ExtendSymbolOffset.X, ExtendSymbolOffset.Y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
e.Graphics.SetDefaultQuality();
|
e.Graphics.SetDefaultQuality();
|
||||||
|
|
||||||
if (ShowTitleIcon && Icon != null)
|
if (ShowTitleIcon && Icon != null)
|
||||||
@ -877,7 +1011,7 @@ namespace Sunny.UI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool showTitleIcon = false;
|
private bool showTitleIcon;
|
||||||
|
|
||||||
[Description("显示标题栏图标"), Category("SunnyUI")]
|
[Description("显示标题栏图标"), Category("SunnyUI")]
|
||||||
[DefaultValue(false)]
|
[DefaultValue(false)]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user