-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLanding.cs
163 lines (126 loc) · 5.84 KB
/
Landing.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
159
160
161
162
163
using System;
using System.Diagnostics;
using System.Net.Http;
using System.Windows.Forms;
using ZedGraph;
namespace Horus
{
public partial class Landing : Form {
String ServerAPIURL = "" + Program.Server;
Panel SubPanel;
Int32 TabInstances = 0;
public Landing() {
InitializeComponent();
}
private async void Access() {
this.MainPanel.Visible = false;
this.WaitAnimation.Visible = true;
try {
if (this.Clave.Text.Trim() != "" && this.Usuario.Text.Trim() != "") {
HttpClient httpClient = new HttpClient();
MultipartFormDataContent form = new MultipartFormDataContent();
HttpResponseMessage response;
form.Add(new StringContent(this.Usuario.Text.Trim()), "user");
form.Add(new StringContent(this.Clave.Text.Trim()), "password");
response = await httpClient.PostAsync(ServerAPIURL + "/api/v2/admin/login", form);
response.EnsureSuccessStatusCode();
httpClient.Dispose();
String[] RecivedMatrix = response.Content.ReadAsStringAsync().Result.Split('|');
if (RecivedMatrix[0] == "200")
{
Program.User = this.Usuario.Text.Trim();
Program.Password = this.Clave.Text.Trim();
Program.LogInToken = RecivedMatrix[1];
TabInstances = 0;
NewStream_Click(null, null);
this.Usuario.Text = "";
this.Clave.Text = "";
}
else {
this.MainPanel.Visible = true;
this.WaitAnimation.Visible = false;
// Application.DoEvents();
MessageBox.Show(RecivedMatrix[1], "Atención", MessageBoxButtons.OK);
}
}
else {
this.MainPanel.Visible = true;
this.WaitAnimation.Visible = false;
// Application.DoEvents();
MessageBox.Show("Faltan datos", "Atención", MessageBoxButtons.OK);
}
}
catch (Exception Ex) {
this.MainPanel.Visible = true;
this.WaitAnimation.Visible = false;
// Application.DoEvents();
MessageBox.Show(Ex.Message, "Error", MessageBoxButtons.OK);
}
this.WaitAnimation.Visible = false;
}
private void Alta_Click(object sender, EventArgs e) {
try {
Process.Start("https://www.proyectohorus.com.ar/Administrador/AddAccount");
}
catch (Exception Ex) {
MessageBox.Show(Ex.Message, "Error", MessageBoxButtons.OK);
}
}
private void SubPanel_unload(object sender, FormClosedEventArgs e) {
this.Streams.TabPages.Remove(this.Streams.SelectedTab);
if (this.Streams.TabCount == 0) {
this.MainPanel.Visible = true;
TabInstances = 0;
}
}
private void Aceptar_Click(object sender, EventArgs e) {
Access();
}
private void Landing_Resize(object sender, EventArgs e) {
LoginPanel.Top = (this.Height / 2) - (LoginPanel.Height / 2);
//LoginPanel.Left = (this.Width / 2) - (LoginPanel.Width / 2);
WaitAnimation.Top = (this.Height / 2) - (WaitAnimation.Height / 2);
WaitAnimation.Left = (this.Width / 2) - (WaitAnimation.Width / 2);
// Application.DoEvents();
}
private void LinkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) {
System.Diagnostics.Process.Start("https://www.proyectohorus.com.ar");
}
private void Timer1_Tick(object sender, EventArgs e) {
if (Program.IsHide == true && this.Visible == true)
this.Visible = false;
if (Program.IsHide == false && this.Visible == false)
this.Visible = true;
}
private void NewStream_Click(object sender, EventArgs e) {
try {
if (this.Streams.TabCount >= Program.MaxStreams) {
MessageBox.Show(this, "Maxima cantidad de streams alcanzada. Adquiera una version full para conseguir más funciones.", "Atencion", MessageBoxButtons.OK);
return;
}
TabInstances++;
String title = "Stream " + TabInstances.ToString();
TabPage myTabPage = new TabPage(title);
this.Streams.TabPages.Add(myTabPage);
Cuentas CuentasWindow = new Cuentas();
CuentasWindow.TopLevel = false;
CuentasWindow.Dock = DockStyle.Fill;
myTabPage.Controls.Add(CuentasWindow);
CuentasWindow.Show();
this.MainPanel.Visible = false;
CuentasWindow.FormClosed += new FormClosedEventHandler(SubPanel_unload);
this.Streams.SelectedIndex = this.Streams.TabCount - 1;
}
catch { }
}
private void Landing_Load(object sender, EventArgs e) {
this.LoginPanel.Left = 0;
this.LoginPanel.Visible = true;
for (Int32 LeftMove = (this.LoginPanel.Width * -1); LeftMove < -9; LeftMove = LeftMove + 30) {
this.LoginPanel.Left = LeftMove;
Landing_Resize(sender, e);
}
this.Usuario.Focus();
}
}
}