Merge pull request #2 from josephmoresena/master
Implement Windows About Window
This commit is contained in:
		
							
								
								
									
										120
									
								
								src/AboutWindow.xaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										120
									
								
								src/AboutWindow.xaml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,120 @@ | |||||||
|  | <Window  | ||||||
|  |   xmlns="https://github.com/avaloniaui" | ||||||
|  |   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||||||
|  |   xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||||||
|  |   xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||||||
|  |   WindowState="Normal" | ||||||
|  |   WindowStartupLocation="CenterOwner" | ||||||
|  |   mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="256" | ||||||
|  |   MinHeight="256" MinWidth="640" | ||||||
|  |   Height="256" Width="640" | ||||||
|  |   MaxHeight="256" MaxWidth="640" | ||||||
|  |   x:Class="AvaloniaCoreRTDemo.AboutWindow" | ||||||
|  |   Title="About" | ||||||
|  |   CanResize="false" | ||||||
|  |   ShowInTaskbar="False"> | ||||||
|  |   <Grid | ||||||
|  |     VerticalAlignment="Top" HorizontalAlignment="Left" | ||||||
|  |     ColumnDefinitions="Auto,Auto"  | ||||||
|  |     RowDefinitions="Auto"> | ||||||
|  |     <Image | ||||||
|  |     Margin="0, 60" | ||||||
|  |     Grid.Row="0"  | ||||||
|  |     Grid.Column="0"  | ||||||
|  |     Stretch="None" | ||||||
|  |     Source="{Binding ComputerImage}" | ||||||
|  |         VerticalAlignment="Top" | ||||||
|  |     HorizontalAlignment="Left"> | ||||||
|  |     </Image> | ||||||
|  |     <ScrollViewer | ||||||
|  |      Margin="0, 10" | ||||||
|  |          Width="500" Height="230" | ||||||
|  |      Grid.Row="0" Grid.Column="1" | ||||||
|  |          VerticalAlignment="Top" HorizontalAlignment="Left" | ||||||
|  |      ScrollViewer.VerticalScrollBarVisibility="Auto" | ||||||
|  |      ScrollViewer.HorizontalScrollBarVisibility="Auto"> | ||||||
|  |     <Grid  | ||||||
|  |       ColumnDefinitions="Auto" | ||||||
|  |       RowDefinitions="Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto"> | ||||||
|  |       <Grid Grid.Row="0" Grid.Column="0" ColumnDefinitions="Auto,Auto" RowDefinitions="Auto"> | ||||||
|  |       <TextBlock Grid.Row="0" Grid.Column="0" VerticalAlignment="Top" HorizontalAlignment="Left" TextAlignment="Left" FontWeight="Bold"  | ||||||
|  |         Text="Number of Cores: "/> | ||||||
|  |       <TextBlock Grid.Row="0" Grid.Column="1" VerticalAlignment="Top" HorizontalAlignment="Left" TextAlignment="Left" | ||||||
|  |         Text="{Binding NCores}"/> | ||||||
|  |       </Grid> | ||||||
|  |       <Grid Grid.Row="1" Grid.Column="0" ColumnDefinitions="Auto,Auto" RowDefinitions="Auto"> | ||||||
|  |       <TextBlock Grid.Row="0" Grid.Column="0" VerticalAlignment="Top" HorizontalAlignment="Left" TextAlignment="Left" FontWeight="Bold" | ||||||
|  |         Text="OS: "/> | ||||||
|  |       <TextBlock Grid.Row="0" Grid.Column="1" VerticalAlignment="Top" HorizontalAlignment="Left" TextAlignment="Left" | ||||||
|  |         Text="{Binding OS}"/> | ||||||
|  |       </Grid> | ||||||
|  |       <Grid Grid.Row="2" Grid.Column="0" ColumnDefinitions="Auto,Auto" RowDefinitions="Auto"> | ||||||
|  |       <TextBlock Grid.Row="0" Grid.Column="0" VerticalAlignment="Top" HorizontalAlignment="Left" TextAlignment="Left" FontWeight="Bold" | ||||||
|  |         Text="OS Arch: "/> | ||||||
|  |       <TextBlock Grid.Row="0" Grid.Column="1" VerticalAlignment="Top" HorizontalAlignment="Left" TextAlignment="Left" | ||||||
|  |         Text="{Binding OSArch}"/> | ||||||
|  |       </Grid> | ||||||
|  |       <Grid Grid.Row="3" Grid.Column="0" ColumnDefinitions="Auto,Auto" RowDefinitions="Auto"> | ||||||
|  |       <TextBlock Grid.Row="0" Grid.Column="0" VerticalAlignment="Top" HorizontalAlignment="Left" TextAlignment="Left" FontWeight="Bold" | ||||||
|  |         Text="OS Version: "/> | ||||||
|  |       <TextBlock Grid.Row="0" Grid.Column="1" VerticalAlignment="Top" HorizontalAlignment="Left" TextAlignment="Left" | ||||||
|  |         Text="{Binding OSVersion}"/> | ||||||
|  |       </Grid> | ||||||
|  |       <Grid Grid.Row="4" Grid.Column="0" ColumnDefinitions="Auto,Auto" RowDefinitions="Auto"> | ||||||
|  |       <TextBlock Grid.Row="0" Grid.Column="0" VerticalAlignment="Top" HorizontalAlignment="Left" TextAlignment="Left" FontWeight="Bold" | ||||||
|  |         Text="Computer: "/> | ||||||
|  |       <TextBlock Grid.Row="0" Grid.Column="1" VerticalAlignment="Top" HorizontalAlignment="Left" TextAlignment="Left" | ||||||
|  |         Text="{Binding ComputerName}"/> | ||||||
|  |       </Grid> | ||||||
|  |       <Grid Grid.Row="5" Grid.Column="0" ColumnDefinitions="Auto,Auto" RowDefinitions="Auto"> | ||||||
|  |       <TextBlock Grid.Row="0" Grid.Column="0" VerticalAlignment="Top" HorizontalAlignment="Left" TextAlignment="Left" FontWeight="Bold" | ||||||
|  |         Text="User: "/> | ||||||
|  |       <TextBlock Grid.Row="0" Grid.Column="1" VerticalAlignment="Top" HorizontalAlignment="Left" TextAlignment="Left" | ||||||
|  |         Text="{Binding UserName}"/> | ||||||
|  |       </Grid> | ||||||
|  |       <Grid Grid.Row="6" Grid.Column="0" ColumnDefinitions="Auto,Auto" RowDefinitions="Auto"> | ||||||
|  |       <TextBlock Grid.Row="0" Grid.Column="0" VerticalAlignment="Top" HorizontalAlignment="Left" TextAlignment="Left" FontWeight="Bold" | ||||||
|  |         Text="System Path: "/> | ||||||
|  |       <TextBlock Grid.Row="0" Grid.Column="1" VerticalAlignment="Top" HorizontalAlignment="Left" TextAlignment="Left" | ||||||
|  |         Text="{Binding SystemPath}"/> | ||||||
|  |       </Grid> | ||||||
|  |       <Grid Grid.Row="7" Grid.Column="0" ColumnDefinitions="Auto,Auto" RowDefinitions="Auto"> | ||||||
|  |       <TextBlock Grid.Row="0" Grid.Column="0" VerticalAlignment="Top" HorizontalAlignment="Left" TextAlignment="Left" FontWeight="Bold" | ||||||
|  |         Text="Current Path: "/> | ||||||
|  |       <TextBlock Grid.Row="0" Grid.Column="1" VerticalAlignment="Top" HorizontalAlignment="Left" TextAlignment="Left" | ||||||
|  |         Text="{Binding CurrentPath}"/> | ||||||
|  |       </Grid> | ||||||
|  |       <Grid Grid.Row="8" Grid.Column="0" ColumnDefinitions="Auto,Auto" RowDefinitions="Auto"> | ||||||
|  |       <TextBlock Grid.Row="0" Grid.Column="0" VerticalAlignment="Top" HorizontalAlignment="Left" TextAlignment="Left" FontWeight="Bold" | ||||||
|  |         Text="Process Arch: "/> | ||||||
|  |       <TextBlock Grid.Row="0" Grid.Column="1" VerticalAlignment="Top" HorizontalAlignment="Left" TextAlignment="Left" | ||||||
|  |         Text="{Binding ProcessArch}"/> | ||||||
|  |       </Grid> | ||||||
|  |       <Grid Grid.Row="9" Grid.Column="0" ColumnDefinitions="Auto,Auto" RowDefinitions="Auto"> | ||||||
|  |       <TextBlock Grid.Row="0" Grid.Column="0" VerticalAlignment="Top" HorizontalAlignment="Left" TextAlignment="Left" FontWeight="Bold" | ||||||
|  |         Text="Runtime Name: "/> | ||||||
|  |       <TextBlock Grid.Row="0" Grid.Column="1" VerticalAlignment="Top" HorizontalAlignment="Left" TextAlignment="Left" | ||||||
|  |         Text="{Binding RuntimeName}"/> | ||||||
|  |       </Grid> | ||||||
|  |       <Grid Grid.Row="10" Grid.Column="0" ColumnDefinitions="Auto,Auto" RowDefinitions="Auto"> | ||||||
|  |       <TextBlock Grid.Row="0" Grid.Column="0" VerticalAlignment="Top" HorizontalAlignment="Left" TextAlignment="Left" FontWeight="Bold" | ||||||
|  |         Text="Runtime Path: "/> | ||||||
|  |       <TextBlock Grid.Row="0" Grid.Column="1" VerticalAlignment="Top" HorizontalAlignment="Left" TextAlignment="Left" | ||||||
|  |         Text="{Binding RuntimePath}"/> | ||||||
|  |       </Grid> | ||||||
|  |       <Grid Grid.Row="11" Grid.Column="0" ColumnDefinitions="Auto,Auto" RowDefinitions="Auto"> | ||||||
|  |       <TextBlock Grid.Row="0" Grid.Column="0" VerticalAlignment="Top" HorizontalAlignment="Left" TextAlignment="Left" FontWeight="Bold" | ||||||
|  |         Text="Runtime Version: "/> | ||||||
|  |       <TextBlock Grid.Row="0" Grid.Column="1" VerticalAlignment="Top" HorizontalAlignment="Left" TextAlignment="Left" | ||||||
|  |         Text="{Binding RuntimeVersion}"/> | ||||||
|  |       </Grid> | ||||||
|  |       <Grid Grid.Row="12" Grid.Column="0" ColumnDefinitions="Auto,Auto" RowDefinitions="Auto"> | ||||||
|  |       <TextBlock Grid.Row="0" Grid.Column="0" VerticalAlignment="Top" HorizontalAlignment="Left" TextAlignment="Left" FontWeight="Bold" | ||||||
|  |         Text="Framework Version: "/> | ||||||
|  |       <TextBlock Grid.Row="0" Grid.Column="1" VerticalAlignment="Top" HorizontalAlignment="Left" TextAlignment="Left" | ||||||
|  |         Text="{Binding FrameworkVersion}"/> | ||||||
|  |       </Grid> | ||||||
|  |     </Grid> | ||||||
|  |     </ScrollViewer> | ||||||
|  |   </Grid> | ||||||
|  | </Window> | ||||||
							
								
								
									
										20
									
								
								src/AboutWindow.xaml.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								src/AboutWindow.xaml.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,20 @@ | |||||||
