diff --git a/KonamiSequence.cs b/KonamiSequence.cs new file mode 100644 index 0000000..c2efad4 --- /dev/null +++ b/KonamiSequence.cs @@ -0,0 +1,50 @@ +using System.Collections.Generic; +using System.Windows.Forms; + +namespace SharpMCL +{ + public class KonamiSequence + { + List Keys = new List{System.Windows.Forms.Keys.Up, System.Windows.Forms.Keys.Up, + System.Windows.Forms.Keys.Down, System.Windows.Forms.Keys.Down, + System.Windows.Forms.Keys.Left, System.Windows.Forms.Keys.Right, + System.Windows.Forms.Keys.Left, System.Windows.Forms.Keys.Right, + System.Windows.Forms.Keys.B, System.Windows.Forms.Keys.A}; + private int mPosition = -1; + + public int Position + { + get { return mPosition; } + private set { mPosition = value; } + } + + public bool IsCompletedBy(Keys key) + { + if (Keys[Position + 1] == key) + { + // move to next + Position++; + } + else if (Position == 1 && key == System.Windows.Forms.Keys.Up) + { + // stay where we are + } + else if (Keys[0] == key) + { + // restart at 1st + Position = 0; + } + else + { + // no match in sequence + Position = -1; + } + if (Position == Keys.Count - 1) + { + Position = -1; + return true; + } + return false; + } + } +} diff --git a/LauncherForm.cs b/LauncherForm.cs index bbff6be..17b9056 100644 --- a/LauncherForm.cs +++ b/LauncherForm.cs @@ -6,64 +6,74 @@ namespace SharpMCL { public partial class LauncherForm : Form - { - public LauncherForm() - { - InitializeComponent(); - } + { + public LauncherForm() + { + InitializeComponent(); + } - private void Form1_Load(object sender, EventArgs e) - { - DirectoryInfo IntancesDir = new DirectoryInfo(System.IO.Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + @".\Instances"); - foreach (var d in IntancesDir.GetDirectories()) - { - listBox1.Items.Add(d.Name); - } - foreach (var d in IntancesDir.GetFiles()) - { - listBox1.Items.Add(d.Name); - } - } + private void Form1_Load(object sender, EventArgs e) + { + DirectoryInfo IntancesDir = new DirectoryInfo(System.IO.Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + @".\Instances"); + foreach (var d in IntancesDir.GetDirectories()) + { + listBox1.Items.Add(d.Name); + } + foreach (var d in IntancesDir.GetFiles()) + { + listBox1.Items.Add(d.Name); + } + } - private void Button1_Click(object sender, EventArgs e) - { - String InstanceName = ""; - String UserName = ""; - InstanceName = listBox1.Text; - UserName = textBox1.Text; - String ClientPath = @"\Instances\" + InstanceName + @"\"; - String clientdir = System.IO.Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + ClientPath; - String client = InstanceName; - String user = UserName; - String uuid = Guid.NewGuid().ToString(); - String session = "0"; - this.Close(); - Program.start(clientdir, client, user, uuid, session); - } + private KonamiSequence sequence = new KonamiSequence(); - private void GroupBox1_Enter(object sender, EventArgs e) - { + private void Form1_KeyUp(object sender, KeyEventArgs e) + { + if (sequence.IsCompletedBy(e.KeyCode)) + { + MessageBox.Show("KONAMI!!!"); + } + } - } + private void Button1_Click(object sender, EventArgs e) + { + String InstanceName = ""; + String UserName = ""; + InstanceName = listBox1.Text; + UserName = textBox1.Text; + String ClientPath = @"\Instances\" + InstanceName + @"\"; + String clientdir = System.IO.Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + ClientPath; + String client = InstanceName; + String user = UserName; + String uuid = Guid.NewGuid().ToString(); + String session = "0"; + this.Close(); + Program.start(clientdir, client, user, uuid, session); + } - private void TextBox1_TextChanged(object sender, EventArgs e) - { + private void GroupBox1_Enter(object sender, EventArgs e) + { - } + } - private void ListBox1_SelectedIndexChanged(object sender, EventArgs e) - { + private void TextBox1_TextChanged(object sender, EventArgs e) + { - } + } - private void TextBox1_TextChanged_1(object sender, EventArgs e) - { + private void ListBox1_SelectedIndexChanged(object sender, EventArgs e) + { - } + } - private void Label1_Click(object sender, EventArgs e) - { + private void TextBox1_TextChanged_1(object sender, EventArgs e) + { - } - } + } + + private void Label1_Click(object sender, EventArgs e) + { + + } + } } diff --git a/Program.cs b/Program.cs index 4fc4141..b8edffb 100644 --- a/Program.cs +++ b/Program.cs @@ -5,6 +5,7 @@ using System.IO; using System.Runtime.InteropServices; using System.Text; +using System.Threading; using System.Windows.Forms; namespace SharpMCL @@ -17,8 +18,8 @@ static class Program [STAThread] static void Main(string[] args) { - Marshal.PrelinkAll(typeof(Program)); - Process currentProcess = Process.GetCurrentProcess(); + Marshal.PrelinkAll(typeof(Program)); + Process currentProcess = Process.GetCurrentProcess(); currentProcess.PriorityClass = ProcessPriorityClass.High; Console.BackgroundColor = ConsoleColor.Black; Console.ForegroundColor = ConsoleColor.White; @@ -28,11 +29,11 @@ static void Main(string[] args) { Application.Run(new LauncherForm()); } - catch (Exception ex) + catch (Exception value) { try { - MessageBox.Show(ex.ToString(), "SharpMCL: Error"); + MessageBox.Show(value.ToString(), "SharpMCL: Error"); } catch { diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index daa5321..67a732f 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -17,7 +17,7 @@ // Установка значения False для параметра ComVisible делает типы в этой сборке невидимыми // для компонентов COM. Если необходимо обратиться к типу в этой сборке через // из модели COM задайте для атрибута ComVisible этого типа значение true. -[assembly: ComVisible(true)] +[assembly: ComVisible(false)] // Следующий GUID представляет идентификатор typelib, если этот проект доступен из модели COM [assembly: Guid("4ccd1f91-1fe9-4611-9486-95bef07901b0")] diff --git a/SharpMCL.csproj b/SharpMCL.csproj index 00dfe41..092ecf8 100644 --- a/SharpMCL.csproj +++ b/SharpMCL.csproj @@ -59,6 +59,7 @@ + Form