You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
182 lines
10 KiB
182 lines
10 KiB
<reactive:ReactiveUserControl xmlns="https://github.com/avaloniaui"
|
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
|
xmlns:vm="using:AuroraDesk.Presentation.ViewModels.Pages"
|
|
xmlns:avaloniaEdit="clr-namespace:AvaloniaEdit;assembly=AvaloniaEdit"
|
|
xmlns:attached="using:AuroraDesk.Presentation.Attached"
|
|
xmlns:reactive="using:ReactiveUI.Avalonia"
|
|
mc:Ignorable="d"
|
|
d:DesignWidth="1200"
|
|
d:DesignHeight="800"
|
|
x:Class="AuroraDesk.Presentation.Views.Pages.FileExplorerPageView"
|
|
x:DataType="vm:FileExplorerPageViewModel">
|
|
|
|
<Design.DataContext>
|
|
<vm:FileExplorerPageViewModel />
|
|
</Design.DataContext>
|
|
|
|
<Grid RowDefinitions="Auto,*">
|
|
<!-- 顶部目录选择区 -->
|
|
<Border Grid.Row="0"
|
|
Background="{StaticResource BackgroundLight}"
|
|
BorderBrush="{StaticResource BorderLight}"
|
|
BorderThickness="0,0,0,1"
|
|
Padding="20">
|
|
<Grid ColumnDefinitions="*,Auto,Auto" ColumnSpacing="16">
|
|
<StackPanel Grid.Column="0" Spacing="10">
|
|
<TextBlock Text="文件目录浏览"
|
|
FontSize="24"
|
|
FontWeight="Bold"
|
|
Foreground="{StaticResource TextPrimary}"/>
|
|
<TextBlock Text="选择一个目录,左侧显示文件列表,右侧使用 AvaloniaEdit 预览文件内容"
|
|
FontSize="14"
|
|
Foreground="{StaticResource SecondaryGrayDark}"/>
|
|
<TextBlock Text="{Binding StatusMessage}"
|
|
FontSize="13"
|
|
Foreground="{StaticResource TextSecondary}"/>
|
|
</StackPanel>
|
|
|
|
<StackPanel Grid.Column="1"
|
|
Orientation="Horizontal"
|
|
Spacing="10"
|
|
VerticalAlignment="Center">
|
|
<TextBox Width="360"
|
|
Text="{Binding SelectedDirectory}"
|
|
IsReadOnly="True"
|
|
Watermark="请选择目录"
|
|
HorizontalAlignment="Stretch"/>
|
|
</StackPanel>
|
|
|
|
<StackPanel Grid.Column="2"
|
|
Orientation="Horizontal"
|
|
Spacing="10"
|
|
VerticalAlignment="Center">
|
|
<Button Content="选择目录"
|
|
Command="{Binding BrowseDirectoryCommand}"
|
|
HorizontalAlignment="Right"/>
|
|
<Button Content="刷新列表"
|
|
Command="{Binding RefreshDirectoryCommand}"
|
|
HorizontalAlignment="Right"/>
|
|
</StackPanel>
|
|
</Grid>
|
|
</Border>
|
|
|
|
<!-- 下方左右布局 -->
|
|
<Grid Grid.Row="1" ColumnDefinitions="320,*" ColumnSpacing="12" Margin="12">
|
|
<!-- 左侧:文件树 -->
|
|
<Border Background="{StaticResource BackgroundWhite}"
|
|
BorderBrush="{StaticResource BorderLight}"
|
|
BorderThickness="1"
|
|
CornerRadius="10"
|
|
Padding="16">
|
|
<Grid RowDefinitions="Auto,Auto,Auto,*" RowSpacing="12">
|
|
<StackPanel Grid.Row="0" Orientation="Horizontal" VerticalAlignment="Center" Spacing="8">
|
|
<TextBlock Text="文件树"
|
|
FontSize="18"
|
|
FontWeight="SemiBold"
|
|
Foreground="{StaticResource TextPrimary}"/>
|
|
<Border Background="{StaticResource BackgroundLight}"
|
|
CornerRadius="12"
|
|
Padding="10,4">
|
|
<TextBlock Text="{Binding TotalFileCount, StringFormat='文件数:{0}'}"
|
|
FontSize="12"
|
|
Foreground="{StaticResource TextSecondary}"/>
|
|
</Border>
|
|
</StackPanel>
|
|
|
|
<TextBlock Grid.Row="1"
|
|
Text="展开左侧树并点击文件,即可在右侧预览内容"
|
|
FontSize="13"
|
|
Foreground="{StaticResource SecondaryGrayDark}"/>
|
|
|
|
<TextBox Grid.Row="2"
|
|
Height="36"
|
|
CornerRadius="8"
|
|
Text="{Binding SearchQuery, UpdateSourceTrigger=PropertyChanged}"
|
|
Watermark="搜索文件或文件夹"
|
|
VerticalAlignment="Center"/>
|
|
|
|
<TreeView Grid.Row="3"
|
|
ItemsSource="{Binding FilteredTreeItems}"
|
|
SelectedItem="{Binding SelectedNode}"
|
|
Background="{StaticResource BackgroundLight}"
|
|
BorderThickness="0"
|
|
ScrollViewer.HorizontalScrollBarVisibility="Disabled">
|
|
<TreeView.Styles>
|
|
<Style Selector="TreeViewItem">
|
|
<Setter Property="Margin" Value="0,2,0,2"/>
|
|
<Setter Property="Padding" Value="6,4"/>
|
|
</Style>
|
|
</TreeView.Styles>
|
|
<TreeView.DataTemplates>
|
|
<TreeDataTemplate DataType="vm:FileExplorerPageViewModel+FileTreeNode"
|
|
ItemsSource="{Binding Children}">
|
|
<StackPanel Spacing="2">
|
|
<TextBlock Text="{Binding Name}"
|
|
FontWeight="SemiBold"
|
|
Foreground="{StaticResource TextPrimary}"
|
|
TextTrimming="CharacterEllipsis"/>
|
|
<TextBlock Text="{Binding SizeDisplay}"
|
|
FontSize="11"
|
|
Foreground="{StaticResource SecondaryGrayDark}"/>
|
|
</StackPanel>
|
|
</TreeDataTemplate>
|
|
</TreeView.DataTemplates>
|
|
</TreeView>
|
|
</Grid>
|
|
</Border>
|
|
|
|
<!-- 右侧:文件内容展示 -->
|
|
<Border Grid.Column="1"
|
|
Background="{StaticResource BackgroundWhite}"
|
|
BorderBrush="{StaticResource BorderLight}"
|
|
BorderThickness="1"
|
|
CornerRadius="10"
|
|
Padding="16">
|
|
<Grid RowDefinitions="Auto,*" RowSpacing="12">
|
|
<StackPanel Orientation="Vertical" Spacing="6">
|
|
<TextBlock Text="{Binding SelectedFileName}"
|
|
FontSize="20"
|
|
FontWeight="SemiBold"
|
|
Foreground="{StaticResource TextPrimary}"/>
|
|
<TextBlock Text="{Binding SelectedFileInfo}"
|
|
FontSize="13"
|
|
Foreground="{StaticResource SecondaryGrayDark}"/>
|
|
<StackPanel Orientation="Horizontal" Spacing="8" VerticalAlignment="Center">
|
|
<TextBlock Text="语法高亮:"
|
|
FontSize="13"
|
|
Foreground="{StaticResource SecondaryGrayDark}"
|
|
VerticalAlignment="Center"/>
|
|
<ComboBox ItemsSource="{Binding AvailableHighlightLanguages}"
|
|
SelectedItem="{Binding SelectedHighlightLanguage}"
|
|
MinWidth="150"
|
|
MaxWidth="200"
|
|
HorizontalAlignment="Left"/>
|
|
</StackPanel>
|
|
</StackPanel>
|
|
|
|
<Border Grid.Row="1"
|
|
Background="{StaticResource BackgroundLight}"
|
|
BorderBrush="{StaticResource BorderLight}"
|
|
BorderThickness="1"
|
|
CornerRadius="8"
|
|
Padding="0">
|
|
<avaloniaEdit:TextEditor attached:TextEditorAssist.Document="{Binding Document}"
|
|
IsReadOnly="True"
|
|
ShowLineNumbers="True"
|
|
FontFamily="Consolas, 'Courier New', monospace"
|
|
FontSize="14"
|
|
HorizontalScrollBarVisibility="Auto"
|
|
VerticalScrollBarVisibility="Visible"
|
|
Background="{StaticResource BackgroundWhite}"
|
|
Foreground="{StaticResource TextPrimary}"
|
|
attached:TextMateHelper.Language="{Binding ActiveHighlightLanguage}"
|
|
Margin="0"/>
|
|
</Border>
|
|
</Grid>
|
|
</Border>
|
|
</Grid>
|
|
</Grid>
|
|
</reactive:ReactiveUserControl>
|
|
|
|
|