From 004f422df146d1074298628261eda2ce82d26650 Mon Sep 17 00:00:00 2001 From: Sunny Date: Thu, 25 Aug 2022 15:20:50 +0800 Subject: [PATCH] =?UTF-8?q?*=20UIButton:=20=E5=A2=9E=E5=8A=A0=E5=90=8C?= =?UTF-8?q?=E4=B8=80=E4=B8=AA=E5=AE=B9=E5=99=A8=E7=9A=84=E7=9B=B8=E5=90=8C?= =?UTF-8?q?GroupIndex=E7=9A=84=E6=8C=89=E9=92=AE=E6=8E=A7=E4=BB=B6?= =?UTF-8?q?=E7=9A=84Selected=E5=8D=95=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SunnyUI/Controls/UIButton.cs | 38 ++++++++++++++++++++++++++++++++++++ SunnyUI/SunnyUI.csproj | 13 ++++++++++++ 2 files changed, 51 insertions(+) diff --git a/SunnyUI/Controls/UIButton.cs b/SunnyUI/Controls/UIButton.cs index 0ee2f564..4c957cc5 100644 --- a/SunnyUI/Controls/UIButton.cs +++ b/SunnyUI/Controls/UIButton.cs @@ -26,9 +26,11 @@ * 2022-02-26: V3.1.1 增加了AutoSize属性 * 2022-03-19: V3.1.1 重构主题配色 * 2022-03-31: V3.1.2 是否显示浅色背景 + * 2022-08-25: V3.2.3 增加同一个容器的相同GroupIndex的按钮控件的Selected单选 ******************************************************************************/ using System; +using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Drawing.Drawing2D; @@ -352,6 +354,38 @@ namespace Sunny.UI { selected = value; Invalidate(); + + if (value && Parent != null) + { + if (this is UISymbolButton) + { + List buttons = Parent.GetControls(); + + foreach (var box in buttons) + { + if (box == this) continue; + if (box.GroupIndex != GroupIndex) continue; + if (box.Selected) box.Selected = false; + } + + return; + } + + if (this is UIButton) + { + List buttons = Parent.GetControls(); + + foreach (var box in buttons) + { + if (box is UISymbolButton) continue; + if (box == this) continue; + if (box.GroupIndex != GroupIndex) continue; + if (box.Selected) box.Selected = false; + } + + return; + } + } } } } @@ -665,5 +699,9 @@ namespace Sunny.UI [DefaultValue(false)] [Description("显示激活时边框线"), Category("SunnyUI")] public bool ShowFocusLine { get; set; } + + [DefaultValue(0)] + [Description("分组编号"), Category("SunnyUI")] + public int GroupIndex { get; set; } } } \ No newline at end of file diff --git a/SunnyUI/SunnyUI.csproj b/SunnyUI/SunnyUI.csproj index e01cc89c..4ecebda9 100644 --- a/SunnyUI/SunnyUI.csproj +++ b/SunnyUI/SunnyUI.csproj @@ -84,6 +84,11 @@ True Resources.resx + + True + True + Settings.settings + @@ -94,4 +99,12 @@ + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + +