Revert "优化代码"

This reverts commit 92bb458345.
This commit is contained in:
2025-09-30 19:15:03 +08:00
parent d9e3524211
commit a9b0ac0595
16 changed files with 131 additions and 71 deletions
+6 -3
View File
@@ -504,7 +504,8 @@ namespace Ink_Canvas
BackgroundPalette.Child = stackPanel;
// 获取主窗口中的根网格,确保面板添加到顶层
if (FindName("Main_Grid") is Grid mainGrid)
Grid mainGrid = FindName("Main_Grid") as Grid;
if (mainGrid != null)
{
// 删除可能已存在的BackgroundPalette
foreach (UIElement element in mainGrid.Children)
@@ -525,7 +526,8 @@ namespace Ink_Canvas
mainGrid.Children.Add(BackgroundPalette);
// 设置面板位置
if (FindName("BoardChangeBackgroundColorBtn") is FrameworkElement clickElement)
var clickElement = FindName("BoardChangeBackgroundColorBtn") as FrameworkElement;
if (clickElement != null)
{
Point position = clickElement.TranslatePoint(new Point(0, 0), mainGrid);
BackgroundPalette.Margin = new Thickness(
@@ -549,9 +551,10 @@ namespace Ink_Canvas
{
if (modePanel.Children.Count > 1)
{
var whiteboardButton = modePanel.Children[0] as Border;
var blackboardButton = modePanel.Children[1] as Border;
if (modePanel.Children[0] is Border whiteboardButton && whiteboardButton.Child is TextBlock whiteboardText)
if (whiteboardButton != null && whiteboardButton.Child is TextBlock whiteboardText)
{
whiteboardButton.Background = Settings.Canvas.UsingWhiteboard ?
new SolidColorBrush(Color.FromRgb(0x25, 0x63, 0xeb)) :