Esempio n. 1
0
        public override void OnMouseUp(ZWPictureBox pictureBox, MouseEventArgs e)
        {
            if (cancelNewFlag)
            {
                cancelNewFlag = false;
                return;
            }

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

            if (newPolyLine == null)
            {
                Point point = new Point((int)(e.X / pictureBox.Zoom - pictureBox.OffsetX), (int)(e.Y / pictureBox.Zoom - pictureBox.OffsetY));
                newPolyLine = new DrawPolyLine(pictureBox, point.X, point.Y, point.X + 1, point.Y + 1);
                AddNewObject(pictureBox, 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(pictureBox);
                    return;
                }
                // Drawing is in process, so simply add a new point
                Point point = new Point((int)(e.X / pictureBox.Zoom - pictureBox.OffsetX), (int)(e.Y / pictureBox.Zoom - pictureBox.OffsetY));
                newPolyLine.AddPoint(pictureBox, point, true);
            }
            pictureBox.Capture = false;
            pictureBox.Refresh();
        }
Esempio n. 2
0
        public override void OnCancel(ZWPictureBox pictureBox, bool cancelSelection)
        {
            base.OnCancel(pictureBox, cancelSelection);

            newPolyLine = null;
        }
Esempio n. 3
0
 private void EndCreating(ZWPictureBox pictureBox)
 {
     newPolyLine.Creating = false;
     newPolyLine          = null;
 }