public RegionCaptureLightForm(Bitmap canvas, bool activeMonitorMode = false) { backgroundImage = canvas; backgroundBrush = new TextureBrush(backgroundImage); borderDotPen = new Pen(Color.Black, 1); borderDotPen2 = new Pen(Color.White, 1); borderDotPen2.DashPattern = new float[] { 5, 5 }; penTimer = Stopwatch.StartNew(); if (activeMonitorMode) { ScreenRectangle = CaptureHelpers.GetActiveScreenBounds(); Helpers.LockCursorToWindow(this); } else { ScreenRectangle = CaptureHelpers.GetScreenBounds(); } InitializeComponent(); Icon = ShareXResources.Icon; Cursor = Helpers.CreateCursor(Resources.Crosshair); timer = new Timer { Interval = 10 }; timer.Tick += timer_Tick; timer.Start(); }
private void ConfigureMenuState() { if (Config.RememberMenuState) { SetMenuCollapsed(Config.MenuCollapsed); } Rectangle rectScreen = CaptureHelpers.GetScreenBounds(); if (Config.RememberMenuState && rectScreen.Contains(Config.MenuPosition)) { menuForm.Location = Config.MenuPosition; } else { Rectangle rectActiveScreen = CaptureHelpers.GetActiveScreenBounds(); if (tsMain.Width < rectActiveScreen.Width) { menuForm.Location = new Point(rectActiveScreen.X + rectActiveScreen.Width / 2 - tsMain.Width / 2, rectActiveScreen.Y + 20); } else { menuForm.Location = rectActiveScreen.Location; } } }
public static bool SelectRegion(out Rectangle rect, TaskSettings taskSettings) { using (RectangleRegion surface = new RectangleRegion()) { surface.Config = taskSettings.CaptureSettings.SurfaceOptions; surface.Config.ShowTips = false; surface.Config.QuickCrop = true; surface.Config.ForceWindowCapture = true; surface.Prepare(); surface.ShowDialog(); if (surface.Result == SurfaceResult.Region) { if (surface.AreaManager.IsCurrentAreaValid) { rect = CaptureHelpers.ClientToScreen(surface.AreaManager.CurrentArea); return(true); } } else if (surface.Result == SurfaceResult.Fullscreen) { rect = CaptureHelpers.GetScreenBounds(); return(true); } else if (surface.Result == SurfaceResult.Monitor) { Screen[] screens = Screen.AllScreens; if (surface.MonitorIndex < screens.Length) { Screen screen = screens[surface.MonitorIndex]; rect = screen.Bounds; return(true); } } else if (surface.Result == SurfaceResult.ActiveMonitor) { rect = CaptureHelpers.GetActiveScreenBounds(); return(true); } } rect = Rectangle.Empty; return(false); }
public static bool GetRectangleRegion(out Rectangle rect, RegionCaptureOptions options) { RegionCaptureOptions newOptions = GetRegionCaptureOptions(options); newOptions.ShowHotkeys = false; using (RegionCaptureForm form = new RegionCaptureForm(RegionCaptureMode.Default, newOptions)) { form.Prepare(); form.ShowDialog(); if (form.Result == RegionResult.Region) { if (form.ShapeManager.IsCurrentShapeValid) { rect = CaptureHelpers.ClientToScreen(form.ShapeManager.CurrentRectangle); return(true); } } else if (form.Result == RegionResult.Fullscreen) { rect = CaptureHelpers.GetScreenBounds(); return(true); } else if (form.Result == RegionResult.Monitor) { Screen[] screens = Screen.AllScreens; if (form.MonitorIndex < screens.Length) { Screen screen = screens[form.MonitorIndex]; rect = screen.Bounds; return(true); } } else if (form.Result == RegionResult.ActiveMonitor) { rect = CaptureHelpers.GetActiveScreenBounds(); return(true); } } rect = Rectangle.Empty; return(false); }
public RegionCaptureTransparentForm(bool activeMonitorMode = false) { clearPen = new Pen(Color.FromArgb(1, 0, 0, 0)); borderDotPen = new Pen(Color.Black, 1); borderDotPen2 = new Pen(Color.White, 1); borderDotPen2.DashPattern = new float[] { 5, 5 }; penTimer = Stopwatch.StartNew(); if (activeMonitorMode) { ScreenRectangle = CaptureHelpers.GetActiveScreenBounds(); Helpers.LockCursorToWindow(this); } else { ScreenRectangle = CaptureHelpers.GetScreenBounds(); } backgroundImage = new Bitmap(ScreenRectangle.Width, ScreenRectangle.Height); gBackgroundImage = Graphics.FromImage(backgroundImage); gBackgroundImage.InterpolationMode = InterpolationMode.NearestNeighbor; gBackgroundImage.SmoothingMode = SmoothingMode.HighSpeed; gBackgroundImage.CompositingMode = CompositingMode.SourceCopy; gBackgroundImage.CompositingQuality = CompositingQuality.HighSpeed; gBackgroundImage.Clear(Color.FromArgb(1, 0, 0, 0)); StartPosition = FormStartPosition.Manual; Bounds = ScreenRectangle; Text = "ShareX - " + Resources.RectangleTransparent_RectangleTransparent_Rectangle_capture_transparent; Cursor = Helpers.CreateCursor(Resources.Crosshair); TopMost = true; Shown += RectangleTransparent_Shown; KeyUp += RectangleTransparent_KeyUp; MouseDown += RectangleTransparent_MouseDown; MouseUp += RectangleTransparent_MouseUp; timer = new Timer { Interval = 10 }; timer.Tick += timer_Tick; timer.Start(); }
public static Image CaptureActiveMonitor() { Rectangle bounds = CaptureHelpers.GetActiveScreenBounds(); return(CaptureRectangle(bounds)); }
public Image Capture(Rectangle r, IntPtr handle, bool captureCursor) { Rectangle bounds = CaptureHelpers.GetActiveScreenBounds(); return(TypeRectangle.Capture(bounds)); }