From f21ffd521a9707a7aae62488c283f962b966a404 Mon Sep 17 00:00:00 2001 From: muqing <1966944300@qq.com> Date: Thu, 16 Jan 2025 19:22:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=BC=82=E5=B8=B8=E5=A4=84?= =?UTF-8?q?=E7=90=86=E3=80=81=E6=8E=A7=E4=BB=B6=E5=B1=9E=E6=80=A7=E5=92=8C?= =?UTF-8?q?=E4=BA=8B=E4=BB=B6=E5=A4=84=E7=90=86=E7=A8=8B=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在 `App.xaml.cs` 文件中,捕获 `Exception` 异常时,添加了调试输出信息,输出内容为“发生未知错误: ”加上异常信息。 在 `EditorWin.xaml` 文件中,将 `TreeView` 的 `CanReorderItems` 属性从 `True` 修改为 `False`。 在 `EditorWin.xaml` 文件中,`TabView` 控件添加了 `AddTabButtonClick` 和 `TabCloseRequested` 事件处理程序,并将 `IsAddTabButtonVisible` 属性设置为 `False`。 在 `EditorWin.xaml.cs` 文件中,添加了 `MyTabView_AddTabButtonClick` 和 `MyTabView_TabCloseRequested` 方法,用于处理添加和关闭选项卡的事件。 在 `RustTools.csproj` 文件中,调整了注释的格式,使其在 VS Code 中显示正确的图标,并调整了 `ItemGroup` 的格式。 --- App.xaml.cs | 2 +- Editor/EditorWin.xaml | 6 ++++-- Editor/EditorWin.xaml.cs | 19 ++++++++++++++++++- RustTools.csproj | 13 ++++++++----- 4 files changed, 31 insertions(+), 9 deletions(-) diff --git a/App.xaml.cs b/App.xaml.cs index 79b2eef..e5f2e92 100644 --- a/App.xaml.cs +++ b/App.xaml.cs @@ -147,7 +147,7 @@ public partial class App : Microsoft.UI.Xaml.Application } catch (Exception ex) { - + Debug.WriteLine("发生未知错误: " + ex.Message); } }).Start(); diff --git a/Editor/EditorWin.xaml b/Editor/EditorWin.xaml index fbe17d5..fc29f43 100644 --- a/Editor/EditorWin.xaml +++ b/Editor/EditorWin.xaml @@ -81,11 +81,11 @@ VerticalScrollBarVisibility="Auto"> @@ -109,7 +109,9 @@ x:Name="tabview" Grid.Row="0" Height="auto" - IsAddTabButtonVisible="False" /> + AddTabButtonClick="MyTabView_AddTabButtonClick" + IsAddTabButtonVisible="False" + TabCloseRequested="MyTabView_TabCloseRequested" /> diff --git a/Editor/EditorWin.xaml.cs b/Editor/EditorWin.xaml.cs index b56e913..9da7e9d 100644 --- a/Editor/EditorWin.xaml.cs +++ b/Editor/EditorWin.xaml.cs @@ -88,6 +88,23 @@ public sealed partial class EditorWin : WindowEx } - + // ѡ + private void MyTabView_AddTabButtonClick(TabView sender, object args) + { + var newTab = new TabViewItem + { + Header = $"New Tab {TabViewList.Count + 1}", + Content = new TextBlock { Text = "This is a new tab." } + }; + TabViewList.Add(newTab); + } + // رѡ + private void MyTabView_TabCloseRequested(TabView sender, TabViewTabCloseRequestedEventArgs args) + { + if (args.Tab is TabViewItem tab) + { + TabViewList.Remove(tab); + } + } } diff --git a/RustTools.csproj b/RustTools.csproj index 05963a0..33d9574 100644 --- a/RustTools.csproj +++ b/RustTools.csproj @@ -33,21 +33,24 @@ - + - - + + Always - + - + \ No newline at end of file