123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- using Auth.Models;
- using Avalonia.Media;
- using Avalonia.Styling;
- using ReactiveUI;
- using System;
- using System.Drawing;
- using System.Security.Cryptography.X509Certificates;
- using Avalonia.Controls;
- using Avalonia.Controls.Shapes;
- using System.Linq;
- using Avalonia.Threading;
- using System.Collections.Generic;
- using System.ComponentModel;
- using Avalonia.Input;
- using System.Windows.Input;
- namespace Auth.ViewModels
- {
- public class CalcVM : ReactiveObject
- {
- public float? chislo1;
- public float? chislo2;
- public string result = "";
- public static List<string> _operation = Models.data.Operation;
- private string _selectedOperation = _operation[0];
- public string znaki = "+";
- public List<String> Operation
- {
- get
- {
- return _operation;
- }
- }
- public string Znaki
- {
- get
- {
- return znaki;
- }
- set
- {
- this.RaiseAndSetIfChanged(ref znaki, value);
- }
- }
- public string SelectedOperation
- {
- get => _selectedOperation;
- set
- {
- this.RaiseAndSetIfChanged(ref _selectedOperation, value);
- if (SelectedOperation == _operation[0])
- {
- Znaki = "+";
- }
- else if (SelectedOperation == _operation[1])
- {
- Znaki = "-";
- }
- else if (SelectedOperation == _operation[2])
- {
- Znaki = "*";
- }
- else if (SelectedOperation == _operation[3])
- {
- Znaki = "/";
- }
- }
- }
- public void Resultat()
- {
- switch (SelectedOperation)
- {
- case "Сложение":
- Result = (Chislo1 + Chislo2).ToString();
- break;
- case "Вычитание":
- Result = (Chislo1 - Chislo2).ToString();
- break;
- case "Умножение":
- Result = (Chislo1 * Chislo2).ToString();
- break;
- case "Деление":
- Result = Chislo2 != 0 ? (Chislo1 / Chislo2).ToString() : float.NaN.ToString();
- break;
- }
- }
- public string Result
- {
- get
- {
- return result;
- }
- set
- {
- this.RaiseAndSetIfChanged(ref result, value);
- }
- }
- public float? Chislo1
- {
- get => chislo1;
- set
- {
- this.RaiseAndSetIfChanged(ref chislo1, value);
- }
- }
- public float? Chislo2
- {
- get => chislo2;
- set
- {
- this.RaiseAndSetIfChanged(ref chislo2, value);
- }
- }
- }
- }
-
|