SystemInformation.PrimaryMonitor : SystemInfo « Development Class « C# / C Sharp






SystemInformation.PrimaryMonitor

 

using System;
using System.Drawing;
using System.Windows.Forms;
   
class ScribbleWithBitmap: Form
{
     bool     bTracking;
     Point    ptLast;
     Bitmap   bitmap;
     Graphics grfxBm;
   
     public static void Main()
     {
          Application.Run(new ScribbleWithBitmap());
     }
     public ScribbleWithBitmap()
     {
          Text = "Scribble with Bitmap";
          Size size = SystemInformation.PrimaryMonitorMaximizedWindowSize;
          bitmap = new Bitmap(size.Width, size.Height);
   
          grfxBm = Graphics.FromImage(bitmap);
          grfxBm.Clear(BackColor);
     }
     protected override void OnMouseDown(MouseEventArgs mea)
     {
          if (mea.Button != MouseButtons.Left)
               return;
   
          ptLast = new Point(mea.X, mea.Y);
          bTracking = true;
     }
     protected override void OnMouseMove(MouseEventArgs mea)
     {
          if (!bTracking)
               return;
   
          Point ptNew = new Point(mea.X, mea.Y);
          
          Pen pen = new Pen(ForeColor);
          Graphics grfx = CreateGraphics();
          grfx.DrawLine(pen, ptLast, ptNew);
          grfx.Dispose();
   
          grfxBm.DrawLine(pen, ptLast, ptNew);
   
          ptLast = ptNew;
     }
     protected override void OnMouseUp(MouseEventArgs mea)
     {
          bTracking = false;
     }
     protected override void OnPaint(PaintEventArgs pea)
     {
          Graphics grfx = pea.Graphics;
          grfx.DrawImage(bitmap, 0, 0, bitmap.Width, bitmap.Height);
     }
}

 








Related examples in the same category

1.SystemInformation.ArrangeDirection
2.SystemInformation.ArrangeStartingPosition
3.SystemInformation.BootMode
4.SystemInformation.Border3DSize
5.SystemInformation.BorderSize
6.SystemInformation.CaptionButtonSize
7.SystemInformation.CaptionHeight
8.SystemInformation.ComputerName
9.SystemInformation.CursorSize
10.SystemInformation.DbcsEnabled
11.Print all System Information