Skip to content

Commit

Permalink
Good Night
Browse files Browse the repository at this point in the history
  • Loading branch information
DartPower committed Jun 2, 2019
1 parent 2c3e313 commit 3771b72
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 53 deletions.
50 changes: 50 additions & 0 deletions KonamiSequence.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using System.Collections.Generic;
using System.Windows.Forms;

namespace SharpMCL
{
public class KonamiSequence
{
List<Keys> Keys = new List<Keys>{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;
}
}
}
106 changes: 58 additions & 48 deletions LauncherForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{

}
}
}
9 changes: 5 additions & 4 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Windows.Forms;

namespace SharpMCL
Expand All @@ -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;
Expand All @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down
1 change: 1 addition & 0 deletions SharpMCL.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="KonamiSequence.cs" />
<Compile Include="LauncherForm.cs">
<SubType>Form</SubType>
</Compile>
Expand Down

0 comments on commit 3771b72

Please sign in to comment.