Index: Core/Gui/src/Core.Gui/Core.Gui.csproj =================================================================== diff -u -r7c5df631cce0db3757a6082a71abfd43de425fab -r7f662d4ad83e09ac71f656dfa7e6e4800616512b --- Core/Gui/src/Core.Gui/Core.Gui.csproj (.../Core.Gui.csproj) (revision 7c5df631cce0db3757a6082a71abfd43de425fab) +++ Core/Gui/src/Core.Gui/Core.Gui.csproj (.../Core.Gui.csproj) (revision 7f662d4ad83e09ac71f656dfa7e6e4800616512b) @@ -7,6 +7,7 @@ + @@ -28,6 +29,10 @@ + + MSBuild:Compile + Designer + MSBuild:Compile Designer Index: Core/Gui/src/Core.Gui/Forms/Backstage/AboutBackstagePage.xaml =================================================================== diff -u --- Core/Gui/src/Core.Gui/Forms/Backstage/AboutBackstagePage.xaml (revision 0) +++ Core/Gui/src/Core.Gui/Forms/Backstage/AboutBackstagePage.xaml (revision 7f662d4ad83e09ac71f656dfa7e6e4800616512b) @@ -0,0 +1,118 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Index: Core/Gui/src/Core.Gui/Forms/Backstage/AboutBackstagePage.xaml.cs =================================================================== diff -u --- Core/Gui/src/Core.Gui/Forms/Backstage/AboutBackstagePage.xaml.cs (revision 0) +++ Core/Gui/src/Core.Gui/Forms/Backstage/AboutBackstagePage.xaml.cs (revision 7f662d4ad83e09ac71f656dfa7e6e4800616512b) @@ -0,0 +1,39 @@ +// Copyright (C) Stichting Deltares 2021. All rights reserved. +// +// This file is part of Riskeer. +// +// Riskeer is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System.Windows.Controls; + +namespace Core.Gui.Forms.Backstage +{ + /// + /// Main user interface of the application. + /// + public partial class AboutBackstagePage : UserControl + { + /// + /// Creates a new instance of . + /// + public AboutBackstagePage() + { + InitializeComponent(); + } + } +} \ No newline at end of file Index: Core/Gui/src/Core.Gui/Forms/Backstage/AboutViewModel.cs =================================================================== diff -u -r7ed9edfa97f83402ba56d518da451e56f0cdccf6 -r7f662d4ad83e09ac71f656dfa7e6e4800616512b --- Core/Gui/src/Core.Gui/Forms/Backstage/AboutViewModel.cs (.../AboutViewModel.cs) (revision 7ed9edfa97f83402ba56d518da451e56f0cdccf6) +++ Core/Gui/src/Core.Gui/Forms/Backstage/AboutViewModel.cs (.../AboutViewModel.cs) (revision 7f662d4ad83e09ac71f656dfa7e6e4800616512b) @@ -19,7 +19,99 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; +using System.Globalization; +using System.Linq; +using System.Management; +using System.Windows; + namespace Core.Gui.Forms.Backstage { - public class AboutViewModel : IBackstagePageViewModel {} + /// + /// ViewModel for . + /// + public class AboutViewModel : IBackstagePageViewModel + { + /// + /// Creates a new instance of . + /// + public AboutViewModel() + { + WindowsEdition = (string) GetOperatingSystemValue("Caption"); + WindowsBuild = (string) GetOperatingSystemValue("BuildNumber"); + Processor = (string) GetProcessorValue("Name"); + } + + /// + /// Gets the application version. + /// + public string Version => "Riskeer 21.2.1.1"; + + /// + /// Gets the Windows edition. + /// + public string WindowsEdition { get; } + + /// + /// Gets the Windows build. + /// + public string WindowsBuild { get; } + + /// + /// Gets the processor information. + /// + public string Processor { get; } + + /// + /// Gets the amount of installed RAM. + /// + public string InstalledRam + { + get + { + const double kilobyteDivider = 1024.0; + const double gigabyteDivider = kilobyteDivider * kilobyteDivider * kilobyteDivider; + double installedRam = (ulong) GetComputerSystemValue("TotalPhysicalMemory") / gigabyteDivider; + + return $"{Math.Round(installedRam, 2).ToString(CultureInfo.InvariantCulture)} GB"; + } + } + + /// + /// Gets the primary display resolution. + /// + public string Resolution => + $"{SystemParameters.PrimaryScreenWidth.ToString(CultureInfo.InvariantCulture)} " + + $"x {SystemParameters.PrimaryScreenHeight.ToString(CultureInfo.InvariantCulture)}"; + + private static object GetOperatingSystemValue(string propertyName) + { + ManagementObject managementObject = + new ManagementObjectSearcher("select * from Win32_OperatingSystem") + .Get() + .Cast() + .First(); + return managementObject[propertyName]; + } + + private static object GetProcessorValue(string propertyName) + { + ManagementObject managementObject = + new ManagementObjectSearcher("select * from Win32_Processor") + .Get() + .Cast() + .First(); + return managementObject[propertyName]; + } + + private static object GetComputerSystemValue(string propertyName) + { + ManagementObject managementObject = + new ManagementObjectSearcher("select * from Win32_ComputerSystem") + .Get() + .Cast() + .First(); + return managementObject[propertyName]; + } + } } \ No newline at end of file Index: Core/Gui/src/Core.Gui/Forms/Backstage/BackstageControl.xaml =================================================================== diff -u -r7c5df631cce0db3757a6082a71abfd43de425fab -r7f662d4ad83e09ac71f656dfa7e6e4800616512b --- Core/Gui/src/Core.Gui/Forms/Backstage/BackstageControl.xaml (.../BackstageControl.xaml) (revision 7c5df631cce0db3757a6082a71abfd43de425fab) +++ Core/Gui/src/Core.Gui/Forms/Backstage/BackstageControl.xaml (.../BackstageControl.xaml) (revision 7f662d4ad83e09ac71f656dfa7e6e4800616512b) @@ -135,7 +135,7 @@ Open - Over + Index: Core/Gui/test/Core.Gui.Test/Core.Gui.Test.csproj =================================================================== diff -u -r3120efcaf6922a96bced4a5c543c7f2096ba5ab1 -r7f662d4ad83e09ac71f656dfa7e6e4800616512b --- Core/Gui/test/Core.Gui.Test/Core.Gui.Test.csproj (.../Core.Gui.Test.csproj) (revision 3120efcaf6922a96bced4a5c543c7f2096ba5ab1) +++ Core/Gui/test/Core.Gui.Test/Core.Gui.Test.csproj (.../Core.Gui.Test.csproj) (revision 7f662d4ad83e09ac71f656dfa7e6e4800616512b) @@ -9,6 +9,7 @@ + Index: Core/Gui/test/Core.Gui.Test/Forms/Backstage/AboutViewModelTest.cs =================================================================== diff -u -r7ed9edfa97f83402ba56d518da451e56f0cdccf6 -r7f662d4ad83e09ac71f656dfa7e6e4800616512b --- Core/Gui/test/Core.Gui.Test/Forms/Backstage/AboutViewModelTest.cs (.../AboutViewModelTest.cs) (revision 7ed9edfa97f83402ba56d518da451e56f0cdccf6) +++ Core/Gui/test/Core.Gui.Test/Forms/Backstage/AboutViewModelTest.cs (.../AboutViewModelTest.cs) (revision 7f662d4ad83e09ac71f656dfa7e6e4800616512b) @@ -19,6 +19,11 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; +using System.Globalization; +using System.Linq; +using System.Management; +using System.Windows; using Core.Gui.Forms.Backstage; using NUnit.Framework; @@ -35,6 +40,46 @@ // Assert Assert.IsInstanceOf(viewModel); + Assert.AreEqual("Riskeer 21.2.1.1", viewModel.Version); + + ManagementObject processorManagementObject = + new ManagementObjectSearcher("select * from Win32_Processor") + .Get() + .Cast() + .First(); + + ManagementObject operatingSystemManagementObject = + new ManagementObjectSearcher("select * from Win32_OperatingSystem") + .Get() + .Cast() + .First(); + + var installedRam = $"{Math.Round(GetInstalledRam(), 2).ToString(CultureInfo.InvariantCulture)} GB"; + + Assert.AreEqual(operatingSystemManagementObject["Caption"], viewModel.WindowsEdition); + Assert.AreEqual(operatingSystemManagementObject["BuildNumber"], viewModel.WindowsBuild); + Assert.AreEqual(processorManagementObject["Name"], viewModel.Processor); + Assert.AreEqual(installedRam, viewModel.InstalledRam); + Assert.AreEqual(GetResolution(), viewModel.Resolution); } + + private static string GetResolution() + { + return $"{SystemParameters.PrimaryScreenWidth.ToString(CultureInfo.InvariantCulture)} " + + $"x {SystemParameters.PrimaryScreenHeight.ToString(CultureInfo.InvariantCulture)}"; + } + + private static double GetInstalledRam() + { + ManagementObject computerSystemManagementObject = + new ManagementObjectSearcher("select * from Win32_ComputerSystem") + .Get() + .Cast() + .First(); + + const double kilobyteDivider = 1024.0; + const double gigabyteDivider = kilobyteDivider * kilobyteDivider * kilobyteDivider; + return (ulong) computerSystemManagementObject["TotalPhysicalMemory"] / gigabyteDivider; + } } } \ No newline at end of file