-
Notifications
You must be signed in to change notification settings - Fork 0
/
Form10.cs
118 lines (103 loc) · 4.55 KB
/
Form10.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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace plato_saga
{
public partial class Form10 : Form
{
String language = plato_saga.Properties.Settings.Default.app_lang;
public String new_pass = String.Empty;
public Boolean cancel = false;
public Form10()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text.Length == 0 || textBox2.Text.Length == 0 || textBox3.Text.Length == 0)
{
if (language == "es") MessageBox.Show("Rellene todos los campos para continuar.");
if (language == "en") MessageBox.Show("Please fill in all text fields.");
return;
}
if (textBox1.Text.Length < 5 || textBox2.Text.Length < 5 || textBox3.Text.Length < 5)
{
if (language == "es") MessageBox.Show("La contraseña debe tener al menos 5 caracteres.");
if (language == "en") MessageBox.Show("Password must be at least 5 characters in lenght.");
return;
}
String pass_file = System.IO.Path.Combine(Environment.GetEnvironmentVariable("appdata"), "platosaga") + "\\" + "pass_file";
String old_pass = "";
if (!File.Exists(pass_file)) old_pass = "carrito";
if (File.Exists(pass_file)) old_pass = File.ReadAllText(pass_file);
if (textBox1.Text != old_pass)
{
if (language == "es") MessageBox.Show("La contraseña anterior es incorrecta.");
if (language == "en") MessageBox.Show("Current password is incorrect.");
return;
}
if (textBox2.Text != textBox3.Text)
{
if (language == "es") MessageBox.Show("La contraseña nueva no coincide en ambos campos.");
if (language == "en") MessageBox.Show("New passwords do not match.");
return;
}
cancel = false;
new_pass = textBox2.Text;
File.WriteAllText(pass_file, new_pass);
if (language == "es") MessageBox.Show("Contraseña modificada correctamente.","Contraseña cambiada",MessageBoxButtons.OK,MessageBoxIcon.Information);
if (language == "en") MessageBox.Show("New password sucessfully set.", "Password changed", MessageBoxButtons.OK, MessageBoxIcon.Information);
this.Close();
}
private void RefreshResources(Control ctrl, ComponentResourceManager res)
{
ctrl.SuspendLayout();
res.ApplyResources(ctrl, ctrl.Name, Thread.CurrentThread.CurrentUICulture);
foreach (Control control in ctrl.Controls)
RefreshResources(control, res); // recursion
ctrl.ResumeLayout(false);
}
private void Form10_Load(object sender, EventArgs e)
{
Thread.CurrentThread.CurrentUICulture = new CultureInfo(plato_saga.Properties.Settings.Default.app_lang);
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form10));
RefreshResources(this, resources);
String pass_file = System.IO.Path.Combine(Environment.GetEnvironmentVariable("appdata"), "platosaga") + "\\" + "pass_file";
}
private void button2_Click(object sender, EventArgs e)
{
cancel = true;
this.Close();
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
if (textBox2.Text.Length > 4) pic1.Visible = true;
else pic1.Visible = false;
if (textBox2.Text != textBox3.Text) pic2.Visible = false;
else
{
pic1.Visible = true;
pic2.Visible = true;
}
}
private void textBox3_TextChanged(object sender, EventArgs e)
{
if (textBox3.Text.Length > 4) pic2.Visible = true;
else pic2.Visible = false;
if (textBox3.Text != textBox2.Text) pic2.Visible = false;
else
{
pic2.Visible = true;
}
}
}
}