|
1 | | -<UserControl xmlns="https://github.com/avaloniaui" |
2 | | - xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
3 | | - xmlns:d="http://schemas.microsoft.com/expression/blend/2008" |
4 | | - xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" |
5 | | - xmlns:m="using:SourceGit.Models" |
6 | | - xmlns:vm="using:SourceGit.ViewModels" |
7 | | - xmlns:v="using:SourceGit.Views" |
8 | | - xmlns:c="using:SourceGit.Converters" |
9 | | - mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" |
10 | | - x:Class="SourceGit.Views.BinaryFileViewer"> |
11 | | - <UserControl.DataTemplates> |
12 | | - <DataTemplate DataType="m:RevisionBinaryFile"> |
13 | | - <StackPanel Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Center"> |
14 | | - <Path Width="64" Height="64" Data="{StaticResource Icons.Binary}" Fill="{DynamicResource Brush.FG2}"/> |
15 | | - <TextBlock Margin="0,16,0,0" Text="{DynamicResource Text.File.Binary}" FontSize="18" FontWeight="Bold" HorizontalAlignment="Center" Foreground="{DynamicResource Brush.FG2}"/> |
16 | | - <StackPanel Margin="0,8,0,0" Orientation="Horizontal" HorizontalAlignment="Center"> |
17 | | - <TextBlock Text="{Binding Size, Converter={x:Static c:LongConverters.ToFileSize}}" Foreground="{DynamicResource Brush.FG2}"/> |
18 | | - </StackPanel> |
19 | | - <Button Classes="flat" |
20 | | - Margin="0,16,0,0" |
21 | | - HorizontalAlignment="Center" |
22 | | - Content="{DynamicResource Text.File.HexViewer}" |
23 | | - Click="OnOpenHexViewer"/> |
24 | | - </StackPanel> |
25 | | - </DataTemplate> |
26 | | - |
27 | | - <DataTemplate DataType="m:Null"> |
28 | | - <v:LoadingIcon Width="64" Height="64" |
29 | | - HorizontalAlignment="Center" VerticalAlignment="Center"/> |
30 | | - </DataTemplate> |
| 1 | +<v:ChromelessWindow xmlns="https://github.com/avaloniaui" |
| 2 | + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
| 3 | + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" |
| 4 | + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" |
| 5 | + xmlns:vm="using:SourceGit.ViewModels" |
| 6 | + xmlns:v="using:SourceGit.Views" |
| 7 | + mc:Ignorable="d" d:DesignWidth="520" d:DesignHeight="230" |
| 8 | + x:Class="SourceGit.Views.BinaryFileViewer" |
| 9 | + x:Name="ThisControl" |
| 10 | + x:DataType="vm:BinaryFileViewer" |
| 11 | + Icon="/App.ico" |
| 12 | + Title="{DynamicResource Text.File.HexViewer}" |
| 13 | + Width="800" Height="600" |
| 14 | + WindowStartupLocation="CenterOwner"> |
| 15 | + <Grid RowDefinitions="Auto,32,*"> |
| 16 | + <!-- TitleBar --> |
| 17 | + <Grid Grid.Row="0" Height="28" IsVisible="{Binding !#ThisControl.UseSystemWindowFrame}"> |
| 18 | + <!-- Bottom border --> |
| 19 | + <Border Background="{DynamicResource Brush.TitleBar}" |
| 20 | + BorderThickness="0,0,0,1" BorderBrush="{DynamicResource Brush.Border2}" |
| 21 | + DoubleTapped="MaximizeOrRestoreWindow" |
| 22 | + PointerPressed="BeginMoveWindow"/> |
| 23 | + |
| 24 | + <Path Width="12" Height="12" |
| 25 | + Margin="10,0,0,0" |
| 26 | + HorizontalAlignment="Left" |
| 27 | + Data="{StaticResource Icons.Binary}" |
| 28 | + IsVisible="{OnPlatform True, macOS=False}"/> |
| 29 | + |
| 30 | + <TextBlock Classes="bold" |
| 31 | + Text="{DynamicResource Text.File.HexViewer}" |
| 32 | + HorizontalAlignment="Center" VerticalAlignment="Center" |
| 33 | + IsHitTestVisible="False"/> |
| 34 | + |
| 35 | + <!-- Caption Buttons (Windows/Linux) --> |
| 36 | + <v:CaptionButtons HorizontalAlignment="Right" IsVisible="{OnPlatform True, macOS=False}"/> |
| 37 | + </Grid> |
| 38 | + |
| 39 | + <!-- File --> |
| 40 | + <Border Grid.Row="1" Height="32" VerticalAlignment="Center"> |
| 41 | + <Grid Margin="8,0" ColumnDefinitions="Auto,*,Auto"> |
| 42 | + <Path Grid.Column="0" |
| 43 | + Width="14" Height="14" |
| 44 | + Data="{StaticResource Icons.File}"/> |
31 | 45 |
|
32 | | - <DataTemplate DataType="vm:BinaryFile"> |
33 | | - <Grid RowDefinitions="28,*" Background="Transparent"> |
34 | | - <v:BinaryFileAddressTextBox Grid.Row="0" |
35 | | - Width="600" Height="26" |
| 46 | + <TextBlock Grid.Column="1" |
| 47 | + Margin="4,0,0,0" |
| 48 | + Text="{Binding File, Mode=OneWay}" |
| 49 | + VerticalAlignment="Center"/> |
| 50 | + |
| 51 | + <v:BinaryFileAddressTextBox Grid.Column="2" |
| 52 | + Width="200" Height="26" |
36 | 53 | HorizontalAlignment="Left" VerticalAlignment="Center" |
37 | 54 | BorderThickness="1" |
38 | 55 | BorderBrush="{DynamicResource Brush.Border2}" |
|
48 | 65 | Data="{StaticResource Icons.Address}"/> |
49 | 66 | </TextBox.InnerLeftContent> |
50 | 67 | </v:BinaryFileAddressTextBox> |
51 | | - |
52 | | - <Grid Grid.Row="1" ColumnDefinitions="*,Auto"> |
53 | | - <v:HexViewer Grid.Column="0" |
54 | | - Foreground="{DynamicResource Brush.FG1}" |
55 | | - HeaderForeground="{DynamicResource Brush.Accent}" |
56 | | - ClipToBounds="True"/> |
57 | | - |
58 | | - <ScrollBar Grid.Column="1" |
59 | | - x:Name="HexViewerScroller" |
60 | | - Margin="0,24,0,0" |
61 | | - Orientation="Vertical" |
62 | | - AllowAutoHide="False" |
63 | | - SmallChange="18" |
64 | | - ValueChanged="OnScrollBarValueChanged" |
65 | | - SizeChanged="OnScrollBarSizeChanged"/> |
66 | | - </Grid> |
67 | 68 | </Grid> |
68 | | - </DataTemplate> |
69 | | - </UserControl.DataTemplates> |
70 | | -</UserControl> |
| 69 | + </Border> |
| 70 | + |
| 71 | + <!-- Body --> |
| 72 | + <Border Grid.Row="2" Margin="4,0,4,4" BorderThickness="1" BorderBrush="{DynamicResource Brush.Border2}"> |
| 73 | + <ContentControl x:Name="ContentPanel" Margin="8,4,0,4" Content="{Binding Content, Mode=OneWay}"> |
| 74 | + <ContentControl.DataTemplates> |
| 75 | + <DataTemplate DataType="vm:BinaryFile"> |
| 76 | + <Grid ColumnDefinitions="*,Auto" Background="Transparent" PointerWheelChanged="OnContentPointerWheelChanged"> |
| 77 | + <v:HexViewer Grid.Column="0" |
| 78 | + Foreground="{DynamicResource Brush.FG1}" |
| 79 | + HeaderForeground="{DynamicResource Brush.Accent}" |
| 80 | + ClipToBounds="True"/> |
| 81 | + |
| 82 | + <ScrollBar Grid.Column="1" |
| 83 | + Margin="0,24,0,0" |
| 84 | + Orientation="Vertical" |
| 85 | + AllowAutoHide="False" |
| 86 | + SmallChange="18" |
| 87 | + ValueChanged="OnScrollBarValueChanged" |
| 88 | + SizeChanged="OnScrollBarSizeChanged"/> |
| 89 | + </Grid> |
| 90 | + </DataTemplate> |
| 91 | + </ContentControl.DataTemplates> |
| 92 | + </ContentControl> |
| 93 | + </Border> |
| 94 | + |
| 95 | + <!-- Loading Icon --> |
| 96 | + <v:LoadingIcon Grid.Row="2" |
| 97 | + Width="64" Height="64" |
| 98 | + IsVisible="{Binding IsLoading, Mode=OneWay}"/> |
| 99 | + </Grid> |
| 100 | +</v:ChromelessWindow> |
0 commit comments