void RenderOpenPath(XGraphics gfx) { gfx.TranslateTransform(15, 20); XPen pen = new XPen(XColors.Navy, Math.PI); pen.DashStyle = XDashStyle.Dash; XGraphicsPath path = new XGraphicsPath(); path.AddLine(10, 120, 50, 60); path.AddArc(50, 20, 110, 80, 180, 180); path.AddLine(160, 60, 220, 100); gfx.DrawPath(pen, path); }
public override void RenderPage(XGraphics gfx) { base.RenderPage(gfx); #if true__ XPen pen = new XPen(XColors.DarkGreen, 20); gfx.DrawLine(pen, 0, 0, 1000, 1000); #endif XGraphicsPath path = new XGraphicsPath(); path.AddString("@", new XFontFamily("Times New Roman"), XFontStyle.BoldItalic, 500, new XPoint(90, 60), XStringFormats.Default); gfx.DrawPath(properties.Pen2.Pen, properties.Brush2.Brush, path); }
/// <summary> /// Strokes an open path. /// </summary> void DrawPathOpen(XGraphics gfx, int number) { BeginBox(gfx, number, "DrawPath (open)"); XPen pen = new XPen(XColors.Navy, Math.PI); pen.DashStyle = XDashStyle.Dash; XGraphicsPath path = new XGraphicsPath(); path.AddLine(10, 120, 50, 60); path.AddArc(50, 20, 110, 80, 180, 180); path.AddLine(160, 60, 220, 100); gfx.DrawPath(pen, path); EndBox(gfx); }
void RenderAlternatePath(XGraphics gfx) { gfx.TranslateTransform(15, 20); XPen pen = new XPen(XColors.Navy, 2.5); // Alternate fill mode XGraphicsPath path = new XGraphicsPath(); path.FillMode = XFillMode.Alternate; path.AddLine(10, 130, 10, 40); path.AddBeziers(new XPoint[]{new XPoint(10, 40), new XPoint(30, 0), new XPoint(40, 20), new XPoint(60, 40), new XPoint(80, 60), new XPoint(100, 60), new XPoint(120, 40)}); path.AddLine(120, 40, 120, 130); path.CloseFigure(); path.AddEllipse(40, 80, 50, 40); gfx.DrawPath(pen, XBrushes.DarkOrange, path); }
public override void RenderPage(XGraphics gfx) { base.RenderPage(gfx); XGraphicsPath path = new XGraphicsPath(); path.AddLine(50, 150, 50, 100); path.AddArc(50, 50, 100, 100, -180, 180); path.AddLine(150, 70, 200, 70); path.AddLine(200, 70, 200, 150); path.CloseFigure(); XPen pen = new XPen(XColors.Red, 50); path.Widen(pen, new XMatrix(), 3); path.FillMode = this.properties.General.FillMode; gfx.DrawPath(properties.Pen2.Pen, properties.Brush2.Brush, path); }
public override void RenderPage(XGraphics gfx) { base.RenderPage(gfx); DrawGridlines(gfx); // Create a new graphical path XGraphicsPath path = new XGraphicsPath(); XSize size = new XSize(90, 140); double rotationAngle = 130; path.AddArc(new XPoint(100, 100), new XPoint(200, 200), size, rotationAngle, false, System.Windows.Media.SweepDirection.Clockwise); path.StartFigure(); path.AddArc(new XPoint(400, 100), new XPoint(500, 200), size, rotationAngle, false, System.Windows.Media.SweepDirection.Counterclockwise); path.StartFigure(); path.AddArc(new XPoint(100, 300), new XPoint(200, 400), size, rotationAngle, true, System.Windows.Media.SweepDirection.Clockwise); path.StartFigure(); path.AddArc(new XPoint(400, 300), new XPoint(500, 400), size, rotationAngle, true, System.Windows.Media.SweepDirection.Counterclockwise); path.StartFigure(); #if DEBUG_ gfx.WriteComment("PathArcSegment"); #endif gfx.DrawPath(XPens.Red, path); }
void RenderGlyphsPath(XGraphics gfx) { gfx.TranslateTransform(15, 20); XGraphicsPath path = new XGraphicsPath(); //path.AddString("Hello!", new XFontFamily("Times New Roman"), XFontStyle.BoldItalic, 100, new XRect(0, 0, 250, 140), // XStringFormat.Center); path.AddString("Hello!", new XFontFamily("Times New Roman"), XFontStyle.BoldItalic, 100, new XRect(0, 0, 250, 140), XStringFormats.Center); gfx.DrawPath(new XPen(XColors.Purple, 2.3), XBrushes.DarkOrchid, path); }
public override void RenderPage(XGraphics gfx) { base.RenderPage(gfx); XGraphicsPath path = new XGraphicsPath(); path.AddLine(50, 150, 50, 100); path.AddArc(50, 50, 100, 100, -180, 180); path.AddLine(150, 70, 200, 70); path.AddLine(200, 70, 200, 150); path.CloseFigure(); path.Flatten(XMatrix.Identity, 0.1); gfx.DrawPath(properties.Pen2.Pen, properties.Brush2.Brush, path); }
/// <summary> /// Draws an alternating and a winding path. /// </summary> void DrawPathAlternateAndWinding(XGraphics gfx, int number) { BeginBox(gfx, number, "DrawPath (alternate / winding)"); XPen pen = new XPen(XColors.Navy, 2.5); // Alternate fill mode XGraphicsPath path = new XGraphicsPath(); path.FillMode = XFillMode.Alternate; path.AddLine(10, 130, 10, 40); path.AddBeziers(new XPoint[]{new XPoint(10, 40), new XPoint(30, 0), new XPoint(40, 20), new XPoint(60, 40), new XPoint(80, 60), new XPoint(100, 60), new XPoint(120, 40)}); path.AddLine(120, 40, 120, 130); path.CloseFigure(); path.AddEllipse(40, 80, 50, 40); gfx.DrawPath(pen, XBrushes.DarkOrange, path); // Winding fill mode path = new XGraphicsPath(); path.FillMode = XFillMode.Winding; path.AddLine(130, 130, 130, 40); path.AddBeziers(new XPoint[]{new XPoint(130, 40), new XPoint(150, 0), new XPoint(160, 20), new XPoint(180, 40), new XPoint(200, 60), new XPoint(220, 60), new XPoint(240, 40)}); path.AddLine(240, 40, 240, 130); path.CloseFigure(); path.AddEllipse(160, 80, 50, 40); gfx.DrawPath(pen, XBrushes.DarkOrange, path); EndBox(gfx); }
/// <summary> /// Converts text to path. /// </summary> void DrawGlyphs(XGraphics gfx, int number) { BeginBox(gfx, number, "Draw Glyphs"); XGraphicsPath path = new XGraphicsPath(); path.AddString("Hello!", new XFontFamily("Times New Roman"), XFontStyle.BoldItalic, 100, new XRect(0, 0, 250, 140), XStringFormats.Center); gfx.DrawPath(new XPen(XColors.Purple, 2.3), XBrushes.DarkOrchid, path); EndBox(gfx); }
static void DrawText(XGraphics gfx, XPen pen, XBrush brush) { XSize size = gfx.PageSize; XGraphicsPath path = new XGraphicsPath(); path.AddString("PDFsharp", new XFontFamily("Verdana"), XFontStyle.BoldItalic, 60, new XRect(0, size.Height / 3.5, size.Width, 0), XStringFormats.Center); gfx.DrawPath(new XPen(pen.Color, 3), brush, path); }
public override void Draw(XGraphics graphics, Palette palette, DrawingContext context) { Random random = new Random(Name.GetHashCode()); var topLeft = InnerBounds.GetCorner(CompassPoint.NorthWest); var topRight = InnerBounds.GetCorner(CompassPoint.NorthEast); var bottomLeft = InnerBounds.GetCorner(CompassPoint.SouthWest); var bottomRight = InnerBounds.GetCorner(CompassPoint.SouthEast); var top = new LineSegment(topLeft, topRight); var right = new LineSegment(topRight, bottomRight); var bottom = new LineSegment(bottomRight, bottomLeft); var left = new LineSegment(bottomLeft, topLeft); context.LinesDrawn.Add(top); context.LinesDrawn.Add(right); context.LinesDrawn.Add(bottom); context.LinesDrawn.Add(left); var brush = context.Selected ? palette.BorderBrush : palette.FillBrush; if (!Settings.DebugDisableLineRendering) { var path = palette.Path(); Drawing.AddLine(path, top, random); Drawing.AddLine(path, right, random); Drawing.AddLine(path, bottom, random); Drawing.AddLine(path, left, random); graphics.DrawPath(brush, path); if (IsDark) { var state = graphics.Save(); graphics.IntersectClip(path); brush = context.Selected ? palette.FillBrush : palette.BorderBrush; graphics.DrawPolygon(brush, new PointF[] { topRight.ToPointF(), new PointF(topRight.X - Settings.DarknessStripeSize, topRight.Y), new PointF(topRight.X, topRight.Y + Settings.DarknessStripeSize) }, XFillMode.Alternate); graphics.Restore(state); } graphics.DrawPath(palette.BorderPen, path); } var font = Settings.LargeFont; brush = context.Selected ? palette.FillBrush : palette.LargeTextBrush; Rect textBounds = InnerBounds; textBounds.Inflate(-5, -5); if (textBounds.Width > 0 && textBounds.Height > 0) { m_name.Draw(graphics, font, brush, textBounds.Position, textBounds.Size, XStringFormats.Center); } var expandedBounds = InnerBounds; expandedBounds.Inflate(Settings.ObjectListOffsetFromRoom, Settings.ObjectListOffsetFromRoom); var drawnObjectList = false; font = Settings.SmallFont; brush = palette.SmallTextBrush; if (!string.IsNullOrEmpty(Objects)) { XStringFormat format = new XStringFormat(); Vector pos = expandedBounds.GetCorner(m_objectsPosition); if (!Drawing.SetAlignmentFromCardinalOrOrdinalDirection(format, m_objectsPosition)) { // object list appears inside the room below its name format.LineAlignment = XLineAlignment.Far; format.Alignment = XStringAlignment.Near; //format.Trimming = StringTrimming.EllipsisCharacter; //format.FormatFlags = StringFormatFlags.LineLimit; var height = InnerBounds.Height / 2 - font.Height / 2; var bounds = new Rect(InnerBounds.Left + Settings.ObjectListOffsetFromRoom, InnerBounds.Bottom - height, InnerBounds.Width - Settings.ObjectListOffsetFromRoom, height - Settings.ObjectListOffsetFromRoom); brush = context.Selected ? palette.FillBrush : brush; if (bounds.Width > 0 && bounds.Height > 0) { m_objects.Draw(graphics, font, brush, bounds.Position, bounds.Size, format); } drawnObjectList = true; } else if (m_objectsPosition == CompassPoint.North || m_objectsPosition == CompassPoint.South) { pos.X += Settings.ObjectListOffsetFromRoom; } if (!drawnObjectList) { m_objects.Draw(graphics, font, brush, pos, Vector.Zero, format); } } }
private static void DrawLineCurveInternal(XGraphics gfx, XPen pen, bool isStroked, ref XPoint pt1, ref XPoint pt2, double curvature, Core2D.Style.CurveOrientation orientation, Core2D.Shape.PointAlignment pt1a, Core2D.Shape.PointAlignment pt2a) { if (isStroked) { var path = new XGraphicsPath(); double p1x = pt1.X; double p1y = pt1.Y; double p2x = pt2.X; double p2y = pt2.Y; Core2D.Shapes.XLineExtensions.GetCurvedLineBezierControlPoints(orientation, curvature, pt1a, pt2a, ref p1x, ref p1y, ref p2x, ref p2y); path.AddBezier( pt1.X, pt1.Y, p1x, p1y, p2x, p2y, pt2.X, pt2.Y); gfx.DrawPath(pen, path); } }
public static void DrawChevron(XGraphics graphics, PointF pos, float angle, float size, Brush fillBrush) { if (m_chevronPath == null) { var apex = new PointF(0.5f, 0); var leftCorner = new PointF(-0.5f, 0.5f); var rightCorner = new PointF(-0.5f, -0.5f); m_chevronPath = new XGraphicsPath(); m_chevronPath.AddLine(apex, rightCorner); m_chevronPath.AddLine(rightCorner, leftCorner); m_chevronPath.AddLine(leftCorner, apex); } var state = graphics.Save(); graphics.TranslateTransform(pos.X, pos.Y); graphics.RotateTransform(angle); graphics.ScaleTransform(size, size); graphics.DrawPath(fillBrush, m_chevronPath); graphics.Restore(state); }
public void Draw(XGraphics graphics, RectangleF rect, MapOptions options, XPen pen) { if (graphics == null) throw new ArgumentNullException("graphics"); RectangleF bounds = TransformedBounds; //graphics.DrawRectangle( new XPen(XColors.Yellow, 1), bounds.X, bounds.Y, bounds.Width, bounds.Height ); if (bounds.IntersectsWith(rect)) { XGraphicsPath path = Path; using (RenderUtil.SaveState(graphics)) { XMatrix matrix = new XMatrix(); matrix.ScalePrepend(ScaleX, ScaleY); matrix.TranslatePrepend(-OriginX, -OriginY); graphics.MultiplyTransform(matrix, XMatrixOrder.Prepend); graphics.DrawPath(pen, path); } } }
void RenderWindingPath(XGraphics gfx) { gfx.TranslateTransform(15, 150); XPen pen = new XPen(XColors.Navy, 2.5); // Winding fill mode XGraphicsPath path = new XGraphicsPath(); path = new XGraphicsPath(); path.FillMode = XFillMode.Winding; path.AddLine(130, 130, 130, 40); path.AddBeziers(new XPoint[]{new XPoint(130, 40), new XPoint(150, 0), new XPoint(160, 20), new XPoint(180, 40), new XPoint(200, 60), new XPoint(220, 60), new XPoint(240, 40)}); path.AddLine(240, 40, 240, 130); path.CloseFigure(); path.AddEllipse(160, 80, 50, 40); gfx.DrawPath(pen, XBrushes.DarkOrange, path); }
public void Fill(XGraphics graphics, RectangleF rect, Brush fillBrush) { if (graphics == null) throw new ArgumentNullException("graphics"); RectangleF bounds = TransformedBounds; if (bounds.IntersectsWith(rect)) { XGraphicsPath path = Path; using (RenderUtil.SaveState(graphics)) { XMatrix matrix = new XMatrix(); matrix.ScalePrepend(ScaleX, ScaleY); matrix.TranslatePrepend(-OriginX, -OriginY); graphics.MultiplyTransform(matrix); graphics.DrawPath(fillBrush, path); } } }
/// <summary> /// Draws the marker given through rendererInfo at the specified position. Position specifies /// the center of the marker. /// </summary> internal static void Draw(XGraphics graphics, XPoint pos, MarkerRendererInfo rendererInfo) { if (rendererInfo.MarkerStyle == MarkerStyle.None) return; double size = rendererInfo.MarkerSize; double size2 = size / 2; double x0, y0, x1, y1; double g; XPen foreground = new XPen(rendererInfo.MarkerForegroundColor, 0.5); XBrush background = new XSolidBrush(rendererInfo.MarkerBackgroundColor); XGraphicsPath gp = new XGraphicsPath(); switch (rendererInfo.MarkerStyle) { case MarkerStyle.Square: x0 = pos.X - size2; y0 = pos.Y - size2; x1 = pos.X + size2; y1 = pos.Y + size2; gp.AddLine(x0, y0, x1, y0); gp.AddLine(x1, y0, x1, y1); gp.AddLine(x1, y1, x0, y1); gp.AddLine(x0, y1, x0, y0); break; case MarkerStyle.Diamond: gp.AddLine(x1 = pos.X + size2, pos.Y, pos.X, y0 = pos.Y - size2); gp.AddLine(pos.X, y0, x0 = pos.X - size2, pos.Y); gp.AddLine(x0, pos.Y, pos.X, y1 = pos.Y + size2); gp.AddLine(pos.X, y1, x1, pos.Y); break; case MarkerStyle.Triangle: y0 = pos.Y + size / 2; y1 = pos.Y - size / 2; g = Math.Sqrt(size * size * 4 / 3) / 2; gp.AddLine(pos.X, y1, pos.X + g, y0); gp.AddLine(pos.X + g, y0, pos.X - g, y0); gp.AddLine(pos.X - g, y0, pos.X, y1); break; case MarkerStyle.Plus: g = size2 / 4; gp.AddLine(pos.X - size2, pos.Y + g, pos.X - g, pos.Y + g); gp.AddLine(pos.X - g, pos.Y + g, pos.X - g, pos.Y + size2); gp.AddLine(pos.X - g, pos.Y + size2, pos.X + g, pos.Y + size2); gp.AddLine(pos.X + g, pos.Y + size2, pos.X + g, pos.Y + g); gp.AddLine(pos.X + g, pos.Y + g, pos.X + size2, pos.Y + g); gp.AddLine(pos.X + size2, pos.Y + g, pos.X + size2, pos.Y - g); gp.AddLine(pos.X + size2, pos.Y - g, pos.X + g, pos.Y - g); gp.AddLine(pos.X + g, pos.Y - g, pos.X + g, pos.Y - size2); gp.AddLine(pos.X + g, pos.Y - size2, pos.X - g, pos.Y - size2); gp.AddLine(pos.X - g, pos.Y - size2, pos.X - g, pos.Y - g); gp.AddLine(pos.X - g, pos.Y - g, pos.X - size2, pos.Y - g); gp.AddLine(pos.X - size2, pos.Y - g, pos.X - size2, pos.Y + g); break; case MarkerStyle.Circle: case MarkerStyle.Dot: x0 = pos.X - size2; y0 = pos.Y - size2; gp.AddEllipse(x0, y0, size, size); break; case MarkerStyle.Dash: x0 = pos.X - size2; y0 = pos.Y - size2 / 3; x1 = pos.X + size2; y1 = pos.Y + size2 / 3; gp.AddLine(x0, y0, x1, y0); gp.AddLine(x1, y0, x1, y1); gp.AddLine(x1, y1, x0, y1); gp.AddLine(x0, y1, x0, y0); break; case MarkerStyle.X: g = size / 4; gp.AddLine(pos.X - size2 + g, pos.Y - size2, pos.X, pos.Y - g); gp.AddLine(pos.X, pos.Y - g, pos.X + size2 - g, pos.Y - size2); gp.AddLine(pos.X + size2 - g, pos.Y - size2, pos.X + size2, pos.Y - size2 + g); gp.AddLine(pos.X + size2, pos.Y - size2 + g, pos.X + g, pos.Y); gp.AddLine(pos.X + g, pos.Y, pos.X + size2, pos.Y + size2 - g); gp.AddLine(pos.X + size2, pos.Y + size2 - g, pos.X + size2 - g, pos.Y + size2); gp.AddLine(pos.X + size2 - g, pos.Y + size2, pos.X, pos.Y + g); gp.AddLine(pos.X, pos.Y + g, pos.X - size2 + g, pos.Y + size2); gp.AddLine(pos.X - size2 + g, pos.Y + size2, pos.X - size2, pos.Y + size2 - g); gp.AddLine(pos.X - size2, pos.Y + size2 - g, pos.X - g, pos.Y); gp.AddLine(pos.X - g, pos.Y, pos.X - size2, pos.Y - size2 + g); break; case MarkerStyle.Star: { XPoint[] points = new XPoint[10]; double radStep = 2 * Math.PI / 5; double outerCircle = size / 2; double innerCircle = size / 5; // outer circle double rad = -(Math.PI / 2); // 90° for (int idx = 0; idx < 10; idx += 2) { points[idx].X = pos.X + outerCircle * Math.Cos(rad); points[idx].Y = pos.Y + outerCircle * Math.Sin(rad); rad += radStep; } // inner circle rad = -(Math.PI / 4); // 45° double x = innerCircle * Math.Cos(rad); double y = innerCircle * Math.Sin(rad); points[1].X = pos.X + x; points[1].Y = pos.Y + y; points[9].X = pos.X - x; points[9].Y = pos.Y + y; rad += radStep; x = innerCircle * Math.Cos(rad); y = innerCircle * Math.Sin(rad); points[3].X = pos.X + x; points[3].Y = pos.Y + y; points[7].X = pos.X - x; points[7].Y = pos.Y + y; rad += radStep; y = innerCircle * Math.Sin(rad); points[5].X = pos.X; points[5].Y = pos.Y + y; gp.AddLines(points); } break; } gp.CloseFigure(); if (rendererInfo.MarkerStyle != MarkerStyle.Dot) { graphics.DrawPath(background, gp); graphics.DrawPath(foreground, gp); } }
private static void RenderToGraphics(Render.RenderContext ctx, int rot, float translateX, float translateY, XGraphics graphics) { graphics.TranslateTransform(translateX, translateY); graphics.RotateTransform(rot * 90); using (Maps.Rendering.RenderUtil.SaveState(graphics)) { if (ctx.clipPath != null) { XMatrix m = ctx.ImageSpaceToWorldSpace; graphics.MultiplyTransform(m); graphics.IntersectClip(ctx.clipPath); m.Invert(); graphics.MultiplyTransform(m); } ctx.graphics = graphics; Maps.Rendering.Render.RenderTile(ctx); } if (ctx.border && ctx.clipPath != null) { using (Maps.Rendering.RenderUtil.SaveState(graphics)) { // Render border in world space XMatrix m = ctx.ImageSpaceToWorldSpace; graphics.MultiplyTransform(m); XPen pen = new XPen(ctx.styles.imageBorderColor, 0.2f); // PdfSharp can't ExcludeClip so we take advantage of the fact that we know // the path starts on the left edge and proceeds clockwise. We extend the // path with a counterclockwise border around it, then use that to exclude // the original path's region for rendering the border. ctx.clipPath.Flatten(); RectangleF bounds = PathUtil.Bounds(ctx.clipPath); bounds.Inflate(2 * (float)pen.Width, 2 * (float)pen.Width); List<byte> types = new List<byte>(ctx.clipPath.Internals.GdiPath.PathTypes); List<PointF> points = new List<PointF>(ctx.clipPath.Internals.GdiPath.PathPoints); PointF key = points[0]; points.Add(new PointF(bounds.Left, key.Y)); types.Add(1); points.Add(new PointF(bounds.Left, bounds.Bottom)); types.Add(1); points.Add(new PointF(bounds.Right, bounds.Bottom)); types.Add(1); points.Add(new PointF(bounds.Right, bounds.Top)); types.Add(1); points.Add(new PointF(bounds.Left, bounds.Top)); types.Add(1); points.Add(new PointF(bounds.Left, key.Y)); types.Add(1); points.Add(new PointF(key.X, key.Y)); types.Add(1); XGraphicsPath path = new XGraphicsPath(points.ToArray(), types.ToArray(), XFillMode.Winding); graphics.IntersectClip(path); graphics.DrawPath(pen, ctx.clipPath); } } }
public override void Draw(XGraphics graphics, Palette palette, DrawingContext context) { Random random = new Random(Name.GetHashCode()); var topLeft = InnerBounds.GetCorner(CompassPoint.NorthWest); var topRight = InnerBounds.GetCorner(CompassPoint.NorthEast); var bottomLeft = InnerBounds.GetCorner(CompassPoint.SouthWest); var bottomRight = InnerBounds.GetCorner(CompassPoint.SouthEast); var topCenter = InnerBounds.GetCorner(CompassPoint.North); var rightCenter = InnerBounds.GetCorner(CompassPoint.East); var bottomCenter = InnerBounds.GetCorner(CompassPoint.South); var leftCenter = InnerBounds.GetCorner(CompassPoint.West); var top = new LineSegment(topLeft, topRight); var right = new LineSegment(topRight, bottomRight); var bottom = new LineSegment(bottomRight, bottomLeft); var left = new LineSegment(bottomLeft, topLeft); var halfTopRight = new LineSegment(topCenter, topRight); var halfBottomRight = new LineSegment(bottomRight, bottomCenter); var centerVertical = new LineSegment(bottomCenter, topCenter); var centerHorizontal = new LineSegment(leftCenter, rightCenter); var halfRightBottom = new LineSegment(rightCenter, bottomRight); var halfLeftBottom = new LineSegment(bottomLeft, leftCenter); var slantUp = new LineSegment(bottomLeft, topRight); var slantDown = new LineSegment(bottomRight, topLeft); context.LinesDrawn.Add(top); context.LinesDrawn.Add(right); context.LinesDrawn.Add(bottom); context.LinesDrawn.Add(left); var brush = context.Selected ? palette.BorderBrush : palette.FillBrush; // Room specific fill brush (White shows global color) if (RoomFill != ColorTranslator.FromHtml("White") && RoomFill != ColorTranslator.FromHtml("#FFFFFF")) { brush = new SolidBrush(RoomFill); } if (!Settings.DebugDisableLineRendering) { var path = palette.Path(); Drawing.AddLine(path, top, random); Drawing.AddLine(path, right, random); Drawing.AddLine(path, bottom, random); Drawing.AddLine(path, left, random); graphics.DrawPath(brush, path); // Second fill for room specific colors with a split option if (SecondFill != ColorTranslator.FromHtml("White") && SecondFill != ColorTranslator.FromHtml("#FFFFFF")) { // Set the second fill color brush = new SolidBrush(SecondFill); // Define the second path based on the second fill location var secondPath = palette.Path(); switch (SecondFillLocation) { case "Bottom": Drawing.AddLine(secondPath, centerHorizontal, random); Drawing.AddLine(secondPath, halfRightBottom, random); Drawing.AddLine(secondPath, bottom, random); Drawing.AddLine(secondPath, halfLeftBottom, random); break; case "BottomRight": Drawing.AddLine(secondPath, slantUp, random); Drawing.AddLine(secondPath, right, random); Drawing.AddLine(secondPath, bottom, random); break; case "Right": Drawing.AddLine(secondPath, halfTopRight, random); Drawing.AddLine(secondPath, right, random); Drawing.AddLine(secondPath, halfBottomRight, random); Drawing.AddLine(secondPath, centerVertical, random); break; case "TopRight": Drawing.AddLine(secondPath, top, random); Drawing.AddLine(secondPath, right, random); Drawing.AddLine(secondPath, slantDown, random); break; default: break; } // Draw the second fill over the first graphics.DrawPath(brush, secondPath); } if (IsDark) { var state = graphics.Save(); graphics.IntersectClip(path); brush = context.Selected ? palette.FillBrush : palette.BorderBrush; // Room specific fill brush (White shows global color) if (RoomBorder != ColorTranslator.FromHtml("White") && RoomBorder != ColorTranslator.FromHtml("#FFFFFF")) { brush = new SolidBrush(RoomBorder); } graphics.DrawPolygon(brush, new PointF[] { topRight.ToPointF(), new PointF(topRight.X - Settings.DarknessStripeSize, topRight.Y), new PointF(topRight.X, topRight.Y + Settings.DarknessStripeSize) }, XFillMode.Alternate); graphics.Restore(state); } if (RoomBorder == ColorTranslator.FromHtml("White") || RoomBorder == ColorTranslator.FromHtml("#FFFFFF")) { graphics.DrawPath(palette.BorderPen, path); } else { var RoomBorderPen = new Pen(RoomBorder, Settings.LineWidth); RoomBorderPen.StartCap = LineCap.Round; RoomBorderPen.EndCap = LineCap.Round; graphics.DrawPath(RoomBorderPen, path); } } var font = Settings.LargeFont; brush = context.Selected ? palette.FillBrush : palette.LargeTextBrush; // Room specific fill brush (White shows global color) if (RoomLargeText != ColorTranslator.FromHtml("White") && RoomLargeText != ColorTranslator.FromHtml("#FFFFFF")) { brush = new SolidBrush(RoomLargeText); } Rect textBounds = InnerBounds; textBounds.Inflate(-5, -5); if (textBounds.Width > 0 && textBounds.Height > 0) { m_name.Draw(graphics, font, brush, textBounds.Position, textBounds.Size, XStringFormats.Center); } var expandedBounds = InnerBounds; expandedBounds.Inflate(Settings.ObjectListOffsetFromRoom, Settings.ObjectListOffsetFromRoom); var drawnObjectList = false; font = Settings.SmallFont; brush = palette.SmallTextBrush; // Room specific fill brush (White shows global color) if (RoomSmallText != ColorTranslator.FromHtml("White") && RoomSmallText != ColorTranslator.FromHtml("#FFFFFF")) { brush = new SolidBrush(RoomSmallText); } if (!string.IsNullOrEmpty(Objects)) { XStringFormat format = new XStringFormat(); Vector pos = expandedBounds.GetCorner(m_objectsPosition); if (!Drawing.SetAlignmentFromCardinalOrOrdinalDirection(format, m_objectsPosition)) { // object list appears inside the room below its name format.LineAlignment = XLineAlignment.Far; format.Alignment = XStringAlignment.Near; //format.Trimming = StringTrimming.EllipsisCharacter; //format.FormatFlags = StringFormatFlags.LineLimit; var height = InnerBounds.Height / 2 - font.Height / 2; var bounds = new Rect(InnerBounds.Left + Settings.ObjectListOffsetFromRoom, InnerBounds.Bottom - height, InnerBounds.Width - Settings.ObjectListOffsetFromRoom, height - Settings.ObjectListOffsetFromRoom); brush = context.Selected ? palette.FillBrush : brush; if (bounds.Width > 0 && bounds.Height > 0) { m_objects.Draw(graphics, font, brush, bounds.Position, bounds.Size, format); } drawnObjectList = true; } else if (m_objectsPosition == CompassPoint.North || m_objectsPosition == CompassPoint.South) { pos.X += Settings.ObjectListOffsetFromRoom; } if (!drawnObjectList) { m_objects.Draw(graphics, font, brush, pos, Vector.Zero, format); } } }