1234567891011121314151617181920212223242526272829303132333435363738 |
- using System;
- using System.Collections.Generic;
- using ReactiveUI;
- using Tmds.DBus.Protocol;
- namespace AuthAndCaptcha.ViewModels
- {
- public class CalculatorViewModel : ReactiveObject
- {
- public static List<string> calcOptions => new List<string>() {"Ñëîæåíèå", "Âû÷èòàíèå", "Óìíîæåíèå", "Äåëåíèå"};
- 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;
- }
- }
- }
|