public virtual bool NotifyMouseMove(System.Windows.Forms.MouseEventArgs e)
        {
            if (e == null)
            {
                throw new System.ArgumentNullException("e");
            }

            if (_areaOriginDefined)
            {
                System.Drawing.RectangleF invalidationRect = System.Drawing.RectangleF.Empty;
                if (_areaDefined)
                {
                    invalidationRect = VObjectsUtils.GetBoundingRectangle(_cornerPoints);
                }

                _areaDefined     = true;
                _cornerPoints[1] = _objectHost.HostViewer.ControlToWorkspace(new System.Drawing.Point(e.X, e.Y), Aurigma.GraphicsMill.Unit.Point);

                invalidationRect = System.Drawing.RectangleF.Union(invalidationRect, VObjectsUtils.GetBoundingRectangle(_cornerPoints));
                invalidationRect.Inflate((int)_borderPen.Width * 2, (int)_borderPen.Width * 2);
                _objectHost.HostViewer.InvalidateViewer(new MultiLayerViewerInvalidationTarget(_objectHost.HostViewer.WorkspaceToControl(invalidationRect, Aurigma.GraphicsMill.Unit.Point)));
            }

            return(true);
        }
예제 #2
0
        protected void UpdatePath()
        {
            // After deserialization _points array will be null.
            if (_points == null)
            {
                return;
            }

            if (_path != null)
            {
                _path.Dispose();
            }

            System.Drawing.RectangleF bounds = VObjectsUtils.GetBoundingRectangle(_points);
            if (bounds.Width < VObject.Eps)
            {
                _points[0].X += 0.05f;
            }
            if (bounds.Height < VObject.Eps)
            {
                _points[0].Y += 0.05f;
            }

            _path = new System.Drawing.Drawing2D.GraphicsPath();
            _path.AddLines(_points);
            if (_closePath)
            {
                _path.CloseFigure();
            }
        }
        protected void SwitchToDefaultDesigner()
        {
            System.Drawing.RectangleF invalidationRect = VObjectsUtils.GetBoundingRectangle(_cornerPoints);
            invalidationRect.Inflate((int)_borderPen.Width * 2, (int)_borderPen.Width * 2);
            _objectHost.HostViewer.InvalidateViewer(new MultiLayerViewerInvalidationTarget(_objectHost.HostViewer.WorkspaceToControl(invalidationRect, Aurigma.GraphicsMill.Unit.Point)));

            _objectHost.CurrentDesigner = _objectHost.DefaultDesigner;
        }
