using System; using Captcha.Views; using System.Collections.Generic; using ReactiveUI; using Tmds.DBus.Protocol; namespace Captcha.ViewModels { public class CalculatorViewModel : ReactiveObject { string valueselect = ""; double first = 0; double second = 0; double result = 0; string plus = "+"; string minus = "-"; string pow = "*"; string del = "/"; public List Arifmetica { get => Models.ArifmClass.Do; } public double FirstCount { get => first; set { this.RaiseAndSetIfChanged(ref first, value); } } public double SecondCount { get => second; set { this.RaiseAndSetIfChanged(ref second, value); } } public void Process() { if(Does == plus) { result = FirstCount + SecondCount; Result++; Result--; } else if (Does == minus) { result = FirstCount - SecondCount; Result++; Result--; } else if (Does == pow) { result = FirstCount * SecondCount; Result++; Result--; } else if (Does == del) { result = FirstCount / SecondCount; Result++; Result--; } } public double Result { get => result; set { this.RaiseAndSetIfChanged(ref result, value); } } public string Does { get => valueselect; set { if (value == "Сумма") { this.RaiseAndSetIfChanged(ref valueselect, plus); } else if (value == "Разность") { this.RaiseAndSetIfChanged(ref valueselect, minus); } else if (value == "Умножение") { this.RaiseAndSetIfChanged(ref valueselect, pow); } else if (value == "Деление") { this.RaiseAndSetIfChanged(ref valueselect, del); } } } } }