* UITabControl:增加只显示激活窗体关闭按钮
This commit is contained in:
parent
af63124c44
commit
18072dfc1a
BIN
Bin/SunnyUI.dll
BIN
Bin/SunnyUI.dll
Binary file not shown.
BIN
Bin/SunnyUI.pdb
BIN
Bin/SunnyUI.pdb
Binary file not shown.
Binary file not shown.
Binary file not shown.
1
SunnyUI.Demo/Controls/FButton.Designer.cs
generated
1
SunnyUI.Demo/Controls/FButton.Designer.cs
generated
@ -984,6 +984,7 @@
|
||||
//
|
||||
// FButton
|
||||
//
|
||||
this.AlwaysOpen = true;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 21F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 534);
|
||||
|
25
SunnyUI.Demo/Controls/FTabControl.Designer.cs
generated
25
SunnyUI.Demo/Controls/FTabControl.Designer.cs
generated
@ -35,6 +35,8 @@
|
||||
this.tabPage9 = new System.Windows.Forms.TabPage();
|
||||
this.tabPage10 = new System.Windows.Forms.TabPage();
|
||||
this.tabPage11 = new System.Windows.Forms.TabPage();
|
||||
this.tabPage12 = new System.Windows.Forms.TabPage();
|
||||
this.tabPage13 = new System.Windows.Forms.TabPage();
|
||||
this.tabPage4 = new System.Windows.Forms.TabPage();
|
||||
this.uiLine1 = new Sunny.UI.UILine();
|
||||
this.uiLine2 = new Sunny.UI.UILine();
|
||||
@ -64,6 +66,8 @@
|
||||
this.uiTabControl1.Controls.Add(this.tabPage9);
|
||||
this.uiTabControl1.Controls.Add(this.tabPage10);
|
||||
this.uiTabControl1.Controls.Add(this.tabPage11);
|
||||
this.uiTabControl1.Controls.Add(this.tabPage12);
|
||||
this.uiTabControl1.Controls.Add(this.tabPage13);
|
||||
this.uiTabControl1.DrawMode = System.Windows.Forms.TabDrawMode.OwnerDrawFixed;
|
||||
this.uiTabControl1.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||
this.uiTabControl1.ItemSize = new System.Drawing.Size(150, 40);
|
||||
@ -72,7 +76,6 @@
|
||||
this.uiTabControl1.Name = "uiTabControl1";
|
||||
this.uiTabControl1.SelectedIndex = 0;
|
||||
this.uiTabControl1.ShowActiveCloseButton = true;
|
||||
this.uiTabControl1.ShowCloseButton = true;
|
||||
this.uiTabControl1.Size = new System.Drawing.Size(670, 183);
|
||||
this.uiTabControl1.SizeMode = System.Windows.Forms.TabSizeMode.Fixed;
|
||||
this.uiTabControl1.TabIndex = 0;
|
||||
@ -132,6 +135,24 @@
|
||||
this.tabPage11.Text = "tabPage11";
|
||||
this.tabPage11.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// tabPage12
|
||||
//
|
||||
this.tabPage12.Location = new System.Drawing.Point(0, 40);
|
||||
this.tabPage12.Name = "tabPage12";
|
||||
this.tabPage12.Size = new System.Drawing.Size(670, 143);
|
||||
this.tabPage12.TabIndex = 7;
|
||||
this.tabPage12.Text = "tabPage12";
|
||||
this.tabPage12.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// tabPage13
|
||||
//
|
||||
this.tabPage13.Location = new System.Drawing.Point(0, 40);
|
||||
this.tabPage13.Name = "tabPage13";
|
||||
this.tabPage13.Size = new System.Drawing.Size(670, 143);
|
||||
this.tabPage13.TabIndex = 8;
|
||||
this.tabPage13.Text = "tabPage13";
|
||||
this.tabPage13.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// tabPage4
|
||||
//
|
||||
this.tabPage4.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(192)))));
|
||||
@ -250,5 +271,7 @@
|
||||
private System.Windows.Forms.TabPage tabPage9;
|
||||
private System.Windows.Forms.TabPage tabPage10;
|
||||
private System.Windows.Forms.TabPage tabPage11;
|
||||
private System.Windows.Forms.TabPage tabPage12;
|
||||
private System.Windows.Forms.TabPage tabPage13;
|
||||
}
|
||||
}
|
@ -285,8 +285,9 @@ namespace Sunny.UI
|
||||
if (pageIndex < 0) return;
|
||||
foreach (var item in PageItems)
|
||||
{
|
||||
if (item.Value.PageIndex == pageIndex)
|
||||
if (item.Value.PageIndex == pageIndex && item.Key!=null)
|
||||
{
|
||||
if (tabControl.TabPages.Contains(item.Key))
|
||||
tabControl.SelectTab(item.Key);
|
||||
}
|
||||
}
|
||||
@ -297,9 +298,10 @@ namespace Sunny.UI
|
||||
if (guid == Guid.Empty) return;
|
||||
foreach (var item in PageItems)
|
||||
{
|
||||
if (item.Value.PageGuid == guid)
|
||||
if (item.Value.PageGuid == guid && item.Key != null)
|
||||
{
|
||||
tabControl.SelectTab(item.Key);
|
||||
if (tabControl.TabPages.Contains(item.Key))
|
||||
tabControl.SelectTab(item.Key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -33,6 +33,8 @@ namespace Sunny.UI
|
||||
public sealed class UITabControl : TabControl, IStyleInterface
|
||||
{
|
||||
private readonly UITabControlHelper Helper;
|
||||
private int DrawedIndex = -1;
|
||||
private readonly Timer timer = new Timer();
|
||||
|
||||
public UITabControl()
|
||||
{
|
||||
@ -46,6 +48,24 @@ namespace Sunny.UI
|
||||
Version = UIGlobal.Version;
|
||||
|
||||
Helper = new UITabControlHelper(this);
|
||||
timer.Interval = 500;
|
||||
timer.Tick += Timer_Tick;
|
||||
}
|
||||
|
||||
private void Timer_Tick(object sender, EventArgs e)
|
||||
{
|
||||
timer.Stop();
|
||||
DrawedIndex = SelectedIndex;
|
||||
}
|
||||
|
||||
protected override void OnSelected(TabControlEventArgs e)
|
||||
{
|
||||
base.OnSelected(e);
|
||||
|
||||
if (ShowActiveCloseButton && !ShowCloseButton)
|
||||
{
|
||||
timer.Start();
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
|
||||
@ -320,27 +340,28 @@ namespace Sunny.UI
|
||||
|
||||
private bool showCloseButton;
|
||||
|
||||
[DefaultValue(false)]
|
||||
[DefaultValue(false),Description("所有Tab页面标题显示关闭按钮")]
|
||||
public bool ShowCloseButton
|
||||
{
|
||||
get => showCloseButton;
|
||||
set
|
||||
{
|
||||
showCloseButton = value;
|
||||
if (showActiveCloseButton) showActiveCloseButton = false;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
private bool showActiveCloseButton;
|
||||
|
||||
[DefaultValue(false)]
|
||||
[Browsable(false)]
|
||||
[DefaultValue(false), Description("当前激活的Tab页面标题显示关闭按钮")]
|
||||
public bool ShowActiveCloseButton
|
||||
{
|
||||
get => showActiveCloseButton;
|
||||
set
|
||||
{
|
||||
showActiveCloseButton = value;
|
||||
if (showCloseButton) showCloseButton = false;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
@ -413,9 +434,10 @@ namespace Sunny.UI
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnMouseClick(MouseEventArgs e)
|
||||
protected override void OnMouseDown(MouseEventArgs e)
|
||||
{
|
||||
base.OnMouseClick(e);
|
||||
base.OnMouseDown(e);
|
||||
|
||||
int removeIndex = -1;
|
||||
for (int index = 0; index <= TabCount - 1; index++)
|
||||
{
|
||||
@ -433,11 +455,27 @@ namespace Sunny.UI
|
||||
return;
|
||||
}
|
||||
|
||||
if (ShowCloseButton || (ShowActiveCloseButton && removeIndex == SelectedIndex))
|
||||
removeIndex.ConsoleWriteLine("removeIndex");
|
||||
var menuItem = Helper[removeIndex];
|
||||
bool showButton = menuItem == null || !menuItem.AlwaysOpen;
|
||||
if (showButton)
|
||||
{
|
||||
if (BeforeRemoveTabPage == null || (BeforeRemoveTabPage != null && BeforeRemoveTabPage.Invoke(this, removeIndex)))
|
||||
if (ShowCloseButton)
|
||||
{
|
||||
RemoveTabPage(removeIndex);
|
||||
if (BeforeRemoveTabPage == null || (BeforeRemoveTabPage != null && BeforeRemoveTabPage.Invoke(this, removeIndex)))
|
||||
{
|
||||
RemoveTabPage(removeIndex);
|
||||
}
|
||||
}
|
||||
else if (ShowActiveCloseButton && removeIndex == SelectedIndex)
|
||||
{
|
||||
if (DrawedIndex == removeIndex)
|
||||
{
|
||||
if (BeforeRemoveTabPage == null || (BeforeRemoveTabPage != null && BeforeRemoveTabPage.Invoke(this, removeIndex)))
|
||||
{
|
||||
RemoveTabPage(removeIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,7 @@
|
||||
******************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Sunny.UI
|
||||
{
|
||||
@ -64,5 +65,23 @@ namespace Sunny.UI
|
||||
}
|
||||
|
||||
protected UITabControl MainTabControl => MainContainer;
|
||||
|
||||
public bool TabVisible
|
||||
{
|
||||
get => MainContainer.TabVisible;
|
||||
set => MainContainer.TabVisible = value;
|
||||
}
|
||||
|
||||
public bool TabShowCloseButton
|
||||
{
|
||||
get => MainContainer.ShowCloseButton;
|
||||
set => MainContainer.ShowCloseButton = value;
|
||||
}
|
||||
|
||||
public bool TabShowActiveCloseButton
|
||||
{
|
||||
get => MainContainer.ShowActiveCloseButton;
|
||||
set => MainContainer.ShowActiveCloseButton = value;
|
||||
}
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@
|
||||
|
||||
2020.06.27
|
||||
* UITabControl:重绘左右按钮
|
||||
+ UITabControl:增加只显示激活窗体关闭按钮
|
||||
|
||||
2020.06.26
|
||||
+ UIDoughnutChart:增加控件:环状图
|
||||
|
Loading…
x
Reference in New Issue
Block a user