private void CaptureAreaToolStripMenuItemClick(object sender, EventArgs e) { BeginInvoke((MethodInvoker) delegate { CaptureHelper.CaptureRegion(false); }); }
/// <summary> /// Registers all hotkeys as configured, displaying a dialog in case of hotkey conflicts with other tools. /// </summary> /// <param name="ignoreFailedRegistration"> /// if true, a failed hotkey registration will not be reported to the user - the /// hotkey will simply not be registered /// </param> /// <returns> /// Whether the hotkeys could be registered to the users content. This also applies if conflicts arise and the /// user decides to ignore these (i.e. not to register the conflicting hotkey). /// </returns> public bool RegisterHotkeys(bool ignoreFailedRegistration) { var success = true; var failedKeys = new StringBuilder(); if (!RegisterWrapper(failedKeys, "CaptureRegion", "RegionHotkey", () => { CaptureHelper.CaptureRegion(true); }, ignoreFailedRegistration)) { success = false; } if (!RegisterWrapper(failedKeys, "CaptureWindow", "WindowHotkey", () => { if (_coreConfiguration.CaptureWindowsInteractive) { CaptureHelper.CaptureWindowInteractive(true); } else { CaptureHelper.CaptureWindow(true); } }, ignoreFailedRegistration)) { success = false; } if (!RegisterWrapper(failedKeys, "CaptureFullScreen", "FullscreenHotkey", () => CaptureHelper.CaptureFullscreen(true, _coreConfiguration.ScreenCaptureMode), ignoreFailedRegistration)) { success = false; } if (!RegisterWrapper(failedKeys, "CaptureLastRegion", "LastregionHotkey", () => CaptureHelper.CaptureLastRegion(true), ignoreFailedRegistration)) { success = false; } if (_coreConfiguration.IECapture) { if (!RegisterWrapper(failedKeys, "CaptureIE", "IEHotkey", () => { if (_coreConfiguration.IECapture) { CaptureHelper.CaptureIe(true, null); } }, ignoreFailedRegistration)) { success = false; } } if (!success && !ignoreFailedRegistration) { success = HandleFailedHotkeyRegistration(failedKeys.ToString()); } return(success || ignoreFailedRegistration); }
/// <summary> /// MultiScreenDropDownOpening is called when mouse hovers over the Capture-Screen context menu /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void MultiScreenDropDownOpening(object sender, EventArgs e) { ToolStripMenuItem captureScreenMenuItem = (ToolStripMenuItem)sender; captureScreenMenuItem.DropDownItems.Clear(); if (Screen.AllScreens.Length > 1) { ToolStripMenuItem captureScreenItem; string allDeviceName = ""; foreach (Screen screen in Screen.AllScreens) { string deviceName = screen.DeviceName; if (allDeviceName.Length > 0) { allDeviceName += " + "; } allDeviceName += deviceName.Substring(deviceName.Length - 1); } captureScreenItem = new ToolStripMenuItem(allDeviceName); captureScreenItem.Click += delegate { BeginInvoke((MethodInvoker) delegate { CaptureHelper.CaptureFullscreen(false, ScreenCaptureMode.FullScreen); }); }; captureScreenMenuItem.DropDownItems.Add(captureScreenItem); foreach (Screen screen in Screen.AllScreens) { Screen screenToCapture = screen; string deviceName = screenToCapture.DeviceName; deviceName = deviceName.Substring(deviceName.Length - 1); captureScreenItem = new ToolStripMenuItem(deviceName); captureScreenItem.Click += delegate { BeginInvoke((MethodInvoker) delegate { CaptureHelper.CaptureRegion(false, screenToCapture.Bounds); }); }; captureScreenMenuItem.DropDownItems.Add(captureScreenItem); } } }
/// <inheritdoc /> public void Capture(string parameters) { if (MainForm.Instance.InvokeRequired) { MainForm.Instance.Invoke((MethodInvoker)(() => Capture(parameters))); return; } Log.Info().WriteLine("Capture requested: {0}", parameters); string[] optionsArray = parameters.Split(','); string captureMode = optionsArray[0]; // Fallback-Destination var designation = _coreConfiguration.OutputDestinations.FirstOrDefault(); var destination = _destinationHolder.SortedActiveDestinations.FirstOrDefault(d => d.Designation == designation); switch (captureMode.ToLower()) { case "region": CaptureHelper.CaptureRegion(false, destination); break; case "window": CaptureHelper.CaptureWindow(false, destination); break; case "fullscreen": CaptureHelper.CaptureFullscreen(false, ScreenCaptureMode.FullScreen, destination); break; default: Log.Warn().WriteLine("Unknown capture option"); break; } }
/// <summary> /// MultiScreenDropDownOpening is called when mouse hovers over the Capture-Screen context menu /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void MultiScreenDropDownOpening(object sender, EventArgs e) { var captureScreenMenuItem = (ToolStripMenuItem)sender; captureScreenMenuItem.DropDownItems.Clear(); if (Screen.AllScreens.Length <= 1) { return; } var allScreensBounds = WindowCapture.GetScreenBounds(); var captureScreenItem = new ToolStripMenuItem(_greenshotLanguage.ContextmenuCapturefullscreenAll); captureScreenItem.Click += (o, args) => BeginInvoke((MethodInvoker)(() => CaptureHelper.CaptureFullscreen(false, ScreenCaptureMode.FullScreen))); captureScreenMenuItem.DropDownItems.Add(captureScreenItem); foreach (var screen in Screen.AllScreens) { var screenToCapture = screen; var deviceAlignment = ""; if (screen.Bounds.Top == allScreensBounds.Top && screen.Bounds.Bottom != allScreensBounds.Bottom) { deviceAlignment += " " + _greenshotLanguage.ContextmenuCapturefullscreenTop; } else if (screen.Bounds.Top != allScreensBounds.Top && screen.Bounds.Bottom == allScreensBounds.Bottom) { deviceAlignment += " " + _greenshotLanguage.ContextmenuCapturefullscreenBottom; } if (screen.Bounds.Left == allScreensBounds.Left && screen.Bounds.Right != allScreensBounds.Right) { deviceAlignment += " " + _greenshotLanguage.ContextmenuCapturefullscreenLeft; } else if (screen.Bounds.Left != allScreensBounds.Left && screen.Bounds.Right == allScreensBounds.Right) { deviceAlignment += " " + _greenshotLanguage.ContextmenuCapturefullscreenRight; } captureScreenItem = new ToolStripMenuItem(deviceAlignment); captureScreenItem.Click += (o, args) => BeginInvoke((MethodInvoker)(() => CaptureHelper.CaptureRegion(false, screenToCapture.Bounds))); captureScreenMenuItem.DropDownItems.Add(captureScreenItem); } }
private void CaptureRegion() { CaptureHelper.CaptureRegion(true); }