public void Paint(DocumentFrame frame, Graphics g, DocumentPaintResources resources) { Point centrePoint = GetCentrePoint(frame); SmoothingMode oldSmoothingMode = g.SmoothingMode; g.SmoothingMode = SmoothingMode.AntiAlias; Rectangle drawRectangle = new Rectangle(centrePoint, new Size(0, 0)); drawRectangle.Inflate(_radius, _radius); g.FillEllipse(resources.HandleBrush, drawRectangle); g.SmoothingMode = oldSmoothingMode; }
private void PaintLine(Graphics g, DocumentPaintResources resources, Rectangle labelRectangle, Point labelCentre, Point lineEnd) { const int marginAroundLabel = 5; Size halfLabelSize = new Size( labelRectangle.Width / 2 + marginAroundLabel, labelRectangle.Height / 2 + marginAroundLabel); // Form two partitions (one "divided" by y = x, the other by y = -x) and join // them to determine which of the four ways the line is headed: Size delta = new Size(lineEnd) - new Size(labelCentre); Size absoluteDelta = new Size(Math.Abs(delta.Width), Math.Abs(delta.Height)); bool inTopLeftTriangle = delta.Height >= delta.Width; bool inTopRightTriangle = delta.Height >= -delta.Width; bool aboveOrBelow = (inTopLeftTriangle == inTopRightTriangle); // Snap the line in to purely vertical or horizontal: const int bandHalfWidth = 15; bool inHorizontalBand = absoluteDelta.Height < bandHalfWidth; bool inVerticalBand = absoluteDelta.Width < bandHalfWidth; if (inVerticalBand) delta.Width = 0; if (inHorizontalBand) delta.Height = 0; Point[] points = new Point[3]; Size leftRightMovement = new Size(delta.Width, 0); Size upDownMovement = new Size(0, delta.Height); points[0] = labelCentre; points[1] = points[0] + (aboveOrBelow ? upDownMovement : leftRightMovement); points[2] = points[1] + (aboveOrBelow ? leftRightMovement : upDownMovement); if (!aboveOrBelow) points[0].X += Math.Sign(delta.Width) * halfLabelSize.Width; if (aboveOrBelow) points[0].Y += Math.Sign(delta.Height) * halfLabelSize.Height; g.DrawLines(Pens.Black, points); }
void PaintLabelText(Graphics g, DocumentPaintResources resources, PointF paintAt) { // If the label is blank or we're selected, draw a background: if (string.IsNullOrEmpty(_label) || resources.IsSelectedFrame) { using (GraphicsPath roundPath = Interlace.Drawing.Utilities.CreateRoundedRectanglePath(HitBounds, 10.0f)) { g.FillPath(resources.HandleBrush, roundPath); } } // Draw the label: g.DrawString(_label, resources.LabelFont, Brushes.Black, paintAt); }
public override void Paint(Graphics g, DocumentPaintResources resources) { TextRenderingHint oldTextRenderingHint = g.TextRenderingHint; g.TextRenderingHint = TextRenderingHint.AntiAlias; SmoothingMode oldSmoothingMode = g.SmoothingMode; g.SmoothingMode = SmoothingMode.AntiAlias; // Update the label size: _lastLabelSize = Size.Ceiling(g.MeasureString(_label, resources.LabelFont)); Rectangle paintAtRectangle = LabelBounds; PointF paintAt = paintAtRectangle.Location; PaintLabelText(g, resources, paintAt); PaintLine(g, resources, paintAtRectangle, _offsetInDocument, new Point(_callOutOffsetInDocument)); g.SmoothingMode = oldSmoothingMode; g.TextRenderingHint = oldTextRenderingHint; }
internal void PaintHandles(Graphics graphics, DocumentPaintResources resources) { foreach (IHandleFlyweight handle in Handles) { handle.Paint(this, graphics, resources); } }
public abstract void Paint(Graphics g, DocumentPaintResources resources);
public void Paint(Rectangle objectRectangle, Point screenTopLeft, Graphics g, DocumentPaintResources resources) { using (ImageAttributes attributes = new ImageAttributes()) { if (resources.IsFadedFrame) { ColorMatrix matrix = new ColorMatrix(); matrix.Matrix33 = 0.5f; attributes.SetColorMatrix(matrix); } Rectangle paintRectangle = new Rectangle(screenTopLeft, objectRectangle.Size); g.DrawImage(resources.ImageLinkCache.GetCachedImage(_imageLink), new Rectangle(screenTopLeft, objectRectangle.Size), objectRectangle.X, objectRectangle.Y, objectRectangle.Width, objectRectangle.Height, GraphicsUnit.Pixel, attributes); } }
public Bitmap Render() { Rectangle bounds = PaintBounds ?? new Rectangle(0, 0, 100, 100); Bitmap image = new Bitmap(bounds.Width, bounds.Height, PixelFormat.Format24bppRgb); try { using (Graphics g = Graphics.FromImage(image)) { g.FillRectangle(Brushes.White, new Rectangle(new Point(0, 0), bounds.Size)); g.TranslateTransform(-bounds.X, -bounds.Y); using (DocumentPaintResources resources = new DocumentPaintResources(_cache)) { foreach (DocumentFrame frame in _document.Frames) { frame.Paint(g, resources); } } } } catch { image.Dispose(); throw; } return image; }
public void Paint(DocumentFrame frame, Graphics g, DocumentPaintResources resources) { // The move handle isn't painted. }
public void Paint(Rectangle objectRectangle, Point screenTopLeft, Graphics g, DocumentPaintResources resources) { Rectangle paintRectangle = new Rectangle(screenTopLeft, objectRectangle.Size); using (SolidBrush brush = new SolidBrush(_color)) { g.FillRectangle(brush, paintRectangle); } }
public void PaintBorder(Graphics g, DocumentPaintResources resources, Point first, Point second) { using (Pen pen = new Pen(SystemColors.ControlDark, 1.0f)) { pen.DashStyle = DashStyle.Dash; g.DrawLine(pen, first, second); } }
public override void Paint(Graphics g, DocumentPaintResources resources) { Point paintTopLeft = _clipBounds.Location + new Size(_offsetInDocument); _framedObject.Paint(_clipBounds, paintTopLeft, g, resources); Rectangle border = _clipBounds; border.Offset(_offsetInDocument); Rectangle objectBounds = _framedObject.ObjectBounds; if (_enableTopCutMarks && objectBounds.Top != _clipBounds.Top) PaintBorder(g, resources, border.Location, border.Location + new Size(border.Width - 1, 0)); if (_enableBottomCutMarks && objectBounds.Bottom != _clipBounds.Bottom) PaintBorder(g, resources, border.Location + new Size(0, border.Height - 1), border.Location + new Size(border.Width - 1, border.Height - 1)); if (_enableLeftCutMarks && objectBounds.Left != _clipBounds.Left) PaintBorder(g, resources, border.Location, border.Location + new Size(0, border.Height - 1)); if (_enableRightCutMarks && objectBounds.Right != _clipBounds.Right) PaintBorder(g, resources, border.Location + new Size(border.Width - 1, 0), border.Location + new Size(border.Width - 1, border.Height - 1)); }
protected override void OnPaint(PaintEventArgs e) { e.Graphics.FillRectangle(Brushes.White, ClientRectangle); using (DocumentPaintResources resources = new DocumentPaintResources(_cache)) { resources.IsFadedFrame = false; foreach (DocumentFrame frame in _document.Frames) { resources.IsSelectedFrame = (frame == _selectedFrame); resources.SelectedHandleOrNull = _dragController != null ? _dragController.Handle : null; frame.Paint(e.Graphics, resources); if (frame == _selectedFrame) { frame.PaintHandles(e.Graphics, resources); resources.IsFadedFrame = true; } } } }
public void Paint(DocumentFrame frame, Graphics g, DocumentPaintResources resources) { SmoothingMode oldSmoothingMode = g.SmoothingMode; g.SmoothingMode = SmoothingMode.AntiAlias; using (GraphicsPath path = Interlace.Drawing.Utilities.CreateRoundedRectanglePath(GetHandleBounds(frame), 5.0f)) { g.FillPath(resources.HandleBrush, path); } g.SmoothingMode = oldSmoothingMode; }