我们需要构建一个记录我们桌面的应用程序。我们在桌面上画线以通知用户我们正在记录他/她的桌面。我们希望在记录完成后擦除这些线。我们使用 C#.net 中的图形绘制线。请检查下面的代码,
IntPtr desktop = GetDC(IntPtr.Zero);
using (Graphics g1 = Graphics.FromHdc(desktop))
{
Pen blackPen = new Pen(Color.Orange, 10);
Point pleftTop = new Point(2, 1);
Point pleftBottom = new Point(2, 765);
g1.DrawLine(blackPen, pleftTop, pleftBottom);
Point pTopLeft = new Point(1, 3);
Point pTopRight = new Point(1356, 3);
g1.DrawLine(blackPen, pTopLeft, pTopRight);
Point pRight1 = new Point(1356, 1356);
Point pRight2 = new Point(1358, 1);
g1.DrawLine(blackPen, pRight1, pRight2);
Point pBottom1 = new Point(1, 765);
Point pBottom2 = new Point(1356, 765);
g1.DrawLine(blackPen, pBottom1, pBottom2);
string text = string.Empty;
int screenHeight = Screen.GetWorkingArea(this).Height;
int screenWidth = Screen.GetWorkingArea(this).Width;
text = "Recording your screen & audio";
int centerWidth = ((screenWidth / 3));
int opacity = 255;
g1.PixelOffsetMode = PixelOffsetMode.HighQuality;
g1.DrawString(text, new Font("Arial", 15), new SolidBrush(Color.FromArgb(opacity, Color.WhiteSmoke)), centerWidth, 0);