├── .gitattributes
├── .gitignore
├── LICENSE
├── Nuget README.md
├── README.md
├── ReadmeAssets
├── Banner.svg
├── Boolean to Visibility.gif
├── Custom Function Animation.gif
├── Custom Function.png
├── Evenly-Spaced Rectangles.png
├── Flattened Oval.png
├── Interpolated String Animation.gif
├── No ConverterParameter.png
├── Now Plus Six Hours.png
├── True Rounded Rectangle.png
├── Wide Rounded Rectangle.png
└── smalllogo.png
└── src
├── CSharp
├── MathConverter
│ ├── AssemblyInfo.cs
│ ├── CompatibilityExtensions.cs
│ ├── ConvertExtension.cs
│ ├── CustomFunctionCollection.cs
│ ├── CustomFunctions.cs
│ ├── EvaluationException.cs
│ ├── MathConverter.cs
│ ├── Operator.cs
│ ├── Parser.cs
│ ├── ParsingException.cs
│ ├── Scanner.cs
│ ├── SyntaxTree.cs
│ └── Token.cs
└── UnitTests
│ └── UnitTests.cs
├── Demos
└── WPF
│ ├── App.xaml
│ ├── App.xaml.cs
│ ├── AssemblyInfo.cs
│ ├── CustomFunctions
│ ├── CustomAverageFunction.cs
│ └── GetWindowTitle.cs
│ ├── Demos
│ ├── BooleanToVisibility.xaml
│ ├── BooleanToVisibility.xaml.cs
│ ├── CountClicks.xaml
│ ├── CountClicks.xaml.cs
│ ├── CustomAverageFunction.xaml
│ ├── CustomAverageFunction.xaml.cs
│ ├── DifferentMargins.xaml
│ ├── DifferentMargins.xaml.cs
│ ├── FlattenedOval.xaml
│ ├── FlattenedOval.xaml.cs
│ ├── NoConverterParameter.xaml
│ ├── NoConverterParameter.xaml.cs
│ ├── NowPlusSixHours.xaml
│ ├── NowPlusSixHours.xaml.cs
│ ├── TrueRoundedRectangle.xaml
│ ├── TrueRoundedRectangle.xaml.cs
│ ├── WideRoundedRectangle.xaml
│ └── WideRoundedRectangle.xaml.cs
│ ├── MainWindow.xaml
│ ├── MainWindow.xaml.cs
│ └── MathConverter.Demo.WPF.csproj
├── MathConverter.MacOS.sln
├── MathConverter.sln
└── Projects
├── Common
├── App.props
├── Common.props
├── StrongNamedAssemblyKey.snk
├── UnitTests.props
└── WPF.props
├── Maui
├── App
│ └── MathConverter.Maui.csproj
└── UnitTests
│ ├── App.xaml
│ ├── App.xaml.cs
│ ├── MathConverter.UnitTests.Maui.csproj
│ ├── MauiProgram.cs
│ ├── Platforms
│ ├── Android
│ │ ├── AndroidManifest.xml
│ │ ├── MainActivity.cs
│ │ └── MainApplication.cs
│ ├── MacCatalyst
│ │ ├── AppDelegate.cs
│ │ ├── Info.plist
│ │ └── Program.cs
│ ├── Windows
│ │ ├── App.xaml
│ │ ├── App.xaml.cs
│ │ ├── Package.appxmanifest
│ │ └── app.manifest
│ └── iOS
│ │ ├── AppDelegate.cs
│ │ ├── Info.plist
│ │ └── Program.cs
│ ├── Properties
│ └── launchSettings.json
│ └── Resources
│ ├── AppIcon
│ ├── androidicon.svg
│ ├── appicon.svg
│ └── appiconfg.svg
│ └── Splash
│ └── splash.svg
├── WPF
├── App
│ └── MathConverter.WPF.csproj
└── UnitTests
│ └── MathConverter.UnitTests.WPF.csproj
└── XamarinForms
├── App
└── MathConverter.XamarinForms.csproj
└── UnitTests
├── Android
├── MainActivity.cs
├── MathConverter.UnitTests.XamarinForms.Android.csproj
├── Properties
│ └── AndroidManifest.xml
└── Resources
│ ├── layout
│ └── activity_main.xml
│ ├── mipmap-hdpi
│ └── ic_launcher.png
│ ├── mipmap-mdpi
│ └── ic_launcher.png
│ ├── mipmap-xhdpi
│ └── ic_launcher.png
│ ├── mipmap-xxhdpi
│ └── ic_launcher.png
│ ├── mipmap-xxxhdpi
│ └── ic_launcher.png
│ └── values
│ ├── colors.xml
│ └── styles.xml
├── DotNet
└── MathConverter.UnitTests.XamarinForms.DotNet.csproj
├── UWP
├── Assets
│ ├── LockScreenLogo.scale-200.png
│ ├── SplashScreen.scale-200.png
│ ├── Square150x150Logo.scale-200.png
│ ├── Square44x44Logo.scale-200.png
│ ├── Square44x44Logo.targetsize-24_altform-unplated.png
│ ├── StoreLogo.png
│ └── Wide310x150Logo.scale-200.png
├── MainPage.xaml
├── MainPage.xaml.cs
├── MathConverter.UnitTests.XamarinForms.UWP.csproj
├── Package.appxmanifest
├── Properties
│ └── Default.rd.xml
├── UnitTestApp.xaml
└── UnitTestApp.xaml.cs
└── iOS
├── AppDelegate.cs
├── Assets.xcassets
└── AppIcon.appiconset
│ ├── Contents.json
│ ├── Icon1024.png
│ ├── Icon120.png
│ ├── Icon152.png
│ ├── Icon167.png
│ ├── Icon180.png
│ ├── Icon20.png
│ ├── Icon29.png
│ ├── Icon40.png
│ ├── Icon58.png
│ ├── Icon60.png
│ ├── Icon76.png
│ ├── Icon80.png
│ └── Icon87.png
├── Entitlements.plist
├── Info.plist
├── Main.cs
├── MathConverter.UnitTests.XamarinForms.iOS.csproj
└── Resources
└── LaunchScreen.storyboard
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | # See https://github.com/alexkaratarakis/gitattributes
3 | * text=auto
4 |
5 | *.cs text diff=csharp
6 | *.cshtml text diff=html
7 | *.csx text diff=csharp
8 | *.xml text
9 | *.sln text eol=crlf
10 | *.csproj text eol=crlf
11 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | obj/
2 | bin/
3 | MathConverter.v12.suo
4 | *.csproj.user
5 | .vs/
6 | /src/Projects/XamarinForms/UnitTests/Android/Resources/Resource.designer.cs
7 | *.DotSettings.user
8 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2015-2020 Hex Innovation
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/Nuget README.md:
--------------------------------------------------------------------------------
1 | [](https://github.com/hexinnovation/MathConverter)
2 |
3 | What is MathConverter?
4 | ----------------------
5 |
6 | `MathConverter` allows you to do Math in XAML.
7 |
8 | `MathConverter` is a powerful `Binding` converter that allows you to specify how to perform conversions directly in XAML, without needing to define a new `IValueConverter` in C# for every single conversion.
9 |
10 | Getting Started:
11 | ----------------
12 |
13 | It's as easy as 1-2-3.
14 |
15 | **1)** Install the Nuget package.
16 |
17 | **2)** Add a `MathConverter` resource.
18 |
19 | ```xaml
20 |
21 |
22 |
23 | ```
24 |
25 | The `math` namespace is defined as follows:
26 |
27 | ```xaml
28 | xmlns:math="http://hexinnovation.com/math"
29 | ```
30 |
31 | **3)** Do Math. Now, you can use `MathConverter` on any `Binding`. Specify a `ConverterParameter` to specify the rules of the conversion.
32 |
33 | ```xaml
34 |
35 | ```
36 | Or, for conversions with multiple bindings.
37 |
38 | ```xaml
39 |
40 | ```
41 |
42 | See [the GitHub repository](https://github.com/hexinnovation/MathConverter) for documentation and examples.
43 |
--------------------------------------------------------------------------------
/ReadmeAssets/Boolean to Visibility.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hexinnovation/MathConverter/5cb55e38d8ae0719219faef61ab1367d92aae2b6/ReadmeAssets/Boolean to Visibility.gif
--------------------------------------------------------------------------------
/ReadmeAssets/Custom Function Animation.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hexinnovation/MathConverter/5cb55e38d8ae0719219faef61ab1367d92aae2b6/ReadmeAssets/Custom Function Animation.gif
--------------------------------------------------------------------------------
/ReadmeAssets/Custom Function.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hexinnovation/MathConverter/5cb55e38d8ae0719219faef61ab1367d92aae2b6/ReadmeAssets/Custom Function.png
--------------------------------------------------------------------------------
/ReadmeAssets/Evenly-Spaced Rectangles.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hexinnovation/MathConverter/5cb55e38d8ae0719219faef61ab1367d92aae2b6/ReadmeAssets/Evenly-Spaced Rectangles.png
--------------------------------------------------------------------------------
/ReadmeAssets/Flattened Oval.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hexinnovation/MathConverter/5cb55e38d8ae0719219faef61ab1367d92aae2b6/ReadmeAssets/Flattened Oval.png
--------------------------------------------------------------------------------
/ReadmeAssets/Interpolated String Animation.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hexinnovation/MathConverter/5cb55e38d8ae0719219faef61ab1367d92aae2b6/ReadmeAssets/Interpolated String Animation.gif
--------------------------------------------------------------------------------
/ReadmeAssets/No ConverterParameter.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hexinnovation/MathConverter/5cb55e38d8ae0719219faef61ab1367d92aae2b6/ReadmeAssets/No ConverterParameter.png
--------------------------------------------------------------------------------
/ReadmeAssets/Now Plus Six Hours.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hexinnovation/MathConverter/5cb55e38d8ae0719219faef61ab1367d92aae2b6/ReadmeAssets/Now Plus Six Hours.png
--------------------------------------------------------------------------------
/ReadmeAssets/True Rounded Rectangle.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hexinnovation/MathConverter/5cb55e38d8ae0719219faef61ab1367d92aae2b6/ReadmeAssets/True Rounded Rectangle.png
--------------------------------------------------------------------------------
/ReadmeAssets/Wide Rounded Rectangle.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hexinnovation/MathConverter/5cb55e38d8ae0719219faef61ab1367d92aae2b6/ReadmeAssets/Wide Rounded Rectangle.png
--------------------------------------------------------------------------------
/ReadmeAssets/smalllogo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hexinnovation/MathConverter/5cb55e38d8ae0719219faef61ab1367d92aae2b6/ReadmeAssets/smalllogo.png
--------------------------------------------------------------------------------
/src/CSharp/MathConverter/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 | #if XAMARIN
5 | using Xamarin.Forms;
6 | #elif MAUI
7 | using Microsoft.Maui.Controls;
8 | #else
9 | using System.Windows;
10 | using System.Windows.Markup;
11 | #endif
12 |
13 | [assembly: AssemblyTrademark("")]
14 | [assembly: AssemblyCulture("")]
15 | [assembly: ComVisible(false)]
16 |
17 | [assembly: XmlnsPrefix("http://hexinnovation.com/math", "math")]
18 | #if !WINDOWS_UWP && !NETSTANDARD1_0 && !NETSTANDARD1_3
19 | [assembly: XmlnsDefinition("http://hexinnovation.com/math", "HexInnovation")]
20 | #endif
21 |
22 | [assembly: InternalsVisibleTo("MathConverter.UnitTests,PublicKey=" +
23 | "0024000004800000940000000602000000240000525341310004000001000100056bb3f4bc6f27" +
24 | "a583fb5713ddbe24f2dabdf9688b60147eca177159a995ef153b183156c4566b457819661af3a1" +
25 | "b6810a9cae7928ccb10b834de2eaa99c133f2c0540f77cd43040853d166227d6bb252618b95ad3" +
26 | "0e3e5a1487c19bb9854e94edadb6c5fb2d2eaf771edb3d290a655bfc8c9eb852855f8d339ab102" +
27 | "78bf44be")]
28 |
--------------------------------------------------------------------------------
/src/CSharp/MathConverter/CompatibilityExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Reflection;
5 |
6 | namespace HexInnovation
7 | {
8 | internal static class CompatibilityExtensions
9 | {
10 | #if NET35
11 | public static string[] MyToArray(this IEnumerable objects)
12 | {
13 | return objects.Cast