新设置窗口:新增可拖动区域 (#401)

* 软件设置内的贡献者列表添加了 PANDA-JSR

* 设置窗口:新增可拖动区域
This commit is contained in:
PANDAJSR
2026-03-14 17:24:54 +08:00
committed by GitHub
parent 133542d7fa
commit bea92f3483
2 changed files with 34 additions and 5 deletions
@@ -650,7 +650,9 @@
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid Height="48" VerticalAlignment="Top" Grid.Row="0">
<Grid Height="48" VerticalAlignment="Top" Grid.Row="0"
Background="Transparent"
MouseLeftButtonDown="SidebarTopBar_MouseLeftButtonDown">
<Border x:Name="SearchButtonBorder" CornerRadius="8" Background="#d9d9d9" Width="34" Height="34" Margin="8,0,0,0" HorizontalAlignment="Left" MouseLeftButtonDown="SearchButton_Click" Cursor="Hand">
<Image Width="16" Height="16">
<Image.Source>
@@ -664,7 +666,8 @@
</Image.Source>
</Image>
</Border>
<TextBlock x:Name="TitleTextBlock" FontSize="15" Text="软件设置" Foreground="#2e3436" FontWeight="Bold" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<TextBlock x:Name="TitleTextBlock" FontSize="15" Text="软件设置" Foreground="#2e3436" FontWeight="Bold"
VerticalAlignment="Center" HorizontalAlignment="Center" IsHitTestVisible="False"/>
<Border CornerRadius="8" Background="#d9d9d9" Width="34" Height="34" Margin="0,0,8,0" HorizontalAlignment="Right" PreviewMouseLeftButtonDown="MenuButton_Click" Cursor="Hand" x:Name="MenuButtonBorder">
<Image Width="16" Height="16">
<Image.Source>
@@ -858,7 +861,8 @@
<!--Topbar-->
<Grid Height="48" VerticalAlignment="Top" Margin="250,0,0,0">
<Border x:Name="TopBarBorder" Height="48" CornerRadius="0,6,0,0" Background="#fafafa">
<Border x:Name="TopBarBorder" Height="48" CornerRadius="0,6,0,0" Background="#fafafa"
MouseLeftButtonDown="TopBarBorder_MouseLeftButtonDown">
<Border.Clip>
<RectangleGeometry Rect="0,0,640,56"/>
</Border.Clip>
@@ -868,7 +872,8 @@
</Border.Effect>
</Border>
</Border>
<TextBlock FontSize="16" Text="设置标题" Name="SettingsWindowTitle" Foreground="#2e3436" FontWeight="Bold" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<TextBlock FontSize="16" Text="设置标题" Name="SettingsWindowTitle" Foreground="#2e3436" FontWeight="Bold"
VerticalAlignment="Center" HorizontalAlignment="Center" IsHitTestVisible="False"/>
<Border CornerRadius="8" Background="#33ef4444" Width="34" Height="34" Margin="0,0,8,0" HorizontalAlignment="Right" MouseLeftButtonDown="CloseButton_Click" Cursor="Hand">
<Image Width="12" Height="12">
<Image.Source>
@@ -1160,6 +1160,30 @@ namespace Ink_Canvas.Windows
_sidebarItemMouseDownBorder = null;
}
private void TopBarBorder_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
if (e.ChangedButton != MouseButton.Left) return;
DragMove();
}
private void SidebarTopBar_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
if (e.ChangedButton != MouseButton.Left) return;
var source = e.OriginalSource as DependencyObject;
if (IsInsideElement(source, SearchButtonBorder) || IsInsideElement(source, MenuButtonBorder))
return;
DragMove();
}
private static bool IsInsideElement(DependencyObject source, DependencyObject target)
{
if (source == null || target == null) return false;
if (source == target) return true;
return IsInsideElement(VisualTreeHelper.GetParent(source), target);
}
private void CloseButton_Click(object sender, MouseButtonEventArgs e)
{
Close();
@@ -1838,4 +1862,4 @@ namespace Ink_Canvas.Windows
#endregion
}
}
}