Пример #1
0
 private void ClearShape(object param)
 {
     this.Items.Clear();
     _points.Clear();
     _lastLine   = null;
     _closeLine  = null;
     ClosedShape = false;
 }
Пример #2
0
        private void CloseShape()
        {
            var firstPoint = _points[0];

            _lastLine.X2 = firstPoint.X;
            _lastLine.Y2 = firstPoint.Y;
            this.Items.Remove(_closeLine);
            _closeLine = null;
            _lastLine  = null;

            ClosedShape = true;
        }
Пример #3
0
        internal bool NotifyMouseClick(Point currentPoint)
        {
            if (ClosedShape)
            {
                return(false);
            }

            currentPoint = Snap.ToGrid(currentPoint);

            if (_points.Count != 0)
            {
                // check if new point has same coordinations as last point
                var lastPoint = _points.Last();
                if (DoubleUtils.Equals(lastPoint, currentPoint))
                {
                    return(true);
                }

                // check if new point has same coordinations as first pont
                var firstPoint = _points[0];
                if (DoubleUtils.Equals(firstPoint, currentPoint))
                {
                    CloseShape();
                    return(true);
                }
            }

            _points.Add(currentPoint);
            _lastLine = new LineViewModel(currentPoint.X, currentPoint.Y, _mousePosition.X, _mousePosition.Y);
            this.Items.Add(_lastLine);

            if (_closeLine == null && this.Items.Count == 2)
            {
                var firstPoint = _points[0];
                _closeLine = new LineViewModel(_mousePosition.X, _mousePosition.Y, firstPoint.X, firstPoint.Y);
                this.Items.Add(_closeLine);
            }

            return(true);
        }