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
|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static Histacom2.Engine.SaveSystem;
using System.IO;
namespace Histacom2
{
public partial class LoadGameProfileItem : UserControl, IMessageFilter
{
public bool OnceRemoveHeight = false;
public bool OnceAddHeight = false;
public bool RequestingNewName = false;
public LoadGameProfileItem()
{
InitializeComponent();
Application.AddMessageFilter(this);
}
//private void LoadGameProfileItem_MouseHover(object sender, EventArgs e)
//{
// exampleTop.Show();
// this.Height += 28;
// OnceRemoveHeight = false;
//}
public bool PreFilterMessage(ref Message m)
{
var mouseLocation = Cursor.Position;
if (!ClientRectangle.Contains(PointToClient(Control.MousePosition)))
{
sidebar.Hide();
if (OnceRemoveHeight == false)
{
this.Height -= 28;
OnceRemoveHeight = true;
profileName.BackColor = Color.Gray;
sidebar.BackColor = Color.Gray;
pnlConfirm.BackColor = Color.Gray;
}
OnceAddHeight = false;
} else
{
sidebar.Show();
if (OnceAddHeight == false)
{
this.Height += 28;
OnceAddHeight = true;
profileName.BackColor = Color.LightGray;
sidebar.BackColor = Color.LightGray;
pnlConfirm.BackColor = Color.LightGray;
}
OnceRemoveHeight = false;
}
if (m.Msg != 0x20a) // Scrolling Message
{
return false;//ignore message
}
return false;
}
private void LoadGameProfileItem_Paint(object sender, PaintEventArgs e)
{
profileName.Text = this.Tag.ToString();
}
private void exampleLoadProfile_Click(object sender, EventArgs e)
{
((LoadGameDialog)this.TopLevelControl).ChooseProfile(this.Tag.ToString());
}
private void button1_Click(object sender, EventArgs e)
{
DeleteProfile();
}
void DeleteProfile()
{
if (Directory.Exists(Path.Combine(AllProfilesDirectory, this.Tag.ToString())))
{
Directory.Delete(Path.Combine(AllProfilesDirectory, this.Tag.ToString()), true);
this.Hide();
}
}
private void button2_Click(object sender, EventArgs e)
{
try
{
if (!RequestingNewName == false)
{
if (textBox1.Text == "")
{
MessageBox.Show("New profile name cannot be empty!");
}
else
{
if (textBox1.Text.Length > 20)
{
MessageBox.Show("The profile name cannot be longer than 20 characters");
}
else
{
if (Directory.Exists(Path.Combine(AllProfilesDirectory, textBox1.Text)))
{
MessageBox.Show("That profile already exists");
}
else
{
Directory.Move(Path.Combine(AllProfilesDirectory, this.Tag.ToString()), Path.Combine(AllProfilesDirectory, textBox1.Text));
this.Tag = textBox1.Text;
this.Invalidate();
}
}
}
}
pnlConfirm.Hide();
} catch
{
}
}
private void exampleDelete_Click(object sender, EventArgs e)
{
label1.Text = "Are you really sure you want to delete this Profile?";
button1.Show();
textBox1.Hide();
button2.Text = "No";
RequestingNewName = false;
pnlConfirm.Show();
}
private void exampleNameBtn_Click(object sender, EventArgs e)
{
label1.Text = "Enter a new profile name: ";
button1.Hide();
textBox1.Show();
button2.Text = "OK";
RequestingNewName = true;
pnlConfirm.Show();
}
}
}
|