public override bool Execute() { if (_openFileDialog.ShowDialog() == DialogResult.OK) { var form = new CaptureForm(_appState, _colorForm, _commsPort) { MdiParent = _mainForm }; form.Show(); form.LoadFile(_openFileDialog.FileName); return(true); } return(false); }
public void SendKeysGrouping() { // Regression https://github.com/dotnet/winforms/issues/6666 using var form = new CaptureForm(); form.Show(); form.Focus(); SendKeys.SendWait("^(a)^(c)"); Assert.Equal(4, form.KeyEvents.Count); Assert.Equal(Keys.ControlKey, form.KeyEvents[0].KeyCode); Assert.Equal(Keys.A, form.KeyEvents[1].KeyCode); Assert.Equal(Keys.Control, form.KeyEvents[1].Modifiers); Assert.Equal(Keys.ControlKey, form.KeyEvents[2].KeyCode); Assert.Equal(Keys.C, form.KeyEvents[3].KeyCode); Assert.Equal(Keys.Control, form.KeyEvents[3].Modifiers); }
//启动截图 public void StartCapture(bool fromClip) { CaptureForm capture = new CaptureForm(); capture.Finishing += Capture_Finish; try { if (!CaptureForm.isAlive) { capture.IsCaptureCursor = false; capture.IsFromClipBoard = fromClip; capture.Show(); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }
private void findGameScreenToolStripMenuItem_Click(object sender, EventArgs e) { if (gameEngine != null) KillGameEngine(); foreach (Screen screen in Screen.AllScreens) { #if DEBUG if (screen.Primary) // DEBUG continue; #endif CaptureForm cf = new CaptureForm(); cf.StartPosition = FormStartPosition.Manual; cf.Bounds = screen.Bounds; cf.WindowState = FormWindowState.Maximized; cf.FormClosed += new FormClosedEventHandler(CaptureForm_Closed); cf.Show(); captureForms.Add(cf); } }
public void Run() { using (CaptureForm form = new CaptureForm()) { const int Fps = 60; const double Wait = 1000.0 / Fps; const int CaptureTimeSec = 30; double endCount = System.Environment.TickCount + CaptureTimeSec * 1000; double nextFrame = System.Environment.TickCount + Wait; form.Show(); form.BeginCapture(); while (form.Created) { try { int now = System.Environment.TickCount; if (now >= nextFrame) { if (now < nextFrame + Wait) { // 更新タイミングなら更新 form.MyUpdate(); form.Render(); } nextFrame += Wait; } int sleepTime = (int)(nextFrame - now); if (sleepTime > 0) Thread.Sleep(sleepTime); Application.DoEvents(); } catch (Exception e) { MessageBox.Show(e.Message); } } } }
private void systemHotkey2_Pressed(object sender, EventArgs e) { bool visible = this.Visible; if(visible) this.Hide(); CaptureForm frm = new CaptureForm(this, visible, clipboardSender, notifyIcon); frm.Show(); frm.Focus(); }