From 43fed8e04df8bd3c5e58745b2b39e2d70c3322f7 Mon Sep 17 00:00:00 2001 From: leo Date: Fri, 7 Mar 2025 15:12:09 +0800 Subject: [PATCH] refactor: re-write `About` window Signed-off-by: leo --- src/Views/About.axaml | 8 ++++---- src/Views/About.axaml.cs | 30 +++++++++--------------------- 2 files changed, 13 insertions(+), 25 deletions(-) diff --git a/src/Views/About.axaml b/src/Views/About.axaml index 6e45ab70..ecdf156e 100644 --- a/src/Views/About.axaml +++ b/src/Views/About.axaml @@ -5,7 +5,7 @@ xmlns:v="using:SourceGit.Views" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" x:Class="SourceGit.Views.About" - x:DataType="v:About" + x:Name="ThisControl" Icon="/App.ico" Title="{DynamicResource Text.About}" SizeToContent="WidthAndHeight" @@ -13,7 +13,7 @@ WindowStartupLocation="CenterScreen"> - + @@ -46,13 +46,13 @@ - + - + diff --git a/src/Views/About.axaml.cs b/src/Views/About.axaml.cs index bbfd659c..631df0f9 100644 --- a/src/Views/About.axaml.cs +++ b/src/Views/About.axaml.cs @@ -5,30 +5,18 @@ namespace SourceGit.Views { public partial class About : ChromelessWindow { - public string Version - { - get; - private set; - } - - public string Copyright - { - get; - private set; - } - public About() { - var ver = Assembly.GetExecutingAssembly().GetName().Version; - if (ver != null) - Version = $"{ver.Major}.{ver.Minor}"; - var attributes = Assembly.GetExecutingAssembly() - .GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false); - if (attributes.Length > 0) - Copyright = ((AssemblyCopyrightAttribute)attributes[0]).Copyright; - - DataContext = this; InitializeComponent(); + + var assembly = Assembly.GetExecutingAssembly(); + var ver = assembly.GetName().Version; + if (ver != null) + TxtVersion.Text = $"{ver.Major}.{ver.Minor:D2}"; + + var copyright = assembly.GetCustomAttribute(); + if (copyright != null) + TxtCopyright.Text = copyright.Copyright; } private void OnVisitAvaloniaUI(object _, PointerPressedEventArgs e)