/// <summary> /// starts the optional exe /// </summary> public virtual void StartMenu(StartModes StartMode = StartModes.Normal) { ShouldBeRunning = true; List <Process> GameProcessesTokill = Process.GetProcesses().Where(pr => pr.ProcessName == Path.GetFileName(ThePath).Replace(".exe", "")).ToList(); foreach (Process process in GameProcessesTokill) { try { process.Kill(); } catch { } } if (StartMode == StartModes.Normal) { MenuGameExe.StartInfo.Arguments = ""; } else { MenuGameExe.StartInfo.Arguments = "-disabled"; } MenuGameExe.Start(); ClientPipe = new JSONRequestClientPipe("GameSelectorService"); }
public static Domino LoadFrom(SavedGame.SavedDomino sd) { StartModes startMode = sd.startMode == StartModes.Forward.ToString() ? StartModes.Forward : (sd.startMode == StartModes.Backward.ToString() ? StartModes.Backward : StartModes.NoStart); return(new Domino(sd.position, sd.rotationY, Space.Self, sd.color, startMode)); }
public void SetStartMode(StartModes mode) { switch (mode) { case StartModes.Windowed: SetWindowed(); break; default: case StartModes.Fullscreen: SetFullscreen(); break; } }
private Domino(Vector3 pos, float rot, Space relativeTo, Color32 color, StartModes startMode) { if (relativeTo == Space.Self) { localPosition = pos; localRotationY = rot; } else { position = pos; rotationY = rot; } this.color = color; this.startMode = startMode; }
/// <summary> /// What happens when the window loads up /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void MainWindow_Load(object sender, EventArgs e) { //maximises the form WindowState = FormWindowState.Maximized; //sets the interactive mode to explode Mode = InteractiveModes.Explode; //updates the mode text mode_lbl.Text = "Mode: " + Mode.ToString(); //sets the starting mode to default StartMode = StartModes.default_; //starts the program Restart(); }
public void ToggleStart() { Analytics.CustomEvent("toggleStart"); switch (startMode) { case StartModes.NoStart: startMode = StartModes.Forward; break; case StartModes.Forward: startMode = StartModes.Backward; break; case StartModes.Backward: startMode = StartModes.NoStart; break; } RefreshStartArrow(); }
public static void Main(string[] args) { App.args = args; HasConsole = WinConsole.Initialize(TestArg("-console")); if (TestArg("-dbg_wait")) { MessageBox.Show("Waiting for debugger. (press ok when attached)"); } if (TestArg("-dbg_log")) { AppDomain.CurrentDomain.FirstChanceException += FirstChanceExceptionHandler; } StartModes startMode = StartModes.Normal; // Normal GUI Mode if (TestArg("-svc")) { startMode = StartModes.Service; } else if (TestArg("-engine")) { startMode = StartModes.Engine; } Log = new AppLog(Key); AppLog.ExceptionLogID = (long)EventIDs.Exception; AppLog.ExceptionCategory = (short)EventFlags.DebugEvents; if (startMode == StartModes.Normal) { Log.EnableLogging(); Log.LoadLog(); } // When running as worker we need the windows event log else if (!Log.UsingEventLog()) { Log.SetupEventLog(Key); } // load current version exePath = Process.GetCurrentProcess().MainModule.FileName; //System.Reflection.Assembly.GetExecutingAssembly().Location; FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(exePath); Version = fvi.FileMajorPart + "." + fvi.FileMinorPart; if (fvi.FileBuildPart != 0) { Version += "." + fvi.FileBuildPart; } if (fvi.FilePrivatePart != 0) { Version += (char)('a' + (fvi.FilePrivatePart - 1)); } appPath = Path.GetDirectoryName(exePath); Translate.Load(); dataPath = appPath + @"\Data"; if (File.Exists(GetINIPath())) // if an ini exists in the app path, its considdered to be a portable run { isPortable = true; AppLog.Debug("Portable Mode"); } else { string progData = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData); if (progData == null) { progData = @"C:\ProgramData"; } dataPath = progData + "\\" + Key; } AppLog.Debug("Config Directory: {0}", dataPath); // execute commandline commands if (ExecuteCommands()) { return; } if (!Directory.Exists(dataPath)) { Directory.CreateDirectory(dataPath); } if (AdminFunc.IsAdministrator()) { FileOps.SetAnyDirSec(dataPath); } App.LogInfo("PrivateWin10 Process Started, Mode {0}.", startMode.ToString()); Session = Process.GetCurrentProcess().SessionId; // setup custom assembly resolution for x86/x64 synamic compatybility AppDomain.CurrentDomain.AssemblyResolve += AssemblyResolveHandler; // is the process starting as a service/worker? if (startMode != StartModes.Normal) { engine = new Priv10Engine(); if (startMode == StartModes.Service) { using (Priv10Service svc = new Priv10Service()) ServiceBase.Run(svc); } else { engine.Run(); } return; } Thread.CurrentThread.Name = "Gui"; client = new Priv10Client(); // Encure wie have the required privilegs //if (!AdminFunc.IsDebugging()) { AppLog.Debug("Trying to connect to Engine..."); int conRes = client.Connect(1000); if (conRes == 0) { if (!AdminFunc.IsAdministrator()) { AppLog.Debug("Trying to obtain Administrative proivilegs..."); if (AdminFunc.SkipUacRun(App.Key, App.args)) { return; } AppLog.Debug("Trying to start with 'runas'..."); // Restart program and run as admin string arguments = "\"" + string.Join("\" \"", args) + "\""; ProcessStartInfo startInfo = new ProcessStartInfo(exePath, arguments); startInfo.UseShellExecute = true; startInfo.Verb = "runas"; try { Process.Start(startInfo); return; // we restarted as admin } catch { //MessageBox.Show(Translate.fmt("msg_admin_rights", mName), mName); //return; // no point in cintinuing without admin rights or an already running engine } } else if (Priv10Service.IsInstalled()) { AppLog.Debug("Trying to start service..."); if (Priv10Service.Startup()) { AppLog.Debug("Trying to connect to service..."); if (client.Connect() != 0) { AppLog.Debug("Connected to service..."); } else { AppLog.Debug("Failed to connect to service..."); } } else { AppLog.Debug("Failed to start service..."); } } } else if (conRes == -1) { MessageBox.Show(Translate.fmt("msg_dupliate_session", Title), Title); return; // no point in cintinuing without admin rights or an already running engine } } // tweaks = new TweakManager(); // if we couldn't connect to the engine start it and connect if (!client.IsConnected() && AdminFunc.IsAdministrator()) { AppLog.Debug("Starting Engine Thread..."); engine = new Priv10Engine(); engine.Start(); AppLog.Debug("... engine started."); client.Connect(); } var app = new App(); app.InitializeComponent(); InitLicense(); MainWnd = new MainWindow(); TrayIcon = new TrayIcon(); TrayIcon.Action += TrayAction; TrayIcon.Visible = (GetConfigInt("Startup", "Tray", 0) != 0) || App.TestArg("-autorun"); if (!App.TestArg("-autorun") || !TrayIcon.Visible) { MainWnd.Show(); } app.Run(); TrayIcon.DestroyNotifyicon(); client.Close(); tweaks.Store(); if (engine != null) { engine.Stop(); } }
public static void Main(string[] args) { App.args = args; HasConsole = WinConsole.Initialize(TestArg("-console")); if (TestArg("-dbg_wait")) { MessageBox.Show("Waiting for debugger. (press ok when attached)"); } if (TestArg("-dbg_log")) { AppDomain.CurrentDomain.FirstChanceException += FirstChanceExceptionHandler; } StartModes startMode = StartModes.Normal; // Normal GUI Mode if (TestArg("-svc")) { startMode = StartModes.Service; } else if (TestArg("-engine")) { startMode = StartModes.Engine; } Log = new AppLog(Key); AppLog.ExceptionLogID = (long)Priv10Logger.EventIDs.Exception; AppLog.ExceptionCategory = (short)Priv10Logger.EventFlags.DebugEvents; // When running as worker we need the windows event log if (!Log.UsingEventLog()) { Log.SetupEventLog(Key); } // load current version exePath = Process.GetCurrentProcess().MainModule.FileName; //System.Reflection.Assembly.GetExecutingAssembly().Location; //*FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(exePath); //Version = fvi.FileMajorPart + "." + fvi.FileMinorPart; //if (fvi.FileBuildPart != 0) // Version += "." + fvi.FileBuildPart; //if (fvi.FilePrivatePart != 0) // Version += (char)('a' + (fvi.FilePrivatePart - 1)); appPath = Path.GetDirectoryName(exePath); dataPath = appPath + @"\Data"; if (File.Exists(GetINIPath())) // if an ini exists in the app path, its considdered to be a portable run { isPortable = true; AppLog.Debug("Portable Mode"); } else { string progData = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData); if (progData == null) { progData = @"C:\ProgramData"; } dataPath = progData + "\\" + Key; } AppLog.Debug("Config Directory: {0}", dataPath); if (!Directory.Exists(dataPath)) { Directory.CreateDirectory(dataPath); } if (AdminFunc.IsAdministrator()) { FileOps.SetAnyDirSec(dataPath); } Priv10Logger.LogInfo("PrivateWin10 Service Process Started, Mode {0}.", startMode.ToString()); // setup custom assembly resolution for x86/x64 synamic compatybility AppDomain.CurrentDomain.AssemblyResolve += AssemblyResolveHandler; // is the process starting as a service/worker? if (startMode != StartModes.Normal) { engine = new Priv10Engine(); if (startMode == StartModes.Service) { using (Priv10Service svc = new Priv10Service()) ServiceBase.Run(svc); } else { engine.Run(); } return; } }