diff --git a/src/CalcViewModel/Common/Utils.cpp b/src/CalcViewModel/Common/Utils.cpp index fbc6d9e1..fdc3f6c1 100644 --- a/src/CalcViewModel/Common/Utils.cpp +++ b/src/CalcViewModel/Common/Utils.cpp @@ -47,20 +47,6 @@ double Utils::GetDoubleFromWstring(wstring input) return stod(ws); } -// Returns windowId for the current view -int Utils::GetWindowId() -{ - int windowId = -1; - - auto window = CoreWindow::GetForCurrentThread(); - if (window != nullptr) - { - windowId = ApplicationView::GetApplicationViewIdForWindow(window); - } - - return windowId; -} - void Utils::RunOnUIThreadNonblocking(std::function&& function, _In_ CoreDispatcher ^ currentDispatcher) { if (currentDispatcher != nullptr) @@ -258,11 +244,6 @@ SolidColorBrush ^ CalculatorApp::ViewModelNative::Common::Utilities::GetContrast return static_cast(Application::Current->Resources->Lookup(L"BlackBrush")); } -int CalculatorApp::ViewModelNative::Common::Utilities::GetWindowId() -{ - return Utils::GetWindowId(); -} - long long CalculatorApp::ViewModelNative::Common::Utilities::GetConst_WINEVENT_KEYWORD_RESPONSE_TIME() { return WINEVENT_KEYWORD_RESPONSE_TIME; diff --git a/src/CalcViewModel/Common/Utils.h b/src/CalcViewModel/Common/Utils.h index 121628a2..af0e8832 100644 --- a/src/CalcViewModel/Common/Utils.h +++ b/src/CalcViewModel/Common/Utils.h @@ -394,7 +394,6 @@ namespace Utils } double GetDoubleFromWstring(std::wstring input); - int GetWindowId(); void RunOnUIThreadNonblocking(std::function&& function, _In_ Windows::UI::Core::CoreDispatcher ^ currentDispatcher); Windows::Foundation::DateTime GetUniversalSystemTime(); @@ -715,7 +714,6 @@ namespace CalculatorApp static Platform::String ^ EscapeHtmlSpecialCharacters(Platform::String ^ originalString); static bool AreColorsEqual(Windows::UI::Color color1, Windows::UI::Color color2); static Windows::UI::Xaml::Media::SolidColorBrush ^ GetContrastColor(Windows::UI::Color backgroundColor); - static int GetWindowId(); static long long GetConst_WINEVENT_KEYWORD_RESPONSE_TIME(); static bool GetIntegratedDisplaySize(double* size); }; diff --git a/src/Calculator.sln b/src/Calculator.sln index 9458f929..9249a50b 100644 --- a/src/Calculator.sln +++ b/src/Calculator.sln @@ -29,6 +29,10 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TraceLogging", "TraceLoggin EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CalcViewModelCopyForUT", "CalcViewModelCopyForUT\CalcViewModelCopyForUT.vcxproj", "{CC9B4FA7-D746-4F52-9401-0AD1B4D6B16D}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CalculatorApp.ViewModel", "CalculatorApp.ViewModel\CalculatorApp.ViewModel.csproj", "{081F0C62-AEAC-47E8-92BC-AD6945F24192}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CalculatorApp.ViewModel.Tests", "CalculatorApp.ViewModel.Tests\CalculatorApp.ViewModel.Tests.csproj", "{3A73F66F-05D7-43CB-8E75-441D7508D943}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|ARM = Debug|ARM @@ -41,6 +45,30 @@ Global Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution + {3B773403-B0D6-4F9A-948E-512A7A5FB315}.Debug|ARM.ActiveCfg = Debug|ARM + {3B773403-B0D6-4F9A-948E-512A7A5FB315}.Debug|ARM.Build.0 = Debug|ARM + {3B773403-B0D6-4F9A-948E-512A7A5FB315}.Debug|ARM.Deploy.0 = Debug|ARM + {3B773403-B0D6-4F9A-948E-512A7A5FB315}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {3B773403-B0D6-4F9A-948E-512A7A5FB315}.Debug|ARM64.Build.0 = Debug|ARM64 + {3B773403-B0D6-4F9A-948E-512A7A5FB315}.Debug|ARM64.Deploy.0 = Debug|ARM64 + {3B773403-B0D6-4F9A-948E-512A7A5FB315}.Debug|x64.ActiveCfg = Debug|x64 + {3B773403-B0D6-4F9A-948E-512A7A5FB315}.Debug|x64.Build.0 = Debug|x64 + {3B773403-B0D6-4F9A-948E-512A7A5FB315}.Debug|x64.Deploy.0 = Debug|x64 + {3B773403-B0D6-4F9A-948E-512A7A5FB315}.Debug|x86.ActiveCfg = Debug|x86 + {3B773403-B0D6-4F9A-948E-512A7A5FB315}.Debug|x86.Build.0 = Debug|x86 + {3B773403-B0D6-4F9A-948E-512A7A5FB315}.Debug|x86.Deploy.0 = Debug|x86 + {3B773403-B0D6-4F9A-948E-512A7A5FB315}.Release|ARM.ActiveCfg = Release|ARM + {3B773403-B0D6-4F9A-948E-512A7A5FB315}.Release|ARM.Build.0 = Release|ARM + {3B773403-B0D6-4F9A-948E-512A7A5FB315}.Release|ARM.Deploy.0 = Release|ARM + {3B773403-B0D6-4F9A-948E-512A7A5FB315}.Release|ARM64.ActiveCfg = Release|ARM64 + {3B773403-B0D6-4F9A-948E-512A7A5FB315}.Release|ARM64.Build.0 = Release|ARM64 + {3B773403-B0D6-4F9A-948E-512A7A5FB315}.Release|ARM64.Deploy.0 = Release|ARM64 + {3B773403-B0D6-4F9A-948E-512A7A5FB315}.Release|x64.ActiveCfg = Release|x64 + {3B773403-B0D6-4F9A-948E-512A7A5FB315}.Release|x64.Build.0 = Release|x64 + {3B773403-B0D6-4F9A-948E-512A7A5FB315}.Release|x64.Deploy.0 = Release|x64 + {3B773403-B0D6-4F9A-948E-512A7A5FB315}.Release|x86.ActiveCfg = Release|x86 + {3B773403-B0D6-4F9A-948E-512A7A5FB315}.Release|x86.Build.0 = Release|x86 + {3B773403-B0D6-4F9A-948E-512A7A5FB315}.Release|x86.Deploy.0 = Release|x86 {311E866D-8B93-4609-A691-265941FEE101}.Debug|ARM.ActiveCfg = Debug|ARM {311E866D-8B93-4609-A691-265941FEE101}.Debug|ARM.Build.0 = Debug|ARM {311E866D-8B93-4609-A691-265941FEE101}.Debug|ARM64.ActiveCfg = Debug|ARM64 @@ -169,30 +197,6 @@ Global {FC81FF41-02CD-4CD9-9BC5-45A1E39AC6ED}.Release|x64.Build.0 = Release|x64 {FC81FF41-02CD-4CD9-9BC5-45A1E39AC6ED}.Release|x86.ActiveCfg = Release|Win32 {FC81FF41-02CD-4CD9-9BC5-45A1E39AC6ED}.Release|x86.Build.0 = Release|Win32 - {3B773403-B0D6-4F9A-948E-512A7A5FB315}.Debug|ARM.ActiveCfg = Debug|ARM - {3B773403-B0D6-4F9A-948E-512A7A5FB315}.Debug|ARM.Build.0 = Debug|ARM - {3B773403-B0D6-4F9A-948E-512A7A5FB315}.Debug|ARM.Deploy.0 = Debug|ARM - {3B773403-B0D6-4F9A-948E-512A7A5FB315}.Debug|ARM64.ActiveCfg = Debug|ARM64 - {3B773403-B0D6-4F9A-948E-512A7A5FB315}.Debug|ARM64.Build.0 = Debug|ARM64 - {3B773403-B0D6-4F9A-948E-512A7A5FB315}.Debug|ARM64.Deploy.0 = Debug|ARM64 - {3B773403-B0D6-4F9A-948E-512A7A5FB315}.Debug|x64.ActiveCfg = Debug|x64 - {3B773403-B0D6-4F9A-948E-512A7A5FB315}.Debug|x64.Build.0 = Debug|x64 - {3B773403-B0D6-4F9A-948E-512A7A5FB315}.Debug|x64.Deploy.0 = Debug|x64 - {3B773403-B0D6-4F9A-948E-512A7A5FB315}.Debug|x86.ActiveCfg = Debug|x86 - {3B773403-B0D6-4F9A-948E-512A7A5FB315}.Debug|x86.Build.0 = Debug|x86 - {3B773403-B0D6-4F9A-948E-512A7A5FB315}.Debug|x86.Deploy.0 = Debug|x86 - {3B773403-B0D6-4F9A-948E-512A7A5FB315}.Release|ARM.ActiveCfg = Release|ARM - {3B773403-B0D6-4F9A-948E-512A7A5FB315}.Release|ARM.Build.0 = Release|ARM - {3B773403-B0D6-4F9A-948E-512A7A5FB315}.Release|ARM.Deploy.0 = Release|ARM - {3B773403-B0D6-4F9A-948E-512A7A5FB315}.Release|ARM64.ActiveCfg = Release|ARM64 - {3B773403-B0D6-4F9A-948E-512A7A5FB315}.Release|ARM64.Build.0 = Release|ARM64 - {3B773403-B0D6-4F9A-948E-512A7A5FB315}.Release|ARM64.Deploy.0 = Release|ARM64 - {3B773403-B0D6-4F9A-948E-512A7A5FB315}.Release|x64.ActiveCfg = Release|x64 - {3B773403-B0D6-4F9A-948E-512A7A5FB315}.Release|x64.Build.0 = Release|x64 - {3B773403-B0D6-4F9A-948E-512A7A5FB315}.Release|x64.Deploy.0 = Release|x64 - {3B773403-B0D6-4F9A-948E-512A7A5FB315}.Release|x86.ActiveCfg = Release|x86 - {3B773403-B0D6-4F9A-948E-512A7A5FB315}.Release|x86.Build.0 = Release|x86 - {3B773403-B0D6-4F9A-948E-512A7A5FB315}.Release|x86.Deploy.0 = Release|x86 {CC9B4FA7-D746-4F52-9401-0AD1B4D6B16D}.Debug|ARM.ActiveCfg = Debug|ARM {CC9B4FA7-D746-4F52-9401-0AD1B4D6B16D}.Debug|ARM.Build.0 = Debug|ARM {CC9B4FA7-D746-4F52-9401-0AD1B4D6B16D}.Debug|ARM64.ActiveCfg = Debug|ARM64 @@ -207,6 +211,46 @@ Global {CC9B4FA7-D746-4F52-9401-0AD1B4D6B16D}.Release|x64.Build.0 = Release|x64 {CC9B4FA7-D746-4F52-9401-0AD1B4D6B16D}.Release|x86.ActiveCfg = Release|Win32 {CC9B4FA7-D746-4F52-9401-0AD1B4D6B16D}.Release|x86.Build.0 = Release|Win32 + {081F0C62-AEAC-47E8-92BC-AD6945F24192}.Debug|ARM.ActiveCfg = Debug|ARM + {081F0C62-AEAC-47E8-92BC-AD6945F24192}.Debug|ARM.Build.0 = Debug|ARM + {081F0C62-AEAC-47E8-92BC-AD6945F24192}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {081F0C62-AEAC-47E8-92BC-AD6945F24192}.Debug|ARM64.Build.0 = Debug|ARM64 + {081F0C62-AEAC-47E8-92BC-AD6945F24192}.Debug|x64.ActiveCfg = Debug|x64 + {081F0C62-AEAC-47E8-92BC-AD6945F24192}.Debug|x64.Build.0 = Debug|x64 + {081F0C62-AEAC-47E8-92BC-AD6945F24192}.Debug|x86.ActiveCfg = Debug|x86 + {081F0C62-AEAC-47E8-92BC-AD6945F24192}.Debug|x86.Build.0 = Debug|x86 + {081F0C62-AEAC-47E8-92BC-AD6945F24192}.Release|ARM.ActiveCfg = Release|ARM + {081F0C62-AEAC-47E8-92BC-AD6945F24192}.Release|ARM.Build.0 = Release|ARM + {081F0C62-AEAC-47E8-92BC-AD6945F24192}.Release|ARM64.ActiveCfg = Release|ARM64 + {081F0C62-AEAC-47E8-92BC-AD6945F24192}.Release|ARM64.Build.0 = Release|ARM64 + {081F0C62-AEAC-47E8-92BC-AD6945F24192}.Release|x64.ActiveCfg = Release|x64 + {081F0C62-AEAC-47E8-92BC-AD6945F24192}.Release|x64.Build.0 = Release|x64 + {081F0C62-AEAC-47E8-92BC-AD6945F24192}.Release|x86.ActiveCfg = Release|x86 + {081F0C62-AEAC-47E8-92BC-AD6945F24192}.Release|x86.Build.0 = Release|x86 + {3A73F66F-05D7-43CB-8E75-441D7508D943}.Debug|ARM.ActiveCfg = Debug|ARM + {3A73F66F-05D7-43CB-8E75-441D7508D943}.Debug|ARM.Build.0 = Debug|ARM + {3A73F66F-05D7-43CB-8E75-441D7508D943}.Debug|ARM.Deploy.0 = Debug|ARM + {3A73F66F-05D7-43CB-8E75-441D7508D943}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {3A73F66F-05D7-43CB-8E75-441D7508D943}.Debug|ARM64.Build.0 = Debug|ARM64 + {3A73F66F-05D7-43CB-8E75-441D7508D943}.Debug|ARM64.Deploy.0 = Debug|ARM64 + {3A73F66F-05D7-43CB-8E75-441D7508D943}.Debug|x64.ActiveCfg = Debug|x64 + {3A73F66F-05D7-43CB-8E75-441D7508D943}.Debug|x64.Build.0 = Debug|x64 + {3A73F66F-05D7-43CB-8E75-441D7508D943}.Debug|x64.Deploy.0 = Debug|x64 + {3A73F66F-05D7-43CB-8E75-441D7508D943}.Debug|x86.ActiveCfg = Debug|x86 + {3A73F66F-05D7-43CB-8E75-441D7508D943}.Debug|x86.Build.0 = Debug|x86 + {3A73F66F-05D7-43CB-8E75-441D7508D943}.Debug|x86.Deploy.0 = Debug|x86 + {3A73F66F-05D7-43CB-8E75-441D7508D943}.Release|ARM.ActiveCfg = Release|ARM + {3A73F66F-05D7-43CB-8E75-441D7508D943}.Release|ARM.Build.0 = Release|ARM + {3A73F66F-05D7-43CB-8E75-441D7508D943}.Release|ARM.Deploy.0 = Release|ARM + {3A73F66F-05D7-43CB-8E75-441D7508D943}.Release|ARM64.ActiveCfg = Release|ARM64 + {3A73F66F-05D7-43CB-8E75-441D7508D943}.Release|ARM64.Build.0 = Release|ARM64 + {3A73F66F-05D7-43CB-8E75-441D7508D943}.Release|ARM64.Deploy.0 = Release|ARM64 + {3A73F66F-05D7-43CB-8E75-441D7508D943}.Release|x64.ActiveCfg = Release|x64 + {3A73F66F-05D7-43CB-8E75-441D7508D943}.Release|x64.Build.0 = Release|x64 + {3A73F66F-05D7-43CB-8E75-441D7508D943}.Release|x64.Deploy.0 = Release|x64 + {3A73F66F-05D7-43CB-8E75-441D7508D943}.Release|x86.ActiveCfg = Release|x86 + {3A73F66F-05D7-43CB-8E75-441D7508D943}.Release|x86.Build.0 = Release|x86 + {3A73F66F-05D7-43CB-8E75-441D7508D943}.Release|x86.Deploy.0 = Release|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/Calculator/Calculator.csproj b/src/Calculator/Calculator.csproj index f47de837..dbbb2071 100644 --- a/src/Calculator/Calculator.csproj +++ b/src/Calculator/Calculator.csproj @@ -797,6 +797,10 @@ + + {081f0c62-aeac-47e8-92bc-ad6945f24192} + CalculatorApp.ViewModel + {812d1a7b-b8ac-49e4-8e6d-af5d59500d56} CalcViewModel diff --git a/src/Calculator/Common/KeyboardShortcutManager.cs b/src/Calculator/Common/KeyboardShortcutManager.cs index f258f824..9e694775 100644 --- a/src/Calculator/Common/KeyboardShortcutManager.cs +++ b/src/Calculator/Common/KeyboardShortcutManager.cs @@ -1,8 +1,10 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +using CalculatorApp.ViewModel.Common; using CalculatorApp.ViewModelNative; using CalculatorApp.ViewModelNative.Common; +using Utilities = CalculatorApp.ViewModel.Common.Utilities; using System; using System.Collections.Generic; diff --git a/src/CalculatorApp.ViewModel.Tests/Assets/LockScreenLogo.scale-200.png b/src/CalculatorApp.ViewModel.Tests/Assets/LockScreenLogo.scale-200.png new file mode 100644 index 00000000..bfd1b0db Binary files /dev/null and b/src/CalculatorApp.ViewModel.Tests/Assets/LockScreenLogo.scale-200.png differ diff --git a/src/CalculatorApp.ViewModel.Tests/Assets/SplashScreen.scale-200.png b/src/CalculatorApp.ViewModel.Tests/Assets/SplashScreen.scale-200.png new file mode 100644 index 00000000..df84c551 Binary files /dev/null and b/src/CalculatorApp.ViewModel.Tests/Assets/SplashScreen.scale-200.png differ diff --git a/src/CalculatorApp.ViewModel.Tests/Assets/Square150x150Logo.scale-200.png b/src/CalculatorApp.ViewModel.Tests/Assets/Square150x150Logo.scale-200.png new file mode 100644 index 00000000..f6e5483e Binary files /dev/null and b/src/CalculatorApp.ViewModel.Tests/Assets/Square150x150Logo.scale-200.png differ diff --git a/src/CalculatorApp.ViewModel.Tests/Assets/Square44x44Logo.scale-200.png b/src/CalculatorApp.ViewModel.Tests/Assets/Square44x44Logo.scale-200.png new file mode 100644 index 00000000..f786a941 Binary files /dev/null and b/src/CalculatorApp.ViewModel.Tests/Assets/Square44x44Logo.scale-200.png differ diff --git a/src/CalculatorApp.ViewModel.Tests/Assets/Square44x44Logo.targetsize-24_altform-unplated.png b/src/CalculatorApp.ViewModel.Tests/Assets/Square44x44Logo.targetsize-24_altform-unplated.png new file mode 100644 index 00000000..4f54c88a Binary files /dev/null and b/src/CalculatorApp.ViewModel.Tests/Assets/Square44x44Logo.targetsize-24_altform-unplated.png differ diff --git a/src/CalculatorApp.ViewModel.Tests/Assets/StoreLogo.png b/src/CalculatorApp.ViewModel.Tests/Assets/StoreLogo.png new file mode 100644 index 00000000..fc77f1a4 Binary files /dev/null and b/src/CalculatorApp.ViewModel.Tests/Assets/StoreLogo.png differ diff --git a/src/CalculatorApp.ViewModel.Tests/Assets/Wide310x150Logo.scale-200.png b/src/CalculatorApp.ViewModel.Tests/Assets/Wide310x150Logo.scale-200.png new file mode 100644 index 00000000..ad540a43 Binary files /dev/null and b/src/CalculatorApp.ViewModel.Tests/Assets/Wide310x150Logo.scale-200.png differ diff --git a/src/CalculatorApp.ViewModel.Tests/CalculatorApp.ViewModel.Tests.csproj b/src/CalculatorApp.ViewModel.Tests/CalculatorApp.ViewModel.Tests.csproj new file mode 100644 index 00000000..b7d19b20 --- /dev/null +++ b/src/CalculatorApp.ViewModel.Tests/CalculatorApp.ViewModel.Tests.csproj @@ -0,0 +1,196 @@ + + + + + Debug + x86 + {3A73F66F-05D7-43CB-8E75-441D7508D943} + AppContainerExe + Properties + CalculatorApp.ViewModel.Tests + CalculatorApp.ViewModel.Tests + en-US + UAP + 10.0.22000.0 + 10.0.19041.0 + 14 + 512 + {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + $(VisualStudioVersion) + false + + + true + bin\x86\Debug\ + DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP + ;2008 + full + x86 + false + prompt + true + + + bin\x86\Release\ + TRACE;NETFX_CORE;WINDOWS_UWP + true + ;2008 + pdbonly + x86 + false + prompt + true + true + + + true + bin\ARM\Debug\ + DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP + ;2008 + full + ARM + false + prompt + true + + + bin\ARM\Release\ + TRACE;NETFX_CORE;WINDOWS_UWP + true + ;2008 + pdbonly + ARM + false + prompt + true + true + + + true + bin\ARM64\Debug\ + DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP + ;2008 + full + ARM64 + false + prompt + true + true + + + bin\ARM64\Release\ + TRACE;NETFX_CORE;WINDOWS_UWP + true + ;2008 + pdbonly + ARM64 + false + prompt + true + true + + + true + bin\x64\Debug\ + DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP + ;2008 + full + x64 + false + prompt + true + + + bin\x64\Release\ + TRACE;NETFX_CORE;WINDOWS_UWP + true + ;2008 + pdbonly + x64 + false + prompt + true + true + + + PackageReference + + + + + + + + UnitTestApp.xaml + + + + + + MSBuild:Compile + Designer + + + + + Designer + + + + + + + + + + + + + + + + + Designer + + + + + 6.2.14 + + + 2.2.10 + + + 2.2.10 + + + + + {081f0c62-aeac-47e8-92bc-ad6945f24192} + CalculatorApp.ViewModel + + + {812d1a7b-b8ac-49e4-8e6d-af5d59500d56} + CalcViewModel + + + {e727a92b-f149-492c-8117-c039a298719b} + GraphControl + + + {fc81ff41-02cd-4cd9-9bc5-45a1e39ac6ed} + TraceLogging + + + + 14.0 + + + + \ No newline at end of file diff --git a/src/CalculatorApp.ViewModel.Tests/Package.appxmanifest b/src/CalculatorApp.ViewModel.Tests/Package.appxmanifest new file mode 100644 index 00000000..4e6d4414 --- /dev/null +++ b/src/CalculatorApp.ViewModel.Tests/Package.appxmanifest @@ -0,0 +1,37 @@ + + + + + + CalculatorApp.ViewModel.Tests + Microsoft Corporation + Assets\StoreLogo.png + + + + + + + + + + + + + + + + + + + + diff --git a/src/CalculatorApp.ViewModel.Tests/Properties/AssemblyInfo.cs b/src/CalculatorApp.ViewModel.Tests/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..4d2c193a --- /dev/null +++ b/src/CalculatorApp.ViewModel.Tests/Properties/AssemblyInfo.cs @@ -0,0 +1,13 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("CalculatorApp.ViewModel.Tests")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft Corporation")] +[assembly: AssemblyProduct("Microsoft Calculator")] +[assembly: AssemblyCopyright("Copyright © Microsoft Corporation. All rights reserved.")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +[assembly: ComVisible(false)] diff --git a/src/CalculatorApp.ViewModel.Tests/Properties/Default.rd.xml b/src/CalculatorApp.ViewModel.Tests/Properties/Default.rd.xml new file mode 100644 index 00000000..996a8392 --- /dev/null +++ b/src/CalculatorApp.ViewModel.Tests/Properties/Default.rd.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/src/CalculatorApp.ViewModel.Tests/UnitTestApp.xaml b/src/CalculatorApp.ViewModel.Tests/UnitTestApp.xaml new file mode 100644 index 00000000..33903874 --- /dev/null +++ b/src/CalculatorApp.ViewModel.Tests/UnitTestApp.xaml @@ -0,0 +1,7 @@ + + + diff --git a/src/CalculatorApp.ViewModel.Tests/UnitTestApp.xaml.cs b/src/CalculatorApp.ViewModel.Tests/UnitTestApp.xaml.cs new file mode 100644 index 00000000..6ba8b054 --- /dev/null +++ b/src/CalculatorApp.ViewModel.Tests/UnitTestApp.xaml.cs @@ -0,0 +1,102 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices.WindowsRuntime; +using Windows.ApplicationModel; +using Windows.ApplicationModel.Activation; +using Windows.Foundation; +using Windows.Foundation.Collections; +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; +using Windows.UI.Xaml.Controls.Primitives; +using Windows.UI.Xaml.Data; +using Windows.UI.Xaml.Input; +using Windows.UI.Xaml.Media; +using Windows.UI.Xaml.Navigation; + +namespace CalculatorApp.ViewModel.Tests +{ + /// + /// Provides application-specific behavior to supplement the default Application class. + /// + sealed partial class App : Application + { + /// + /// Initializes the singleton application object. This is the first line of authored code + /// executed, and as such is the logical equivalent of main() or WinMain(). + /// + public App() + { + this.InitializeComponent(); + this.Suspending += OnSuspending; + } + + /// + /// Invoked when the application is launched normally by the end user. Other entry points + /// will be used such as when the application is launched to open a specific file. + /// + /// Details about the launch request and process. + protected override void OnLaunched(LaunchActivatedEventArgs e) + { + +#if DEBUG + if (System.Diagnostics.Debugger.IsAttached) + { + this.DebugSettings.EnableFrameRateCounter = true; + } +#endif + + Frame rootFrame = Window.Current.Content as Frame; + + // Do not repeat app initialization when the Window already has content, + // just ensure that the window is active + if (rootFrame == null) + { + // Create a Frame to act as the navigation context and navigate to the first page + rootFrame = new Frame(); + + rootFrame.NavigationFailed += OnNavigationFailed; + + if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) + { + //TODO: Load state from previously suspended application + } + + // Place the frame in the current Window + Window.Current.Content = rootFrame; + } + + Microsoft.VisualStudio.TestPlatform.TestExecutor.UnitTestClient.CreateDefaultUI(); + + // Ensure the current window is active + Window.Current.Activate(); + + Microsoft.VisualStudio.TestPlatform.TestExecutor.UnitTestClient.Run(e.Arguments); + } + + /// + /// Invoked when Navigation to a certain page fails + /// + /// The Frame which failed navigation + /// Details about the navigation failure + void OnNavigationFailed(object sender, NavigationFailedEventArgs e) + { + throw new Exception("Failed to load Page " + e.SourcePageType.FullName); + } + + /// + /// Invoked when application execution is being suspended. Application state is saved + /// without knowing whether the application will be terminated or resumed with the contents + /// of memory still intact. + /// + /// The source of the suspend request. + /// Details about the suspend request. + private void OnSuspending(object sender, SuspendingEventArgs e) + { + var deferral = e.SuspendingOperation.GetDeferral(); + //TODO: Save application state and stop any background activity + deferral.Complete(); + } + } +} diff --git a/src/CalculatorApp.ViewModel.Tests/UtilitiesTests.cs b/src/CalculatorApp.ViewModel.Tests/UtilitiesTests.cs new file mode 100644 index 00000000..1febd580 --- /dev/null +++ b/src/CalculatorApp.ViewModel.Tests/UtilitiesTests.cs @@ -0,0 +1,15 @@ +using CalculatorApp.ViewModel.Common; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace CalculatorApp.ViewModel.Tests +{ + [TestClass] + public class UtilitiesTests + { + [TestMethod] + public void NoCoreWindowOnThread_WindowIdIsNegative1() + { + Assert.AreEqual(-1, Utilities.GetWindowId()); + } + } +} diff --git a/src/CalculatorApp.ViewModel/CalculatorApp.ViewModel.csproj b/src/CalculatorApp.ViewModel/CalculatorApp.ViewModel.csproj new file mode 100644 index 00000000..4afeea4b --- /dev/null +++ b/src/CalculatorApp.ViewModel/CalculatorApp.ViewModel.csproj @@ -0,0 +1,134 @@ + + + + + Debug + x86 + {081F0C62-AEAC-47E8-92BC-AD6945F24192} + Library + Properties + CalculatorApp.ViewModel + CalculatorApp.ViewModel + en-US + UAP + 10.0.22000.0 + 10.0.17763.0 + 14 + 512 + {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + + + x86 + true + bin\x86\Debug\ + DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP + ;2008 + full + false + prompt + + + x86 + bin\x86\Release\ + TRACE;NETFX_CORE;WINDOWS_UWP + true + ;2008 + pdbonly + false + prompt + + + ARM + true + bin\ARM\Debug\ + DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP + ;2008 + full + false + prompt + + + ARM + bin\ARM\Release\ + TRACE;NETFX_CORE;WINDOWS_UWP + true + ;2008 + pdbonly + false + prompt + + + ARM64 + true + bin\ARM64\Debug\ + DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP + ;2008 + full + false + prompt + + + ARM64 + bin\ARM64\Release\ + TRACE;NETFX_CORE;WINDOWS_UWP + true + ;2008 + pdbonly + false + prompt + + + x64 + true + bin\x64\Debug\ + DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP + ;2008 + full + false + prompt + + + x64 + bin\x64\Release\ + TRACE;NETFX_CORE;WINDOWS_UWP + true + ;2008 + pdbonly + false + prompt + + + PackageReference + + + + + + + + + 6.2.14 + + + + + {812d1a7b-b8ac-49e4-8e6d-af5d59500d56} + CalcViewModel + + + {fc81ff41-02cd-4cd9-9bc5-45a1e39ac6ed} + TraceLogging + + + + 14.0 + + + + diff --git a/src/CalculatorApp.ViewModel/Common/Utilities.cs b/src/CalculatorApp.ViewModel/Common/Utilities.cs new file mode 100644 index 00000000..513fac4b --- /dev/null +++ b/src/CalculatorApp.ViewModel/Common/Utilities.cs @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Windows.UI.Core; +using Windows.UI.ViewManagement; + +namespace CalculatorApp.ViewModel.Common +{ + public static class Utilities + { + public static int GetWindowId() + { + int windowId = -1; + + var window = CoreWindow.GetForCurrentThread(); + if (window != null) + { + windowId = ApplicationView.GetApplicationViewIdForWindow(window); + } + + return windowId; + } + } +} diff --git a/src/CalculatorApp.ViewModel/Properties/AssemblyInfo.cs b/src/CalculatorApp.ViewModel/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..c4f3ac17 --- /dev/null +++ b/src/CalculatorApp.ViewModel/Properties/AssemblyInfo.cs @@ -0,0 +1,13 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("CalculatorApp.ViewModel")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft Corporation")] +[assembly: AssemblyProduct("Microsoft Calculator")] +[assembly: AssemblyCopyright("Copyright © Microsoft Corporation. All rights reserved.")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +[assembly: ComVisible(false)] diff --git a/src/CalculatorApp.ViewModel/Properties/Calculator.ViewModel.rd.xml b/src/CalculatorApp.ViewModel/Properties/Calculator.ViewModel.rd.xml new file mode 100644 index 00000000..bd2ebdb4 --- /dev/null +++ b/src/CalculatorApp.ViewModel/Properties/Calculator.ViewModel.rd.xml @@ -0,0 +1,33 @@ + + + + + + + + +