123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- using Avalonia.Controls;
- using Avalonia.Threading;
- using AvaloniaApplication4.Models;
- using ReactiveUI;
- using System;
- namespace AvaloniaApplication4.ViewModels
- {
- public class MainWindowViewModel : ViewModelBase
- {
- UserControl _us = new Page1();
- public UserControl Us
- {
- get => _us;
- set => this.RaiseAndSetIfChanged(ref _us, value);
- }
- Page1ViewModel _page1VM = new Page1ViewModel();
- public Page1ViewModel Page1VM
- {
- get => _page1VM;
- set => _page1VM = value;
- }
- Page2ViewModel page2VM = new Page2ViewModel();
- public Page2ViewModel Page2VM
- {
- get => page2VM;
- set => page2VM = value;
- }
- public void ToPage2()
- {
- Us = new Page2();
- }
- public void ToPage1()
- {
- Us = new Page1();
- }
- public void proverka()
- {
- if (Page1VM.loginn == Model.login && Page1VM.pass == Model.parol)
- {
- Page1VM.Res = "Верный логин и пароль";
-
- Us = new Page2();
- }
- else if (Page1VM.loginn != Model.login || Page1VM.pass != Model.parol)
- {
- Page1VM.Res = "Неверный логин или пароль";
- Page1VM.IsButtonVisible = false;
- Page1VM.IsButtonVisible1 = true;
- Page1VM.IsButtonVisible2 = true;
- Page1VM.IsTBvis = true;
- Page1VM.CreateCaptha();
- Page1VM.count++;
- }
- }
- public void CheckCaptcha()
- {
- if (Page1VM.count != 2)
- {
- if (Page1VM.loginn == Model.login && Page1VM.pass == Model.parol)
- {
- string captchaText = new string(Page1VM.stringChars);
- if (Page1VM.enteredtext.ToLower() == captchaText.ToLower())
- {
- Page1VM.Res = "Верный логин и пароль";
- Page1VM.Res1 = "Верный код капчи";
- Us = new Page2();
- }
- else
- {
- Page1VM.Res1 = "Неверный код капчи";
- Page1VM.count++;
- Page1VM.CreateCaptha();
- }
- }
- else
- {
- Page1VM.Res = "Неверный логин или пароль";
- Page1VM.CreateCaptha();
- Page1VM.count++;
- }
- }
- else
- {
- Page1VM.Enabled = false;
- Page1VM.IsButtonVisible1 = false;
- Page1VM.IsButtonVisible2 = false;
- Page1VM.IsTBvis = false;
- DispatcherTimer timer = new DispatcherTimer();
- timer.Interval = new TimeSpan(0, 0, 10);
- timer.Tick += (sender, e) =>
- {
- Page1VM.IsButtonVisible1 = true;
- Page1VM.IsButtonVisible2 = true;
- Page1VM.IsTBvis = true;
- Page1VM.Enabled = true;
- Page1VM.Login = "";
- Page1VM.Password = 0;
- Page1VM.Enteredt = "";
- Page1VM.count = 0;
- Page1VM.CreateCaptha();
- timer.Stop();
- };
- timer.Start();
- }
- }
- }
- }
|