using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace sharpcapture { public partial class CapturingWindow : Form { private Rectangle? area = null; public Rectangle Area { set { area = value; Invalidate(); } } public CapturingWindow() { InitializeComponent(); } protected override void OnPaint(PaintEventArgs e) { Pen pen = new Pen(Color.Black, 2f); if (area.HasValue) { int x = area.Value.Left; int y = area.Value.Top; int width = area.Value.Width; int height = area.Value.Height; Rectangle rectangle = new Rectangle(x, y, width, height); e.Graphics.DrawRectangle(pen, rectangle); } base.OnPaint(e); } } }