Skip to content

Commit 6c372c3

Browse files
authored
Merge branch 'main' into dev/doti/tip-calc
2 parents 6fc6c61 + 7fe8ed6 commit 6c372c3

File tree

332 files changed

+13190
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

332 files changed

+13190
-0
lines changed

10.0/Apps/RpnCalculator/README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
name: .NET MAUI - RPN Calculator
3+
description: An RPN (Reverse Polish Notation) calculator allows numbers and operations to be entered without parentheses or an equal key. RPN (also called...
4+
page_type: sample
5+
languages:
6+
- csharp
7+
- xaml
8+
products:
9+
- dotnet-maui
10+
urlFragment: rpncalculator
11+
---
12+
# RPN Calculator
13+
14+
An RPN (Reverse Polish Notation) calculator allows numbers and operations to be entered without parentheses or an equal key. RPN (also called postfix notation) is described in the Wikipedia article [**Reverse Polish notation**](https://en.wikipedia.org/wiki/Reverse_Polish_notation). This sample demonstrates how to build an RPN calculator using .NET MAUI.
15+
16+
RPN is based on a stack. Numbers are pushed on the stack by pressing the ENTER key. Unary operations (such as **log** and **sin**) pop a number from the stack, apply the operation, and push the result back on the stack. Binary operations (such as **+** and **/**) pop two numbers from the stack, perform the operation, and push the result on the stack.
17+
18+
To perform the calculation
19+
20+
5 × (3 + 4) – 2
21+
22+
press the following keys:
23+
24+
5 ENTER 3 ENTER 4 ENTER + × 2 ENTER –
25+
26+
The + operation adds 3 and 4, the times operation multiplies 5 and that result, and the minus operation subtracts 2 from that result.
27+
28+
The layout of the keys appears twice in the **MainPage.xaml** file, separately for portrait mode and landscape mode. The **MainPage.xaml.cs** code-behind file switches between these two layouts based on the relative width and height of the page.
29+
30+
The calculator logic is encapsulated in the **RpnCalculatorViewModel.cs** file. The XAML file and the ViewModel are linked through XAML-based data bindings, which are described in detail in the series of articles on [**Data Binding**](https://docs.microsoft.com/dotnet/maui/fundamentals/data-binding/), and particularly the [**The Command Interface**](https://docs.microsoft.com/dotnet/maui/fundamentals/data-binding/commanding) article.
31+
32+
![RPN Calculator application screenshot](Screenshots/rpn-calculator-vertical.png "RPN Calculator application screenshot")
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.14.36221.1 d17.14
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RpnCalculator", "RpnCalculator\RpnCalculator.csproj", "{DEF0A9EC-6E64-4D73-8EA0-E57585B76253}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{DEF0A9EC-6E64-4D73-8EA0-E57585B76253}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{DEF0A9EC-6E64-4D73-8EA0-E57585B76253}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{DEF0A9EC-6E64-4D73-8EA0-E57585B76253}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{DEF0A9EC-6E64-4D73-8EA0-E57585B76253}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {AF39BAFC-5362-4DE0-99C1-F12D24DA1B9A}
24+
EndGlobalSection
25+
EndGlobal
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version = "1.0" encoding = "UTF-8" ?>
2+
<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
4+
xmlns:local="clr-namespace:RpnCalculator"
5+
x:Class="RpnCalculator.App">
6+
<Application.Resources>
7+
<ResourceDictionary>
8+
<ResourceDictionary.MergedDictionaries>
9+
<ResourceDictionary Source="Resources/Styles/Colors.xaml" />
10+
<ResourceDictionary Source="Resources/Styles/Styles.xaml" />
11+
</ResourceDictionary.MergedDictionaries>
12+
</ResourceDictionary>
13+
</Application.Resources>
14+
</Application>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
namespace RpnCalculator;
2+
3+
public partial class App : Application
4+
{
5+
public App()
6+
{
7+
InitializeComponent();
8+
}
9+
10+
protected override Window CreateWindow(IActivationState? activationState)
11+
{
12+
return new Window(new MainPage());
13+
}
14+
}

0 commit comments

Comments
 (0)