WIn_RustTools/Editor/EditorWin.xaml

124 lines
4.8 KiB
Plaintext
Raw Permalink Normal View History

<?xml version="1.0" encoding="utf-8" ?>
<windowex:WindowEx
x:Class="RustTools.Editor.EditorWin"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
重构 EditorTreeView 以使用 Microsoft.UI.Xaml.Controls 在 `EditorTreeView.cs` 中: - 添加了 `Microsoft.UI.Xaml.Controls`、`RustTools.muqing` 和 `WinUIEditor` 的引用。 - 将 `EditorTreeView` 类从继承 `TreeView` 改为继承 `Microsoft.UI.Xaml.Controls.TreeView`。 - 修改了事件处理程序的绑定方式,去掉了 `this` 关键字。 - 修改了 `TreeView_ItemInvoked`、`TreeView_Expanding` 和 `TreeView_Collapsed` 方法的参数类型,使用了 `Microsoft.UI.Xaml.Controls.TreeView`。 - 在 `TreeView_ItemInvoked` 方法中,添加了处理文件点击事件的逻辑,包括创建 `CodeEditorControl` 实例并将其添加到 `TabViewItem` 中。 - 添加了 `AddTabItem` 事件。 在 `EditorWin.xaml` 中: - 添加了 `WinUIEditor` 的命名空间引用。 - 在 `Grid` 中添加了 `RowDefinition`,用于定义 `TabView` 的头部和内容区域的高度。 - 注释掉了 `CodeEditorControl` 的 XAML 定义。 在 `EditorWin.xaml.cs` 中: - 添加了 `Microsoft.UI.Xaml.Media` 和 `WinUIEditor` 的引用。 - 在 `EditorWin` 构造函数中,添加了 `gridedit.SizeChanged` 事件处理程序,用于调整 `TabView` 的高度。 - 添加了 `TreeView_AddTabItem` 方法,用于处理 `AddTabItem` 事件。 - 删除了 `MyTabView_AddTabButtonClick` 方法。 在 `RustTools.csproj` 中: - 添加了 `WinUIEdit` 包的引用。 重构 EditorTreeView 并添加 WinUI 支持 将 EditorTreeView 类更改为 Microsoft.UI.Xaml.Controls.TreeView,添加相关命名空间引用。更新方法参数类型并处理文件点击事件。调整 EditorWin.xaml 和 EditorWin.xaml.cs 文件,添加事件处理逻辑。移除 MyTabView_AddTabButtonClick 方法,并在 RustTools.csproj 中添加 WinUIEdit 包引用。
2025-01-21 11:26:04 +00:00
xmlns:WinUIEditor="using:WinUIEditor"
2024-08-09 07:05:40 +00:00
xmlns:controlpages="using:RustTools.Editor"
2024-08-13 10:47:12 +00:00
xmlns:controls="using:CommunityToolkit.WinUI.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:editor="using:RustTools.Editor"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:windowex="using:WinUIEx"
MinWidth="500"
MinHeight="500"
mc:Ignorable="d">
2024-08-09 07:05:40 +00:00
<Page Name="page">
<Page.Resources>
<!-- 这是文件夹 -->
<DataTemplate x:Key="FolderTemplate" x:DataType="editor:FileItem">
2024-08-09 07:05:40 +00:00
<TreeViewItem
AutomationProperties.Name="{x:Bind Name}"
IsExpanded="{x:Bind IsExpanded, Mode=TwoWay}"
ItemsSource="{x:Bind Children}">
2024-08-09 07:05:40 +00:00
<StackPanel Orientation="Horizontal">
<FontIcon Glyph="&#xE8B7;" />
<TextBlock Margin="0,0,10,0" />
<TextBlock Text="{x:Bind Name}" />
2024-08-09 07:05:40 +00:00
</StackPanel>
</TreeViewItem>
</DataTemplate>
<!-- 这是文件 -->
2024-08-09 07:05:40 +00:00
<DataTemplate x:Key="FileTemplate">
2024-08-13 11:30:40 +00:00
<TreeViewItem AutomationProperties.Name="{Binding Name}" IsExpanded="False">
2024-08-09 07:05:40 +00:00
<StackPanel Orientation="Horizontal">
<FontIcon Glyph="&#xE8A5;" />
<TextBlock Margin="0,0,10,0" />
<TextBlock Text="{Binding Name}" />
</StackPanel>
</TreeViewItem>
</DataTemplate>
<controlpages:ExplorerItemTemplateSelector
x:Key="ExplorerItemTemplateSelector"
FileTemplate="{StaticResource FileTemplate}"
FolderTemplate="{StaticResource FolderTemplate}" />
</Page.Resources>
<Grid>
<Grid.ColumnDefinitions>
2024-08-13 10:47:12 +00:00
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
2024-08-09 07:05:40 +00:00
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
2024-08-09 07:05:40 +00:00
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid
Grid.Row="0"
Padding="9"
Visibility="Visible">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock
Name="TitleText"
Grid.Column="0"
Margin="16,0,0,0" />
</Grid>
<ScrollViewer
2024-08-13 10:47:12 +00:00
x:Name="scrollview"
2024-08-09 07:05:40 +00:00
Grid.Row="2"
Grid.Column="0"
Width="300"
Margin="0,9,0,6"
2025-01-16 10:40:04 +00:00
Padding="0,0,16,16"
2024-08-13 10:47:12 +00:00
HorizontalScrollBarVisibility="Auto"
VerticalScrollBarVisibility="Auto">
<!--
TreeView 绑定资源和拖放事件
-->
2024-08-13 10:47:12 +00:00
<controlpages:EditorTreeView
x:Name="treeView"
AllowDrop="True"
CanReorderItems="False"
2024-08-09 07:05:40 +00:00
ItemTemplateSelector="{StaticResource ExplorerItemTemplateSelector}"
ItemsSource="{x:Bind DataSource}"
SelectionMode="Single" />
</ScrollViewer>
2024-08-13 10:47:12 +00:00
<controls:PropertySizer
2024-08-11 11:16:42 +00:00
Grid.Row="1"
Grid.Column="1"
2024-08-13 10:47:12 +00:00
Binding="{x:Bind scrollview.Width, Mode=TwoWay}"
Maximum="350"
Minimum="200"
Visibility="Visible" />
<Grid
x:Name="gridedit"
Grid.Row="1"
Grid.Column="2">
<Grid.RowDefinitions>
重构 EditorTreeView 以使用 Microsoft.UI.Xaml.Controls 在 `EditorTreeView.cs` 中: - 添加了 `Microsoft.UI.Xaml.Controls`、`RustTools.muqing` 和 `WinUIEditor` 的引用。 - 将 `EditorTreeView` 类从继承 `TreeView` 改为继承 `Microsoft.UI.Xaml.Controls.TreeView`。 - 修改了事件处理程序的绑定方式,去掉了 `this` 关键字。 - 修改了 `TreeView_ItemInvoked`、`TreeView_Expanding` 和 `TreeView_Collapsed` 方法的参数类型,使用了 `Microsoft.UI.Xaml.Controls.TreeView`。 - 在 `TreeView_ItemInvoked` 方法中,添加了处理文件点击事件的逻辑,包括创建 `CodeEditorControl` 实例并将其添加到 `TabViewItem` 中。 - 添加了 `AddTabItem` 事件。 在 `EditorWin.xaml` 中: - 添加了 `WinUIEditor` 的命名空间引用。 - 在 `Grid` 中添加了 `RowDefinition`,用于定义 `TabView` 的头部和内容区域的高度。 - 注释掉了 `CodeEditorControl` 的 XAML 定义。 在 `EditorWin.xaml.cs` 中: - 添加了 `Microsoft.UI.Xaml.Media` 和 `WinUIEditor` 的引用。 - 在 `EditorWin` 构造函数中,添加了 `gridedit.SizeChanged` 事件处理程序,用于调整 `TabView` 的高度。 - 添加了 `TreeView_AddTabItem` 方法,用于处理 `AddTabItem` 事件。 - 删除了 `MyTabView_AddTabButtonClick` 方法。 在 `RustTools.csproj` 中: - 添加了 `WinUIEdit` 包的引用。 重构 EditorTreeView 并添加 WinUI 支持 将 EditorTreeView 类更改为 Microsoft.UI.Xaml.Controls.TreeView,添加相关命名空间引用。更新方法参数类型并处理文件点击事件。调整 EditorWin.xaml 和 EditorWin.xaml.cs 文件,添加事件处理逻辑。移除 MyTabView_AddTabButtonClick 方法,并在 RustTools.csproj 中添加 WinUIEdit 包引用。
2025-01-21 11:26:04 +00:00
<RowDefinition Height="Auto" />
<!-- TabView header height -->
2024-08-13 10:47:12 +00:00
<RowDefinition Height="*" />
重构 EditorTreeView 以使用 Microsoft.UI.Xaml.Controls 在 `EditorTreeView.cs` 中: - 添加了 `Microsoft.UI.Xaml.Controls`、`RustTools.muqing` 和 `WinUIEditor` 的引用。 - 将 `EditorTreeView` 类从继承 `TreeView` 改为继承 `Microsoft.UI.Xaml.Controls.TreeView`。 - 修改了事件处理程序的绑定方式,去掉了 `this` 关键字。 - 修改了 `TreeView_ItemInvoked`、`TreeView_Expanding` 和 `TreeView_Collapsed` 方法的参数类型,使用了 `Microsoft.UI.Xaml.Controls.TreeView`。 - 在 `TreeView_ItemInvoked` 方法中,添加了处理文件点击事件的逻辑,包括创建 `CodeEditorControl` 实例并将其添加到 `TabViewItem` 中。 - 添加了 `AddTabItem` 事件。 在 `EditorWin.xaml` 中: - 添加了 `WinUIEditor` 的命名空间引用。 - 在 `Grid` 中添加了 `RowDefinition`,用于定义 `TabView` 的头部和内容区域的高度。 - 注释掉了 `CodeEditorControl` 的 XAML 定义。 在 `EditorWin.xaml.cs` 中: - 添加了 `Microsoft.UI.Xaml.Media` 和 `WinUIEditor` 的引用。 - 在 `EditorWin` 构造函数中,添加了 `gridedit.SizeChanged` 事件处理程序,用于调整 `TabView` 的高度。 - 添加了 `TreeView_AddTabItem` 方法,用于处理 `AddTabItem` 事件。 - 删除了 `MyTabView_AddTabButtonClick` 方法。 在 `RustTools.csproj` 中: - 添加了 `WinUIEdit` 包的引用。 重构 EditorTreeView 并添加 WinUI 支持 将 EditorTreeView 类更改为 Microsoft.UI.Xaml.Controls.TreeView,添加相关命名空间引用。更新方法参数类型并处理文件点击事件。调整 EditorWin.xaml 和 EditorWin.xaml.cs 文件,添加事件处理逻辑。移除 MyTabView_AddTabButtonClick 方法,并在 RustTools.csproj 中添加 WinUIEdit 包引用。
2025-01-21 11:26:04 +00:00
<!-- TabView content area height -->
2024-08-13 10:47:12 +00:00
</Grid.RowDefinitions>
<TabView
x:Name="tabview"
IsAddTabButtonVisible="False"
TabCloseRequested="MyTabView_TabCloseRequested" />
2024-08-11 11:16:42 +00:00
重构 EditorTreeView 以使用 Microsoft.UI.Xaml.Controls 在 `EditorTreeView.cs` 中: - 添加了 `Microsoft.UI.Xaml.Controls`、`RustTools.muqing` 和 `WinUIEditor` 的引用。 - 将 `EditorTreeView` 类从继承 `TreeView` 改为继承 `Microsoft.UI.Xaml.Controls.TreeView`。 - 修改了事件处理程序的绑定方式,去掉了 `this` 关键字。 - 修改了 `TreeView_ItemInvoked`、`TreeView_Expanding` 和 `TreeView_Collapsed` 方法的参数类型,使用了 `Microsoft.UI.Xaml.Controls.TreeView`。 - 在 `TreeView_ItemInvoked` 方法中,添加了处理文件点击事件的逻辑,包括创建 `CodeEditorControl` 实例并将其添加到 `TabViewItem` 中。 - 添加了 `AddTabItem` 事件。 在 `EditorWin.xaml` 中: - 添加了 `WinUIEditor` 的命名空间引用。 - 在 `Grid` 中添加了 `RowDefinition`,用于定义 `TabView` 的头部和内容区域的高度。 - 注释掉了 `CodeEditorControl` 的 XAML 定义。 在 `EditorWin.xaml.cs` 中: - 添加了 `Microsoft.UI.Xaml.Media` 和 `WinUIEditor` 的引用。 - 在 `EditorWin` 构造函数中,添加了 `gridedit.SizeChanged` 事件处理程序,用于调整 `TabView` 的高度。 - 添加了 `TreeView_AddTabItem` 方法,用于处理 `AddTabItem` 事件。 - 删除了 `MyTabView_AddTabButtonClick` 方法。 在 `RustTools.csproj` 中: - 添加了 `WinUIEdit` 包的引用。 重构 EditorTreeView 并添加 WinUI 支持 将 EditorTreeView 类更改为 Microsoft.UI.Xaml.Controls.TreeView,添加相关命名空间引用。更新方法参数类型并处理文件点击事件。调整 EditorWin.xaml 和 EditorWin.xaml.cs 文件,添加事件处理逻辑。移除 MyTabView_AddTabButtonClick 方法,并在 RustTools.csproj 中添加 WinUIEdit 包引用。
2025-01-21 11:26:04 +00:00
<!--<WinUIEditor:CodeEditorControl
x:Name="MyEditor"
HighlightingLanguage="csharp"
DataContextChanged="OnCodeTextChanged" />-->
2024-08-13 10:47:12 +00:00
</Grid>
</Grid>
2024-08-09 07:05:40 +00:00
</Page>
</windowex:WindowEx>