Beispiel #1
0
        public override void OnMouseUp(RichPictureBox richPictureBox, MouseEventArgs e)
        {
            if (cancelNewFlag)
            {
                cancelNewFlag = false;
                return;
            }

            // if new object creation is canceled
            if (!richPictureBox.CreatingDrawObject && newPolyLine != null)
            {
                return;
            }

            if (newPolyLine == null)
            {
                Point point = new Point((int)(e.X / richPictureBox.Zoom - richPictureBox.OffsetX), (int)(e.Y / richPictureBox.Zoom - richPictureBox.OffsetY));
                newPolyLine = new DrawPolyLine(richPictureBox, point.X, point.Y, point.X + 1, point.Y + 1);
                AddNewObject(richPictureBox, newPolyLine);
            }
            else
            {
                // polygon gate should have at least 3 points
                if (newPolyLine.CloseToFirstPoint(e.Location) && newPolyLine.PointCount > 3)
                {
                    newPolyLine.RemovePointAt(newPolyLine.PointCount - 1); // remove the last added point, it is closed to first
                    EndCreating(richPictureBox);
                    return;
                }
                // Drawing is in process, so simply add a new point
                Point point = e.Location;
                newPolyLine.AddPoint(richPictureBox, point, true);
            }
            richPictureBox.Capture = false;
            richPictureBox.Invalidate();
        }
Beispiel #2
0
        public override void OnCancel(RichPictureBox richPictureBox, bool cancelSelection)
        {
            base.OnCancel(richPictureBox, cancelSelection);

            newPolyLine = null;
        }
Beispiel #3
0
 private void EndCreating(RichPictureBox richPictureBox)
 {
     newPolyLine.Creating = false;
     newPolyLine          = null;
 }