Skip to content

Commit 43fed8e

Browse files
committed
refactor: re-write About window
Signed-off-by: leo <longshuang@msn.cn>
1 parent 83f2358 commit 43fed8e

File tree

2 files changed

+12
-24
lines changed

2 files changed

+12
-24
lines changed

src/Views/About.axaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
xmlns:v="using:SourceGit.Views"
66
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
77
x:Class="SourceGit.Views.About"
8-
x:DataType="v:About"
8+
x:Name="ThisControl"
99
Icon="/App.ico"
1010
Title="{DynamicResource Text.About}"
1111
SizeToContent="WidthAndHeight"
1212
CanResize="False"
1313
WindowStartupLocation="CenterScreen">
1414
<Grid RowDefinitions="Auto,*">
1515
<!-- TitleBar -->
16-
<Grid Grid.Row="0" Height="28" IsVisible="{Binding !UseSystemWindowFrame}">
16+
<Grid Grid.Row="0" Height="28" IsVisible="{Binding !#ThisControl.UseSystemWindowFrame}">
1717
<Border Background="{DynamicResource Brush.TitleBar}"
1818
BorderThickness="0,0,0,1" BorderBrush="{DynamicResource Brush.Border0}"
1919
PointerPressed="BeginMoveWindow"/>
@@ -46,13 +46,13 @@
4646
<StackPanel Height="48" Orientation="Horizontal">
4747
<TextBlock Classes="bold" Text="SourceGit" FontSize="32" />
4848
<Border Margin="12,0,0,0" Height="20" CornerRadius="10" Background="{DynamicResource Brush.Accent}" Effect="drop-shadow(0 0 6 #40000000)">
49-
<TextBlock Classes="primary" Margin="8,0" Text="{Binding Version}" FontSize="12" Foreground="White"/>
49+
<TextBlock x:Name="TxtVersion" Classes="primary" Margin="8,0" FontSize="12" Foreground="White"/>
5050
</Border>
5151
</StackPanel>
5252

5353
<TextBlock Margin="2,0,0,0" Text="{DynamicResource Text.About.SubTitle}" FontSize="16"/>
5454

55-
<TextBlock Margin="2,8,0,0" Text="{Binding Copyright}" Foreground="{DynamicResource Brush.FG2}"/>
55+
<TextBlock x:Name="TxtCopyright" Margin="2,8,0,0" Foreground="{DynamicResource Brush.FG2}"/>
5656

5757
<StackPanel Orientation="Vertical" Margin="0,24,0,0">
5858
<StackPanel Orientation="Horizontal" Height="18">

src/Views/About.axaml.cs

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,18 @@ namespace SourceGit.Views
55
{
66
public partial class About : ChromelessWindow
77
{
8-
public string Version
9-
{
10-
get;
11-
private set;
12-
}
13-
14-
public string Copyright
15-
{
16-
get;
17-
private set;
18-
}
19-
208
public About()
219
{
22-
var ver = Assembly.GetExecutingAssembly().GetName().Version;
10+
InitializeComponent();
11+
12+
var assembly = Assembly.GetExecutingAssembly();
13+
var ver = assembly.GetName().Version;
2314
if (ver != null)
24-
Version = $"{ver.Major}.{ver.Minor}";
25-
var attributes = Assembly.GetExecutingAssembly()
26-
.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false);
27-
if (attributes.Length > 0)
28-
Copyright = ((AssemblyCopyrightAttribute)attributes[0]).Copyright;
15+
TxtVersion.Text = $"{ver.Major}.{ver.Minor:D2}";
2916

30-
DataContext = this;
31-
InitializeComponent();
17+
var copyright = assembly.GetCustomAttribute<AssemblyCopyrightAttribute>();
18+
if (copyright != null)
19+
TxtCopyright.Text = copyright.Copyright;
3220
}
3321

3422
private void OnVisitAvaloniaUI(object _, PointerPressedEventArgs e)

0 commit comments

Comments
 (0)