From 88d9aa2d441ee3e6d726e92f39d991191a3ea2ca Mon Sep 17 00:00:00 2001 From: WMJ Date: Mon, 26 Jun 2023 10:59:18 +0800 Subject: [PATCH] ! Tweak style of buttons on symbol list --- Codist/Controls/SymbolMenu.cs | 13 +++++-------- Codist/Controls/ThemedButton.cs | 6 ++++++ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/Codist/Controls/SymbolMenu.cs b/Codist/Controls/SymbolMenu.cs index c0158824..db3725f0 100644 --- a/Codist/Controls/SymbolMenu.cs +++ b/Codist/Controls/SymbolMenu.cs @@ -29,17 +29,14 @@ public SymbolMenu(SemanticContext semanticContext, SymbolListType listType) : ba new Separator() } }; - HeaderButtons = new StackPanel { - Orientation = Orientation.Horizontal, - Children = { - new ThemedButton(ThemeHelper.GetImage(IconIds.TogglePinning), R.CMD_Pin, TogglePinButton), + HeaderButtons = new ThemedControlGroup() + .AddRange( + new ThemedToggleButton(IconIds.TogglePinning, R.CMD_Pin, TogglePinButton), new ThemedButton(IconIds.Close, R.CMD_Close, () => { var a = _ExternalAdornment; a.RemoveAndDispose(this); a.FocusOnTextView(); - }) - } - }; + })); MouseLeftButtonUp += MenuItemSelect; _ExternalAdornment.MakeDraggable(this); } @@ -59,7 +56,7 @@ public override void Dispose() { } void TogglePinButton(object sender, RoutedEventArgs e) { - ((ThemedButton)e.Source).Content = ThemeHelper.GetImage((IsPinned = !IsPinned) ? IconIds.Pin : IconIds.Unpin); + ((ThemedToggleButton)e.Source).Content = ThemeHelper.GetImage((IsPinned = !IsPinned) ? IconIds.Pin : IconIds.Unpin); } public void Show(UIElement relativeElement = null) { diff --git a/Codist/Controls/ThemedButton.cs b/Codist/Controls/ThemedButton.cs index dc902a83..7128fe93 100644 --- a/Codist/Controls/ThemedButton.cs +++ b/Codist/Controls/ThemedButton.cs @@ -124,6 +124,12 @@ public ThemedToggleButton(int imageId, string toolTip) { this.ReferenceCrispImageBackground(EnvironmentColors.MainWindowActiveCaptionColorKey); } + public ThemedToggleButton(int imageId, string toolTip, RoutedEventHandler changedHandler) + : this(imageId, toolTip) { + Checked += changedHandler; + Unchecked += changedHandler; + } + public TextBlock Text { get => _Text; set {