sourcegit/src/Views/SelfUpdate.axaml
leo e3c0f7d496
refactor: rewrite chromeless window (#634)
* use system chrome instead of custom caption button on macOS
* move `BeginMoveWindow` and `MaximizeOrRestoreWindow` to `ChromelessWindow`
* better supports for fullscreen mode on macOS
* redesign the layout of title bar for all windows

Signed-off-by: leo <longshuang@msn.cn>
2024-11-01 09:38:42 +08:00

131 lines
6.4 KiB
XML

<v:ChromelessWindow 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:m="using:SourceGit.Models"
xmlns:vm="using:SourceGit.ViewModels"
xmlns:v="using:SourceGit.Views"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="SourceGit.Views.SelfUpdate"
x:DataType="vm:SelfUpdate"
x:Name="ThisControl"
Title="{DynamicResource Text.SelfUpdate.Title}"
Icon="/App.ico"
SizeToContent="WidthAndHeight"
CanResize="False"
WindowStartupLocation="CenterOwner">
<Grid RowDefinitions="Auto,*">
<!-- TitleBar -->
<Grid Grid.Row="0" Height="28" IsVisible="{Binding !#ThisControl.UseSystemWindowFrame}">
<Border Background="{DynamicResource Brush.TitleBar}"
BorderThickness="0,0,0,1" BorderBrush="{DynamicResource Brush.Border0}"
PointerPressed="BeginMoveWindow"/>
<Path Width="14" Height="14"
Margin="10,0,0,0"
HorizontalAlignment="Left"
Data="{StaticResource Icons.SoftwareUpdate}"
IsVisible="{OnPlatform True, macOS=False}"/>
<TextBlock Classes="bold"
Text="{DynamicResource Text.SelfUpdate.Title}"
HorizontalAlignment="Center" VerticalAlignment="Center"
IsHitTestVisible="False"/>
<v:CaptionButtons HorizontalAlignment="Right"
IsCloseButtonOnly="True"
IsVisible="{OnPlatform True, macOS=False}"/>
</Grid>
<!-- Body -->
<Grid Grid.Row="1">
<ContentControl Content="{Binding Data}">
<ContentControl.DataTemplates>
<DataTemplate DataType="m:Version">
<StackPanel Orientation="Vertical" Margin="16,8">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,8">
<Path Width="14" Height="14" Data="{StaticResource Icons.Info}" Fill="Green"/>
<TextBlock Margin="8,0,0,0" FontWeight="Bold" FontSize="14" Text="{DynamicResource Text.SelfUpdate.Available}"/>
<Border Margin="4,0,0,0" Height="20" CornerRadius="10" Background="{DynamicResource Brush.Accent}" Effect="drop-shadow(0 0 6 #40000000)">
<TextBlock Classes="primary" Margin="8,0" Text="{Binding TagName}" FontSize="12" Foreground="White"/>
</Border>
</StackPanel>
<TextBox IsReadOnly="True"
TextWrapping="Wrap"
ScrollViewer.VerticalScrollBarVisibility="Auto"
MaxWidth="500" MaxHeight="400"
Margin="0,8" Padding="0"
VerticalContentAlignment="Top"
Text="{Binding Body}"/>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<Button Classes="flat primary"
Height="30"
Click="GotoDownload"
HorizontalContentAlignment="Center"
VerticalContentAlignment="Center">
<StackPanel Orientation="Horizontal">
<Path Width="12" Height="12" Data="{StaticResource Icons.Pull}" Fill="White"/>
<TextBlock Text="{DynamicResource Text.SelfUpdate.GotoDownload}" Margin="8,0,0,0"/>
</StackPanel>
</Button>
<Button Classes="flat"
Height="30"
Margin="8,0,0,0"
Click="IgnoreThisVersion"
HorizontalContentAlignment="Center"
VerticalContentAlignment="Center">
<StackPanel Orientation="Horizontal">
<Path Width="12" Height="12" Data="{StaticResource Icons.File.Ignore}"/>
<TextBlock Text="{DynamicResource Text.SelfUpdate.IgnoreThisVersion}" Margin="8,0,0,0"/>
</StackPanel>
</Button>
</StackPanel>
</StackPanel>
</DataTemplate>
<DataTemplate DataType="sys:Exception">
<StackPanel Orientation="Vertical" Margin="16,8">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<Path Width="14" Height="14" Data="{StaticResource Icons.Error}" Fill="Red"/>
<TextBlock Margin="8,0,0,0" FontWeight="Bold" FontSize="14" Text="{DynamicResource Text.SelfUpdate.Error}"/>
</StackPanel>
<TextBlock Text="{Binding Message}" MaxWidth="500" TextWrapping="Wrap" Margin="0,8"/>
<Button Classes="flat primary"
Height="30"
Margin="4,0"
Click="CloseWindow"
Content="{DynamicResource Text.Close}"
HorizontalAlignment="Center"
HorizontalContentAlignment="Center"
VerticalContentAlignment="Center"/>
</StackPanel>
</DataTemplate>
<DataTemplate DataType="m:AlreadyUpToDate">
<StackPanel Orientation="Vertical" Margin="16,8">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,8">
<Path Width="14" Height="14" Data="{StaticResource Icons.Info}" Fill="Green"/>
<TextBlock Margin="8,0,0,0" Text="{DynamicResource Text.SelfUpdate.UpToDate}"/>
</StackPanel>
<Button Classes="flat primary"
Height="30"
Margin="4,0"
Click="CloseWindow"
Content="{DynamicResource Text.Close}"
HorizontalAlignment="Center"
HorizontalContentAlignment="Center"
VerticalContentAlignment="Center"/>
</StackPanel>
</DataTemplate>
</ContentControl.DataTemplates>
</ContentControl>
</Grid>
</Grid>
</v:ChromelessWindow>