Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Avalonia.Data.Converters;
- using System;
- using System.Collections.Generic;
- using System.Globalization;
- namespace MeksMathGame.Services;
- public static class ValueConverters
- {
- public static IValueConverter OperationToString = new OperationValueConverter();
- private class OperationValueConverter : IValueConverter
- {
- public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
- => value is Operation operation && _operationSymbols.TryGetValue(operation, out var symbol)
- ? symbol
- : null;
- public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) => throw new NotImplementedException();
- private Dictionary<Operation, string> _operationSymbols = new()
- {
- [Operation.Addition] = "➕",
- [Operation.Subtraction] = "➖",
- [Operation.Multiplication] = "✖️",
- [Operation.Division] = "➗"
- };
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment