public override void Draw(System.Drawing.Graphics g, ICoordinateMapper coordinateMapper) { if (g == null) { throw new System.ArgumentNullException("g"); } if (coordinateMapper == null) { throw new System.ArgumentNullException("coordinateMapper"); } if (!base.Enabled || _path == null) { return; } System.Drawing.Point drawPnt = coordinateMapper.WorkspaceToControl(base.Location, Aurigma.GraphicsMill.Unit.Point); using (System.Drawing.Drawing2D.Matrix m = new System.Drawing.Drawing2D.Matrix(1.0f, 0.0f, 0.0f, 1.0f, drawPnt.X, drawPnt.Y)) { g.Transform = m; if (_brush != null) { g.FillPath(_brush, _path); } if (this.Pen != null) { g.DrawPath(_pen, _path); } g.Transform = new System.Drawing.Drawing2D.Matrix(); } }
public override bool HitTest(System.Drawing.Point point, ICoordinateMapper coordinateMapper) { if (coordinateMapper == null) { throw new System.ArgumentNullException("coordinateMapper"); } bool result = false; if (base.Enabled && _path != null) { System.Drawing.Point convertedPoint = coordinateMapper.WorkspaceToControl(base.Location, Aurigma.GraphicsMill.Unit.Point); point.X -= convertedPoint.X; point.Y -= convertedPoint.Y; result = _path.IsVisible(point); if (!result && this.Pen != null) { result = _path.IsOutlineVisible(point, this.Pen); } } return(result); }
private void DrawInternal(System.Drawing.Graphics g, ICoordinateMapper coordinateMapper, System.Drawing.Rectangle renderingRect) { System.Drawing.Region oldClip = g.Clip; g.SetClip(renderingRect); System.Drawing.Drawing2D.Matrix oldMatrix = (System.Drawing.Drawing2D.Matrix)g.Transform.Clone(); try { if (_rect.DrawMode == VObjectDrawMode.Normal) { g.SmoothingMode = normalSmoothingMode; g.InterpolationMode = normalInterpolationMode; } else { g.SmoothingMode = draftSmoothingMode; g.InterpolationMode = draftInterpolationMode; } System.Drawing.RectangleF bounds = _rect.GetVObjectBounds(); System.Drawing.RectangleF transformedBounds = _rect.GetTransformedVObjectBounds(); System.Drawing.Rectangle mappedBounds = coordinateMapper.WorkspaceToControl(transformedBounds, Aurigma.GraphicsMill.Unit.Point); if (transformedBounds.Width > VObject.Eps && transformedBounds.Height > VObject.Eps) { float scaleX = mappedBounds.Width / transformedBounds.Width, scaleY = mappedBounds.Height / transformedBounds.Height; using (System.Drawing.Drawing2D.Matrix outputMatrix = (System.Drawing.Drawing2D.Matrix)_rect.Transform.Clone()) { outputMatrix.Translate(-transformedBounds.X, -transformedBounds.Y, System.Drawing.Drawing2D.MatrixOrder.Append); outputMatrix.Scale(scaleX, scaleY, System.Drawing.Drawing2D.MatrixOrder.Append); outputMatrix.Translate(mappedBounds.X, mappedBounds.Y, System.Drawing.Drawing2D.MatrixOrder.Append); g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality; g.Transform = outputMatrix; g.DrawImage(this.DrawnImage, 0, 0, bounds.Width, bounds.Height); } } } finally { g.Transform = oldMatrix; g.SetClip(oldClip, System.Drawing.Drawing2D.CombineMode.Replace); } }
public override void Draw(System.Drawing.Rectangle renderingRect, System.Drawing.Graphics g, ICoordinateMapper coordinateMapper) { if (g == null) { throw new System.ArgumentNullException("g"); } if (coordinateMapper == null) { throw new System.ArgumentNullException("coordinateMapper"); } System.Drawing.Rectangle screenBounds = coordinateMapper.WorkspaceToControl(_rect.GetTransformedVObjectBounds(), Aurigma.GraphicsMill.Unit.Point); System.Drawing.Rectangle visiblePart = System.Drawing.Rectangle.Intersect(screenBounds, renderingRect); if (visiblePart.Width > 0 && visiblePart.Height > 0) { DrawInternal(g, coordinateMapper, renderingRect); } }
public void DrawContent(System.Drawing.Graphics g, System.Drawing.Rectangle rect, ICoordinateMapper coordinateMapper) { for (int i = 0; i < _layers.Count; i++) { if (!_layers[i].Visible) { continue; } for (int j = 0; j < _layers[i].VObjects.Count; j++) { IVObject obj = _layers[i].VObjects[j]; if (rect.IntersectsWith(coordinateMapper.WorkspaceToControl(obj.GetTransformedVObjectBounds(), Aurigma.GraphicsMill.Unit.Point))) { obj.Draw(rect, g, coordinateMapper); } } } }
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); } }
private System.Drawing.Drawing2D.GraphicsPath CreateViewportPath(ICoordinateMapper coordinateMapper) { System.Drawing.Drawing2D.GraphicsPath result = (System.Drawing.Drawing2D.GraphicsPath) this.Path.Clone(); result.Transform(_matrix); System.Drawing.RectangleF pathBounds = this.Path.GetBounds(_matrix); System.Drawing.Rectangle mappedBounds = coordinateMapper.WorkspaceToControl(pathBounds, Aurigma.GraphicsMill.Unit.Point); if (pathBounds.Width > VObject.Eps && pathBounds.Height > VObject.Eps) { float scaleX = (float)mappedBounds.Width / pathBounds.Width, scaleY = (float)mappedBounds.Height / pathBounds.Height; using (System.Drawing.Drawing2D.Matrix m = new System.Drawing.Drawing2D.Matrix()) { m.Translate(mappedBounds.X, mappedBounds.Y); m.Scale(scaleX, scaleY); m.Translate(-pathBounds.X, -pathBounds.Y); result.Transform(m); } } return(result); }
public override void Draw(System.Drawing.Rectangle renderingRect, System.Drawing.Graphics g, ICoordinateMapper coordinateMapper) { if (g == null) { throw new System.ArgumentNullException("g"); } if (coordinateMapper == null) { throw new System.ArgumentNullException("coordinateMapper"); } // FillPath doesn't support specifying FillMode, it always uses FillMode.Alternate, // so we have to use Graphics.FillPolygon method in other cases. if (!_closePath || base.Brush == null || _fillMode == System.Drawing.Drawing2D.FillMode.Alternate) { base.Draw(renderingRect, g, coordinateMapper); } else { System.Drawing.PointF[] transformedPoints = VObjectsUtils.TransformPoints(base.Transform, _points); for (int i = 0; i < transformedPoints.Length; i++) { transformedPoints[i] = coordinateMapper.WorkspaceToControl(transformedPoints[i], Aurigma.GraphicsMill.Unit.Point); } System.Drawing.Drawing2D.SmoothingMode oldSmoothingMode = g.SmoothingMode; System.Drawing.Pen pen = base.CreateViewportPen(coordinateMapper); try { switch (base.DrawMode) { case VObjectDrawMode.Draft: g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighSpeed; break; case VObjectDrawMode.Normal: g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; break; default: throw new Aurigma.GraphicsMill.UnexpectedException(StringResources.GetString("ExStrUnexpectedDrawMode")); } if (base.Brush != null) { AdaptBrushToViewport(coordinateMapper); try { g.FillPolygon(base.Brush, transformedPoints, _fillMode); } finally { RestoreBrush(); } } if (pen != null) { g.DrawPolygon(pen, transformedPoints); } } finally { pen.Dispose(); g.SmoothingMode = oldSmoothingMode; } } }