From e411e00cd18478fc3460057a5ed8f88ef9210931 Mon Sep 17 00:00:00 2001 From: liuxiaoqing Date: Tue, 25 Mar 2025 15:23:56 +0800 Subject: [PATCH 1/2] fix(AvalonDock): Fix the activation logic of selected items in the navigation window -Optimized the processing logic for changes in the SelectedDocument and SelectedAnchorable properties -Added left mouse button press event handling to ensure that users can correctly select and activate items when clicking -Removed redundant conditional judgments and simplified code structure --- .../AvalonDock/Controls/NavigatorWindow.cs | 40 +++++++++++-------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/source/Components/AvalonDock/Controls/NavigatorWindow.cs b/source/Components/AvalonDock/Controls/NavigatorWindow.cs index 7deee8ca..54d028bd 100644 --- a/source/Components/AvalonDock/Controls/NavigatorWindow.cs +++ b/source/Components/AvalonDock/Controls/NavigatorWindow.cs @@ -154,18 +154,11 @@ public LayoutDocumentItem SelectedDocument /// Provides derived classes an opportunity to handle changes to the property. protected virtual void OnSelectedDocumentChanged(DependencyPropertyChangedEventArgs e) { - if (_internalSetSelectedDocument || SelectedDocument == null) + if (!_internalSetSelectedDocument && SelectedDocument != null && SelectedDocument.ActivateCommand.CanExecute(null)) { - return; - } - - if (!SelectedDocument.ActivateCommand.CanExecute(null)) - { - return; + SelectedAnchorable = null; + CloseAndActiveSelected(); } - - Close(); - SelectedDocument.ActivateCommand.Execute(null); } #endregion SelectedDocument @@ -190,13 +183,10 @@ public LayoutAnchorableItem SelectedAnchorable /// Provides derived classes an opportunity to handle changes to the property. protected virtual void OnSelectedAnchorableChanged(DependencyPropertyChangedEventArgs e) { - if (_internalSetSelectedAnchorable) return; - // TODO: What goes on here?? - var selectedAnchorable = e.NewValue as LayoutAnchorableItem; - if (SelectedAnchorable != null && SelectedAnchorable.ActivateCommand.CanExecute(null)) + if (!_internalSetSelectedAnchorable && SelectedAnchorable != null && SelectedAnchorable.ActivateCommand.CanExecute(null)) { - Close(); - SelectedAnchorable.ActivateCommand.Execute(null); + SelectedDocument = null; + CloseAndActiveSelected(); } } @@ -240,10 +230,12 @@ private void ItemContainerGenerator_StatusChanged(object sender, EventArgs e) if (isListOfDocuments) { container.IsKeyboardFocusedChanged += DocumentsItemContainer_IsKeyboardFocusedChanged; + container.PreviewMouseLeftButtonDown += DocumentsItemContainer_PreviewMouseLeftButtonDown; } else { container.IsKeyboardFocusedChanged += AnchorablesItemContainer_IsKeyboardFocusedChanged; + container.PreviewMouseLeftButtonDown += AnchorablesItemContainer_PreviewMouseLeftButtonDown; } } } @@ -262,6 +254,14 @@ private void AnchorablesItemContainer_IsKeyboardFocusedChanged(object sender, De } } + private void AnchorablesItemContainer_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e) + { + ListBoxItem item = (ListBoxItem)sender; + _internalSetSelectedAnchorable = false; + item.IsSelected = true; + _internalSetSelectedAnchorable = false; + } + private void DocumentsItemContainer_IsKeyboardFocusedChanged(object sender, DependencyPropertyChangedEventArgs e) { ListBoxItem item = (ListBoxItem)sender; @@ -273,6 +273,14 @@ private void DocumentsItemContainer_IsKeyboardFocusedChanged(object sender, Depe } } + private void DocumentsItemContainer_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e) + { + ListBoxItem item = (ListBoxItem)sender; + _internalSetSelectedDocument = false; + item.IsSelected = true; + _internalSetSelectedDocument = false; + } + /// protected override void OnKeyDown(KeyEventArgs e) { From 26225e08cfe9824cd45bdaf6739d6c7d6dbba9bc Mon Sep 17 00:00:00 2001 From: liuxiaoqing Date: Wed, 26 Mar 2025 15:24:49 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8DVS2013.Theme=20Navigatior?= =?UTF-8?q?Window=20selectedElementDescription=20=E5=B8=83=E5=B1=80?= =?UTF-8?q?=E5=92=8CForeground?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Themes/Generic.xaml | 2546 +++++++++-------- 1 file changed, 1278 insertions(+), 1268 deletions(-) diff --git a/source/Components/AvalonDock.Themes.VS2013/Themes/Generic.xaml b/source/Components/AvalonDock.Themes.VS2013/Themes/Generic.xaml index e62e831c..fb84763e 100644 --- a/source/Components/AvalonDock.Themes.VS2013/Themes/Generic.xaml +++ b/source/Components/AvalonDock.Themes.VS2013/Themes/Generic.xaml @@ -1,23 +1,23 @@ + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:avalonDock="clr-namespace:AvalonDock;assembly=AvalonDock" + xmlns:avalonDockControls="clr-namespace:AvalonDock.Controls;assembly=AvalonDock" + xmlns:avalonDockConverters="clr-namespace:AvalonDock.Converters;assembly=AvalonDock" + xmlns:avalonDockProperties="clr-namespace:AvalonDock.Properties;assembly=AvalonDock" + xmlns:reskeys="clr-namespace:AvalonDock.Themes.VS2013.Themes" + xmlns:shell="clr-namespace:Microsoft.Windows.Shell;assembly=AvalonDock"> @@ -65,24 +65,27 @@ --> - @@ -390,69 +289,133 @@ - - - - - - - - - - - - + + + @@ -566,134 +569,134 @@ + Background="{TemplateBinding Background}" + BorderBrush="{TemplateBinding BorderBrush}" + BorderThickness="{TemplateBinding BorderThickness}"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Margin="1,1,1,0" + VerticalAlignment="Center" + DropDownContextMenu="{Binding Model.Root.Manager.AnchorableContextMenu, RelativeSource={RelativeSource TemplatedParent}}" + DropDownContextMenuDataContext="{Binding Path=LayoutItem, RelativeSource={RelativeSource TemplatedParent}}" + Focusable="False" + Style="{StaticResource AvalonDockThemeVs2013ToolButtonStyle}" + ToolTip="{x:Static avalonDockProperties:Resources.Anchorable_CxMenu_Hint}"> + x:Name="PART_ImgMenuPin" + Width="8" + Height="8" + Margin="0,0,0,1" + Data="{DynamicResource PinMenu}" + Fill="{DynamicResource {x:Static reskeys:ResourceKeys.ToolWindowCaptionButtonInactiveGlyph}}" + Stretch="Uniform" /> - - + @@ -721,9 +724,9 @@ - + @@ -811,53 +814,53 @@ + MinWidth="6" + MinHeight="6" + Orientation="{Binding Path=Model.Side, RelativeSource={RelativeSource AncestorType={x:Type avalonDockControls:LayoutAnchorSideControl}, Mode=FindAncestor}, Converter={avalonDockConverters:AnchorSideToOrientationConverter}}" /> - - - - - - - - - - + + + + + + + + + + - - + + @@ -880,95 +883,94 @@ @@ -1265,23 +1268,21 @@ - + + VerticalAlignment="Center" + Text="{Binding Title}" + TextTrimming="CharacterEllipsis" /> + VerticalAlignment="Center" + Text="{Binding Title}" + TextTrimming="CharacterEllipsis" /> @@ -1294,84 +1295,84 @@ + Command="{Binding Path=HideCommand}" + Header="{x:Static avalonDockProperties:Resources.Anchorable_Hide}" + Visibility="{Binding Path=IsEnabled, RelativeSource={RelativeSource Self}, Mode=OneWay, Converter={avalonDockConverters:BoolToVisibilityConverter}}" /> + Command="{Binding Path=CloseCommand}" + Header="{x:Static avalonDockProperties:Resources.Document_Close}" + Visibility="{Binding Path=IsEnabled, RelativeSource={RelativeSource Self}, Mode=OneWay, Converter={avalonDockConverters:BoolToVisibilityConverter}}" /> + Command="{Binding Path=NewHorizontalTabGroupCommand}" + Header="{x:Static avalonDockProperties:Resources.Document_NewHorizontalTabGroup}" + Visibility="{Binding Path=IsEnabled, RelativeSource={RelativeSource Self}, Mode=OneWay, Converter={avalonDockConverters:BoolToVisibilityConverter}}"> + Width="14" + Height="14" + VerticalAlignment="Center" + Data="{DynamicResource HTabGroup}" + Fill="{DynamicResource {x:Static reskeys:ResourceKeys.ToolWindowCaptionButtonInactiveGlyph}}" + Stretch="Uniform" /> + Command="{Binding Path=NewVerticalTabGroupCommand}" + Header="{x:Static avalonDockProperties:Resources.Document_NewVerticalTabGroup}" + Visibility="{Binding Path=IsEnabled, RelativeSource={RelativeSource Self}, Mode=OneWay, Converter={avalonDockConverters:BoolToVisibilityConverter}}"> + Width="14" + Height="14" + VerticalAlignment="Center" + Data="{DynamicResource VTabGroup}" + Fill="{DynamicResource {x:Static reskeys:ResourceKeys.ToolWindowCaptionButtonInactiveGlyph}}" + Stretch="Uniform" /> + Command="{Binding Path=MoveToNextTabGroupCommand}" + Header="{x:Static avalonDockProperties:Resources.Document_MoveToNextTabGroup}" + Visibility="{Binding Path=IsEnabled, RelativeSource={RelativeSource Self}, Mode=OneWay, Converter={avalonDockConverters:BoolToVisibilityConverter}}" /> + Command="{Binding Path=MoveToPreviousTabGroupCommand}" + Header="{x:Static avalonDockProperties:Resources.Document_MoveToPreviousTabGroup}" + Visibility="{Binding Path=IsEnabled, RelativeSource={RelativeSource Self}, Mode=OneWay, Converter={avalonDockConverters:BoolToVisibilityConverter}}" /> - - + + + @@ -2471,33 +2479,31 @@ + RadiusX="2" + RadiusY="2" + Stroke="{DynamicResource {x:Static reskeys:ResourceKeys.PanelBorderBrush}}" + StrokeThickness="1" />