* UITabControl:增加MainPage属性,显示关闭按钮时,此页面无按钮且不可关闭

This commit is contained in:
Sunny 2021-01-01 21:38:19 +08:00
parent d316efc1d3
commit 7b0f763324
7 changed files with 28 additions and 6 deletions

Binary file not shown.

Binary file not shown.

View File

@ -120,6 +120,9 @@
<metadata name="uiToolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <metadata name="uiToolTip1.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="uiToolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>52</value> <value>52</value>
</metadata> </metadata>

View File

@ -72,6 +72,7 @@
this.uiTabControl1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.uiTabControl1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.uiTabControl1.ItemSize = new System.Drawing.Size(150, 40); this.uiTabControl1.ItemSize = new System.Drawing.Size(150, 40);
this.uiTabControl1.Location = new System.Drawing.Point(30, 52); this.uiTabControl1.Location = new System.Drawing.Point(30, 52);
this.uiTabControl1.MainPage = "tabPage1";
this.uiTabControl1.MenuStyle = Sunny.UI.UIMenuStyle.Custom; this.uiTabControl1.MenuStyle = Sunny.UI.UIMenuStyle.Custom;
this.uiTabControl1.Name = "uiTabControl1"; this.uiTabControl1.Name = "uiTabControl1";
this.uiTabControl1.SelectedIndex = 0; this.uiTabControl1.SelectedIndex = 0;

View File

@ -33,7 +33,7 @@ namespace Sunny.UI
[ToolboxItem(true)] [ToolboxItem(true)]
public class UILineChart : UIChart public class UILineChart : UIChart
{ {
private bool NeedDraw; protected bool NeedDraw;
protected override void OnSizeChanged(EventArgs e) protected override void OnSizeChanged(EventArgs e)
{ {
@ -72,7 +72,7 @@ namespace Sunny.UI
private double[] YLabels; private double[] YLabels;
private double[] XLabels; private double[] XLabels;
private void CalcAxises() protected void CalcAxises()
{ {
if (Option.XAxisType == UIAxisType.DateTime) if (Option.XAxisType == UIAxisType.DateTime)
XScale = new UIDateScale(); XScale = new UIDateScale();
@ -257,7 +257,7 @@ namespace Sunny.UI
} }
} }
private void DrawSeries(Graphics g, Color color, UILineSeries series) protected virtual void DrawSeries(Graphics g, Color color, UILineSeries series)
{ {
if (series.Points.Count == 0) if (series.Points.Count == 0)
{ {

View File

@ -59,6 +59,20 @@ namespace Sunny.UI
timer.Dispose(); timer.Dispose();
} }
private string mainPage = "";
[DefaultValue(true)]
[Description("主页名称,此页面不显示关闭按钮"), Category("SunnyUI")]
public string MainPage
{
get => mainPage;
set
{
mainPage = value;
Invalidate();
}
}
private void Timer_Tick(object sender, EventArgs e) private void Timer_Tick(object sender, EventArgs e)
{ {
timer.Stop(); timer.Stop();
@ -432,7 +446,9 @@ namespace Sunny.UI
g.DrawString(TabPages[index].Text, Font, index == SelectedIndex ? tabSelectedForeColor : TabUnSelectedForeColor, textLeft, TabRect.Top + 2 + (TabRect.Height - sf.Height - 4) / 2.0f); g.DrawString(TabPages[index].Text, Font, index == SelectedIndex ? tabSelectedForeColor : TabUnSelectedForeColor, textLeft, TabRect.Top + 2 + (TabRect.Height - sf.Height - 4) / 2.0f);
var menuItem = Helper[index]; var menuItem = Helper[index];
bool showButton = menuItem == null || !menuItem.AlwaysOpen; bool show1 = TabPages[index].Text != MainPage;
bool show2 = menuItem == null || !menuItem.AlwaysOpen;
bool showButton = show1 && show2;
if (showButton) if (showButton)
{ {
@ -484,7 +500,9 @@ namespace Sunny.UI
} }
var menuItem = Helper[removeIndex]; var menuItem = Helper[removeIndex];
bool showButton = menuItem == null || !menuItem.AlwaysOpen; bool show1 = TabPages[removeIndex].Text != MainPage;
bool show2 = menuItem == null || !menuItem.AlwaysOpen;
bool showButton = show1 && show2;
if (showButton) if (showButton)
{ {
if (ShowCloseButton) if (ShowCloseButton)

View File

@ -685,7 +685,7 @@ namespace Sunny.UI
if (haveImage) if (haveImage)
{ {
if (TreeNodeSelected(e) && e.Node.SelectedImageIndex >= 0 && if (e.Node == SelectedNode && e.Node.SelectedImageIndex >= 0 &&
e.Node.SelectedImageIndex < ImageList.Images.Count) e.Node.SelectedImageIndex < ImageList.Images.Count)
e.Graphics.DrawImage(ImageList.Images[e.Node.SelectedImageIndex], imageLeft, e.Graphics.DrawImage(ImageList.Images[e.Node.SelectedImageIndex], imageLeft,
e.Bounds.Y + (e.Bounds.Height - ImageList.ImageSize.Height) / 2); e.Bounds.Y + (e.Bounds.Height - ImageList.ImageSize.Height) / 2);