|
@@ -0,0 +1,163 @@
|
|
|
|
+using System;
|
|
|
|
+using System.Collections.Generic;
|
|
|
|
+using System.Linq;
|
|
|
|
+using System.Text;
|
|
|
|
+using System.Threading;
|
|
|
|
+using System.Threading.Tasks;
|
|
|
|
+using System.Windows;
|
|
|
|
+using System.Windows.Controls;
|
|
|
|
+using System.Windows.Data;
|
|
|
|
+using System.Windows.Documents;
|
|
|
|
+using System.Windows.Input;
|
|
|
|
+using System.Windows.Media;
|
|
|
|
+using System.Windows.Media.Imaging;
|
|
|
|
+using System.Windows.Navigation;
|
|
|
|
+using System.Windows.Shapes;
|
|
|
|
+using System.Windows.Threading;
|
|
|
|
+
|
|
|
|
+namespace WpfApp10
|
|
|
|
+{
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// Логика взаимодействия для MainWindow.xaml
|
|
|
|
+ /// </summary>
|
|
|
|
+ public partial class MainWindow : Window
|
|
|
|
+ {
|
|
|
|
+ public DispatcherTimer dispatcherTimer;
|
|
|
|
+ public string result, buffer, temp;
|
|
|
|
+ public MainWindow()
|
|
|
|
+ {
|
|
|
|
+ InitializeComponent();
|
|
|
|
+ dispatcherTimer = new DispatcherTimer();
|
|
|
|
+ dispatcherTimer.Tick += new EventHandler(timer);
|
|
|
|
+ dispatcherTimer.Interval = new TimeSpan(0, 0, 10);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void timer(object sender, EventArgs e)
|
|
|
|
+ {
|
|
|
|
+ ris_SizeChanged(null, null);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void prov_Click(object sender, RoutedEventArgs e)
|
|
|
|
+ {
|
|
|
|
+ int chack = 0;
|
|
|
|
+ if (log.Text == "1" && par.Text == "1" && captcha.Visibility == Visibility.Hidden)
|
|
|
|
+ {
|
|
|
|
+ MessageBox.Show("Вошли");
|
|
|
|
+ }
|
|
|
|
+ if ((log.Text != "1" || par.Text != "1") && captcha.Visibility == Visibility.Hidden)
|
|
|
|
+ {
|
|
|
|
+ MessageBox.Show("Не вошли");
|
|
|
|
+ captcha.Visibility = Visibility.Visible;
|
|
|
|
+ chack = 1;
|
|
|
|
+ }
|
|
|
|
+ if (captcha.Visibility == Visibility.Visible)
|
|
|
|
+ {
|
|
|
|
+ if (chack == 1)
|
|
|
|
+ {
|
|
|
|
+ if (log.Text == "1" && par.Text == "1" && txt.Text == result)
|
|
|
|
+ {
|
|
|
|
+ MessageBox.Show("Вошли");
|
|
|
|
+ }
|
|
|
|
+ else if (log.Text != "1" || par.Text != "1" || txt.Text != result)
|
|
|
|
+ {
|
|
|
|
+ ris.Children.Clear();
|
|
|
|
+ result = "";
|
|
|
|
+ ris_SizeChanged(null, null);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ if (log.Text == "1" && par.Text == "1" && txt.Text == result)
|
|
|
|
+ {
|
|
|
|
+ MessageBox.Show("Вошли");
|
|
|
|
+ }
|
|
|
|
+ else if (log.Text != "1" || par.Text != "1" || txt.Text != result)
|
|
|
|
+ {
|
|
|
|
+ ris.Children.Clear();
|
|
|
|
+ prov.IsEnabled = false;
|
|
|
|
+ dispatcherTimer.Start();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void Button_Click(object sender, RoutedEventArgs e)
|
|
|
|
+ {
|
|
|
|
+ ris.Children.Clear();
|
|
|
|
+ result = "";
|
|
|
|
+ ris_SizeChanged(null, null);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void ris_SizeChanged(object sender, SizeChangedEventArgs e)
|
|
|
|
+ {
|
|
|
|
+ prov.IsEnabled = true;
|
|
|
|
+ dispatcherTimer.Stop();
|
|
|
|
+
|
|
|
|
+ result = "";
|
|
|
|
+ buffer = "";
|
|
|
|
+ temp = "";
|
|
|
|
+
|
|
|
|
+ Random random = new Random();
|
|
|
|
+
|
|
|
|
+ string allchars = "Q,W,E,R,T,Y,U,I,O,P,A,S,D,F,G,H,J,K,L,Z,X,C,V,B,N,M,1,2,3,4,5,6,7,8,9,0";
|
|
|
|
+ char[] del = { ',' };
|
|
|
|
+ string[] itog = allchars.Split(del);
|
|
|
|
+ byte R, G, B;
|
|
|
|
+
|
|
|
|
+ for (int i = 0; i < 4; i++)
|
|
|
|
+ {
|
|
|
|
+ temp = itog[random.Next(0, itog.Length)];
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ R = (byte)random.Next(0, 255);
|
|
|
|
+ G = (byte)random.Next(0, 255);
|
|
|
|
+ B = (byte)random.Next(0, 255);
|
|
|
|
+
|
|
|
|
+ TextBlock textBlock = new TextBlock()
|
|
|
|
+ {
|
|
|
|
+ TextAlignment = TextAlignment.Center,
|
|
|
|
+ FontSize = random.Next(20, 50),
|
|
|
|
+ LayoutTransform = new RotateTransform(random.Next(-10, 10)),
|
|
|
|
+ Foreground = new SolidColorBrush(Color.FromRgb(R, G, B)),
|
|
|
|
+ Margin = new Thickness(i * 50, 0, 0, 0)
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ textBlock.Text = temp;
|
|
|
|
+ buffer += temp;
|
|
|
|
+ ris.Children.Add(textBlock);
|
|
|
|
+ }
|
|
|
|
+ result = buffer;
|
|
|
|
+
|
|
|
|
+ for (int i = 0; i < 5; i++)
|
|
|
|
+ {
|
|
|
|
+ int x = 0;
|
|
|
|
+ int x2 = 200;
|
|
|
|
+
|
|
|
|
+ int y = random.Next(0, 60);
|
|
|
|
+ int y2 = random.Next(0, 60);
|
|
|
|
+ ris.Children.Add(line(x, x2, y, y2));
|
|
|
|
+ }
|
|
|
|
+ for (int i = 0; i < 5; i++)
|
|
|
|
+ {
|
|
|
|
+ int y = 0;
|
|
|
|
+ int y2 = 60;
|
|
|
|
+
|
|
|
|
+ int x = random.Next(0, 200);
|
|
|
|
+ int x2 = random.Next(0, 200);
|
|
|
|
+ ris.Children.Add(line(x, x2, y, y2));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ private Line line(int x, int x2, int y, int y2)
|
|
|
|
+ {
|
|
|
|
+ Line line = new Line();
|
|
|
|
+ line.X1 = x;
|
|
|
|
+ line.Y1 = y;
|
|
|
|
+ line.X2 = x2;
|
|
|
|
+ line.Y2 = y2;
|
|
|
|
+ line.Stroke = Brushes.Black;
|
|
|
|
+ return line;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|