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.uiAvatar = new Sunny.UI.UIAvatar();
|
||||
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.uiContextMenuStrip1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// Aside
|
||||
@ -99,11 +103,36 @@
|
||||
this.uiAvatar.TabIndex = 4;
|
||||
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
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 21F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
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.MinimumSize = new System.Drawing.Size(1024, 720);
|
||||
this.Name = "FMain";
|
||||
@ -114,7 +143,10 @@
|
||||
this.ShowShadow = true;
|
||||
this.Text = "SunnyUI.Net";
|
||||
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.uiContextMenuStrip1.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
@ -124,5 +156,8 @@
|
||||
private UILogo uiLogo1;
|
||||
private UIAvatar uiAvatar;
|
||||
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();
|
||||
}
|
||||
|
||||
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">
|
||||
<value>17, 17</value>
|
||||
</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" />
|
||||
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
|
@ -22,12 +22,14 @@
|
||||
* 2020-07-05: V2.2.6 更新窗体控制按钮圆角和跟随窗体圆角变化。
|
||||
* 2020-09-17: V2.2.7 重写WindowState相关代码
|
||||
* 2020-09-17: V2.2.7 增加了窗体可拉拽调整大小ShowDragStretch属性
|
||||
* 2021-02-04: V3.0.1 标题栏增加扩展按钮
|
||||
******************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Design;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Sunny.UI
|
||||
@ -57,10 +59,76 @@ namespace Sunny.UI
|
||||
UpdateStyles();
|
||||
|
||||
Version = UIGlobal.Version;
|
||||
extendSymbol = 0;
|
||||
FormBorderStyle = FormBorderStyle.None;
|
||||
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属性
|
||||
[Browsable(false)]
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
@ -321,6 +389,8 @@ namespace Sunny.UI
|
||||
|
||||
private Rectangle MinimizeBoxRect;
|
||||
|
||||
private Rectangle ExtendBoxRect;
|
||||
|
||||
private int ControlBoxLeft;
|
||||
|
||||
private void CalcSystemBoxPos()
|
||||
@ -351,10 +421,22 @@ namespace Sunny.UI
|
||||
{
|
||||
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
|
||||
{
|
||||
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;
|
||||
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>
|
||||
/// 窗体最大化前的大小
|
||||
@ -500,7 +597,7 @@ namespace Sunny.UI
|
||||
{
|
||||
base.OnMouseDown(e);
|
||||
|
||||
if (InControlBox || InMaxBox || InMinBox) return;
|
||||
if (InControlBox || InMaxBox || InMinBox || InExtendBox) return;
|
||||
if (!ShowTitle) return;
|
||||
if (e.Y > Padding.Top) return;
|
||||
|
||||
@ -517,7 +614,7 @@ namespace Sunny.UI
|
||||
base.OnMouseDoubleClick(e);
|
||||
|
||||
if (!MaximizeBox) return;
|
||||
if (InControlBox || InMaxBox || InMinBox) return;
|
||||
if (InControlBox || InMaxBox || InMinBox || InExtendBox) return;
|
||||
if (!ShowTitle) return;
|
||||
if (e.Y > Padding.Top) return;
|
||||
|
||||
@ -623,6 +720,7 @@ namespace Sunny.UI
|
||||
bool inControlBox = e.Location.InRect(ControlBoxRect);
|
||||
bool inMaxBox = e.Location.InRect(MaximizeBoxRect);
|
||||
bool inMinBox = e.Location.InRect(MinimizeBoxRect);
|
||||
bool inExtendBox = e.Location.InRect(ExtendBoxRect);
|
||||
bool isChange = false;
|
||||
|
||||
if (inControlBox != InControlBox)
|
||||
@ -643,6 +741,12 @@ namespace Sunny.UI
|
||||
isChange = true;
|
||||
}
|
||||
|
||||
if (inExtendBox != InExtendBox)
|
||||
{
|
||||
InExtendBox = inExtendBox;
|
||||
isChange = true;
|
||||
}
|
||||
|
||||
if (isChange)
|
||||
{
|
||||
Invalidate();
|
||||
@ -650,7 +754,7 @@ namespace Sunny.UI
|
||||
}
|
||||
else
|
||||
{
|
||||
InControlBox = InMaxBox = InMinBox = false;
|
||||
InExtendBox = InControlBox = InMaxBox = InMinBox = false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -660,11 +764,11 @@ namespace Sunny.UI
|
||||
protected override void OnMouseLeave(EventArgs e)
|
||||
{
|
||||
base.OnMouseLeave(e);
|
||||
InControlBox = InMaxBox = InMinBox = false;
|
||||
InExtendBox = InControlBox = InMaxBox = InMinBox = false;
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
private bool InControlBox, InMaxBox, InMinBox;
|
||||
private bool InControlBox, InMaxBox, InMinBox, InExtendBox;
|
||||
|
||||
/// <summary>
|
||||
/// 是否屏蔽Alt+F4
|
||||
@ -854,11 +958,41 @@ namespace Sunny.UI
|
||||
e.Graphics.DrawLine(Color.White,
|
||||
MinimizeBoxRect.Left + MinimizeBoxRect.Width / 2 - 6,
|
||||
MinimizeBoxRect.Top + MinimizeBoxRect.Height / 2,
|
||||
MinimizeBoxRect.Left + MinimizeBoxRect.Width / 2 + 6,
|
||||
MinimizeBoxRect.Left + MinimizeBoxRect.Width / 2 + 5,
|
||||
MinimizeBoxRect.Top + MinimizeBoxRect.Height / 2);
|
||||
//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();
|
||||
|
||||
if (ShowTitleIcon && Icon != null)
|
||||
@ -877,7 +1011,7 @@ namespace Sunny.UI
|
||||
}
|
||||
}
|
||||
|
||||
private bool showTitleIcon = false;
|
||||
private bool showTitleIcon;
|
||||
|
||||
[Description("显示标题栏图标"), Category("SunnyUI")]
|
||||
[DefaultValue(false)]
|
||||
|
Loading…
x
Reference in New Issue
Block a user