-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFormMain.cs
More file actions
130 lines (102 loc) · 4.39 KB
/
FormMain.cs
File metadata and controls
130 lines (102 loc) · 4.39 KB
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
using System.Windows.Forms;
namespace M9Studio.ShadowTalk.Server
{
public partial class FormMain : Form
{
private Server server;
private Logger logger;
public FormMain()
{
InitializeComponent();
this.Shown += post_init;
}
private void post_init(object sender, EventArgs e)
{
logger = new Logger(
labelAddress,
labelUser,
labelUserOnline,
labelMessage,
labelMessageWaiting,
labelMessageDeleted,
listBoxLog);
server = new Server(logger);
}
private void button1_Click(object sender, EventArgs e)
{
listBoxLog.Items.Clear();
}
private void listBox1_DoubleClick(object sender, EventArgs e)
{
if (listBoxLog.SelectedItem != null)
{
string fullText = listBoxLog.SelectedItem.ToString();
// Ñîçäàåì è ïîêàçûâàåì íîâîå îêíî
Form detailForm = new Form();
detailForm.Text = "Ïîëíûé òåêñò";
TextBox textBox = new TextBox();
textBox.Multiline = true;
textBox.ReadOnly = true;
textBox.Text = fullText;
textBox.Dock = DockStyle.Fill;
textBox.ScrollBars = ScrollBars.Vertical;
detailForm.Controls.Add(textBox);
detailForm.Size = new Size(400, 300);
detailForm.StartPosition = FormStartPosition.CenterParent;
detailForm.Show(); // èëè Show(), åñëè íå íóæíî áëîêèðîâàòü îñíîâíîå îêíî
}
}
private void button2_Click(object sender, EventArgs e)
{
InputForm inputForm = new InputForm();
inputForm.OnSave = Save;
inputForm.ShowDialog();
}
private void Save(string nick, string login, string password)
{
int id = server.@base.Count("SELECT IFNULL(MAX(id), 0) AS num FROM users") + 1;
string RSA = "<RSAKeyValue><Modulus>t6hxT8GPOvYBdUmtt6M8zVguGu9XTIjG+EO7nWlMNQLFDgU6Aksa8/YTM1puetcr8xsX0EO9ZxJqrlb19JogyEO1W3HmPYd/mI6VfXEYPlAB32XGD3lTb3DjZ+DEJ6HyIT0YsKG9YUztebuUGk6ZvheXOp0fByn1oQbRrIGjJZLh9ZfXeqii0yHiKWyyxoUPqkEvGwNABXgKjvHtYODiyVxOfATFBS+1m6uRPgm5/cDSEBJ72GvMHAwE1bx+UeNDmOvXBP0Kn/xqQwFUQHwcjBdKYw+iwQI0oVkVLJkJn7PU7vEbL7Kp9ed1Rky4OR5zJVIaUT998Rjf8+8iDuUHHQ==</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>";
server.@base.Send("INSERT INTO users (id, name, email, password, rsa, is2fa) VALUES (?, ?, ?, ?, ?, 0)", id, nick, login, password, RSA);
server.Update();
}
}
public partial class InputForm : Form
{
private TextBox textNick;
private TextBox textLogin;
private TextBox textPassword;
private Button btnSave;
public Action<string, string, string> OnSave; // äåëåãàò äëÿ ïåðåäà÷è äàííûõ
public InputForm()
{
SetupUI();
}
private void SetupUI()
{
this.Text = "Ââåäèòå äàííûå";
this.Size = new System.Drawing.Size(300, 230);
var labelNick = new Label() { Text = "Íèê:", Left = 10, Top = 20 };
textNick = new TextBox() { Left = 120, Top = 20, Width = 150 };
var labelLogin = new Label() { Text = "Ëîãèí:", Left = 10, Top = 60 };
textLogin = new TextBox() { Left = 120, Top = 60, Width = 150 };
textLogin.Text = "@com.com";
var labelPassword = new Label() { Text = "Ïàðîëü:", Left = 10, Top = 100 };
textPassword = new TextBox() { Left = 120, Top = 100, Width = 150, PasswordChar = '*' };
textPassword.Text = "00000000";
btnSave = new Button() { Text = "Ñîõðàíèòü", Left = 100, Top = 140, Width = 100 };
btnSave.Click += BtnSave_Click;
this.Controls.AddRange(new Control[] {
labelNick, textNick, labelLogin, textLogin,
labelPassword, textPassword, btnSave
});
}
private void BtnSave_Click(object sender, EventArgs e)
{
string nick = textNick.Text;
string login = textLogin.Text;
string password = textPassword.Text;
OnSave?.Invoke(nick, login, password); // âûçûâàåì êîëáýê
this.Close(); // çàêðûâàåì îêíî
}
}
}