コード例 #1
0
 private void DisplayBox_MouseMove(object sender, MouseEventArgs e)
 {
     if (isMouseDown && isDrawEnabled)
     {
         if (lastPoint != null)
         {
             if (DisplayBox.Image == null)
             {
                 Bitmap bmp = new Bitmap(DisplayBox.Width, DisplayBox.Height);
                 DisplayBox.Image = bmp;
             }
             using (Graphics g = Graphics.FromImage(DisplayBox.Image))
             {
                 g.DrawLine(new Pen(Color.Black, 2), lastPoint, e.Location);
                 g.SmoothingMode = SmoothingMode.AntiAlias;
             }
             DisplayBox.Invalidate(); //refreshes the picturebox
             lastPoint = e.Location;  //keep assigning the lastPoint
         }
     }
 }
コード例 #2
0
 private void RefreshDisplayBox()
 {
     DisplayBox.Invalidate();
 }