diff --git a/.gitignore b/.gitignore index e829ebaeabd679dff4ac6753f5b5d50768699a52..4d496a0845dc4ae164519f896aa3b387c8cae40f 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ /HZH_Controls/Help /HZH_Controls/HZH_Controls.sln.GhostDoc.xml /HZH_Controls/.vs/ +/.vs/hzh_control/v17 diff --git a/HZH_Controls/HZH_Controls/Controls/UCControlBase.cs b/HZH_Controls/HZH_Controls/Controls/UCControlBase.cs index b9d84a903bb28ccb54a442e1a5b5f08487096887..02749b7c27cc74046044d78930236e3980482bd8 100644 --- a/HZH_Controls/HZH_Controls/Controls/UCControlBase.cs +++ b/HZH_Controls/HZH_Controls/Controls/UCControlBase.cs @@ -45,12 +45,19 @@ namespace HZH_Controls.Controls /// The corner radius /// private int _cornerRadius = 24; - - /// - /// The is show rect + /// 标记上一次修改Region的时候bounds,防止不停重绘 /// - private bool _isShowRect = false; + private Rectangle bounds_reg; + /// + /// 标记上一次修改Region的时候radius,防止不停重绘 + /// + private int radius_reg; + + /// + /// The is show rect + /// + private bool _isShowRect = false; /// /// The rect color @@ -192,17 +199,20 @@ namespace HZH_Controls.Controls { if (this.Visible) { - if (this._isRadius) - { - this.SetWindowRegion(); - } - else + if (NeedSetRegion()) { - //关闭圆角后显示为原矩形 - GraphicsPath g = new GraphicsPath(); - g.AddRectangle(base.ClientRectangle); - g.CloseFigure(); - base.Region = new Region(g); + if (this._isRadius) + { + this.SetWindowRegion(); + } + else + { + //关闭圆角后显示为原矩形 + GraphicsPath g = new GraphicsPath(); + g.AddRectangle(base.ClientRectangle); + g.CloseFigure(); + base.Region = new Region(g); + } } GraphicsPath graphicsPath = new GraphicsPath(); @@ -235,10 +245,27 @@ namespace HZH_Controls.Controls base.OnPaint(e); } - /// - /// Sets the window region. - /// - private void SetWindowRegion() + private bool NeedSetRegion() + { + if (this.bounds_reg != this.Bounds) + { + this.bounds_reg = this.Bounds; + this.radius_reg = this.ConerRadius; + return true; + } + if (this.radius_reg != this.ConerRadius) + { + this.bounds_reg = this.Bounds; + this.radius_reg = this.ConerRadius; + return true; + } + return false; + } + + /// + /// Sets the window region. + /// + private void SetWindowRegion() { GraphicsPath path = new GraphicsPath(); Rectangle rect = new Rectangle(-1, -1, base.Width + 1, base.Height);