From 153ce87884e61371ee5f3124861759b1fa3aa1d4 Mon Sep 17 00:00:00 2001 From: xirreal Date: Sat, 2 Nov 2024 13:05:49 +0100 Subject: [PATCH] Add version display in settings --- Views/Settings.xaml | 15 ++++++++++++--- Views/Settings.xaml.cs | 37 ++++++++++++++++++------------------- 2 files changed, 30 insertions(+), 22 deletions(-) diff --git a/Views/Settings.xaml b/Views/Settings.xaml index 33d6641..b1e9095 100644 --- a/Views/Settings.xaml +++ b/Views/Settings.xaml @@ -8,12 +8,21 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"> - - + + + + + + + + + - + + + diff --git a/Views/Settings.xaml.cs b/Views/Settings.xaml.cs index 3bd659e..76933a2 100644 --- a/Views/Settings.xaml.cs +++ b/Views/Settings.xaml.cs @@ -1,29 +1,28 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Runtime.InteropServices.WindowsRuntime; -using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; -using Microsoft.UI.Xaml.Controls.Primitives; -using Microsoft.UI.Xaml.Data; -using Microsoft.UI.Xaml.Input; -using Microsoft.UI.Xaml.Media; -using Microsoft.UI.Xaml.Navigation; -using Windows.Foundation; -using Windows.Foundation.Collections; - -// To learn more about WinUI, the WinUI project structure, -// and more about our project templates, see: http://aka.ms/winui-project-info. +using Windows.ApplicationModel; namespace TailscaleClient.Views; -/// -/// An empty page that can be used on its own or navigated to within a Frame. -/// + public sealed partial class Settings : Page { + private readonly string Version; + + public static string GetAppVersion() + { + try + { + var version = Package.Current.Id.Version; + return string.Format("{0}.{1}.{2}", version.Major, version.Minor, version.Build); + } + catch + { + return "Unpackaged build"; + } + } + public Settings() { this.InitializeComponent(); + Version = GetAppVersion(); } }