diff --git a/Bin/net40/SunnyUI.Demo.exe b/Bin/net40/SunnyUI.Demo.exe index 44c73f72..5ec7be43 100644 Binary files a/Bin/net40/SunnyUI.Demo.exe and b/Bin/net40/SunnyUI.Demo.exe differ diff --git a/Bin/net40/SunnyUI.dll b/Bin/net40/SunnyUI.dll index 0a185620..a2119c31 100644 Binary files a/Bin/net40/SunnyUI.dll and b/Bin/net40/SunnyUI.dll differ diff --git a/SunnyUI.Demo/Controls/FHeaderButton.Designer.cs b/SunnyUI.Demo/Controls/FHeaderButton.Designer.cs index 7e865793..ac382685 100644 --- a/SunnyUI.Demo/Controls/FHeaderButton.Designer.cs +++ b/SunnyUI.Demo/Controls/FHeaderButton.Designer.cs @@ -52,6 +52,7 @@ namespace Sunny.UI.Demo // uiLine2 // this.uiLine2.Font = new System.Drawing.Font("微软雅黑", 12F); + this.uiLine2.IsScaled = false; this.uiLine2.Location = new System.Drawing.Point(30, 198); this.uiLine2.MinimumSize = new System.Drawing.Size(16, 16); this.uiLine2.Name = "uiLine2"; @@ -63,6 +64,7 @@ namespace Sunny.UI.Demo // uiLine1 // this.uiLine1.Font = new System.Drawing.Font("微软雅黑", 12F); + this.uiLine1.IsScaled = false; this.uiLine1.Location = new System.Drawing.Point(30, 55); this.uiLine1.MinimumSize = new System.Drawing.Size(16, 16); this.uiLine1.Name = "uiLine1"; @@ -82,6 +84,7 @@ namespace Sunny.UI.Demo this.uiPanel2.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(37)))), ((int)(((byte)(40)))), ((int)(((byte)(43))))); this.uiPanel2.Font = new System.Drawing.Font("微软雅黑", 12F); this.uiPanel2.ForeColor = System.Drawing.Color.Silver; + this.uiPanel2.IsScaled = false; this.uiPanel2.Location = new System.Drawing.Point(30, 237); this.uiPanel2.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.uiPanel2.MinimumSize = new System.Drawing.Size(1, 1); @@ -106,6 +109,7 @@ namespace Sunny.UI.Demo this.uiHeaderButton6.ForePressColor = System.Drawing.Color.FromArgb(((int)(((byte)(130)))), ((int)(((byte)(130)))), ((int)(((byte)(130))))); this.uiHeaderButton6.ForeSelectedColor = System.Drawing.Color.FromArgb(((int)(((byte)(130)))), ((int)(((byte)(130)))), ((int)(((byte)(130))))); this.uiHeaderButton6.Image = global::Sunny.UI.Demo.Properties.Resources._7; + this.uiHeaderButton6.IsScaled = false; this.uiHeaderButton6.Location = new System.Drawing.Point(600, 1); this.uiHeaderButton6.MinimumSize = new System.Drawing.Size(1, 1); this.uiHeaderButton6.Name = "uiHeaderButton6"; @@ -119,6 +123,7 @@ namespace Sunny.UI.Demo this.uiHeaderButton6.Symbol = 0; this.uiHeaderButton6.TabIndex = 5; this.uiHeaderButton6.Text = "设置"; + this.uiHeaderButton6.TipsFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); // // uiHeaderButton7 // @@ -132,6 +137,7 @@ namespace Sunny.UI.Demo this.uiHeaderButton7.ForePressColor = System.Drawing.Color.FromArgb(((int)(((byte)(130)))), ((int)(((byte)(130)))), ((int)(((byte)(130))))); this.uiHeaderButton7.ForeSelectedColor = System.Drawing.Color.FromArgb(((int)(((byte)(130)))), ((int)(((byte)(130)))), ((int)(((byte)(130))))); this.uiHeaderButton7.Image = global::Sunny.UI.Demo.Properties.Resources._5; + this.uiHeaderButton7.IsScaled = false; this.uiHeaderButton7.Location = new System.Drawing.Point(500, 1); this.uiHeaderButton7.MinimumSize = new System.Drawing.Size(1, 1); this.uiHeaderButton7.Name = "uiHeaderButton7"; @@ -145,6 +151,7 @@ namespace Sunny.UI.Demo this.uiHeaderButton7.Symbol = 0; this.uiHeaderButton7.TabIndex = 4; this.uiHeaderButton7.Text = "朋友"; + this.uiHeaderButton7.TipsFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); // // uiHeaderButton4 // @@ -158,6 +165,7 @@ namespace Sunny.UI.Demo this.uiHeaderButton4.ForePressColor = System.Drawing.Color.FromArgb(((int)(((byte)(130)))), ((int)(((byte)(130)))), ((int)(((byte)(130))))); this.uiHeaderButton4.ForeSelectedColor = System.Drawing.Color.FromArgb(((int)(((byte)(130)))), ((int)(((byte)(130)))), ((int)(((byte)(130))))); this.uiHeaderButton4.Image = global::Sunny.UI.Demo.Properties.Resources._4; + this.uiHeaderButton4.IsScaled = false; this.uiHeaderButton4.Location = new System.Drawing.Point(400, 1); this.uiHeaderButton4.MinimumSize = new System.Drawing.Size(1, 1); this.uiHeaderButton4.Name = "uiHeaderButton4"; @@ -171,6 +179,7 @@ namespace Sunny.UI.Demo this.uiHeaderButton4.Symbol = 0; this.uiHeaderButton4.TabIndex = 3; this.uiHeaderButton4.Text = "手机"; + this.uiHeaderButton4.TipsFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); // // uiHeaderButton5 // @@ -184,6 +193,7 @@ namespace Sunny.UI.Demo this.uiHeaderButton5.ForePressColor = System.Drawing.Color.FromArgb(((int)(((byte)(130)))), ((int)(((byte)(130)))), ((int)(((byte)(130))))); this.uiHeaderButton5.ForeSelectedColor = System.Drawing.Color.FromArgb(((int)(((byte)(130)))), ((int)(((byte)(130)))), ((int)(((byte)(130))))); this.uiHeaderButton5.Image = global::Sunny.UI.Demo.Properties.Resources._3; + this.uiHeaderButton5.IsScaled = false; this.uiHeaderButton5.Location = new System.Drawing.Point(300, 1); this.uiHeaderButton5.MinimumSize = new System.Drawing.Size(1, 1); this.uiHeaderButton5.Name = "uiHeaderButton5"; @@ -197,6 +207,7 @@ namespace Sunny.UI.Demo this.uiHeaderButton5.Symbol = 0; this.uiHeaderButton5.TabIndex = 2; this.uiHeaderButton5.Text = "邮件"; + this.uiHeaderButton5.TipsFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); // // uiHeaderButton3 // @@ -210,6 +221,7 @@ namespace Sunny.UI.Demo this.uiHeaderButton3.ForePressColor = System.Drawing.Color.FromArgb(((int)(((byte)(130)))), ((int)(((byte)(130)))), ((int)(((byte)(130))))); this.uiHeaderButton3.ForeSelectedColor = System.Drawing.Color.FromArgb(((int)(((byte)(130)))), ((int)(((byte)(130)))), ((int)(((byte)(130))))); this.uiHeaderButton3.Image = global::Sunny.UI.Demo.Properties.Resources._2; + this.uiHeaderButton3.IsScaled = false; this.uiHeaderButton3.Location = new System.Drawing.Point(200, 1); this.uiHeaderButton3.MinimumSize = new System.Drawing.Size(1, 1); this.uiHeaderButton3.Name = "uiHeaderButton3"; @@ -223,6 +235,7 @@ namespace Sunny.UI.Demo this.uiHeaderButton3.Symbol = 0; this.uiHeaderButton3.TabIndex = 1; this.uiHeaderButton3.Text = "消息"; + this.uiHeaderButton3.TipsFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); // // uiHeaderButton2 // @@ -236,6 +249,7 @@ namespace Sunny.UI.Demo this.uiHeaderButton2.ForePressColor = System.Drawing.Color.FromArgb(((int)(((byte)(130)))), ((int)(((byte)(130)))), ((int)(((byte)(130))))); this.uiHeaderButton2.ForeSelectedColor = System.Drawing.Color.FromArgb(((int)(((byte)(130)))), ((int)(((byte)(130)))), ((int)(((byte)(130))))); this.uiHeaderButton2.Image = global::Sunny.UI.Demo.Properties.Resources._1; + this.uiHeaderButton2.IsScaled = false; this.uiHeaderButton2.Location = new System.Drawing.Point(100, 1); this.uiHeaderButton2.MinimumSize = new System.Drawing.Size(1, 1); this.uiHeaderButton2.Name = "uiHeaderButton2"; @@ -249,6 +263,7 @@ namespace Sunny.UI.Demo this.uiHeaderButton2.Symbol = 0; this.uiHeaderButton2.TabIndex = 0; this.uiHeaderButton2.Text = "主页"; + this.uiHeaderButton2.TipsFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); // // uiPanel1 // @@ -260,6 +275,7 @@ namespace Sunny.UI.Demo this.uiPanel1.Controls.Add(this.uiHeaderButton1); this.uiPanel1.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(160)))), ((int)(((byte)(255))))); this.uiPanel1.Font = new System.Drawing.Font("微软雅黑", 12F); + this.uiPanel1.IsScaled = false; this.uiPanel1.Location = new System.Drawing.Point(30, 92); this.uiPanel1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.uiPanel1.MinimumSize = new System.Drawing.Size(1, 1); @@ -276,6 +292,7 @@ namespace Sunny.UI.Demo this.uiHeaderButton12.CircleColor = System.Drawing.Color.Olive; this.uiHeaderButton12.Cursor = System.Windows.Forms.Cursors.Hand; this.uiHeaderButton12.Font = new System.Drawing.Font("微软雅黑", 12F); + this.uiHeaderButton12.IsScaled = false; this.uiHeaderButton12.Location = new System.Drawing.Point(600, 1); this.uiHeaderButton12.MinimumSize = new System.Drawing.Size(1, 1); this.uiHeaderButton12.Name = "uiHeaderButton12"; @@ -290,12 +307,14 @@ namespace Sunny.UI.Demo this.uiHeaderButton12.SymbolSize = 41; this.uiHeaderButton12.TabIndex = 5; this.uiHeaderButton12.Text = "设置"; + this.uiHeaderButton12.TipsFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); // // uiHeaderButton11 // this.uiHeaderButton11.CircleColor = System.Drawing.Color.Purple; this.uiHeaderButton11.Cursor = System.Windows.Forms.Cursors.Hand; this.uiHeaderButton11.Font = new System.Drawing.Font("微软雅黑", 12F); + this.uiHeaderButton11.IsScaled = false; this.uiHeaderButton11.Location = new System.Drawing.Point(500, 1); this.uiHeaderButton11.MinimumSize = new System.Drawing.Size(1, 1); this.uiHeaderButton11.Name = "uiHeaderButton11"; @@ -310,12 +329,14 @@ namespace Sunny.UI.Demo this.uiHeaderButton11.SymbolSize = 40; this.uiHeaderButton11.TabIndex = 4; this.uiHeaderButton11.Text = "朋友"; + this.uiHeaderButton11.TipsFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); // // uiHeaderButton10 // this.uiHeaderButton10.CircleColor = System.Drawing.Color.Teal; this.uiHeaderButton10.Cursor = System.Windows.Forms.Cursors.Hand; this.uiHeaderButton10.Font = new System.Drawing.Font("微软雅黑", 12F); + this.uiHeaderButton10.IsScaled = false; this.uiHeaderButton10.Location = new System.Drawing.Point(400, 1); this.uiHeaderButton10.MinimumSize = new System.Drawing.Size(1, 1); this.uiHeaderButton10.Name = "uiHeaderButton10"; @@ -330,12 +351,14 @@ namespace Sunny.UI.Demo this.uiHeaderButton10.SymbolSize = 38; this.uiHeaderButton10.TabIndex = 3; this.uiHeaderButton10.Text = "手机"; + this.uiHeaderButton10.TipsFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); // // uiHeaderButton9 // this.uiHeaderButton9.CircleColor = System.Drawing.Color.DarkOrange; this.uiHeaderButton9.Cursor = System.Windows.Forms.Cursors.Hand; this.uiHeaderButton9.Font = new System.Drawing.Font("微软雅黑", 12F); + this.uiHeaderButton9.IsScaled = false; this.uiHeaderButton9.Location = new System.Drawing.Point(300, 1); this.uiHeaderButton9.MinimumSize = new System.Drawing.Size(1, 1); this.uiHeaderButton9.Name = "uiHeaderButton9"; @@ -350,12 +373,14 @@ namespace Sunny.UI.Demo this.uiHeaderButton9.SymbolSize = 40; this.uiHeaderButton9.TabIndex = 2; this.uiHeaderButton9.Text = "邮件"; + this.uiHeaderButton9.TipsFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); // // uiHeaderButton8 // this.uiHeaderButton8.CircleColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(192)))), ((int)(((byte)(0))))); this.uiHeaderButton8.Cursor = System.Windows.Forms.Cursors.Hand; this.uiHeaderButton8.Font = new System.Drawing.Font("微软雅黑", 12F); + this.uiHeaderButton8.IsScaled = false; this.uiHeaderButton8.Location = new System.Drawing.Point(200, 1); this.uiHeaderButton8.MinimumSize = new System.Drawing.Size(1, 1); this.uiHeaderButton8.Name = "uiHeaderButton8"; @@ -370,6 +395,7 @@ namespace Sunny.UI.Demo this.uiHeaderButton8.SymbolSize = 44; this.uiHeaderButton8.TabIndex = 1; this.uiHeaderButton8.Text = "消息"; + this.uiHeaderButton8.TipsFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); // // uiHeaderButton1 // @@ -377,6 +403,7 @@ namespace Sunny.UI.Demo this.uiHeaderButton1.CircleHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(255))))); this.uiHeaderButton1.Cursor = System.Windows.Forms.Cursors.Hand; this.uiHeaderButton1.Font = new System.Drawing.Font("微软雅黑", 12F); + this.uiHeaderButton1.IsScaled = false; this.uiHeaderButton1.Location = new System.Drawing.Point(100, 1); this.uiHeaderButton1.MinimumSize = new System.Drawing.Size(1, 1); this.uiHeaderButton1.Name = "uiHeaderButton1"; @@ -385,16 +412,18 @@ namespace Sunny.UI.Demo this.uiHeaderButton1.RadiusSides = Sunny.UI.UICornerRadiusSides.None; this.uiHeaderButton1.RectSides = System.Windows.Forms.ToolStripStatusLabelBorderSides.None; this.uiHeaderButton1.ShowCircleHoverColor = true; + this.uiHeaderButton1.ShowTips = true; this.uiHeaderButton1.Size = new System.Drawing.Size(100, 88); this.uiHeaderButton1.Style = Sunny.UI.UIStyle.Custom; this.uiHeaderButton1.Symbol = 61461; this.uiHeaderButton1.TabIndex = 0; this.uiHeaderButton1.Text = "主页"; + this.uiHeaderButton1.TipsFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.uiHeaderButton1.TipsText = "12"; // // FHeaderButton // this.AllowShowTitle = true; - this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 21F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; this.ClientSize = new System.Drawing.Size(800, 450); this.Controls.Add(this.uiLine2); diff --git a/SunnyUI.Demo/Controls/FTabControl.Designer.cs b/SunnyUI.Demo/Controls/FTabControl.Designer.cs index 2ef23239..bc2b6ad3 100644 --- a/SunnyUI.Demo/Controls/FTabControl.Designer.cs +++ b/SunnyUI.Demo/Controls/FTabControl.Designer.cs @@ -106,6 +106,7 @@ namespace Sunny.UI.Demo // uiLine2 // this.uiLine2.Font = new System.Drawing.Font("微软雅黑", 12F); + this.uiLine2.IsScaled = false; this.uiLine2.Location = new System.Drawing.Point(30, 286); this.uiLine2.MinimumSize = new System.Drawing.Size(16, 16); this.uiLine2.Name = "uiLine2"; @@ -117,6 +118,7 @@ namespace Sunny.UI.Demo // uiLine1 // this.uiLine1.Font = new System.Drawing.Font("微软雅黑", 12F); + this.uiLine1.IsScaled = false; this.uiLine1.Location = new System.Drawing.Point(30, 55); this.uiLine1.MinimumSize = new System.Drawing.Size(16, 16); this.uiLine1.Name = "uiLine1"; @@ -147,6 +149,7 @@ namespace Sunny.UI.Demo this.uiTabControl1.Size = new System.Drawing.Size(670, 183); this.uiTabControl1.SizeMode = System.Windows.Forms.TabSizeMode.Fixed; this.uiTabControl1.TabIndex = 22; + this.uiTabControl1.TipsFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.uiTabControl1.BeforeRemoveTabPage += new Sunny.UI.UITabControl.OnBeforeRemoveTabPage(this.uiTabControl1_BeforeRemoveTabPage); // // tabPage1 @@ -165,14 +168,14 @@ namespace Sunny.UI.Demo this.tabPage2.Name = "tabPage2"; this.tabPage2.Size = new System.Drawing.Size(670, 143); this.tabPage2.TabIndex = 1; - this.tabPage2.Text = "tabPage2"; + this.tabPage2.Text = "页面"; // // tabPage3 // this.tabPage3.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(255)))), ((int)(((byte)(192))))); this.tabPage3.Location = new System.Drawing.Point(0, 40); this.tabPage3.Name = "tabPage3"; - this.tabPage3.Size = new System.Drawing.Size(670, 143); + this.tabPage3.Size = new System.Drawing.Size(200, 60); this.tabPage3.TabIndex = 2; this.tabPage3.Text = "tabPage3"; // @@ -180,7 +183,7 @@ namespace Sunny.UI.Demo // this.tabPage9.Location = new System.Drawing.Point(0, 40); this.tabPage9.Name = "tabPage9"; - this.tabPage9.Size = new System.Drawing.Size(670, 143); + this.tabPage9.Size = new System.Drawing.Size(200, 60); this.tabPage9.TabIndex = 4; this.tabPage9.Text = "tabPage9"; this.tabPage9.UseVisualStyleBackColor = true; @@ -189,7 +192,7 @@ namespace Sunny.UI.Demo // this.tabPage10.Location = new System.Drawing.Point(0, 40); this.tabPage10.Name = "tabPage10"; - this.tabPage10.Size = new System.Drawing.Size(670, 143); + this.tabPage10.Size = new System.Drawing.Size(200, 60); this.tabPage10.TabIndex = 5; this.tabPage10.Text = "tabPage10"; this.tabPage10.UseVisualStyleBackColor = true; @@ -198,7 +201,7 @@ namespace Sunny.UI.Demo // this.tabPage11.Location = new System.Drawing.Point(0, 40); this.tabPage11.Name = "tabPage11"; - this.tabPage11.Size = new System.Drawing.Size(670, 143); + this.tabPage11.Size = new System.Drawing.Size(200, 60); this.tabPage11.TabIndex = 6; this.tabPage11.Text = "tabPage11"; this.tabPage11.UseVisualStyleBackColor = true; @@ -207,7 +210,7 @@ namespace Sunny.UI.Demo // this.tabPage12.Location = new System.Drawing.Point(0, 40); this.tabPage12.Name = "tabPage12"; - this.tabPage12.Size = new System.Drawing.Size(670, 143); + this.tabPage12.Size = new System.Drawing.Size(200, 60); this.tabPage12.TabIndex = 7; this.tabPage12.Text = "tabPage12"; this.tabPage12.UseVisualStyleBackColor = true; @@ -216,7 +219,7 @@ namespace Sunny.UI.Demo // this.tabPage13.Location = new System.Drawing.Point(0, 40); this.tabPage13.Name = "tabPage13"; - this.tabPage13.Size = new System.Drawing.Size(670, 143); + this.tabPage13.Size = new System.Drawing.Size(200, 60); this.tabPage13.TabIndex = 8; this.tabPage13.Text = "tabPage13"; this.tabPage13.UseVisualStyleBackColor = true; diff --git a/SunnyUI.Demo/Controls/FTabControl.cs b/SunnyUI.Demo/Controls/FTabControl.cs index 3324ede7..fd164f3d 100644 --- a/SunnyUI.Demo/Controls/FTabControl.cs +++ b/SunnyUI.Demo/Controls/FTabControl.cs @@ -5,6 +5,8 @@ public FTabControl() { InitializeComponent(); + + uiTabControl1.SetTipsText(tabPage2, "6"); } private bool uiTabControl1_BeforeRemoveTabPage(object sender, int index) diff --git a/SunnyUI/Controls/UIHeaderButton.cs b/SunnyUI/Controls/UIHeaderButton.cs index 84241aad..ef30ea1c 100644 --- a/SunnyUI/Controls/UIHeaderButton.cs +++ b/SunnyUI/Controls/UIHeaderButton.cs @@ -22,6 +22,7 @@ * 2021-06-22: V3.0.4 增加ShowSelected,是否显示选中状态 * 2021-09-21: V3.0.7 增加Disabled颜色 * 2021-12-07: V3.0.9 更改图片自动刷新 + * 2022-01-02: V3.0.9 增加角标 ******************************************************************************/ using System; @@ -65,6 +66,90 @@ namespace Sunny.UI rectDisableColor = UIStyles.GetStyleColor(UIStyle.Blue).RectDisableColor; } + private bool showTips = false; + + [Description("是否显示角标"), Category("SunnyUI")] + [DefaultValue(false)] + public bool ShowTips + { + get + { + return showTips; + } + set + { + if (showTips != value) + { + showTips = value; + Invalidate(); + } + } + } + + private string tipsText = ""; + + [Description("角标文字"), Category("SunnyUI")] + [DefaultValue("")] + public string TipsText + { + get { return tipsText; } + set + { + if (tipsText != value) + { + tipsText = value; + if (ShowTips) + { + Invalidate(); + } + } + } + } + + private Color tipsColor = Color.Red; + + [Description("角标背景颜色"), Category("SunnyUI")] + [DefaultValue(typeof(Color), "Red")] + public Color TipsColor + { + get => tipsColor; + set + { + tipsColor = value; + Invalidate(); + } + } + + private Color tipsForeColor = Color.White; + + [DefaultValue(typeof(Color), "White"), Category("SunnyUI"), Description("角标文字颜色")] + public Color TipsForeColor + { + get => tipsForeColor; + set + { + tipsForeColor = value; + Invalidate(); + } + } + + private Font tipsFont = UIFontColor.SubFont(); + + [Description("角标文字字体"), Category("SunnyUI")] + [DefaultValue(typeof(Font), "微软雅黑, 9pt")] + public Font TipsFont + { + get { return tipsFont; } + set + { + if (!tipsFont.Equals(value)) + { + tipsFont = value; + Invalidate(); + } + } + } + private bool isClick; public void PerformClick() @@ -599,6 +684,33 @@ namespace Sunny.UI } break; } + + if (Enabled && ShowTips && !string.IsNullOrEmpty(TipsText)) + { + e.Graphics.SetHighQuality(); + sf = e.Graphics.MeasureString(TipsText, TempFont); + float sfMax = Math.Max(sf.Width, sf.Height); + float x = Width - 1 - 2 - sfMax; + float y = 1 + 1; + e.Graphics.FillEllipse(TipsColor, x, y, sfMax, sfMax); + e.Graphics.DrawString(TipsText, TempFont, TipsForeColor, x + sfMax / 2.0f - sf.Width / 2.0f, y + sfMax / 2.0f - sf.Height / 2.0f); + } + } + + Font tmpFont; + + private Font TempFont + { + get + { + if (tmpFont == null || !tmpFont.Size.EqualsFloat(TipsFont.DPIScaleFontSize())) + { + tmpFont?.Dispose(); + tmpFont = TipsFont.DPIScaleFont(); + } + + return tmpFont; + } } [DefaultValue(null)] diff --git a/SunnyUI/Controls/UINavMenuHelper.cs b/SunnyUI/Controls/UINavMenuHelper.cs index 5d78963d..c0012a66 100644 --- a/SunnyUI/Controls/UINavMenuHelper.cs +++ b/SunnyUI/Controls/UINavMenuHelper.cs @@ -191,6 +191,18 @@ namespace Sunny.UI } } + public void SetTipsText(int pageIndex, string tipsText) + { + TabPage tabPage = CreateTabIfNotExists(pageIndex); + tabControl.SetTipsText(tabPage, tipsText); + } + + public void SetTipsText(Guid pageGuid, string tipsText) + { + TabPage tabPage = CreateTabIfNotExists(pageGuid); + tabControl.SetTipsText(tabPage, tipsText); + } + public UIPage AddPage(int pageIndex, UIPage page) { page.PageIndex = pageIndex; diff --git a/SunnyUI/Controls/UITabControl.cs b/SunnyUI/Controls/UITabControl.cs index 81bf27af..bb1b07ab 100644 --- a/SunnyUI/Controls/UITabControl.cs +++ b/SunnyUI/Controls/UITabControl.cs @@ -23,10 +23,12 @@ * 2021-06-08: V3.0.4 Tab页标题选中高亮颜色增加可调整高度 * 2021-07-14: V3.0.5 支持Tab在下方显示 * 2021-08-14: V3.0.6 增加DisposeTabPageAfterRemove标志,移除TabPage后,是否自动销毁TabPage + * 2022-01-02: V3.0.9 增加角标 ******************************************************************************/ using Sunny.UI.Win32; using System; +using System.Collections.Concurrent; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; @@ -62,6 +64,65 @@ namespace Sunny.UI timer.Tick += Timer_Tick; } + private ConcurrentDictionary TipsTexts = new ConcurrentDictionary(); + + public void SetTipsText(TabPage tabPage, string tipsText) + { + if (TipsTexts.ContainsKey(tabPage)) + TipsTexts[tabPage] = tipsText; + else + TipsTexts.TryAdd(tabPage, tipsText); + } + + private string GetTipsText(TabPage tabPage) + { + return TipsTexts.ContainsKey(tabPage) ? TipsTexts[tabPage] : string.Empty; + } + + private Color tipsColor = Color.Red; + + [Description("角标背景颜色"), Category("SunnyUI")] + [DefaultValue(typeof(Color), "Red")] + public Color TipsColor + { + get => tipsColor; + set + { + tipsColor = value; + Invalidate(); + } + } + + private Color tipsForeColor = Color.White; + + [DefaultValue(typeof(Color), "White"), Category("SunnyUI"), Description("角标文字颜色")] + public Color TipsForeColor + { + get => tipsForeColor; + set + { + tipsForeColor = value; + Invalidate(); + } + } + + private Font tipsFont = UIFontColor.SubFont(); + + [Description("角标文字字体"), Category("SunnyUI")] + [DefaultValue(typeof(Font), "微软雅黑, 9pt")] + public Font TipsFont + { + get { return tipsFont; } + set + { + if (!tipsFont.Equals(value)) + { + tipsFont = value; + Invalidate(); + } + } + } + [Browsable(false)] public bool IsScaled { get; private set; } @@ -135,6 +196,10 @@ namespace Sunny.UI public UIPage GetPage(Guid guid) => Helper.GetPage(guid); + public void SetTipsText(int pageIndex, string tipsText) => Helper.SetTipsText(pageIndex, tipsText); + + public void SetTipsText(Guid guid, string tipsText) => Helper.SetTipsText(guid, tipsText); + public void AddPages(params UIPage[] pages) { foreach (var page in pages) AddPage(page); @@ -475,6 +540,7 @@ namespace Sunny.UI { TabRect = new Rectangle(GetTabRect(index).Location.X - 2, GetTabRect(index).Location.Y + 2, ItemSize.Width, ItemSize.Height); } + Bitmap bmp = new Bitmap(TabRect.Width, TabRect.Height); Graphics g = Graphics.FromImage(bmp); @@ -528,6 +594,20 @@ namespace Sunny.UI } } + string TipsText = GetTipsText(TabPages[index]); + if (Enabled && TipsText.IsValid()) + { + g.SetHighQuality(); + sf = g.MeasureString(TipsText, TempFont); + float sfMax = Math.Max(sf.Width, sf.Height); + float x = TabRect.Width - 1 - 2 - sfMax; + if (showActiveCloseButton || ShowCloseButton) + x -= 24; + float y = 1 + 1; + g.FillEllipse(TipsColor, x, y, sfMax, sfMax); + g.DrawString(TipsText, TempFont, TipsForeColor, x + sfMax / 2.0f - sf.Width / 2.0f, y + sfMax / 2.0f - sf.Height / 2.0f); + } + if (RightToLeftLayout && RightToLeft == RightToLeft.Yes) { bmp = bmp.HorizontalFlip(); @@ -538,6 +618,22 @@ namespace Sunny.UI } } + Font tmpFont; + + private Font TempFont + { + get + { + if (tmpFont == null || !tmpFont.Size.EqualsFloat(TipsFont.DPIScaleFontSize())) + { + tmpFont?.Dispose(); + tmpFont = TipsFont.DPIScaleFont(); + } + + return tmpFont; + } + } + protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e);