123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- 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<string> 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;
- }
- }
- }
- }
|