Commits

Christian Specht committed 139b412 Draft

add AboutWindowViewModel, load information from assembly info

  • Participants
  • Parent commits 4ba04c1

Comments (0)

Files changed (4)

src/MissileSharp.Launcher/MissileSharp.Launcher.csproj

       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
     </ApplicationDefinition>
+    <Compile Include="ViewModels\AboutWindowViewModel.cs">
+      <SubType>Code</SubType>
+    </Compile>
     <Compile Include="ViewModels\BaseViewModel.cs" />
     <Compile Include="ViewModels\MessageBoxWindowViewModel.cs" />
     <Compile Include="Views\AboutWindow.xaml.cs">

src/MissileSharp.Launcher/ViewModels/AboutWindowViewModel.cs

+using System.Diagnostics;
+using System.Reflection;
+
+namespace MissileSharp.Launcher.ViewModels
+{
+    public class AboutWindowViewModel : BaseViewModel
+    {
+        private FileVersionInfo info;
+
+        public AboutWindowViewModel()
+        {
+            this.info = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location);
+        }
+
+        public string VersionNumber
+        {
+            get { return this.info.ProductName + " " + this.info.FileVersion; }
+        }
+
+        public string CopyRight
+        {
+            get { return this.info.LegalCopyright; }
+        }
+    }
+}

src/MissileSharp.Launcher/Views/AboutWindow.xaml

             <Image Grid.Column="0" Source="logo64x64.png" Height="64" Width="64" Margin="0 0 10 0" />
             
             <StackPanel Grid.Column="1">
-                <TextBlock Text="MissileSharp" FontSize="16"/>
-                <TextBlock Text="by Christian Specht" FontSize="14" Margin="0 10" />
+                <TextBlock Text="{Binding VersionNumber}" FontSize="16"/>
+                <TextBlock Text="{Binding CopyRight}" FontSize="14" Margin="0 10" />
             </StackPanel>
         </Grid>
 

src/MissileSharp.Launcher/Views/AboutWindow.xaml.cs

 using MahApps.Metro.Controls;
+using MissileSharp.Launcher.ViewModels;
 
 namespace MissileSharp.Launcher.Views
 {
     /// </summary>
     public partial class AboutWindow : MetroWindow
     {
-        public AboutWindow()
+        public AboutWindow(AboutWindowViewModel viewmodel)
         {
+            this.DataContext = viewmodel;
             InitializeComponent();
         }
     }