public RegionCaptureForm(RegionCaptureMode mode) { Mode = mode; ScreenRectangle = CaptureHelpers.GetScreenBounds(); ScreenRectangle0Based = CaptureHelpers.ScreenToClient(ScreenRectangle); ImageRectangle = ScreenRectangle0Based; InitializeComponent(); Config = new RegionCaptureOptions(); DrawableObjects = new List <DrawableObject>(); timerStart = new Stopwatch(); timerFPS = new Stopwatch(); colorBlinkAnimation = new ColorBlinkAnimation(); borderPen = new Pen(Color.Black); borderDotPen = new Pen(Color.White) { DashPattern = new float[] { 5, 5 } }; nodeBackgroundBrush = new SolidBrush(Color.White); infoFont = new Font("Verdana", 9); infoFontMedium = new Font("Verdana", 12); infoFontBig = new Font("Verdana", 16, FontStyle.Bold); textBackgroundBrush = new SolidBrush(Color.FromArgb(150, Color.FromArgb(42, 131, 199))); textOuterBorderPen = new Pen(Color.FromArgb(150, Color.White)); textInnerBorderPen = new Pen(Color.FromArgb(150, Color.FromArgb(0, 81, 145))); markerPen = new Pen(Color.FromArgb(200, Color.Red)); }
public static void RegionCapture(RegionCaptureMode mode, bool creatClip = false) { using (RegionCaptureForm regionCapture = new RegionCaptureForm(ScreenHelper.GetScreenBounds(), mode)) { regionCapture.ShowDialog(); LastRegionResult?.Dispose(); LastRegionResult = regionCapture.GetRsult(); if (LastRegionResult.Result == RegionResult.Close) { return; } if (LastRegionResult.Result == RegionResult.Color) { if (SettingsManager.RegionCaptureSettings.Auto_Copy_Color) { ClipboardHelper.FormatCopyColor(SettingsManager.MiscSettings.Default_Color_Format, LastRegionResult.Color); } return; } if (SettingsManager.RegionCaptureSettings.Auto_Copy_Image) { ClipboardHelper.CopyImage(LastRegionResult.Image); } string path = string.Empty; if (InternalSettings.Save_Images_To_Disk) { path = PathHelper.GetNewImageFileName(); } if (creatClip) { ClipOptions ops = new ClipOptions(ScreenHelper.GetRectangle0Based(LastRegionResult.Region).Location); ops.FilePath = path; ClipManager.CreateClip(LastRegionResult.Image, ops); } if (InternalSettings.Save_Images_To_Disk) { Save(path, LastRegionResult.Image); } if (LastRegionResult.Image != null) { LastRegionResult.Image.Dispose(); } } }
public static Image AnnotateImage(Image img, string filePath, RegionCaptureOptions options, Action <Image, string> saveImageRequested, Action <Image, string> saveImageAsRequested, Action <Image> copyImageRequested, Action <Image> uploadImageRequested, Action <Image> printImageRequested, bool taskMode = false) { RegionCaptureMode mode = taskMode ? RegionCaptureMode.TaskEditor : RegionCaptureMode.Editor; using (RegionCaptureForm form = new RegionCaptureForm(mode, options)) { form.ImageFilePath = filePath; form.Prepare(img); form.ShowDialog(); switch (form.Result) { case RegionResult.Close: // Esc case RegionResult.AnnotateCancelTask: return(null); case RegionResult.Region: // Enter case RegionResult.AnnotateRunAfterCaptureTasks: return(form.GetResultImage()); case RegionResult.Fullscreen: // Space or right click case RegionResult.AnnotateContinueTask: return((Image)form.Image.Clone()); case RegionResult.AnnotateSaveImage: using (Image resultSaveImage = form.GetResultImage()) { saveImageRequested(resultSaveImage, form.ImageFilePath); } break; case RegionResult.AnnotateSaveImageAs: using (Image resultSaveImageAs = form.GetResultImage()) { saveImageAsRequested(resultSaveImageAs, form.ImageFilePath); } break; case RegionResult.AnnotateCopyImage: using (Image resultCopyImage = form.GetResultImage()) { copyImageRequested(resultCopyImage); } break; case RegionResult.AnnotateUploadImage: Image resultUploadImage = form.GetResultImage(); uploadImageRequested(resultUploadImage); break; case RegionResult.AnnotatePrintImage: using (Image resultPrintImage = form.GetResultImage()) { printImageRequested(resultPrintImage); } break; } } return(null); }
public RegionCaptureForm(RegionCaptureMode mode) { Mode = mode; ScreenRectangle = CaptureHelpers.GetScreenBounds(); ScreenRectangle0Based = CaptureHelpers.ScreenToClient(ScreenRectangle); ImageRectangle = ScreenRectangle0Based; InitializeComponent(); Config = new RegionCaptureOptions(); DrawableObjects = new List<DrawableObject>(); timerStart = new Stopwatch(); timerFPS = new Stopwatch(); colorBlinkAnimation = new ColorBlinkAnimation(); borderPen = new Pen(Color.Black); borderDotPen = new Pen(Color.White) { DashPattern = new float[] { 5, 5 } }; nodeBackgroundBrush = new SolidBrush(Color.White); infoFont = new Font("Verdana", 9); infoFontMedium = new Font("Verdana", 12); infoFontBig = new Font("Verdana", 16, FontStyle.Bold); textBackgroundBrush = new SolidBrush(Color.FromArgb(75, Color.Black)); textBackgroundPenWhite = new Pen(Color.FromArgb(50, Color.White)); textBackgroundPenBlack = new Pen(Color.FromArgb(150, Color.Black)); markerPen = new Pen(Color.FromArgb(200, Color.Red)); }
public static Bitmap AnnotateImage(Bitmap bmp, string filePath, TaskSettings taskSettings, bool taskMode = false) { if (bmp != null) { using (bmp) { RegionCaptureMode mode = taskMode ? RegionCaptureMode.TaskEditor : RegionCaptureMode.Editor; RegionCaptureOptions options = taskSettings.CaptureSettingsReference.SurfaceOptions; using (RegionCaptureForm form = new RegionCaptureForm(mode, options, bmp)) { form.ImageFilePath = filePath; form.SaveImageRequested += (output, newFilePath) => { using (output) { if (string.IsNullOrEmpty(newFilePath)) { string fileName = GetFilename(taskSettings, taskSettings.ImageSettings.ImageFormat.GetDescription(), output); newFilePath = Path.Combine(taskSettings.GetScreenshotsFolder(), fileName); } ImageHelpers.SaveImage(output, newFilePath); } return(newFilePath); }; form.SaveImageAsRequested += (output, newFilePath) => { using (output) { if (string.IsNullOrEmpty(newFilePath)) { string fileName = GetFilename(taskSettings, taskSettings.ImageSettings.ImageFormat.GetDescription(), output); newFilePath = Path.Combine(taskSettings.GetScreenshotsFolder(), fileName); } newFilePath = ImageHelpers.SaveImageFileDialog(output, newFilePath); } return(newFilePath); }; form.CopyImageRequested += output => { Option.MainForm.Invoke(() => { using (output) { ClipboardHelpers.CopyImage(output); } }); }; form.UploadImageRequested += output => { Option.MainForm.Invoke(() => { //UploadManager.UploadImage(output); }); }; form.PrintImageRequested += output => { Option.MainForm.Invoke(() => { using (output) { PrintImage(output); } }); }; form.ShowDialog(); switch (form.Result) { case RegionResult.Close: // Esc case RegionResult.AnnotateCancelTask: return(null); case RegionResult.Region: // Enter case RegionResult.AnnotateRunAfterCaptureTasks: return(form.GetResultImage()); case RegionResult.Fullscreen: // Space or right click case RegionResult.AnnotateContinueTask: return((Bitmap)form.Canvas.Clone()); } } } } return(null); }
public RegionCaptureForm(Rectangle region, RegionCaptureMode mode_) { SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true); // force the client area to be at 0, 0 so that when you draw using graphics it draws in the correct location clientArea = new Rectangle(new Point(0, 0), new Size(region.Width, region.Height)); mode = mode_; // borderDotPen draws the dashed lines for the screenwide corsshair and selection box // magnifierBorderPen draws the border around the magnifier // magnifierGridPen draws the grid on the magnifier // borderPen draws the border on the info text // magnifierCrosshairBrush draws the magnifier crosshair borderDotPen = new Pen(SettingsManager.RegionCaptureSettings.Screen_Wide_Crosshair_Color); magnifierBorderPen = new Pen(SettingsManager.RegionCaptureSettings.Magnifier_Border_Color); magnifierGridPen = new Pen(SettingsManager.RegionCaptureSettings.Magnifier_Grid_Color); borderPen = new Pen(SettingsManager.RegionCaptureSettings.Info_Text_Border_Color); magnifierCrosshairBrush = new SolidBrush(SettingsManager.RegionCaptureSettings.Magnifier_Crosshair_Color); // textBackgroundBrush is used to fill the color behind the info text // textFontBrush is used to specify the color of the info text textBackgroundBrush = new SolidBrush(SettingsManager.RegionCaptureSettings.Info_Text_Back_Color); textFontBrush = new SolidBrush(SettingsManager.RegionCaptureSettings.Info_Text_Color); // infoFont is used to specify the font / size of the info text infoFont = new Font("Verdana", 12); // 10 if (SettingsManager.RegionCaptureSettings.Draw_Marching_Ants) { borderDotPen.DashPattern = new float[] { 5, 5 }; } InitializeComponent(); // this has to be done after InitializeComponent // otherwise the taskbar will be in front of the window SuspendLayout(); BackColor = Color.Black; MinimumSize = new Size(clientArea.Width, clientArea.Height); MaximumSize = new Size(clientArea.Width, clientArea.Height); Bounds = region; #if !DEBUG TopMost = true; #endif ResumeLayout(); // set the cursor var buffer = Properties.Resources.Crosshair; using (MemoryStream m = new MemoryStream(buffer)) { Cursor = new Cursor(m); } image = ScreenshotHelper.CaptureRectangle(region); using (Bitmap DimmedCanvas = image.CloneSafe()) using (Graphics g = Graphics.FromImage(DimmedCanvas)) using (Brush brush = new SolidBrush(SettingsManager.RegionCaptureSettings.Background_Overlay_Color)) { if (SettingsManager.RegionCaptureSettings.Draw_Background_Overlay) { g.FillRectangle(brush, 0, 0, DimmedCanvas.Width, DimmedCanvas.Height); } backgroundBrush = new TextureBrush(DimmedCanvas) { WrapMode = WrapMode.Clamp }; } // used to make the selection box fill with the same color as background backgroundHighlightBrush = new TextureBrush(image) { WrapMode = WrapMode.Clamp }; }