123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- 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<string> 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);
- }
- }
- }
-
- }
- }
|