-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathfrmSplash.cs
136 lines (109 loc) · 4.68 KB
/
frmSplash.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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
//NCShark - By AlSch092 @ Github, thanks to @Diamondo25 for MapleShark
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.Win32;
using ScriptNET.Runtime;
using System.Reflection;
using System.Security.Principal;
namespace NCShark
{
public partial class frmSplash : Form
{
public frmSplash()
{
InitializeComponent();
centerX = this.Size.Width / 2;
centerY = this.Size.Height / 2;
centerX -= pictureBox1.Size.Width / 2;
centerY -= pictureBox1.Size.Height / 2;
}
int centerX = 0, centerY = 0;
int lastX = -1;
int timer = 0;
bool lastOrientation = true;
private void frmSplash_Load(object sender, EventArgs e)
{
initialisator.RunWorkerAsync();
}
private void timer1_Tick(object sender, EventArgs e)
{
timer += 25;
var pic = pictureBox1;
var time = timer++;
var tmp = time / 360.0f;
var x = Math.Sin(tmp) * 90;
x += centerX;
var y = pic.Location.Y;
pic.Location = new Point((int)x, (int)y);
bool goLeft = lastX > (int)x;
if (goLeft != lastOrientation)
{
Image img = pic.Image.Clone() as Image;
img.RotateFlip(RotateFlipType.RotateNoneFlipX);
pic.Image = img;
lastOrientation = goLeft;
}
lastX = (int)x;
}
private void initialisator_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
this.DialogResult = System.Windows.Forms.DialogResult.OK;
this.Close();
}
private void initialisator_DoWork(object sender, DoWorkEventArgs e)
{
var filepath = Assembly.GetExecutingAssembly().Location;
Environment.CurrentDirectory = filepath.Remove(filepath.LastIndexOf(System.IO.Path.DirectorySeparatorChar));
initialisator.ReportProgress(0, "Checking for updates");
CraftNetTools.AppUpdates.Check();
//initialisator.ReportProgress(0, "Initializing MapleStory AES Keys");
//MapleKeys.Initialize();
initialisator.ReportProgress(0, "Loading Script.NET context");
RuntimeHost.Initialize();
initialisator.ReportProgress(0, "Loading packet definitions");
DefinitionsContainer.Load();
initialisator.ReportProgress(0, "Loading + saving config file");
Config.Instance.Save();
initialisator.ReportProgress(0, "Registering .msb extension");
RegisterFileAssociation(".msb", "NCShark", "NCShark Binary File", filepath, string.Empty, 0);
}
private static void RegisterFileAssociation(string pExtension, string pProgramId, string pDescription, string pEXE, string pIconPath, int pIconIndex)
{
try
{
if (pExtension.Length != 0)
{
if (pExtension[0] != '.') pExtension = "." + pExtension;
using (RegistryKey key = Registry.ClassesRoot.OpenSubKey(pExtension)) if (key == null) using (RegistryKey extKey = Registry.ClassesRoot.CreateSubKey(pExtension)) extKey.SetValue(string.Empty, pProgramId);
using (RegistryKey extKey = Registry.ClassesRoot.OpenSubKey(pExtension))
using (RegistryKey key = extKey.OpenSubKey(pProgramId))
{
if (key == null)
{
using (RegistryKey progIdKey = Registry.ClassesRoot.CreateSubKey(pProgramId))
{
progIdKey.SetValue(string.Empty, pDescription);
using (RegistryKey defaultIcon = progIdKey.CreateSubKey("DefaultIcon")) defaultIcon.SetValue(string.Empty, String.Format("\"{0}\",{1}", pIconPath, pIconIndex));
using (RegistryKey command = progIdKey.CreateSubKey("shell\\open\\command")) command.SetValue(string.Empty, String.Format("\"{0}\" \"%1\"", pEXE));
}
}
}
}
}
catch (Exception ex)
{
Console.WriteLine("Error registering file association: {0}", ex.ToString());
}
}
private void initialisator_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
label2.Text = (string)e.UserState;
}
}
}