semen hace 1 mes
padre
commit
17a700b98b

+ 1 - 0
Captcha/Models/ModelClass.cs

@@ -10,6 +10,7 @@ namespace Captcha.Models
     {
         static string _login = "timan_cool";
         static string _password = "10082005";
+
         public static List<string> _arithmetic = new List<string>
         {
             "Сложение",

+ 37 - 6
Captcha/ViewModels/PageCalculateVM.cs

@@ -17,27 +17,58 @@ namespace Captcha.ViewModels
 
         char _c = ' ';
 
+        string selIt = "";
+
         public List<string> Arif { get => _arif; set => _arif = value; }
         public float A { get => _a; set => _a = value; }
         public float B { get => _b; set => _b = value; }
-        public char C { get => _c; set => _c = value; }
+        public char C { get => _c; set => this.RaiseAndSetIfChanged(ref _c, value); }
         public float Result { get => _result; set => this.RaiseAndSetIfChanged(ref _result, value); }
-        void Сalculation()
+        public string SelIt 
+        { 
+            get => selIt; 
+            set
+            {
+                int index = 0;
+                index = _arif.IndexOf(value);
+                switch (index)
+                {
+                    case 0:
+                        C = '+';
+                        break;
+                    case 1:
+                        C = '-';
+                        break;
+                    case 2:
+                        C = '*';
+                        break;
+                    case 3:
+                        C = '/';
+                        break;
+                    default:
+                        break;
+                }
+                selIt = value;
+            }
+        }
+
+        public void Сalculation()
         {
             int index = 0;
+            index = _arif.IndexOf(SelIt);
             switch (index)
             {
                 case 0:
-                    _result = A + B;
+                    Result = A + B;
                     break;
                 case 1:
-                    _result = A - B;
+                    Result = A - B;
                     break;
                 case 2:
-                    _result = A * B;
+                    Result = A * B;
                     break;
                 case 3:
-                    _result = A / B;
+                    Result = A / B;
                     break;
                 default:
                     break;

+ 2 - 2
Captcha/Views/PageCalculate.axaml

@@ -19,9 +19,9 @@
 						<TextBox Text="{Binding A}" Margin="0,0,20,20"></TextBox>
 						<TextBlock Text="{Binding C}" Margin="0,0,20,20"></TextBlock>
 						<TextBox Text="{Binding B}" Margin="0,0,0,20"></TextBox>
-					</StackPanel>
+					</StackPanel> 
 					<StackPanel>
-						<Button HorizontalAlignment = "Center" Margin="0,0,0,20" Content="Вычислить"/>
+						<Button Command = "{Binding Сalculation}" HorizontalAlignment = "Center" Margin="0,0,0,20">Вычислить</Button>
 						<StackPanel Orientation="Horizontal">
 							<TextBlock Text="Результат: " Margin="0,0,0,20"></TextBlock>
 							<TextBlock Text="{Binding Result}" Margin="0,0,0,20"></TextBlock>