diff --git a/Bin/net40/SunnyUI.Demo.exe b/Bin/net40/SunnyUI.Demo.exe index e2105d1c..ab451f39 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 ae794e89..8b20c710 100644 Binary files a/Bin/net40/SunnyUI.dll and b/Bin/net40/SunnyUI.dll differ diff --git a/Bin/net45/SunnyUI.dll b/Bin/net45/SunnyUI.dll index 66c6b586..7d92a66d 100644 Binary files a/Bin/net45/SunnyUI.dll and b/Bin/net45/SunnyUI.dll differ diff --git a/Bin/net5.0-windows/SunnyUI.dll b/Bin/net5.0-windows/SunnyUI.dll index de071e0a..6f5f48b0 100644 Binary files a/Bin/net5.0-windows/SunnyUI.dll and b/Bin/net5.0-windows/SunnyUI.dll differ diff --git a/Bin/net5.0-windows/ref/SunnyUI.dll b/Bin/net5.0-windows/ref/SunnyUI.dll index d3bfa415..37d8c117 100644 Binary files a/Bin/net5.0-windows/ref/SunnyUI.dll and b/Bin/net5.0-windows/ref/SunnyUI.dll differ diff --git a/Bin/netcoreapp3.1/SunnyUI.dll b/Bin/netcoreapp3.1/SunnyUI.dll index 0fb48dfc..58c379cb 100644 Binary files a/Bin/netcoreapp3.1/SunnyUI.dll and b/Bin/netcoreapp3.1/SunnyUI.dll differ diff --git a/SunnyUI.Demo/Controls/FFlowLayoutPanel.Designer.cs b/SunnyUI.Demo/Controls/FFlowLayoutPanel.Designer.cs index 5ece3b96..e96d52e5 100644 --- a/SunnyUI.Demo/Controls/FFlowLayoutPanel.Designer.cs +++ b/SunnyUI.Demo/Controls/FFlowLayoutPanel.Designer.cs @@ -31,6 +31,8 @@ namespace Sunny.UI.Demo { this.uiButton1 = new Sunny.UI.UIButton(); this.uiFlowLayoutPanel1 = new Sunny.UI.UIFlowLayoutPanel(); + this.uiButton2 = new Sunny.UI.UIButton(); + this.uiButton3 = new Sunny.UI.UIButton(); this.SuspendLayout(); // // uiButton1 @@ -42,7 +44,7 @@ namespace Sunny.UI.Demo this.uiButton1.Name = "uiButton1"; this.uiButton1.Size = new System.Drawing.Size(100, 35); this.uiButton1.TabIndex = 11; - this.uiButton1.Text = "AddControl"; + this.uiButton1.Text = "增加"; this.uiButton1.Click += new System.EventHandler(this.uiButton1_Click); // // uiFlowLayoutPanel1 @@ -53,16 +55,43 @@ namespace Sunny.UI.Demo this.uiFlowLayoutPanel1.MinimumSize = new System.Drawing.Size(1, 1); this.uiFlowLayoutPanel1.Name = "uiFlowLayoutPanel1"; this.uiFlowLayoutPanel1.Padding = new System.Windows.Forms.Padding(2); - this.uiFlowLayoutPanel1.Size = new System.Drawing.Size(249, 390); + this.uiFlowLayoutPanel1.Size = new System.Drawing.Size(334, 390); this.uiFlowLayoutPanel1.TabIndex = 10; - this.uiFlowLayoutPanel1.Text = "uiFlowLayoutPanel1"; + this.uiFlowLayoutPanel1.Text = "`"; this.uiFlowLayoutPanel1.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter; // + // uiButton2 + // + this.uiButton2.Cursor = System.Windows.Forms.Cursors.Hand; + this.uiButton2.Font = new System.Drawing.Font("微软雅黑", 12F); + this.uiButton2.Location = new System.Drawing.Point(264, 462); + this.uiButton2.MinimumSize = new System.Drawing.Size(1, 1); + this.uiButton2.Name = "uiButton2"; + this.uiButton2.Size = new System.Drawing.Size(100, 35); + this.uiButton2.TabIndex = 12; + this.uiButton2.Text = "清除"; + this.uiButton2.Click += new System.EventHandler(this.uiButton2_Click); + // + // uiButton3 + // + this.uiButton3.Cursor = System.Windows.Forms.Cursors.Hand; + this.uiButton3.Enabled = false; + this.uiButton3.Font = new System.Drawing.Font("微软雅黑", 12F); + this.uiButton3.Location = new System.Drawing.Point(147, 462); + this.uiButton3.MinimumSize = new System.Drawing.Size(1, 1); + this.uiButton3.Name = "uiButton3"; + this.uiButton3.Size = new System.Drawing.Size(100, 35); + this.uiButton3.TabIndex = 13; + this.uiButton3.Text = "移除"; + this.uiButton3.Click += new System.EventHandler(this.uiButton3_Click); + // // FFlowLayoutPanel // this.AllowShowTitle = true; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; this.ClientSize = new System.Drawing.Size(800, 539); + this.Controls.Add(this.uiButton3); + this.Controls.Add(this.uiButton2); this.Controls.Add(this.uiButton1); this.Controls.Add(this.uiFlowLayoutPanel1); this.Name = "FFlowLayoutPanel"; @@ -78,5 +107,7 @@ namespace Sunny.UI.Demo private UIButton uiButton1; private UIFlowLayoutPanel uiFlowLayoutPanel1; + private UIButton uiButton2; + private UIButton uiButton3; } } \ No newline at end of file diff --git a/SunnyUI.Demo/Controls/FFlowLayoutPanel.cs b/SunnyUI.Demo/Controls/FFlowLayoutPanel.cs index 6bfa6df4..b0ae7614 100644 --- a/SunnyUI.Demo/Controls/FFlowLayoutPanel.cs +++ b/SunnyUI.Demo/Controls/FFlowLayoutPanel.cs @@ -13,18 +13,49 @@ uiFlowLayoutPanel1.Clear(); index = 0; - for (int i = 0; i < 30; i++) + for (int i = 0; i < 20; i++) { uiButton1.PerformClick(); } } private int index; + UIButton btn; private void uiButton1_Click(object sender, System.EventArgs e) { - UIButton btn = new UIButton(); + btn = new UIButton(); btn.Text = "Button" + index++.ToString("D2"); - uiFlowLayoutPanel1.AddControl(btn); + //可以用原生方法Controls.Add + uiFlowLayoutPanel1.Controls.Add(btn); + //或者封装的方法Add + //uiFlowLayoutPanel1.Add(btn); + + uiButton3.Enabled = true; + } + + private void uiButton2_Click(object sender, System.EventArgs e) + { + //清除用Clear方法 + uiFlowLayoutPanel1.Clear(); + //或者用 + //uiFlowLayoutPanel1.Panel.Controls.Clear(); + + uiButton3.Enabled = false; + } + + private void uiButton3_Click(object sender, System.EventArgs e) + { + if (btn != null) + { + //移除用Remove方法 + uiFlowLayoutPanel1.Remove(btn); + //或者用 + //uiFlowLayoutPanel1.Panel.Controls.Remove(btn); + + btn = null; + } + + uiButton3.Enabled = false; } } } diff --git a/SunnyUI.Net5.Demo/bin/net5.0-windows/SunnyUI.Common.dll b/SunnyUI.Net5.Demo/bin/net5.0-windows/SunnyUI.Common.dll deleted file mode 100644 index 6741d9f0..00000000 Binary files a/SunnyUI.Net5.Demo/bin/net5.0-windows/SunnyUI.Common.dll and /dev/null differ diff --git a/SunnyUI.Net5.Demo/bin/net5.0-windows/SunnyUI.Net5.Demo.deps.json b/SunnyUI.Net5.Demo/bin/net5.0-windows/SunnyUI.Net5.Demo.deps.json deleted file mode 100644 index beb7d423..00000000 --- a/SunnyUI.Net5.Demo/bin/net5.0-windows/SunnyUI.Net5.Demo.deps.json +++ /dev/null @@ -1,59 +0,0 @@ -{ - "runtimeTarget": { - "name": ".NETCoreApp,Version=v5.0", - "signature": "" - }, - "compilationOptions": {}, - "targets": { - ".NETCoreApp,Version=v5.0": { - "SunnyUI.Net5.Demo/3.0.5": { - "dependencies": { - "SunnyUI": "3.0.5" - }, - "runtime": { - "SunnyUI.Net5.Demo.dll": {} - } - }, - "SunnyUI/3.0.5": { - "dependencies": { - "SunnyUI.Common": "3.0.5" - }, - "runtime": { - "lib/net5.0-windows7.0/SunnyUI.dll": { - "assemblyVersion": "3.0.5.0", - "fileVersion": "3.0.5.0" - } - } - }, - "SunnyUI.Common/3.0.5": { - "runtime": { - "lib/net5.0/SunnyUI.Common.dll": { - "assemblyVersion": "3.0.5.0", - "fileVersion": "3.0.5.0" - } - } - } - } - }, - "libraries": { - "SunnyUI.Net5.Demo/3.0.5": { - "type": "project", - "serviceable": false, - "sha512": "" - }, - "SunnyUI/3.0.5": { - "type": "package", - "serviceable": true, - "sha512": "sha512-0+U39GWGWBQFmoZom+UOzuST9FxsbUol5RWZgnBLzfGDlR+O4C72HjQ38u9G/SppWBswr5+dmGvFYHBA2HS4uQ==", - "path": "sunnyui/3.0.5", - "hashPath": "sunnyui.3.0.5.nupkg.sha512" - }, - "SunnyUI.Common/3.0.5": { - "type": "package", - "serviceable": true, - "sha512": "sha512-bP9fQW8P4fJAV6FfU2Xfw3MtOduLoj/j+MRfdIn3eq9bGqDepg/w5/xqXi393Vuxvxk24eY9+5YMRVyeS+tiRg==", - "path": "sunnyui.common/3.0.5", - "hashPath": "sunnyui.common.3.0.5.nupkg.sha512" - } - } -} \ No newline at end of file diff --git a/SunnyUI.Net5.Demo/bin/net5.0-windows/SunnyUI.Net5.Demo.dll b/SunnyUI.Net5.Demo/bin/net5.0-windows/SunnyUI.Net5.Demo.dll deleted file mode 100644 index 27dca2cf..00000000 Binary files a/SunnyUI.Net5.Demo/bin/net5.0-windows/SunnyUI.Net5.Demo.dll and /dev/null differ diff --git a/SunnyUI.Net5.Demo/bin/net5.0-windows/SunnyUI.Net5.Demo.exe b/SunnyUI.Net5.Demo/bin/net5.0-windows/SunnyUI.Net5.Demo.exe deleted file mode 100644 index ca410760..00000000 Binary files a/SunnyUI.Net5.Demo/bin/net5.0-windows/SunnyUI.Net5.Demo.exe and /dev/null differ diff --git a/SunnyUI.Net5.Demo/bin/net5.0-windows/SunnyUI.Net5.Demo.runtimeconfig.dev.json b/SunnyUI.Net5.Demo/bin/net5.0-windows/SunnyUI.Net5.Demo.runtimeconfig.dev.json deleted file mode 100644 index cc6de40e..00000000 --- a/SunnyUI.Net5.Demo/bin/net5.0-windows/SunnyUI.Net5.Demo.runtimeconfig.dev.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "runtimeOptions": { - "additionalProbingPaths": [ - "C:\\Users\\Administrator\\.dotnet\\store\\|arch|\\|tfm|", - "C:\\Users\\Administrator\\.nuget\\packages" - ] - } -} \ No newline at end of file diff --git a/SunnyUI.Net5.Demo/bin/net5.0-windows/SunnyUI.Net5.Demo.runtimeconfig.json b/SunnyUI.Net5.Demo/bin/net5.0-windows/SunnyUI.Net5.Demo.runtimeconfig.json deleted file mode 100644 index dae617c0..00000000 --- a/SunnyUI.Net5.Demo/bin/net5.0-windows/SunnyUI.Net5.Demo.runtimeconfig.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "runtimeOptions": { - "tfm": "net5.0", - "framework": { - "name": "Microsoft.WindowsDesktop.App", - "version": "5.0.0" - } - } -} \ No newline at end of file diff --git a/SunnyUI.Net5.Demo/bin/net5.0-windows/SunnyUI.dll b/SunnyUI.Net5.Demo/bin/net5.0-windows/SunnyUI.dll deleted file mode 100644 index 6945d7f3..00000000 Binary files a/SunnyUI.Net5.Demo/bin/net5.0-windows/SunnyUI.dll and /dev/null differ diff --git a/SunnyUI.Net5.Demo/bin/net5.0-windows/ref/SunnyUI.Net5.Demo.dll b/SunnyUI.Net5.Demo/bin/net5.0-windows/ref/SunnyUI.Net5.Demo.dll deleted file mode 100644 index 87cb2778..00000000 Binary files a/SunnyUI.Net5.Demo/bin/net5.0-windows/ref/SunnyUI.Net5.Demo.dll and /dev/null differ diff --git a/SunnyUI/Controls/UIFlowLayoutPanel.cs b/SunnyUI/Controls/UIFlowLayoutPanel.cs index 14fc05d2..6d4b4ec6 100644 --- a/SunnyUI/Controls/UIFlowLayoutPanel.cs +++ b/SunnyUI/Controls/UIFlowLayoutPanel.cs @@ -58,11 +58,108 @@ namespace Sunny.UI timer.Start(); } - ~UIFlowLayoutPanel() + protected override void Dispose(bool disposing) { + base.Dispose(disposing); timer.Stop(); } + protected override void OnControlAdded(ControlEventArgs e) + { + if (e.Control is UIHorScrollBarEx bar1) + { + if (bar1.TagString == "79E1E7DD-3E4D-916B-C8F1-F45B579C290C") + { + base.OnControlAdded(e); + return; + } + } + + if (e.Control is UIVerScrollBarEx bar2) + { + if (bar2.TagString == "63FD1249-41D3-E08A-F8F5-CC41CC30FD03") + { + base.OnControlAdded(e); + return; + } + } + + if (e.Control is FlowLayoutPanel panel) + { + if (panel.Tag.ToString() == "69605093-6397-AD32-9F69-3C29F642F87E") + { + base.OnControlAdded(e); + return; + } + } + + if (Panel != null && !IsDesignMode) + { + Add(e.Control); + } + else + { + base.OnControlAdded(e); + if (Panel != null) Panel.SendToBack(); + } + } + + public void Remove(Control control) + { + if (Panel != null) + { + if (Panel.Controls.Contains(control)) + Panel.Controls.Remove(control); + } + } + + public void Add(Control control) + { + if (control is IStyleInterface ctrl) + { + if (!ctrl.StyleCustomMode) ctrl.Style = Style; + } + + if (Panel != null) + { + Panel.Controls.Add(control); + } + } + + [Obsolete("此方法已优化,用Add代替")] + public void AddControl(Control control) + { + if (control is IStyleInterface ctrl) + { + if (!ctrl.StyleCustomMode) ctrl.Style = Style; + } + + if (Panel != null) + { + Panel.Controls.Add(control); + } + } + + [Obsolete("此方法已优化,用Remove代替")] + public void RemoveControl(Control control) + { + if (Panel != null) + { + if (Panel.Controls.Contains(control)) + Panel.Controls.Remove(control); + } + } + + public void Clear() + { + foreach (Control control in Panel.Controls) + { + control.Dispose(); + } + + Panel.Controls.Clear(); + } + private void Timer_Tick(object sender, EventArgs e) { if (VBar.Maximum != Panel.VerticalScroll.Maximum || @@ -145,31 +242,6 @@ namespace Sunny.UI } } - public void AddControl(Control control) - { - if (control is IStyleInterface ctrl) - { - if (!ctrl.StyleCustomMode) ctrl.Style = Style; - } - - Panel.Controls.Add(control); - } - - public void RemoveControl(Control control) - { - Panel.Controls.Remove(control); - } - - public void Clear() - { - foreach (Control control in Panel.Controls) - { - control.Dispose(); - } - - Panel.Controls.Clear(); - } - private void Panel_MouseClick(object sender, MouseEventArgs e) { Panel.Focus(); @@ -277,11 +349,12 @@ namespace Sunny.UI this.flowLayoutPanel.Name = "flowLayoutPanel"; this.flowLayoutPanel.Size = new System.Drawing.Size(429, 383); this.flowLayoutPanel.TabIndex = 0; + this.flowLayoutPanel.Tag = "69605093-6397-AD32-9F69-3C29F642F87E"; // // VBar // this.VBar.BoundsHeight = 10; - this.VBar.Font = new System.Drawing.Font("微软雅黑", 12F); + this.VBar.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); this.VBar.LargeChange = 10; this.VBar.Location = new System.Drawing.Point(410, 5); this.VBar.Maximum = 100; @@ -289,6 +362,7 @@ namespace Sunny.UI this.VBar.Name = "VBar"; this.VBar.Size = new System.Drawing.Size(18, 377); this.VBar.TabIndex = 1; + this.VBar.TagString = "63FD1249-41D3-E08A-F8F5-CC41CC30FD03"; this.VBar.Text = "uiVerScrollBarEx1"; this.VBar.Value = 0; this.VBar.Visible = false; @@ -296,7 +370,7 @@ namespace Sunny.UI // HBar // this.HBar.BoundsWidth = 10; - this.HBar.Font = new System.Drawing.Font("微软雅黑", 12F); + this.HBar.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); this.HBar.LargeChange = 10; this.HBar.Location = new System.Drawing.Point(5, 364); this.HBar.Maximum = 100; @@ -304,6 +378,7 @@ namespace Sunny.UI this.HBar.Name = "HBar"; this.HBar.Size = new System.Drawing.Size(399, 18); this.HBar.TabIndex = 2; + this.HBar.TagString = "79E1E7DD-3E4D-916B-C8F1-F45B579C290C"; this.HBar.Text = "uiHorScrollBarEx1"; this.HBar.Value = 0; this.HBar.Visible = false; diff --git a/SunnyUI/Controls/UIFlowLayoutPanel.resx b/SunnyUI/Controls/UIFlowLayoutPanel.resx index 1af7de15..f298a7be 100644 --- a/SunnyUI/Controls/UIFlowLayoutPanel.resx +++ b/SunnyUI/Controls/UIFlowLayoutPanel.resx @@ -1,64 +1,4 @@ - - - +