From da66b3e389b36e6e6ec7ac5a16ea1d69abf5bd4f Mon Sep 17 00:00:00 2001 From: "zhengxuan.zhang" Date: Thu, 26 Mar 2026 11:19:51 +0800 Subject: [PATCH] =?UTF-8?q?#0045=20=E4=BF=AE=E5=A4=8D=E7=AE=97=E5=AD=90?= =?UTF-8?q?=E5=B7=A5=E5=85=B7=E7=AE=B1=E8=BE=B9=E6=A1=86=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ImageProcessing/OperatorToolboxView.xaml | 39 +++++++++++++++++-- .../OperatorToolboxView.xaml.cs | 16 ++++++++ .../OperatorToolboxWindow.xaml | 10 ++++- .../OperatorToolboxWindow.xaml.cs | 18 +++++++++ XplorePlane/Views/Main/MainWindow.xaml | 5 --- XplorePlane/readme.txt | 13 ++++++- 6 files changed, 89 insertions(+), 12 deletions(-) diff --git a/XplorePlane/Views/ImageProcessing/OperatorToolboxView.xaml b/XplorePlane/Views/ImageProcessing/OperatorToolboxView.xaml index b1c27cf..b640ea9 100644 --- a/XplorePlane/Views/ImageProcessing/OperatorToolboxView.xaml +++ b/XplorePlane/Views/ImageProcessing/OperatorToolboxView.xaml @@ -27,10 +27,41 @@ - - - + + + + + + diff --git a/XplorePlane/Views/ImageProcessing/OperatorToolboxView.xaml.cs b/XplorePlane/Views/ImageProcessing/OperatorToolboxView.xaml.cs index 99f0049..31d7f67 100644 --- a/XplorePlane/Views/ImageProcessing/OperatorToolboxView.xaml.cs +++ b/XplorePlane/Views/ImageProcessing/OperatorToolboxView.xaml.cs @@ -25,8 +25,24 @@ namespace XplorePlane.Views Loaded += OnLoaded; } + /// + /// 当宿主为无边框窗口时,启用标题栏拖拽和关闭按钮 + /// + private void SetupBorderlessWindowSupport() + { + var hostWindow = Window.GetWindow(this); + if (hostWindow is OperatorToolboxWindow toolboxWindow) + { + TitleBar.MouseLeftButtonDown += toolboxWindow.TitleBar_MouseLeftButtonDown; + CloseBtn.Visibility = Visibility.Visible; + CloseBtn.Click += toolboxWindow.CloseButton_Click; + } + } + private void OnLoaded(object sender, RoutedEventArgs e) { + SetupBorderlessWindowSupport(); + ToolboxListBox.PreviewMouseLeftButtonDown += OnPreviewMouseDown; ToolboxListBox.PreviewMouseMove += OnPreviewMouseMove; _logger?.Debug("OperatorToolboxView 原生拖拽源已注册, DataContext={Type}", diff --git a/XplorePlane/Views/ImageProcessing/OperatorToolboxWindow.xaml b/XplorePlane/Views/ImageProcessing/OperatorToolboxWindow.xaml index 2e9bab9..519f94c 100644 --- a/XplorePlane/Views/ImageProcessing/OperatorToolboxWindow.xaml +++ b/XplorePlane/Views/ImageProcessing/OperatorToolboxWindow.xaml @@ -6,6 +6,14 @@ Width="260" Height="500" WindowStartupLocation="CenterOwner" ShowInTaskbar="False" + WindowStyle="None" + AllowsTransparency="True" + Background="Transparent" ResizeMode="CanResizeWithGrip"> - + + + + + + diff --git a/XplorePlane/Views/ImageProcessing/OperatorToolboxWindow.xaml.cs b/XplorePlane/Views/ImageProcessing/OperatorToolboxWindow.xaml.cs index d3e2637..db12343 100644 --- a/XplorePlane/Views/ImageProcessing/OperatorToolboxWindow.xaml.cs +++ b/XplorePlane/Views/ImageProcessing/OperatorToolboxWindow.xaml.cs @@ -1,4 +1,5 @@ using System.Windows; +using System.Windows.Input; namespace XplorePlane.Views { @@ -8,5 +9,22 @@ namespace XplorePlane.Views { InitializeComponent(); } + + /// + /// 允许通过标题栏区域拖动无边框窗口 + /// + public void TitleBar_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) + { + if (e.ClickCount == 1) + DragMove(); + } + + /// + /// 关闭窗口 + /// + public void CloseButton_Click(object sender, RoutedEventArgs e) + { + Close(); + } } } diff --git a/XplorePlane/Views/Main/MainWindow.xaml b/XplorePlane/Views/Main/MainWindow.xaml index ba86a2d..3defa1d 100644 --- a/XplorePlane/Views/Main/MainWindow.xaml +++ b/XplorePlane/Views/Main/MainWindow.xaml @@ -375,11 +375,6 @@ -