using System; using System.Collections.Generic; using ReactiveUI; using Tmds.DBus.Protocol; namespace AuthAndCaptcha.ViewModels { public class CalculatorViewModel : ReactiveObject { public static List calcOptions => new List() {"Сложение", "Вычитание", "Умножение", "Деление"}; string selectedOption = calcOptions[0]; public string SelectedOption { get => selectedOption; set { this.RaiseAndSetIfChanged(ref selectedOption, value); ChangeSign(); } } char sign = '+'; public char Sign { get => sign; set => this.RaiseAndSetIfChanged(ref sign, value); } int n, m, result; public int N { get => n; set => n = value; } public int M { get => m; set => m = value; } public int Result { get => result; set => this.RaiseAndSetIfChanged(ref result, value); } public void ChangeSign() { if (SelectedOption == "Сложение") Sign = '+'; else if (SelectedOption == "Вычитание") Sign = '-'; else if (SelectedOption == "Умножение") Sign = '*'; else if (SelectedOption == "Деление") Sign = '/'; } public void Calculation() { if (SelectedOption == "Сложение") Result = N + M; else if (SelectedOption == "Вычитание") Result = N - M; else if (SelectedOption == "Умножение") Result = N * M; else if (SelectedOption == "Деление") Result = N / M; } } }