using Culusas.Models; using ReactiveUI; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Culusas.ViewModels { public class CululViewModel : ReactiveObject { public double result; public string prover = ""; public string oper = "0000"; public int indexA = -1; public List deistV => PiusMinusITD.Deistvia; public double InitA { get => PiusMinusITD.a; set { this.RaiseAndSetIfChanged(ref PiusMinusITD.a, value); } } public double InitB { get => PiusMinusITD.b; set { this.RaiseAndSetIfChanged(ref PiusMinusITD.b, value); } } public double Resultat { get => result; set { this.RaiseAndSetIfChanged(ref result, value); } } public string Provertik { get => prover; set { this.RaiseAndSetIfChanged(ref prover, value); } } public string Operator { get => oper; set { this.RaiseAndSetIfChanged(ref oper, value); } } public int Index { get => indexA; set { this.RaiseAndSetIfChanged(ref indexA, value); switch (indexA) { case 0: Operator = "+"; break; case 1: Operator = "-"; break; case 2: Operator = "*"; break; case 3: Operator = "/"; break; default: Operator = "!"; break; } } } public void DeistviaAandB() { switch (indexA) { case 0: Resultat = InitA + InitB; Provertik = Resultat.ToString(); break; case 1: Resultat = InitA - InitB; Provertik = Resultat.ToString(); break; case 2: Resultat = InitA * InitB; Provertik = Resultat.ToString(); break; case 3: if (InitB != 0) { Resultat = InitA / InitB; Provertik = Resultat.ToString(); } else Provertik = "Нельзя делить на 0!"; break; default: Provertik = "Вы не заполнили поля или не выбрали действие!"; break; } } } }