예제 #4
0
 private void UpdateBaseRectangle()
 {
     if (_children.Count > 0)
     {
         _baseRect = VObjectsUtils.GetBoundingRectangle(_children[0].GetVObjectBounds(), _children[0].Transform);
         for (int i = 1; i < _children.Count; i++)
         {
             _baseRect = System.Drawing.RectangleF.Union(_baseRect, VObjectsUtils.GetBoundingRectangle(_children[i].GetVObjectBounds(), _children[i].Transform));
         }
     }
 }
        protected override System.Drawing.Rectangle GetInvalidationRectangle()
        {
            System.Drawing.Rectangle result = VObjectsUtils.GetBoundingRectangle((System.Drawing.Point[])_points.ToArray(typeof(System.Drawing.Point)));

            if (base.Pen != null)
            {
                int inflateValue = (int)System.Math.Ceiling(base.Pen.Width * base.VObjectHost.HostViewer.GetControlPixelsPerUnitX(Aurigma.GraphicsMill.Unit.Point));
                result.Inflate(inflateValue, inflateValue);
            }

            return(result);
        }
        protected override System.Drawing.Rectangle GetInvalidationRectangle()
        {
            System.Drawing.Rectangle result = System.Drawing.Rectangle.Empty;
            if (_points.Count > 0)
            {
                System.Drawing.Point[] points = GetViewportPoints(_points.Count + 1);
                points[points.Length - 1] = _viewportMousePosition;
                result = VObjectsUtils.GetBoundingRectangle(points);

                int inflateValue = (int)System.Math.Ceiling(System.Math.Max(1.0f, 2 * base.Pen.Width * base.VObjectHost.HostViewer.Zoom));
                result.Inflate(inflateValue, inflateValue);
            }

            return(result);
        }
        protected override IVObject CreateObject()
        {
            PolylineVObject result = null;

            if (_points.Count > 1)
            {
                System.Drawing.PointF[]   points       = (System.Drawing.PointF[])_points.ToArray(typeof(System.Drawing.PointF));
                System.Drawing.RectangleF pointsBounds = VObjectsUtils.GetBoundingRectangle(points);
                if (pointsBounds.Width > 1.0f && pointsBounds.Height > 1.0f)
                {
                    result       = new PolylineVObject(points, _closePath, _fillMode);
                    result.Pen   = base.Pen;
                    result.Brush = base.Brush;
                }
            }

            return(result);
        }
        public virtual bool NotifyMouseUp(System.Windows.Forms.MouseEventArgs e)
        {
            if (e == null)
            {
                throw new System.ArgumentNullException("e");
            }

            if (e.Button == System.Windows.Forms.MouseButtons.Left && _areaOriginDefined)
            {
                System.Drawing.RectangleF destinationRect;
                if (_areaDefined)
                {
                    destinationRect = VObjectsUtils.GetBoundingRectangle(_cornerPoints);
                }
                else
                {
                    destinationRect = new System.Drawing.RectangleF(_cornerPoints[0], System.Drawing.SizeF.Empty);
                }

                System.Drawing.Rectangle invalidationRect = System.Drawing.Rectangle.Empty;
                IVObject obj = CreateObject(destinationRect);
                if (obj != null)
                {
                    _objectHost.CurrentLayer.VObjects.Add(obj);
                    invalidationRect = _objectHost.HostViewer.WorkspaceToControl(obj.GetTransformedVObjectBounds(), Aurigma.GraphicsMill.Unit.Point);
                }

                if (_areaDefined)
                {
                    System.Drawing.Rectangle tmp = _objectHost.HostViewer.WorkspaceToControl(destinationRect, Aurigma.GraphicsMill.Unit.Point);
                    tmp.Inflate((int)_borderPen.Width * 2, (int)_borderPen.Width * 2);
                    invalidationRect = System.Drawing.Rectangle.Union(invalidationRect, tmp);
                    _areaDefined     = false;
                }

                _objectHost.HostViewer.InvalidateViewer(new MultiLayerViewerInvalidationTarget(invalidationRect, _objectHost.CurrentLayer));
                _objectHost.CurrentDesigner = _objectHost.DefaultDesigner;
            }

            return(true);
        }
        public override bool NotifyMouseMove(System.Windows.Forms.MouseEventArgs e)
        {
            if (_dragging)
            {
                System.Drawing.PointF[] points = new System.Drawing.PointF[3];
                points[0] = _point0;
                points[1] = _point1;

                _point1   = base.VObjectHost.HostViewer.ControlToWorkspace(new System.Drawing.Point(e.X, e.Y), Aurigma.GraphicsMill.Unit.Point);
                points[2] = _point1;

                System.Drawing.RectangleF workspaceChangedRect = VObjectsUtils.GetBoundingRectangle(points);
                if (base.Pen != null)
                {
                    workspaceChangedRect.Inflate(base.Pen.Width * 2, base.Pen.Width * 2);
                }

                System.Drawing.Rectangle invalidationRect = base.VObjectHost.HostViewer.WorkspaceToControl(workspaceChangedRect, Aurigma.GraphicsMill.Unit.Point);
                invalidationRect.Inflate(VObject.InvalidationMargin);
                base.VObjectHost.HostViewer.InvalidateViewer(new MultiLayerViewerInvalidationTarget(invalidationRect));
            }

            return(base.NotifyMouseMove(e));
        }
 protected System.Drawing.RectangleF GetWorkspaceRectangle()
 {
     return(VObjectsUtils.GetBoundingRectangle(_point0, _point1));
 }