public int Launch() { if (mCore == null || !mCore.Initialised) { return(0); } if (mConfig.GUI) { if (mConfig.BasicGUI) { ProcessWrangler.BlockingRunForm(BasicForm, Coordinator); } else { ProcessWrangler.BlockingRunForm(Form, Coordinator); } } else { //Thread t = new Thread(() => { while (!Console.ReadLine().ToUpper().StartsWith("Q")) { ; } mCore.Close(); //}); //t.Name = "Input Thread"; //t.Start(); } return(mCore != null ? mCore.ExitCode : 0); }
private void ScreenshotProcessor() { while (mRunning || mScreenshots.Count > 0) { if (mScreenshots.Count > 0) { ImageToSave toSave = mScreenshots.Dequeue(); Bitmap screenshot = toSave.Image; using (Bitmap resized = new Bitmap(screenshot, new Size(screenshot.Height, screenshot.Height))) { int image = toSave.ImageNumber; Rotation rot = GetRotation(image); string name = GetImageName(image); string folder = GetSaveFolder(toSave.Name); string imageFile = Path.Combine(folder, name); string ptoFile = GetPTOFile(folder, toSave.Name); Logger.Info("Writing Photosphere image to: " + imageFile + "."); resized.Save(imageFile); if ((image / 3) == 0) { StartPTOFile(ptoFile); } File.AppendAllLines(ptoFile, new string[] { "#-hugin cropFactor=1", string.Format("i w{0} h{0} f0 v{1} Ra0 Rb0 Rc0 Rd0 Re0 Eev0 Er1 Eb1 r0 p{2} y{3} TrX0 TrY0 TrZ0 Tpy0 Tpp0 j0 a0 b0 c0 d0 e0 g0 t0 Va1 Vb0 Vc0 Vd0 Vx0 Vy0 Vm5 n\"{4}\"", resized.Height, mFoV, rot.Pitch * -1.0, rot.Yaw * -1.0, name) }); if ((image / 3) == TotalImages - 1) { FinishPTOFile(ptoFile); if (mConfig.PhotosphereAddBatch) { Logger.Info("Adding " + toSave.Name + " as batch processing job" + (mConfig.PhotosphereAutoStartBatch ? " and starting batcher" : "") + "."); string args = String.Format("{0} {1}.pto {1}.jpg", (mConfig.PhotosphereAutoStartBatch ? " --batch" : ""), toSave.Name); Logger.Debug(mConfig.PhotosphereAutoStartBatch + args); ProcessWrangler.InitProcess(mConfig.PhotosphereBatcherExe, folder, args).Start(); } } } screenshot.Dispose(); } Thread.Sleep(5); } mRunning = false; if (mConfig.AutoShutdown) { mForm.Close(); } }
private void mPlugin_MouseMoved(int x, int y) { if (Created && !IsDisposed && !Disposing) { Invoke(new Action(() => { positionLabel.Text = string.Format("{0,-4},{1,-4}", x, y); cursorHandleLabel.Text = ProcessWrangler.GetGlobalCursor().ToString(); })); } }
private void DrawCursor(Cursor cursor) { if (mOverlayManager == null) { ProcessWrangler.SetGlobalCursor(cursor); } else { mOverlayManager.Cursor = cursor; } }
private void ResetCursor() { if (mOverlayManager == null) { ProcessWrangler.SetGlobalCursor(mCompletedCursor); } else { mOverlayManager.ResetCursor(); } }
static void sServerProcess_Exited(object sender, EventArgs e) { if (mShutdown) { return; } Process server = ProcessWrangler.InitProcess(sServerExe); server.Exited += sServerProcess_Exited; server.Start(); }
static void sProxyProcess_Exited(object sender, EventArgs e) { if (mShutdown) { return; } Process proxy = ProcessWrangler.InitProcess(sProxyExe); proxy.Exited += sProxyProcess_Exited; proxy.Start(); }
static void Main(string[] args) { LauncherConfig cfg = new LauncherConfig(); if (cfg.LaunchServer) { sServerExe = cfg.ServerExe; sServerProcess = ProcessWrangler.InitProcess(sServerExe); //if (cfg.AutoRestart) //sServerProcess.Exited += sServerProcess_Exited; sServerProcess.Start(); Console.WriteLine("Server started."); Thread.Sleep(35 * 1000); } //sProxyExe = typeof(ChimeraLauncher).Assembly.Location; sProxyExe = cfg.ProxyExe; sProxyProcess = ProcessWrangler.InitProcess(sProxyExe); //if (cfg.AutoRestart) //sProxyProcess.Exited += sProxyProcess_Exited; sProxyProcess.Start(); Console.WriteLine("Chimera started."); Thread input = new Thread(() => { Console.WriteLine("Type Exit to quit."); string line = Console.ReadLine(); while (!line.ToUpper().Equals("EXIT")) { line = Console.ReadLine(); if (line.ToUpper().Equals("CLOSE PROXY")) { ProcessWrangler.PressKey(sProxyProcess, "{F4}", false, true, false); } } mShutdown = true; ProcessWrangler.PressKey(sProxyProcess, "{F4}", false, true, false); if (sServerProcess != null) { ProcessWrangler.PressKey(sServerProcess, "q{ENTER}"); } }); input.Name = "Launcher input thread."; //input.Start(); }
private void Init(Size size, Action <Graphics, Rectangle, double> drawStep) { if (!GlobalCursorIsHover()) { mCompletedCursor = new Cursor(ProcessWrangler.GetGlobalCursor()); } for (double i = 0.0; i < sSteps; i++) { //TODO - using means the bmp is disposed which could cause issues. using (Bitmap b = new Bitmap(size.Width, size.Height)) { using (Graphics g = Graphics.FromImage(b)) { drawStep(g, new Rectangle(new Point(0, 0), size), i / sSteps); } Cursor c = CreateCursor(b, size.Width / 2, size.Height / 2); sCursors.Add(c.Handle); mCursors[(int)i] = c; } } }
/// <summary> /// Handle a crash event, /// </summary> public void OnCrash(Exception e) { string dump = "Crash: " + DateTime.UtcNow.ToString("u") + Environment.NewLine; dump += "Uptime: " + DateTime.UtcNow.Subtract(mStart) + Environment.NewLine; dump += String.Format("{1}{0}{2}{0}{0}", Environment.NewLine, e.Message, e.StackTrace); dump += String.Format("-----------Core-----------{0}", Environment.NewLine); dump += "Virtual Position: " + mPosition + Environment.NewLine; dump += "Virtual Orientation | Yaw: " + mOrientation.Yaw + ", Pitch: " + mOrientation.Pitch + Environment.NewLine; dump += "Eye Position: " + mEyePosition + Environment.NewLine; /* * if (mActiveState != null) { * dump += Environment.NewLine + "--------------" + mActiveState.Type + " Active-------------------" + Environment.NewLine; * dump += "Instance: " + mActiveState.Name + Environment.NewLine; * try { * dump += mActiveState.State; * } catch (Exception ex) { * dump += "Unable to get stats for the active menu item. " + ex.Message + Environment.NewLine; * dump += ex.StackTrace; * } * } */ if (mFrames.Count > 0) { dump += String.Format("{0}{0}--------Frames--------{0}", Environment.NewLine); foreach (var window in Frames) { try { dump += Environment.NewLine + window.State; } catch (Exception ex) { dump += "Unable to get stats for window " + window.Name + ". " + ex.Message + Environment.NewLine; dump += ex.StackTrace; } } dump += Environment.NewLine; } if (mPlugins.Count > 0) { dump += String.Format("{0}{0}--------Plugins--------{0}", Environment.NewLine); foreach (var plugin in mPlugins) { if (plugin.Enabled) { try { dump += Environment.NewLine + plugin.State; } catch (Exception ex) { dump += "Unable to get stats for plugin " + plugin.Name + ". " + ex.Message + Environment.NewLine; dump += ex.StackTrace; } } else { dump += Environment.NewLine + "--------" + plugin.Name + "--------" + Environment.NewLine + "Disabled"; } } dump += Environment.NewLine; } dump += String.Format("{0}{0}------------------------End of Crash Report------------------------{0}{0}", Environment.NewLine); ProcessWrangler.Dump(dump, "-Crash.log"); Close("-Crash"); }
public void TakePhotosphere() { Rotation r = mCore.Orientation; /* * for (int i = 1; i < 7; i++) { * mCore.Update(mCore.Position, Vector3.Zero, GetRotation(i), Rotation.Zero); * Thread.Sleep(500); * } */ mOriginalRotation = mCore.Orientation; mOriginalWidth = mFrame.Width; mOriginalHeight = mFrame.Height; mFrame.LinkFoVs = false; mFrame.HFieldOfView = (Math.PI / 180) * mFoV; mFrame.VFieldOfView = mFrame.HFieldOfView; if (mFrame.Output.Process != null) { ProcessWrangler.BringToFront(mFrame.Output.Process); } string saveFolder = GetSaveFolder(PhotosphereName); string ptoFile = GetPTOFile(saveFolder, PhotosphereName); if (File.Exists(ptoFile)) { File.Delete(ptoFile); } if (!Directory.Exists(saveFolder)) { Directory.CreateDirectory(saveFolder); } if (!mRunning) { mRunning = true; Thread t = new Thread(ScreenshotProcessor); t.Name = "Photosphere Image Processor"; t.Start(); } mCentre = mCore.Position; mCurrentImage = 0; for (int image = 0; mCurrentImage != 0 || image == 0; image++) { ShowNextImage(); Thread.Sleep(mConfig.PhotosphereCaptureDelayMS); TakeScreenshot(); } mCore.Update(mCore.Position, Vector3.Zero, mOriginalRotation, Rotation.Zero); mFrame.Width = mOriginalWidth; mFrame.Height = mOriginalHeight; mFrame.LinkFoVs = true; //mRunning = false; mCore.Update(mCore.Position, Vector3.Zero, r, mOriginalRotation); }
public static bool GlobalCursorIsHover() { return(sCursors.Contains(ProcessWrangler.GetGlobalCursor())); }
internal void Dump(string reason) { ProcessWrangler.Dump(Statistics, reason + ".html"); }
public void TriggerListener(ITrigger source) { ProcessWrangler.Click(mLeft); }