private void UpdateScreenshot() { #if WINDOWS || MONOMAC bool f12Pressed = false; KeyboardState keyState = Keyboard.GetState(); f12Pressed = keyState.IsKeyDown(Keys.F12); if (f12Pressed && !F12Pressed) { string path = System.IO.Path.GetDirectoryName(Global.GAME_ASSEMBLY.Location); path = Path.Combine(path, "Screenshots"); try { if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } string filename = System.IO.Path.GetFileNameWithoutExtension(Global.GAME_ASSEMBLY.Location) + "_"; int i = 0; while (File.Exists(Path.Combine( path, filename + i.ToString("D4") + ".png"))) { i++; } // save render target to disk using (FileStream fs = new FileStream(Path.Combine( path, filename + i.ToString("D4") + ".png"), FileMode.OpenOrCreate)) { Renderer.SaveScreenshot(fs); } } // Could not save screenshot because no folder permissions catch (UnauthorizedAccessException e) { Global.play_se(System_Sounds.Buzzer); return; } } F12Pressed = f12Pressed; #endif }