This repository has been archived by the owner on Mar 6, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lxMessageInputBox.cs
158 lines (151 loc) · 9.36 KB
/
lxMessageInputBox.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Net;
using System.Text.RegularExpressions;
using System.Windows.Forms;
namespace lxMeets {
#pragma warning disable IDE1006 // Estilos de nombres
public static class lxMessageInputBox
#pragma warning restore IDE1006 // Estilos de nombres
{
public static string ShowDialog(string title, string body, bool anio = false, bool usuario = false, string contrasenaText = "") {
List<String> anios = new List<String>();
Form prompt = new Form();
ComboBox aniosLect = new ComboBox() { Left = 16, Width = 80, Top = 80, TabIndex = 1, TabStop = true };
ComponentResourceManager resources = new ComponentResourceManager(typeof(GradeWindow));
prompt.Width = 280;
prompt.Text = title;
prompt.Icon = ((Icon)(resources.GetObject("$this.Icon")));
prompt.BackColor = Color.FromArgb(((int)(((byte)(45)))), ((int)(((byte)(45)))), ((int)(((byte)(48)))));
prompt.FormBorderStyle = FormBorderStyle.None;
prompt.Opacity = 0.85D;
prompt.StartPosition = FormStartPosition.CenterScreen;
if (usuario) {
prompt.Height = 200;
TextBox textBox = new TextBox() { Left = 16, Top = 45, Width = 220, TabIndex = 0, TabStop = true };
TextBox passBox = new TextBox() { Left = 16, Top = 100, Width = 220, TabIndex = 0, TabStop = true };
passBox.PasswordChar = '*';
Label textLabel = new Label() { Left = 16, Top = 20, Width = 240, Text = body };
textLabel.ForeColor = Color.White;
prompt.Controls.Add(textLabel);
Label passLabel = new Label() { Left = 16, Top = 80, Width = 240, Text = contrasenaText };
passLabel.ForeColor = Color.White;
prompt.Controls.Add(passLabel);
Button confirmation = new Button() { Text = "Consultar", Left = 16, Width = 80, Top = 150, TabIndex = 1, TabStop = true };
confirmation.BackColor = Color.FromArgb(((int)(((byte)(45)))), ((int)(((byte)(45)))), ((int)(((byte)(48)))));
confirmation.FlatAppearance.MouseOverBackColor = Color.Gray;
confirmation.FlatStyle = FlatStyle.Flat;
confirmation.ForeColor = Color.White;
confirmation.Click += (sender, e) => { prompt.Close(); };
Button cancelation = new Button() { Text = "Cancelar", Left = 130, Width = 80, Top = 150, TabIndex = 1, TabStop = true };
cancelation.BackColor = Color.FromArgb(((int)(((byte)(45)))), ((int)(((byte)(45)))), ((int)(((byte)(48)))));
cancelation.FlatAppearance.MouseOverBackColor = Color.Gray;
cancelation.FlatStyle = FlatStyle.Flat;
cancelation.ForeColor = Color.White;
cancelation.Click += (sender, e) => { textBox.Text = "Cancel"; prompt.Close(); };
prompt.Controls.Add(textBox);
prompt.Controls.Add(passBox);
prompt.Controls.Add(confirmation);
prompt.AcceptButton = confirmation;
prompt.Controls.Add(cancelation);
prompt.CancelButton = cancelation;
prompt.ShowDialog();
string final = "(" + textBox.Text + ")[" + passBox.Text + "]";
return final;
} else {
if (!anio) {
prompt.Height = 160;
TextBox textBox = new TextBox() { Left = 16, Top = 45, Width = 240, TabIndex = 0, TabStop = true };
Button confirmation = new Button() { Text = "Consultar", Left = 16, Width = 80, Top = 88, TabIndex = 1, TabStop = true };
confirmation.BackColor = Color.FromArgb(((int)(((byte)(45)))), ((int)(((byte)(45)))), ((int)(((byte)(48)))));
confirmation.FlatAppearance.MouseOverBackColor = Color.Gray;
confirmation.FlatStyle = FlatStyle.Flat;
confirmation.ForeColor = Color.White;
confirmation.Click += (sender, e) => { prompt.Close(); };
Label textLabel = new Label() { Left = 16, Top = 20, Width = 240, Text = body };
textLabel.ForeColor = Color.White;
prompt.Controls.Add(textLabel);
Button cancelation = new Button() { Text = "Cancelar", Left = 130, Width = 80, Top = 88, TabIndex = 1, TabStop = true };
cancelation.BackColor = Color.FromArgb(((int)(((byte)(45)))), ((int)(((byte)(45)))), ((int)(((byte)(48)))));
cancelation.FlatAppearance.MouseOverBackColor = Color.Gray;
cancelation.FlatStyle = FlatStyle.Flat;
cancelation.ForeColor = Color.White;
cancelation.Click += (sender, e) => { textBox.Text = "Cancel"; prompt.Close(); };
prompt.Controls.Add(textBox);
prompt.AcceptButton = confirmation;
prompt.Controls.Add(confirmation);
prompt.Controls.Add(cancelation);
prompt.CancelButton = cancelation;
prompt.ShowDialog();
return textBox.Text;
} else {
prompt.Height = 200;
TextBox textBox = new TextBox() { Left = 16, Top = 45, Width = 220, TabIndex = 0, TabStop = true };
Button getAnios = new Button() { Text = "↻", Left = 240, Top = 45, Width = 30, TabIndex = 0, TabStop = true };
getAnios.BackColor = Color.FromArgb(((int)(((byte)(45)))), ((int)(((byte)(45)))), ((int)(((byte)(48)))));
getAnios.FlatAppearance.MouseOverBackColor = Color.Gray;
getAnios.FlatStyle = FlatStyle.Flat;
getAnios.ForeColor = Color.White;
getAnios.Click += (sender, e) => { fetchAnios(textBox.Text); };
Label textLabel = new Label() { Left = 16, Top = 20, Width = 240, Text = body };
textLabel.ForeColor = Color.White;
prompt.Controls.Add(textLabel);
Button confirmation = new Button() { Text = "Consultar", Left = 16, Width = 80, Top = 150, TabIndex = 1, TabStop = true };
confirmation.BackColor = Color.FromArgb(((int)(((byte)(45)))), ((int)(((byte)(45)))), ((int)(((byte)(48)))));
confirmation.FlatAppearance.MouseOverBackColor = Color.Gray;
confirmation.FlatStyle = FlatStyle.Flat;
confirmation.ForeColor = Color.White;
confirmation.Click += (sender, e) => { prompt.Close(); };
Button cancelation = new Button() { Text = "Cancelar", Left = 130, Width = 80, Top = 150, TabIndex = 1, TabStop = true };
cancelation.BackColor = Color.FromArgb(((int)(((byte)(45)))), ((int)(((byte)(45)))), ((int)(((byte)(48)))));
cancelation.FlatAppearance.MouseOverBackColor = Color.Gray;
cancelation.FlatStyle = FlatStyle.Flat;
cancelation.ForeColor = Color.White;
cancelation.Click += (sender, e) => { textBox.Text = "Cancel"; prompt.Close(); };
prompt.Controls.Add(textBox);
prompt.Controls.Add(confirmation);
prompt.Controls.Add(getAnios);
prompt.AcceptButton = confirmation;
prompt.Controls.Add(cancelation);
prompt.CancelButton = cancelation;
prompt.ShowDialog();
string final = "(" + textBox.Text + ")[" + aniosLect.SelectedItem + "]";
return final;
}
}
async void fetchAnios(string cedula) {
if (!Regex.IsMatch(cedula, @"^\d+$")) {
MessageBox.Show("Cédula inválida" + cedula);
return;
}
try {
string url = @"https://api.lxndr.dev/uae/notas/anioLect?ced=" + cedula;
var client = new WebClient();
var json = await client.DownloadStringTaskAsync(url);
dynamic stuff = JsonConvert.DeserializeObject(json);
if ((bool)stuff.error) {
MessageBox.Show(stuff.message.ToString());
return;
}
foreach (var s in stuff.anioLect) {
anios.Add(s.ToString());
}
aniosLect.DataSource = anios;
aniosLect.BackColor = Color.FromArgb(((int)(((byte)(45)))), ((int)(((byte)(45)))), ((int)(((byte)(48)))));
aniosLect.DropDownStyle = ComboBoxStyle.DropDownList;
aniosLect.ForeColor = Color.White;
aniosLect.FormattingEnabled = true;
prompt.Controls.Add(aniosLect);
MessageBox.Show(stuff.apellidos.ToString() + " " + stuff.nombres.ToString() + "\nCarrera: " + stuff.carrera.ToString(), "Estudiante encontrado");
return;
} catch {
MessageBox.Show("Ocurrió un error conectando al servidor");
return;
}
}
}
}
}