|  | using Avalonia; | ||||||
|  | using Avalonia.Controls; | ||||||
|  | using Avalonia.Markup.Xaml; | ||||||
|  |  | ||||||
|  | namespace AvaloniaCoreRTDemo | ||||||
|  | { | ||||||
|  |     public class AboutWindow : Window | ||||||
|  |     { | ||||||
|  |         public AboutWindow() | ||||||
|  |         { | ||||||
|  |             this.InitializeComponent(); | ||||||
|  |             this.DataContext = new AboutWindowViewModel(); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         private void InitializeComponent() | ||||||
|  |         { | ||||||
|  |             AvaloniaXamlLoader.Load(this); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | } | ||||||
							
								
								
									
										63
									
								
								src/AboutWindowViewModel.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										63
									
								
								src/AboutWindowViewModel.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,63 @@ | |||||||
|  | using System; | ||||||
|  | using System.IO; | ||||||
|  | using System.Linq; | ||||||
|  | using System.Reflection; | ||||||
|  | using System.Runtime.InteropServices; | ||||||
|  | using Avalonia.Media.Imaging; | ||||||
|  | using ReactiveUI; | ||||||
|  | namespace AvaloniaCoreRTDemo | ||||||
|  | { | ||||||
|  |     public class AboutWindowViewModel : ReactiveObject | ||||||
|  |     { | ||||||
|  |         private readonly IBitmap computerImage; | ||||||
|  |  | ||||||
|  |         public IBitmap ComputerImage => computerImage; | ||||||
|  |         public String NCores => Environment.ProcessorCount.ToString(); | ||||||
|  |         public String OS => RuntimeInformation.OSDescription; | ||||||
|  |         public String OSArch => RuntimeInformation.OSArchitecture.ToString(); | ||||||
|  |         public String OSVersion => Environment.OSVersion.ToString(); | ||||||
|  |         public String ComputerName => Environment.MachineName; | ||||||
|  |         public String UserName => Environment.UserName; | ||||||
|  |         public String SystemPath => Environment.SystemDirectory; | ||||||
|  |         public String CurrentPath => Environment.CurrentDirectory; | ||||||
|  |         public String ProcessArch => RuntimeInformation.ProcessArchitecture.ToString(); | ||||||
|  |         public String RuntimeName => RuntimeInformation.FrameworkDescription; | ||||||
|  |         public String RuntimePath => RuntimeEnvironment.GetRuntimeDirectory(); | ||||||
|  |         public String RuntimeVersion => RuntimeEnvironment.GetSystemVersion(); | ||||||
|  |         public String FrameworkVersion => Environment.Version.ToString(); | ||||||
|  |  | ||||||
|  |         private String ComputerImageName | ||||||
|  |         { | ||||||
|  |             get | ||||||
|  |             { | ||||||
|  |                 if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) | ||||||
|  |                     return "windows.png"; | ||||||
|  |                 else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) | ||||||
|  |                     return "macos.png"; | ||||||
|  |                 else | ||||||
|  |                     return "linux.png"; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         public AboutWindowViewModel() | ||||||
|  |         { | ||||||
|  |             this.computerImage = GetImageFromResources(this.ComputerImageName); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         ~AboutWindowViewModel() | ||||||
|  |         { | ||||||
|  |             this.computerImage.Dispose(); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         private static Bitmap GetImageFromResources(String fileName) | ||||||
|  |         { | ||||||
|  |             Assembly asm = Assembly.GetExecutingAssembly(); | ||||||
|  |             String resourceName = asm.GetManifestResourceNames().FirstOrDefault(str => str.EndsWith(fileName)); | ||||||
|  |             if (resourceName != null) | ||||||
|  |                 using (Stream a = asm.GetManifestResourceStream(resourceName)) | ||||||
|  |                     return new Bitmap(a); | ||||||
|  |             else | ||||||
|  |                 return null; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | } | ||||||
| @@ -28,6 +28,10 @@ | |||||||
|     <AvaloniaResource Include="**\*.xaml"> |     <AvaloniaResource Include="**\*.xaml"> | ||||||
|       <SubType>Designer</SubType> |       <SubType>Designer</SubType> | ||||||
|     </AvaloniaResource> |     </AvaloniaResource> | ||||||
|  |     <AvaloniaResource Include="app.ico" /> | ||||||
|  |     <EmbeddedResource Include="linux.png" /> | ||||||
|  |     <EmbeddedResource Include="macos.png" /> | ||||||
|  |     <EmbeddedResource Include="windows.png" /> | ||||||
|   </ItemGroup> |   </ItemGroup> | ||||||
|   <ItemGroup> |   <ItemGroup> | ||||||
|     <PackageReference Include="Avalonia" Version="0.9.9" /> |     <PackageReference Include="Avalonia" Version="0.9.9" /> | ||||||
|   | |||||||
| @@ -6,14 +6,16 @@ | |||||||
|         x:Class="AvaloniaCoreRTDemo.MainWindow" |         x:Class="AvaloniaCoreRTDemo.MainWindow" | ||||||
|         Width="640" Height="480" |         Width="640" Height="480" | ||||||
|         WindowStartupLocation="CenterScreen" |         WindowStartupLocation="CenterScreen" | ||||||
|         Title="AvaloniaCoreRTDemo"> |         Title="AvaloniaCoreRTDemo" | ||||||
|  | 		Icon="avares://AvaloniaCoreRTDemo/app.ico" | ||||||
|  |         MinWidth="400" MinHeight="350"> | ||||||
|     <DockPanel> |     <DockPanel> | ||||||
|         <Menu DockPanel.Dock="Top"> |         <Menu DockPanel.Dock="Top"> | ||||||
|             <MenuItem Header="_File"> |             <MenuItem Header="_File"> | ||||||
|                 <MenuItem Header="_Exit" Command="{Binding FileExitCommand}"/> |                 <MenuItem Header="_Exit" Command="{Binding FileExitCommand}"/> | ||||||
|             </MenuItem> |             </MenuItem> | ||||||
|             <MenuItem Header="_Help"> |             <MenuItem Header="_Help"> | ||||||
|                 <MenuItem Header="About"/> |                 <MenuItem Header="About" Command="{Binding HelpAboutMethod}"/> | ||||||
|             </MenuItem> |             </MenuItem> | ||||||
|         </Menu> |         </Menu> | ||||||
|         <Grid ColumnDefinitions="*,*" RowDefinitions="Auto,Auto,*" Margin="32"> |         <Grid ColumnDefinitions="*,*" RowDefinitions="Auto,Auto,*" Margin="32"> | ||||||
|   | |||||||
| @@ -10,7 +10,7 @@ namespace AvaloniaCoreRTDemo | |||||||
|         public MainWindow() |         public MainWindow() | ||||||
|         { |         { | ||||||
|             InitializeComponent(); |             InitializeComponent(); | ||||||
|             this.DataContext = new MainWindowViewModel(); |             this.DataContext = new MainWindowViewModel(this); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         private void InitializeComponent() |         private void InitializeComponent() | ||||||
|   | |||||||
| @@ -9,13 +9,14 @@ namespace AvaloniaCoreRTDemo | |||||||
| { | { | ||||||
|     public class MainWindowViewModel: ReactiveObject |     public class MainWindowViewModel: ReactiveObject | ||||||
|     { |     { | ||||||
|         public MainWindowViewModel() |         public MainWindowViewModel(MainWindow window) | ||||||
|         { |         { | ||||||
|  |             _window = window; | ||||||
|  | 			 | ||||||
|             DotNetImage = new Bitmap(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "dotnet.png")); |             DotNetImage = new Bitmap(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "dotnet.png")); | ||||||
|             AvaloniaImage = new Bitmap(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "avalonia.png")); |             AvaloniaImage = new Bitmap(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "avalonia.png")); | ||||||
|  |  | ||||||
|             FileExitCommand = ReactiveCommand.Create(RunFileExit); |             FileExitCommand = ReactiveCommand.Create(RunFileExit); | ||||||
|             HelpAboutCommand = ReactiveCommand.Create(RunHelpAbout); |  | ||||||
|         } |         } | ||||||
|          |          | ||||||
|         public IBitmap DotNetImage |         public IBitmap DotNetImage | ||||||
| @@ -31,7 +32,7 @@ namespace AvaloniaCoreRTDemo | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         public ReactiveCommand<Unit, Unit> FileExitCommand { get; } |         public ReactiveCommand<Unit, Unit> FileExitCommand { get; } | ||||||
|         public ReactiveCommand<Unit, Unit> HelpAboutCommand { get; } |         public void HelpAboutMethod() => RunHelpAbout(); | ||||||
|  |  | ||||||
|         void RunFileExit() |         void RunFileExit() | ||||||
|         { |         { | ||||||
| @@ -40,10 +41,11 @@ namespace AvaloniaCoreRTDemo | |||||||
|  |  | ||||||
|         void RunHelpAbout() |         void RunHelpAbout() | ||||||
|         { |         { | ||||||
|             // Code for executing the command here. |             new AboutWindow().ShowDialog(_window); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         private IBitmap dotNetImage; |         private IBitmap dotNetImage; | ||||||
|         private IBitmap avaloniaImage; |         private IBitmap avaloniaImage; | ||||||
|  |         private readonly MainWindow _window; | ||||||
|     } |     } | ||||||
| } | } | ||||||
							
								
								
									
										
											BIN
										
									
								
								src/app.ico
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								src/app.ico
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 179 KiB | 
							
								
								
									
										
											BIN
										
									
								
								src/linux.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								src/linux.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 11 KiB | 
							
								
								
									
										
											BIN
										
									
								
								src/macos.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								src/macos.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 11 KiB | 
							
								
								
									
										
											BIN
										
									
								
								src/windows.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								src/windows.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 1.3 KiB | 
		Reference in New Issue
	
	Block a user
	 Todor Totev
					Todor Totev