Sfoglia il codice sorgente

Added tooltips and used variable for assembly version

CPKreuz 4 anni fa
parent
commit
6c48cbba5e

+ 3 - 6
PixiEditor/Helpers/AssemblyHelper.cs

@@ -8,11 +8,8 @@ namespace PixiEditor.Helpers
 {
     public static class AssemblyHelper
     {
-        public static string GetCurrentAssemblyVersion()
-        {
-            var assembly = Assembly.GetExecutingAssembly();
-            FileVersionInfo info = FileVersionInfo.GetVersionInfo(assembly.Location);
-            return info.FileVersion;
-        }
+        public static Version GetCurrentAssemblyVersion() => Assembly.GetExecutingAssembly().GetName().Version;
+
+        public static string GetCurrentAssemblyVersion(Func<Version, string> toString) => toString(GetCurrentAssemblyVersion());
     }
 }

+ 2 - 2
PixiEditor/ViewModels/SubViewModels/Main/UpdateViewModel.cs

@@ -129,7 +129,7 @@ namespace PixiEditor.ViewModels.SubViewModels.Main
 
         private static void OpenExeInstaller(string updateExeFile)
         {
-            bool alreadyUpdated = AssemblyHelper.GetCurrentAssemblyVersion() ==
+            bool alreadyUpdated = AssemblyHelper.GetCurrentAssemblyVersion().ToString() ==
                     updateExeFile.Split('-')[1].Split(".exe")[0];
 
             if (!alreadyUpdated)
@@ -186,7 +186,7 @@ namespace PixiEditor.ViewModels.SubViewModels.Main
 
         private void InitUpdateChecker()
         {
-            string version = AssemblyHelper.GetCurrentAssemblyVersion();
+            string version = AssemblyHelper.GetCurrentAssemblyVersion().ToString();
             UpdateChecker = new UpdateChecker(version);
             VersionText = $"Version {version}";
         }

+ 2 - 2
PixiEditor/Views/Dialogs/HelloTherePopup.xaml.cs

@@ -20,8 +20,8 @@ namespace PixiEditor.Views.Dialogs
         public static readonly DependencyProperty RecentlyOpenedEmptyProperty =
             DependencyProperty.Register(nameof(RecentlyOpenedEmpty), typeof(bool), typeof(HelloTherePopup));
 
-        public static string VersionText => $"v{Assembly.GetExecutingAssembly().GetName().Version.Major}.{Assembly.GetExecutingAssembly().GetName().Version.Minor}" +
-                (Assembly.GetExecutingAssembly().GetName().Version.Build != 0 ? $".{Assembly.GetExecutingAssembly().GetName().Version.Build}" : "");
+        public static string VersionText => 
+            $"v{AssemblyHelper.GetCurrentAssemblyVersion(x => $"{x.Major}.{x.Minor}" + (x.Revision != 0 ? $".{x.Revision}" : ""))}";
 
         public FileViewModel FileViewModel { get => (FileViewModel)GetValue(FileViewModelProperty); set => SetValue(FileViewModelProperty, value); }
 

+ 5 - 2
PixiEditor/Views/MainWindow.xaml

@@ -175,8 +175,11 @@
         </DockPanel>
         <StackPanel Background="{StaticResource MainColor}" Orientation="Horizontal" Grid.ColumnSpan="3" Grid.Column="0"
                      Grid.Row="1">
-            <Button Margin="1,0,0,0" Command="{Binding UndoSubViewModel.UndoCommand}" Style="{StaticResource ToolSettingsGlyphButton}" Content="&#xE7A7;"/>
-            <Button Command="{Binding UndoSubViewModel.RedoCommand}" Style="{StaticResource ToolSettingsGlyphButton}" Content="&#xE7A6;"/>
+            <Button Margin="1,0,0,0" Command="{Binding UndoSubViewModel.UndoCommand}"
+                    ToolTip="Undo"
+                    Style="{StaticResource ToolSettingsGlyphButton}" Content="&#xE7A7;"/>
+            <Button Command="{Binding UndoSubViewModel.RedoCommand}" ToolTip="Redo"
+                    Style="{StaticResource ToolSettingsGlyphButton}" Content="&#xE7A6;"/>
             <Grid Margin="5,5,10,5" Background="{StaticResource BrighterAccentColor}" Width="5"/>
             <Label Style="{StaticResource BaseLabel}" FontSize="12"
                    VerticalAlignment="Center" Content="{Binding BitmapManager.SelectedTool.DisplayName}"