diff --git a/src/Calculator.sln b/src/Calculator.sln
index bd6ac391..d51cad82 100644
--- a/src/Calculator.sln
+++ b/src/Calculator.sln
@@ -25,6 +25,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GraphControl", "GraphContro
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TraceLogging", "TraceLogging\TraceLogging.vcxproj", "{FC81FF41-02CD-4CD9-9BC5-45A1E39AC6ED}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Calculator", "Calculator\Calculator.csproj", "{3B773403-B0D6-4F9A-948E-512A7A5FB315}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|ARM = Debug|ARM
@@ -165,6 +167,30 @@ 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
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/src/Calculator/App.xaml b/src/Calculator/App.xaml
new file mode 100644
index 00000000..4a0cca57
--- /dev/null
+++ b/src/Calculator/App.xaml
@@ -0,0 +1,1778 @@
+
+
+
+
+
+
+
+
+
+ 0,0,0,0
+ 0
+ #FF000000
+ #FF2B2B2B
+ #FF858585
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Dark
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 0,0,0,0
+ 0
+ #FFF2F2F2
+ #FFE0E0E0
+ #FF858585
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Light
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 0,1,0,0
+ 2
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Dark
+
+
+
+
+
+
+
+
+
+ 500
+ 320
+
+ ms-appx:///Assets/CalcMDL2.ttf#Calculator MDL2 Assets
+
+ 256
+ 0,1,0,0
+ 15
+ SemiBold
+
+ 64
+ 24
+ 24
+ 16
+
+ 64
+ 16
+ 20
+ 10
+
+ 38
+ 12
+ 16
+ 8
+
+ 12
+ 15
+ 24
+
+
+ 40
+ 40
+
+ 34
+ 38
+ 48
+ 24
+
+ 20
+ 22
+ 15
+ 12
+
+ 14
+ 16
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Calculator/App.xaml.cs b/src/Calculator/App.xaml.cs
new file mode 100644
index 00000000..b682beac
--- /dev/null
+++ b/src/Calculator/App.xaml.cs
@@ -0,0 +1,511 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+// App.xaml.h
+// Declaration of the App class.
+//
+
+using CalculatorApp.Common;
+using CalculatorApp.Common.Automation;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Threading;
+using System.Threading.Tasks;
+
+using Windows.ApplicationModel;
+using Windows.ApplicationModel.Activation;
+using Windows.ApplicationModel.Core;
+using Windows.Foundation;
+using Windows.Storage;
+using Windows.UI.Core;
+using Windows.UI.StartScreen;
+using Windows.UI.ViewManagement;
+using Windows.UI.Xaml;
+using Windows.UI.Xaml.Controls;
+
+namespace CalculatorApp
+{
+ namespace ApplicationResourceKeys
+ {
+ static public partial class Globals
+ {
+ public static readonly string AppMinWindowHeight = "AppMinWindowHeight";
+ public static readonly string AppMinWindowWidth = "AppMinWindowWidth";
+ }
+ }
+
+ ///
+ /// Provides application-specific behavior to supplement the default Application class.
+ ///
+ sealed partial class App
+ {
+ ///
+ /// 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()
+ {
+ InitializeComponent();
+
+ m_preLaunched = false;
+
+ RegisterDependencyProperties();
+
+ // TODO: MSFT 14645325: Set this directly from XAML.
+ // Currently this is bugged so the property is only respected from code-behind.
+ HighContrastAdjustment = ApplicationHighContrastAdjustment.None;
+
+ Suspending += OnSuspending;
+
+ // CSHARP_MIGRATION: TODO:
+#if DEBUG
+ DebugSettings.IsBindingTracingEnabled = true;
+ DebugSettings.BindingFailed += (sender, args) =>
+ {
+ if (Debugger.IsAttached)
+ {
+ string errorMessage = args.Message;
+ Debugger.Break();
+ }
+ };
+#endif
+ }
+
+ ///
+ /// Invoked when the application is launched normally by the end user. Other entry points
+ /// will be used when the application is launched to open a specific file, to display
+ /// search results, and so forth.
+ ///
+ /// Details about the launch request and process.
+ protected override void OnLaunched(LaunchActivatedEventArgs args)
+ {
+ if (args.PrelaunchActivated)
+ {
+ // If the app got pre-launch activated, then save that state in a flag
+ m_preLaunched = true;
+ }
+ OnAppLaunch(args, args.Arguments);
+ }
+
+ protected override void OnActivated(IActivatedEventArgs args)
+ {
+ if (args.Kind == ActivationKind.Protocol)
+ {
+ // We currently don't pass the uri as an argument,
+ // and handle any protocol launch as a normal app launch.
+ OnAppLaunch(args, null);
+ }
+ }
+
+ internal void RemoveWindow(WindowFrameService frameService)
+ {
+ // Shell does not allow killing the main window.
+ if (m_mainViewId != frameService.GetViewId())
+ {
+ _ = HandleViewReleaseAndRemoveWindowFromMap(frameService);
+ }
+ }
+
+ internal void RemoveSecondaryWindow(WindowFrameService frameService)
+ {
+ // Shell does not allow killing the main window.
+ if (m_mainViewId != frameService.GetViewId())
+ {
+ RemoveWindowFromMap(frameService.GetViewId());
+ }
+ }
+
+ private static Frame CreateFrame()
+ {
+ var frame = new Frame();
+ frame.FlowDirection = LocalizationService.GetInstance().GetFlowDirection();
+ return frame;
+ }
+
+ private static void SetMinWindowSizeAndActivate(Frame rootFrame, Size minWindowSize)
+ {
+ // SetPreferredMinSize should always be called before Window.Activate
+ ApplicationView appView = ApplicationView.GetForCurrentView();
+ appView.SetPreferredMinSize(minWindowSize);
+
+ // Place the frame in the current Window
+ Window.Current.Content = rootFrame;
+ Window.Current.Activate();
+ }
+
+ private void OnAppLaunch(IActivatedEventArgs args, string argument)
+ {
+ // Uncomment the following lines to display frame-rate and per-frame CPU usage info.
+ //#if _DEBUG
+ // if (IsDebuggerPresent())
+ // {
+ // DebugSettings->EnableFrameRateCounter = true;
+ // }
+ //#endif
+
+ args.SplashScreen.Dismissed += DismissedEventHandler;
+
+ var rootFrame = (Window.Current.Content as Frame);
+ WeakReference weak = new WeakReference(this);
+
+ float minWindowWidth = (float)((double)Resources[ApplicationResourceKeys.Globals.AppMinWindowWidth]);
+ float minWindowHeight = (float)((double)Resources[ApplicationResourceKeys.Globals.AppMinWindowHeight]);
+ Size minWindowSize = SizeHelper.FromDimensions(minWindowWidth, minWindowHeight);
+
+ ApplicationView appView = ApplicationView.GetForCurrentView();
+ ApplicationDataContainer localSettings = ApplicationData.Current.LocalSettings;
+ // For very first launch, set the size of the calc as size of the default standard mode
+ if (!localSettings.Values.ContainsKey("VeryFirstLaunch"))
+ {
+ localSettings.Values.Add("VeryFirstLaunch", false);
+ appView.SetPreferredMinSize(minWindowSize);
+ appView.TryResizeView(minWindowSize);
+ }
+ else
+ {
+ ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.Auto;
+ }
+
+ // Do not repeat app initialization when the Window already has content,
+ // just ensure that the window is active
+ if (rootFrame == null)
+ {
+ if (!Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons")) // PC Family
+ {
+ // Disable the system view activation policy during the first launch of the app
+ // only for PC family devices and not for phone family devices
+ try
+ {
+ ApplicationViewSwitcher.DisableSystemViewActivationPolicy();
+ }
+ catch (Exception)
+ {
+ // Log that DisableSystemViewActionPolicy didn't work
+ }
+ }
+
+ // Create a Frame to act as the navigation context
+ rootFrame = App.CreateFrame();
+
+ // When the navigation stack isn't restored navigate to the first page,
+ // configuring the new page by passing required information as a navigation
+ // parameter
+ if (!rootFrame.Navigate(typeof(MainPage), argument))
+ {
+ // We couldn't navigate to the main page, kill the app so we have a good
+ // stack to debug
+ throw new SystemException();
+ }
+
+ SetMinWindowSizeAndActivate(rootFrame, minWindowSize);
+ m_mainViewId = ApplicationView.GetForCurrentView().Id;
+ AddWindowToMap(WindowFrameService.CreateNewWindowFrameService(rootFrame, false, weak));
+ }
+ else
+ {
+ // For first launch, LaunchStart is logged in constructor, this is for subsequent launches.
+
+ // !Phone check is required because even in continuum mode user interaction mode is Mouse not Touch
+ if ((UIViewSettings.GetForCurrentView().UserInteractionMode == UserInteractionMode.Mouse)
+ && (!Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons")))
+ {
+ // If the pre-launch hasn't happened then allow for the new window/view creation
+ if (!m_preLaunched)
+ {
+ var newCoreAppView = CoreApplication.CreateNewView();
+ _ = newCoreAppView.Dispatcher.RunAsync(
+ CoreDispatcherPriority.Normal, async () =>
+ {
+ var that = weak.Target as App;
+ if (that != null)
+ {
+ var newRootFrame = App.CreateFrame();
+
+ SetMinWindowSizeAndActivate(newRootFrame, minWindowSize);
+
+ if (!newRootFrame.Navigate(typeof(MainPage), argument))
+ {
+ // We couldn't navigate to the main page, kill the app so we have a good
+ // stack to debug
+ throw new SystemException();
+ }
+
+ var frameService = WindowFrameService.CreateNewWindowFrameService(newRootFrame, true, weak);
+ that.AddWindowToMap(frameService);
+
+ var dispatcher = CoreWindow.GetForCurrentThread().Dispatcher;
+
+ // CSHARP_MIGRATION_ANNOTATION:
+ // class SafeFrameWindowCreation is being interpreted into a IDisposable class
+ // in order to enhance its RAII capability that was written in C++/CX
+ using (var safeFrameServiceCreation = new SafeFrameWindowCreation(frameService, that))
+ {
+ int newWindowId = ApplicationView.GetApplicationViewIdForWindow(CoreWindow.GetForCurrentThread());
+
+ ActivationViewSwitcher activationViewSwitcher = null;
+ var activateEventArgs = (args as IViewSwitcherProvider);
+ if (activateEventArgs != null)
+ {
+ activationViewSwitcher = activateEventArgs.ViewSwitcher;
+ }
+
+ if (activationViewSwitcher != null)
+ {
+ _ = activationViewSwitcher.ShowAsStandaloneAsync(newWindowId, ViewSizePreference.Default);
+ safeFrameServiceCreation.SetOperationSuccess(true);
+ }
+ else
+ {
+ var activatedEventArgs = (args as IApplicationViewActivatedEventArgs);
+ if ((activatedEventArgs != null) && (activatedEventArgs.CurrentlyShownApplicationViewId != 0))
+ {
+ // CSHARP_MIGRATION_ANNOTATION:
+ // here we don't use ContinueWith() to interpret origin code because we would like to
+ // pursue the design of class SafeFrameWindowCreate whichi was using RAII to ensure
+ // some states get handled properly when its instance is being destructed.
+ //
+ // To achieve that, SafeFrameWindowCreate has been reinterpreted using IDisposable
+ // pattern, which forces we use below way to keep async works being controlled within
+ // a same code block.
+ var viewShown = await ApplicationViewSwitcher.TryShowAsStandaloneAsync(
+ frameService.GetViewId(),
+ ViewSizePreference.Default,
+ activatedEventArgs.CurrentlyShownApplicationViewId,
+ ViewSizePreference.Default);
+ // SafeFrameServiceCreation is used to automatically remove the frame
+ // from the list of frames if something goes bad.
+ safeFrameServiceCreation.SetOperationSuccess(viewShown);
+ }
+ }
+ }
+ }
+ });
+ }
+ else
+ {
+ ActivationViewSwitcher activationViewSwitcher = null;
+ var activateEventArgs = (args as IViewSwitcherProvider);
+ if (activateEventArgs != null)
+ {
+ activationViewSwitcher = activateEventArgs.ViewSwitcher;
+ }
+
+ if (activationViewSwitcher != null)
+ {
+ _ = activationViewSwitcher.ShowAsStandaloneAsync(
+ ApplicationView.GetApplicationViewIdForWindow(CoreWindow.GetForCurrentThread()), ViewSizePreference.Default);
+ }
+ else
+ {
+ TraceLogger.GetInstance().LogError(ViewMode.None, "App.OnAppLaunch", "Null_ActivationViewSwitcher");
+ }
+ }
+ // Set the preLaunched flag to false
+ m_preLaunched = false;
+ }
+ else // for touch devices
+ {
+ if (rootFrame.Content == null)
+ {
+ // When the navigation stack isn't restored navigate to the first page,
+ // configuring the new page by passing required information as a navigation
+ // parameter
+ if (!rootFrame.Navigate(typeof(MainPage), argument))
+ {
+ // We couldn't navigate to the main page,
+ // kill the app so we have a good stack to debug
+ throw new SystemException();
+ }
+ }
+ if (ApplicationView.GetForCurrentView().ViewMode != ApplicationViewMode.CompactOverlay)
+ {
+ if (!Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons"))
+ {
+ // for tablet mode: since system view activation policy is disabled so do ShowAsStandaloneAsync if activationViewSwitcher exists in
+ // activationArgs
+ ActivationViewSwitcher activationViewSwitcher = null;
+ var activateEventArgs = (args as IViewSwitcherProvider);
+ if (activateEventArgs != null)
+ {
+ activationViewSwitcher = activateEventArgs.ViewSwitcher;
+ }
+ if (activationViewSwitcher != null)
+ {
+ var viewId = (args as IApplicationViewActivatedEventArgs).CurrentlyShownApplicationViewId;
+ if (viewId != 0)
+ {
+ _ = activationViewSwitcher.ShowAsStandaloneAsync(viewId);
+ }
+ }
+ }
+ // Ensure the current window is active
+ Window.Current.Activate();
+ }
+ }
+ }
+ }
+
+ private void DismissedEventHandler(SplashScreen sender, object e)
+ {
+ _ = SetupJumpList();
+ }
+
+ private void RegisterDependencyProperties()
+ {
+ NarratorNotifier.RegisterDependencyProperties();
+ }
+
+ private void OnSuspending(object sender, SuspendingEventArgs args)
+ {
+ TraceLogger.GetInstance().LogButtonUsage();
+ }
+
+ private sealed class SafeFrameWindowCreation : IDisposable
+ {
+ public SafeFrameWindowCreation(WindowFrameService frameService, App parent)
+ {
+ m_frameService = frameService;
+ m_frameOpenedInWindow = false;
+ m_parent = parent;
+ }
+
+ public void SetOperationSuccess(bool success)
+ {
+ m_frameOpenedInWindow = success;
+ }
+
+ public void Dispose()
+ {
+ if (!m_frameOpenedInWindow)
+ {
+ // Close the window as the navigation to the window didn't succeed
+ // and this is not visible to the user.
+ m_parent.RemoveWindowFromMap(m_frameService.GetViewId());
+ }
+
+ GC.SuppressFinalize(this);
+ }
+
+ ~SafeFrameWindowCreation()
+ {
+ Dispose();
+ }
+
+ private WindowFrameService m_frameService;
+ private bool m_frameOpenedInWindow;
+ private App m_parent;
+ };
+
+ // CSHARP_MIGRATION: TODO: check what is the pragma used for???
+ //#pragma optimize("", off) // Turn off optimizations to work around coroutine optimization bug
+ private async Task SetupJumpList()
+ {
+ try
+ {
+ // CSHARP_MIGRATION: TODO:
+ var calculatorOptions = NavCategoryGroup.CreateCalculatorCategory();
+
+ var jumpList = await JumpList.LoadCurrentAsync();
+ jumpList.SystemGroupKind = JumpListSystemGroupKind.None;
+ jumpList.Items.Clear();
+
+ // CSHARP_MIGRATION: TODO:
+ foreach (NavCategory option in calculatorOptions.Categories)
+ {
+ if (!option.IsEnabled)
+ {
+ continue;
+ }
+ ViewMode mode = option.Mode;
+ var item = JumpListItem.CreateWithArguments(((int)mode).ToString(), "ms-resource:///Resources/" + NavCategory.GetNameResourceKey(mode));
+ item.Description = "ms-resource:///Resources/" + NavCategory.GetNameResourceKey(mode);
+ item.Logo = new Uri("ms-appx:///Assets/" + mode.ToString() + ".png");
+
+ jumpList.Items.Add(item);
+ }
+
+ await jumpList.SaveAsync();
+ }
+ catch
+ {
+ }
+ }
+
+ private async Task HandleViewReleaseAndRemoveWindowFromMap(WindowFrameService frameService)
+ {
+ WeakReference weak = new WeakReference(this);
+
+ // Unregister the event handler of the Main Page
+ var frame = (Window.Current.Content as Frame);
+ var mainPage = (frame.Content as MainPage);
+
+ mainPage.UnregisterEventHandlers();
+
+ await frameService.HandleViewRelease();
+ await Task.Run(() =>
+ {
+ var that = weak.Target as App;
+ that.RemoveWindowFromMap(frameService.GetViewId());
+ }).ConfigureAwait(false /* task_continuation_context::use_arbitrary() */);
+ }
+
+ private void AddWindowToMap(WindowFrameService frameService)
+ {
+ m_windowsMapLock.EnterWriteLock();
+ try
+ {
+ m_secondaryWindows[frameService.GetViewId()] = frameService;
+ TraceLogger.GetInstance().UpdateWindowCount(m_secondaryWindows.size());
+ }
+ finally
+ {
+ m_windowsMapLock.ExitWriteLock();
+ }
+ }
+
+ private WindowFrameService GetWindowFromMap(int viewId)
+ {
+ m_windowsMapLock.EnterReadLock();
+ try
+ {
+ if (m_secondaryWindows.TryGetValue(viewId, out var windowMapEntry))
+ {
+ return windowMapEntry;
+ }
+ else
+ {
+ return null;
+ }
+ }
+ finally
+ {
+ m_windowsMapLock.ExitReadLock();
+ }
+ }
+
+ private void RemoveWindowFromMap(int viewId)
+ {
+ m_windowsMapLock.EnterWriteLock();
+ try
+ {
+ bool removed = m_secondaryWindows.Remove(viewId);
+ Debug.Assert(removed != false, "Window does not exist in the list");
+ }
+ finally
+ {
+ m_windowsMapLock.ExitWriteLock();
+ }
+ }
+
+ private readonly ReaderWriterLockSlim m_windowsMapLock = new ReaderWriterLockSlim();
+ private Dictionary m_secondaryWindows = new Dictionary();
+ private int m_mainViewId;
+ private bool m_preLaunched;
+
+ // CSHARP_MIGRATION: TODO: check whether or not this field is in use.
+ private Windows.UI.Xaml.Controls.Primitives.Popup m_aboutPopup;
+ }
+}
+
diff --git a/src/Calculator/Calculator.csproj b/src/Calculator/Calculator.csproj
new file mode 100644
index 00000000..6e80c349
--- /dev/null
+++ b/src/Calculator/Calculator.csproj
@@ -0,0 +1,728 @@
+
+
+
+
+ Debug
+ x86
+ {3B773403-B0D6-4F9A-948E-512A7A5FB315}
+ AppContainerExe
+ Properties
+ CalculatorApp
+ CalculatorApp
+ en-US
+ UAP
+ 10.0.19041.0
+ 10.0.17763.0
+ 14
+ 512
+ {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+ true
+ True
+ B06D4942DD6AAC6D5659E3AF866A11D0081C12C1
+ WindowsDev_TemporaryKey.pfx
+
+
+ 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
+
+
+ 0.0.0.0
+
+
+
+
+
+
+ AboutFlyout.xaml
+
+
+ App.xaml
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ EquationStylePanelControl.xaml
+
+
+
+ Calculator.xaml
+
+
+ CalculatorProgrammerBitFlipPanel.xaml
+
+
+ CalculatorProgrammerOperators.xaml
+
+
+ CalculatorProgrammerRadixOperators.xaml
+
+
+ CalculatorScientificAngleButtons.xaml
+
+
+ CalculatorScientificOperators.xaml
+
+
+ CalculatorStandardOperators.xaml
+
+
+ DateCalculator.xaml
+
+
+ EquationInputArea.xaml
+
+
+ GraphingCalculator.xaml
+
+
+ GraphingNumPad.xaml
+
+
+ GraphingSettings.xaml
+
+
+ KeyGraphFeaturesPanel.xaml
+
+
+ HistoryList.xaml
+
+
+ MainPage.xaml
+
+
+
+
+
+ Memory.xaml
+
+
+ MemoryListItem.xaml
+
+
+ NumberPad.xaml
+
+
+ OperatorsPanel.xaml
+
+
+
+ CalculatorProgrammerDisplayPanel.xaml
+
+
+
+ SupplementaryResults.xaml
+
+
+ TitleBar.xaml
+
+
+
+
+
+
+ Designer
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Designer
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ MSBuild:Compile
+ Designer
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ MSBuild:Compile
+ Designer
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+
+
+ 6.2.10
+
+
+
+
+
+ {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/Calculator/Common/AlwaysSelectedCollectionView.cs b/src/Calculator/Common/AlwaysSelectedCollectionView.cs
new file mode 100644
index 00000000..43db8d46
--- /dev/null
+++ b/src/Calculator/Common/AlwaysSelectedCollectionView.cs
@@ -0,0 +1,256 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using Windows.Foundation;
+using Windows.Foundation.Collections;
+using Windows.UI.Xaml.Data;
+
+namespace CalculatorApp
+{
+ namespace Common
+ {
+ sealed class AlwaysSelectedCollectionView : Windows.UI.Xaml.DependencyObject, Windows.UI.Xaml.Data.ICollectionView
+ {
+ internal AlwaysSelectedCollectionView(IList source)
+ {
+ m_currentPosition = -1;
+ m_source = source;
+
+ var observable = source as Windows.UI.Xaml.Interop.IBindableObservableVector;
+ if (observable != null)
+ {
+ observable.VectorChanged += OnSourceBindableVectorChanged;
+ }
+ }
+
+ public bool MoveCurrentTo(object item)
+ {
+ if (item != null)
+ {
+ int newCurrentPosition = m_source.IndexOf(item);
+ if (newCurrentPosition != -1)
+ {
+ m_currentPosition = newCurrentPosition;
+ CurrentChanged(this, null);
+ return true;
+ }
+ }
+
+ // The item is not in the collection
+ // We're going to schedule a call back later so we
+ // restore the selection to the way we wanted it to begin with
+ if (m_currentPosition >= 0 && m_currentPosition < m_source.Count)
+ {
+ Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, new Windows.UI.Core.DispatchedHandler(() =>
+ {
+ CurrentChanged(this, null);
+ })).AsTask().Wait();
+ }
+ return false;
+ }
+
+ public bool MoveCurrentToPosition(int index)
+ {
+ if (index < 0 || index >= m_source.Count)
+ {
+ return false;
+ }
+
+ m_currentPosition = index;
+ CurrentChanged(this, null);
+ return true;
+ }
+
+ #region no implementations
+
+ public bool MoveCurrentToFirst()
+ {
+ throw new NotImplementedException();
+ }
+
+ public bool MoveCurrentToLast()
+ {
+ throw new NotImplementedException();
+ }
+
+ public bool MoveCurrentToNext()
+ {
+ throw new NotImplementedException();
+ }
+
+ public bool MoveCurrentToPrevious()
+ {
+ throw new NotImplementedException();
+ }
+
+ public IAsyncOperation LoadMoreItemsAsync(uint count)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void Insert(int index, object item)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void RemoveAt(int index)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void Add(object item)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void Clear()
+ {
+ throw new NotImplementedException();
+ }
+
+ public bool Contains(object item)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void CopyTo(object[] array, int arrayIndex)
+ {
+ throw new NotImplementedException();
+ }
+
+ public bool Remove(object item)
+ {
+ throw new NotImplementedException();
+ }
+
+ public bool IsReadOnly => throw new NotImplementedException();
+
+ #endregion no implementations
+
+ public object this[int index]
+ {
+ get
+ {
+ return m_source[index];
+ }
+
+ set => throw new NotImplementedException();
+ }
+
+ public int Count
+ {
+ get
+ {
+ return m_source.Count;
+ }
+ }
+
+ public IObservableVector