diff --git a/Ink Canvas/InkCanvasForClass.csproj b/Ink Canvas/InkCanvasForClass.csproj index 45a51123..2de08462 100644 --- a/Ink Canvas/InkCanvasForClass.csproj +++ b/Ink Canvas/InkCanvasForClass.csproj @@ -329,6 +329,7 @@ + @@ -621,7 +622,6 @@ - diff --git a/Ink Canvas/MainWindow.xaml b/Ink Canvas/MainWindow.xaml index 9304e290..07ac4d68 100644 --- a/Ink Canvas/MainWindow.xaml +++ b/Ink Canvas/MainWindow.xaml @@ -3986,7 +3986,7 @@ CornerRadius="{Binding ElementName=BorderImageSelectionControl, Path=CornerRadius}" Width="40" MouseDown="Border_MouseDown" MouseUp="BorderImageClone_MouseUp"> - @@ -4002,7 +4002,7 @@ Visibility="{Binding Visibility, ElementName=GridBackgroundCover}"> - @@ -4045,14 +4045,14 @@ - - - + /// 刷新图片选中栏图标 + /// + private void RefreshImageSelectionIcons() + { + try + { + if (BorderImageSelectionControl != null) + { + // 强制刷新图片选中栏的视觉状态 + BorderImageSelectionControl.InvalidateVisual(); + + // 刷新图片选中栏内的所有图标 + var viewbox = BorderImageSelectionControl.Child as Viewbox; + if (viewbox?.Child is ui.SimpleStackPanel stackPanel) + { + RefreshImageSelectionIconsRecursive(stackPanel); + } + } + } + catch (Exception) + { + // 忽略异常,确保主题切换不会因为图标刷新失败而中断 + } + } + + /// + /// 递归刷新图片选中栏内的图标 + /// + private void RefreshImageSelectionIconsRecursive(System.Windows.Controls.Panel panel) + { + try + { + foreach (var child in panel.Children) + { + if (child is Image image) + { + // 强制刷新图像 + image.InvalidateVisual(); + } + else if (child is System.Windows.Controls.Panel childPanel) + { + // 递归处理子面板 + RefreshImageSelectionIconsRecursive(childPanel); + } + else if (child is Border border && border.Child is System.Windows.Controls.Panel borderPanel) + { + // 处理Border内的面板 + RefreshImageSelectionIconsRecursive(borderPanel); + } + else if (child is Grid grid) + { + // 处理Grid内的子元素 + foreach (var gridChild in grid.Children) + { + if (gridChild is Image gridImage) + { + gridImage.InvalidateVisual(); + } + } + } + } + } + catch (Exception) + { + // 忽略异常 + } + } } } \ No newline at end of file diff --git a/Ink Canvas/Resources/Styles/Dark.xaml b/Ink Canvas/Resources/Styles/Dark.xaml index a6be59a2..25f52bfd 100644 --- a/Ink Canvas/Resources/Styles/Dark.xaml +++ b/Ink Canvas/Resources/Styles/Dark.xaml @@ -57,6 +57,13 @@ + + + + + + + diff --git a/Ink Canvas/Resources/Styles/Light.xaml b/Ink Canvas/Resources/Styles/Light.xaml index f9d66cfb..6c7eb63b 100644 --- a/Ink Canvas/Resources/Styles/Light.xaml +++ b/Ink Canvas/Resources/Styles/Light.xaml @@ -57,6 +57,13 @@ + + + + + + +