예제 #1
0
        public override void Draw(System.Drawing.Graphics g)
        {
            if (g == null)
            {
                throw new System.ArgumentNullException("g");
            }

            if (base.Dragging)
            {
                System.Drawing.Rectangle rectangle = GetViewportRectangle();

                if (base.Brush != null)
                {
                    System.Drawing.Drawing2D.Matrix prevBrushMatrix = PathVObjectCreateDesigner.AdaptBrushToViewport(base.Brush, this.VObjectHost.HostViewer);
                    try
                    {
                        g.FillEllipse(base.Brush, rectangle);
                    }
                    finally
                    {
                        if (prevBrushMatrix != null)
                        {
                            VObjectsUtils.SetBrushMatrix(base.Brush, prevBrushMatrix);
                        }
                    }
                }

                if (base.Pen != null)
                {
                    using (System.Drawing.Pen pen = CreateViewportPen())
                        g.DrawEllipse(pen, rectangle);
                }
            }
        }
예제 #2
0
        protected void RestoreBrush()
        {
            if (_brush != null && _brush.GetType() != typeof(System.Drawing.SolidBrush) && _brush.GetType() != typeof(System.Drawing.Drawing2D.HatchBrush))
            {
                if (_brushMatrices.Count < 1)
                {
                    throw new Aurigma.GraphicsMill.UnexpectedException(StringResources.GetString("ExStrModifyBrushTransformOrderCorrupted"));
                }

                VObjectsUtils.SetBrushMatrix(_brush, (System.Drawing.Drawing2D.Matrix)_brushMatrices.Peek());
            }
        }
        public override void Draw(System.Drawing.Graphics g)
        {
            if (g == null)
            {
                throw new System.ArgumentNullException("g");
            }

            if (_points.Count > 0)
            {
                System.Drawing.Point[] points = GetViewportPoints(_points.Count + 1);
                points[points.Length - 1] = _viewportMousePosition;

                if (_closePath)
                {
                    if (base.Brush != null)
                    {
                        System.Drawing.Drawing2D.Matrix prevBrushMatrix = PathVObjectCreateDesigner.AdaptBrushToViewport(base.Brush, this.VObjectHost.HostViewer);
                        try
                        {
                            g.FillPolygon(base.Brush, points, _fillMode);
                        }
                        finally
                        {
                            if (prevBrushMatrix != null)
                            {
                                VObjectsUtils.SetBrushMatrix(base.Brush, prevBrushMatrix);
                            }
                        }
                    }
                    if (base.Pen != null)
                    {
                        g.DrawPolygon(base.CreateViewportPen(), points);
                    }
                }
                else
                {
                    if (base.Pen != null)
                    {
                        g.DrawLines(base.CreateViewportPen(), points);
                    }
                }
            }
        }
예제 #4
0
        internal static System.Drawing.Drawing2D.Matrix AdaptBrushToViewport(System.Drawing.Brush brush, Aurigma.GraphicsMill.WinControls.ICoordinateMapper coordinateMapper)
        {
            System.Drawing.Drawing2D.Matrix originalMatrix = null;

            if (brush != null && brush.GetType() != typeof(System.Drawing.SolidBrush) && brush.GetType() != typeof(System.Drawing.Drawing2D.HatchBrush))
            {
                originalMatrix = VObjectsUtils.GetBrushMatrix(brush);

                System.Drawing.Point viewportTranslation = coordinateMapper.WorkspaceToControl(System.Drawing.PointF.Empty, Aurigma.GraphicsMill.Unit.Pixel);
                float scale = coordinateMapper.GetControlPixelsPerUnitX(Aurigma.GraphicsMill.Unit.Point);

                System.Drawing.Drawing2D.Matrix brushMatrix = new System.Drawing.Drawing2D.Matrix();
                brushMatrix.Scale(scale, scale, System.Drawing.Drawing2D.MatrixOrder.Append);
                brushMatrix.Translate(viewportTranslation.X, viewportTranslation.Y, System.Drawing.Drawing2D.MatrixOrder.Append);
                brushMatrix.Multiply(originalMatrix, System.Drawing.Drawing2D.MatrixOrder.Prepend);

                VObjectsUtils.SetBrushMatrix(brush, brushMatrix);
            }

            return(originalMatrix);
        }
        public override void Draw(System.Drawing.Graphics g)
        {
            if (g == null)
            {
                throw new System.ArgumentNullException("g");
            }

            if (_points.Count > 1)
            {
                using (System.Drawing.Pen pen = CreateViewportPen())
                {
                    System.Drawing.Point[] points = (System.Drawing.Point[])_points.ToArray(typeof(System.Drawing.Point));

                    if (_closePath)
                    {
                        if (base.Brush != null)
                        {
                            System.Drawing.Drawing2D.Matrix prevBrushMatrix = PathVObjectCreateDesigner.AdaptBrushToViewport(base.Brush, base.VObjectHost.HostViewer);
                            try
                            {
                                g.FillPolygon(base.Brush, points, _fillMode);
                            }
                            finally
                            {
                                if (prevBrushMatrix != null)
                                {
                                    VObjectsUtils.SetBrushMatrix(base.Brush, prevBrushMatrix);
                                }
                            }
                        }
                        g.DrawPolygon(pen, points);
                    }
                    else
                    {
                        g.DrawLines(pen, points);
                    }
                }
            }
        }
예제 #6
0
        protected void AdaptBrushToViewport(ICoordinateMapper coordinateMapper)
        {
            if (coordinateMapper == null)
            {
                throw new System.ArgumentNullException("coordinateMapper");
            }

            if (_brush != null && _brush.GetType() != typeof(System.Drawing.SolidBrush) && _brush.GetType() != typeof(System.Drawing.Drawing2D.HatchBrush))
            {
                System.Drawing.Drawing2D.Matrix originalMatrix = VObjectsUtils.GetBrushMatrix(_brush);
                _brushMatrices.Push(originalMatrix);

                System.Drawing.Point viewportTranslation = coordinateMapper.WorkspaceToControl(System.Drawing.PointF.Empty, Aurigma.GraphicsMill.Unit.Pixel);
                float scale = coordinateMapper.GetControlPixelsPerUnitX(Aurigma.GraphicsMill.Unit.Point);

                System.Drawing.Drawing2D.Matrix brushMatrix = (System.Drawing.Drawing2D.Matrix)_matrix.Clone();
                brushMatrix.Scale(scale, scale, System.Drawing.Drawing2D.MatrixOrder.Append);
                brushMatrix.Translate(viewportTranslation.X, viewportTranslation.Y, System.Drawing.Drawing2D.MatrixOrder.Append);
                brushMatrix.Multiply(originalMatrix, System.Drawing.Drawing2D.MatrixOrder.Prepend);

                VObjectsUtils.SetBrushMatrix(_brush, brushMatrix);
            }
        }