123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- using System;
- using System.Collections.Generic;
- using ReactiveUI;
- using Avalonia.Media;
- using Avalonia.Controls.Shapes;
- using Avalonia.Threading;
- using AvaloniaApplication4.Models;
- using Avalonia.Controls;
- using static System.Net.Mime.MediaTypeNames;
- using Avalonia.Controls.Documents;
- namespace AvaloniaApplication4.ViewModels
- {
- public class Page2ViewModel : ReactiveObject
- {
- public static List<string> funclis => Models.Model.funclist;
- public string _selectedFunclist = funclis[0];
- // ñâîéñòâî äëÿ îòîáðàæåíèÿ èçíà÷àëüíî âûáðàííîãî çíà÷åèÿ â ñïèñêå
- public List<String> Funclist
- {
- get
- {
- return funclis;
- }
- }
- public string Selectedfunc
- {
-
- get => _selectedFunclist;
- set
- {
- this.RaiseAndSetIfChanged(ref _selectedFunclist, value);
- Calculate();
- }
- }
- double _num1;
- public double Num1
- {
- get => _num1;
- set => this.RaiseAndSetIfChanged(ref _num1, value);
- }
- double _num2;
- public double Num2
- {
- get => _num2;
- set => this.RaiseAndSetIfChanged(ref _num2, value);
- }
- string _symb;
- public string Symb
- {
- get => _symb;
- set => this.RaiseAndSetIfChanged(ref _symb, value);
- }
- string _result ="";
- public string Result
- {
- get => _result;
- set => this.RaiseAndSetIfChanged(ref _result, value);
- }
- double res = 0;
- public void Calculate()
- {
- if (Selectedfunc == "Ñëîæåíèå")
- {
- res = _num1 + _num2;
- Result = ""+res;
- Symb = "+";
- }
- if (Selectedfunc == "Äåëåíèå")
- {
- if (_num1 == 0 || _num2 == 0 || (_num2 == 0 && _num1 == 0))
- {
- Result = "äåëåíèå íà íîëü";
- }
- else
- {
- res = _num1 / _num2;
- Result = "" + res;
- Symb = "/";
- }
-
- }
- if (Selectedfunc == "Óìíîæåíèå")
- {
- res = _num1 * _num2;
- Result = "" + res;
- Symb = "*";
- }
- if (Selectedfunc == "Âû÷èòàíèå")
- {
- res = _num1 - _num2;
- Result = "" + res;
- Symb = "-";
- }
- }
- }
- }
|