90af5adcd2
* Merged PR 10748585: Recall | Connect UserActivity to support restoring from snapshots ## What Thanks to @<Brendan Elliott ⌨> for his PoC !10573092 This PR is going to use `UserActivity` APIs to connect the app to Recall so that we can take a snapshot when asked and then retore our states from the snapshot later. ## How - Add a new type `SnapshotLaunchArguments` to identify a protocol launch requested by Recall. - Add an extension `LaunchExtensions` as helper to retrieve key information from fundamental types. - Refactor `App::OnActivated()` and `MainPage::OnNavigatedTo()` to handle different protocols properly. - Create or parse `UserActivity` in `MainPage` in the way like what the PoC is doing. - Improve the coding style a bit for `MainPage`. ## Note The serialization work and restoring from JSON is going to be done in a separate PR. ## Testing Manually tested. Some typical test cases: - Launch the app from *Start menu* - Launch the app from *Task bar* - Launch the app from *Command line* - Launch with the protocol for Recall - Launch with the protocol that is injected with evil data. Related work items: #50854714 * Merged PR 10741448: [Recall] Snapshot saving and restoring ####What According to PM [Spec](https://microsoft.sharepoint-df.com/:w:/t/PAXEssentialExperiences421/EcpP5tGRtFdIsRrP84ueRfUBjb6tfayxWtF9ujvJuNx6Dg?e=AeRzVf), saving and restoring Calculator snapshot when required. The current snapshot supports to: - Restore the calculator mode. - Restore the current calculation (display value and expression). - Restore the history of calculations (either in Standard mode or Scientific mode) shown at the time the snapshot was taken. - Restore the current calculation error state, if applicable. ####How - Added `SnapshotHelper` to help save and restore snapshots. - Besides the existing snapshot information from view models, added an extra field `SnapshotVersion` in `ApplicationSnapshot` for backward compatibility. #### Note Unit tests will be added in a separate PR. Related work items: #50701758 * Merged PR 10772614: Recall | Update the LaunchURI design ## What Since `System.Uri` already has the `Segment` property which contains the parsed path blocks, Query in Uri looks too heavy and intrusive in implementation to retrieve the activity id. ## Changes Changed the launch URI from something like `ms-calculator:///snapshot?activityId=<a guid>` to `ms-calculator:snapshots/<a guid>` Related work items: #50854714 * Merged PR 10778666: Recall | Show error dialog if launching from snapshot has failed ## What Per Figma design, we can show an error dialog with messages for the failures happens during snapshot launch. ## Notes - Fixed a crash about taking a snapshot when Calculator hasn't initialized a standard calculator. - Simplified the restore path. ## Screenshot ![image.png](https://dev.azure.com/microsoft/d1a24475-535d-4c83-988a-9491e6dbc858/_apis/git/repositories/6255259e-4ead-4d8d-b165-55eeacc5ca48/pullRequests/10778666/attachments/image.png) Related work items: #50858262 * Merged PR 10790341: [Recall] Update calculator engine with snapshot for further calculations ####What When restoring from snapshot, we need to set calculator engine properly to make further calculations correct. ####How Update calculator engine by a serial of corresponding commands from snapshot. To get the commands for the display area when saving snapshot, 1. If the expression is not from history and the primary display is the result of the expression, `DisplayCommands` of `StandardCalculatorSnapshot` will be empty, and we will use the commands from `ExpressionDisplay` for restoring in the future. 2. If the expression is not from history and the primary display is not the result of the expression, `DisplayCommands` of `StandardCalculatorSnapshot` will be the commands from the history collector in addition to the operand command in the primary display, and it will be used for restoring in the future. 3. If the expression and primary display are from history, `DisplayCommands` will be incomplete with the operand command in the primary display missing as by current design of history, and the commands from `ExpressionDisplay` will be used for restoring in the future. Related work items: #51002745 * Merged PR 10802927: Recall | Add threat model ## What The support for Recall introduced a URI activation process allowing the Recall app to launch Calculator with desired snapshot metadata. This led to a potential security problem, and we need to address it by providing justifications. Threat model is a well-known practice among Inbox Apps. After offline discussion, we decide to add diagrams for this Recall feature to prepare for the security review. ## Diagram preview ![image.png](https://dev.azure.com/microsoft/d1a24475-535d-4c83-988a-9491e6dbc858/_apis/git/repositories/6255259e-4ead-4d8d-b165-55eeacc5ca48/pullRequests/10802927/attachments/image.png) ![image (2).png](https://dev.azure.com/microsoft/d1a24475-535d-4c83-988a-9491e6dbc858/_apis/git/repositories/6255259e-4ead-4d8d-b165-55eeacc5ca48/pullRequests/10802927/attachments/image%20%282%29.png) Related work items: #51165486 * Merged PR 10794979: Add Recall Telemetry **Snapshot** EventName: `RecallSnapshot` Payload example:` { "CalcMode": "Standard"}` **_Fires when a snapshot (UserActivityRequested) is triggered_** **Restore** EventName: `RecallRestore` Payload example:`{ "CalcMode": "Standard"}` **_Fires when launching by snapshot (recall restore)** **Error** EventName: `Exception` Payload example: `{ "CalcMode": "Standard", "FunctionName" : "MainPage::ShowSnapshotLaunchErrorAsync", "Message": "SnapshotRestoreError" }` **_Fires when launching by snapshot failed_** Related work items: #51114542 --------- Co-authored-by: Tian Liao ☕ <tilia@microsoft.com> Co-authored-by: Jian Zhang <zjian@microsoft.com> |
||
---|---|---|
.config | ||
.github | ||
Tools | ||
build | ||
docs | ||
src | ||
.clang-format | ||
.editorconfig | ||
.gitattributes | ||
.gitignore | ||
CODE_OF_CONDUCT.md | ||
CONTRIBUTING.md | ||
LICENSE | ||
NOTICE.txt | ||
README.md | ||
SECURITY.md | ||
nuget.config |
README.md
Calculator
The Windows Calculator app is a modern Windows app written in C++ and C# that ships pre-installed with Windows. The app provides standard, scientific, and programmer calculator functionality, as well as a set of converters between various units of measurement and currencies.
Calculator ships regularly with new features and bug fixes. You can get the latest version of Calculator in the Microsoft Store.
Features
- Standard Calculator functionality which offers basic operations and evaluates commands immediately as they are entered.
- Scientific Calculator functionality which offers expanded operations and evaluates commands using order of operations.
- Programmer Calculator functionality which offers common mathematical operations for developers including conversion between common bases.
- Date Calculation functionality which offers the difference between two dates, as well as the ability to add/subtract years, months and/or days to/from a given input date.
- Calculation history and memory capabilities.
- Conversion between many units of measurement.
- Currency conversion based on data retrieved from Bing.
- Infinite precision for basic arithmetic operations (addition, subtraction, multiplication, division) so that calculations never lose precision.
Getting started
Prerequisites:
-
Your computer must be running Windows 11, build 22000 or newer.
-
Install the latest version of Visual Studio (the free community edition is sufficient).
- Install the "Universal Windows Platform Development" workload.
- Install the optional "C++ Universal Windows Platform tools" component.
- Install the latest Windows 11 SDK.
-
Install the XAML Styler Visual Studio extension.
-
Get the code:
git clone https://github.com/Microsoft/calculator.git
-
Open src\Calculator.sln in Visual Studio to build and run the Calculator app.
-
For a general description of the Calculator project architecture see ApplicationArchitecture.md.
-
To run the UI Tests, you need to make sure that Windows Application Driver (WinAppDriver) is installed.
Contributing
Want to contribute? The team encourages community feedback and contributions. Please follow our contributing guidelines.
If Calculator is not working properly, please file a report in the Feedback Hub. We also welcome issues submitted on GitHub.
Roadmap
For information regarding Windows Calculator plans and release schedule, please see the Windows Calculator Roadmap.
Graphing Mode
Adding graphing calculator functionality is on the project roadmap and we hope that this project can create a great end-user experience around graphing. To that end, the UI from the official in-box Windows Calculator is currently part of this repository, although the proprietary Microsoft-built graphing engine, which also drives graphing in Microsoft Mathematics and OneNote, is not. Community members can still be involved in the creation of the UI, however developer builds will not have graphing functionality due to the use of a mock implementation of the engine built on top of a common graphing API.
Diagnostic Data
This project collects usage data and sends it to Microsoft to help improve our products and services.
Read our privacy statement to learn more.
Diagnostic data is disabled in development builds by default, and can be enabled with the SEND_DIAGNOSTICS
build flag.
Currency Converter
Windows Calculator includes a currency converter feature that uses mock data in developer builds. The data that Microsoft uses for the currency converter feature (e.g., in the retail version of the application) is not licensed for your use. The mock data will be clearly identifiable as it references planets instead of countries, and remains static regardless of selected inputs.
Reporting Security Issues
Please refer to SECURITY.md.
License
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the MIT License.