aboutsummaryrefslogtreecommitdiff
path: root/Histacom2/SaveDialogs/LoadGameProfileItem.cs
diff options
context:
space:
mode:
authorlempamo <[email protected]>2017-08-23 13:38:40 -0400
committerlempamo <[email protected]>2017-08-23 13:38:40 -0400
commit3306d36ecbc024775972e5cf7971b2a7a70671d0 (patch)
tree0a79e67b6723a8c75ffd66c7828bdd0ebb1bf74d /Histacom2/SaveDialogs/LoadGameProfileItem.cs
parent99fef5c57360f07259fc86f433bed8a9ab59c48e (diff)
downloadhistacom2-3306d36ecbc024775972e5cf7971b2a7a70671d0.tar.gz
histacom2-3306d36ecbc024775972e5cf7971b2a7a70671d0.tar.bz2
histacom2-3306d36ecbc024775972e5cf7971b2a7a70671d0.zip
Renaming the game!
Diffstat (limited to 'Histacom2/SaveDialogs/LoadGameProfileItem.cs')
-rw-r--r--Histacom2/SaveDialogs/LoadGameProfileItem.cs152
1 files changed, 152 insertions, 0 deletions
diff --git a/Histacom2/SaveDialogs/LoadGameProfileItem.cs b/Histacom2/SaveDialogs/LoadGameProfileItem.cs
new file mode 100644
index 0000000..bdc0b7c
--- /dev/null
+++ b/Histacom2/SaveDialogs/LoadGameProfileItem.cs
@@ -0,0 +1,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();
+ }
+ }
+}