-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Mashed.cs
125 lines (110 loc) · 5.02 KB
/
Mashed.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
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using System.Runtime.InteropServices;
using Microsoft.Win32;
using System.Security.Permissions;
using System.Security;
namespace SciLor_s_Mashed_Runner {
class Mashed {
public static Version version = null;
[DllImport("user32.dll")]
private static extern void SwitchToThisWindow(IntPtr hWnd, bool fAltTab);
public const String EMPTY_VIDEO = "SciLorsEmptyVideo.mpg";
public const String BASE_VIDEO_DIR = @"TOASTART\PC\MOVIES\";
public static String[] VIDEO_NAMES = {
"empire.mpg",
"intro.mpg",
"renderware.mpg",
"small.mpg",
"supersonic.mpg"
};
public const String SAVE = ""; //@"save\";
public static IconFile[] ICOS = {
new IconFile(@"TOASTART\Common\PANEL\NFLRed.png"),
new IconFile(@"TOASTART\Common\PANEL\NFLBluejay.png"),
new IconFile(@"TOASTART\Common\PANEL\NFLGold.png"),
new IconFile(@"TOASTART\Common\PANEL\NFLMelon.png"),
new IconFile(@"TOASTART\Common\PANEL\NFLPink.png"),
new IconFile(@"TOASTART\Common\PANEL\NFLShadow.png"),
};
public const String ICO = @"TOASTART\Common\PANEL\NFLRed.png";
public const String ICO_SMALL = "mashed.ICO";
public static void Run(bool video, bool control, bool exit, frmMashed form) { //-VS0 -CS0 -L1
if (!checkExe()) return;
form.Enabled = false;
//form.WindowState = FormWindowState.Minimized;
int lang = 0;
if (form.cmbLanguage.SelectedItem != null) {
Language langObj = (Language)form.cmbLanguage.SelectedItem;
lang = langObj.Id;
}
Process p = new Process();
p.StartInfo.FileName = Properties.Settings.Default.Path + version.EXE();
p.StartInfo.Arguments = "-VS" + bool2int(video) + " " + "-CS" + bool2int(control) + " " + "-L" + lang;
p.StartInfo.WorkingDirectory = Properties.Settings.Default.Path + Mashed.SAVE;
p.Start();
if (exit) {
form.Close();
Application.Exit();
} else {
p.WaitForExit();
form.Enabled = true;
form.Refresh();
if (form.WindowState != FormWindowState.Minimized)
form.WindowState = FormWindowState.Minimized;
//form.WindowState = FormWindowState.Normal;
SwitchToThisWindow(form.Handle, true);
form.Show();
}
}
private static int bool2int(bool value) {
if (value) return 1;
return 0;
}
private static RegistryKey getRegistryBase(String subkey) {
RegistryKey baseKey = Registry.LocalMachine.OpenSubKey("Software", true);
return baseKey.CreateSubKey(version.REGISTRY_BASE()).CreateSubKey(subkey);
}
private static bool setRegistryInstallation(String path, RegistryKey key) {
try {
key.DeleteValue("installpath", false);
key.SetValue("installpath", path, RegistryValueKind.String);
key.DeleteValue("installstatus", false);
key.SetValue("installstatus", "2", RegistryValueKind.String);
key.Close();
return true;
} catch (SecurityException) {}
return false;
}
public static bool setRegistryInstallation(String path) {
bool fine = false;
fine = setRegistryInstallation(path, getRegistryBase(version.REGISTRY_SUBKEY()));
return fine;
}
public static bool setRegistryLanguage(Language lang, RegistryKey key) {
try {
key.SetValue("language", lang.Identifier, RegistryValueKind.String);
key.Close();
} catch (SecurityException) { }
return false;
}
public static bool setRegistryLanguage(Language lang) {
bool fine = false;
fine = setRegistryLanguage(lang, getRegistryBase(version.REGISTRY_SUBKEY()));
return fine;
}
public static bool checkExe() {
if (!System.IO.File.Exists(Util.GetMashedDir() + version.EXE())) {
MessageBox.Show(version.EXE() + " " + "not found" + "\r\n" +
"Please copy this application into the " + version.NAME() + " directory" + "\r\n" +
"or select the right path to its executable.",
"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
return true;
}
}
}