public override void Draw(XGraphics graphics, Palette palette, DrawingContext context) { List <LineSegment> lineSegments; if (context.UseSmartLineSegments) { lineSegments = m_smartSegments; } else { lineSegments = GetSegments(); } var path = palette.Path(); var random = new Random(GetHashCode()); foreach (var lineSegment in lineSegments) { var pen = palette.GetLinePen(context.Selected, context.Hover, Style == ConnectionStyle.Dashed); if (!Settings.DebugDisableLineRendering) { graphics.DrawLine(pen, lineSegment.Start.ToPointF(), lineSegment.End.ToPointF()); } var delta = lineSegment.Delta; if (Flow == ConnectionFlow.OneWay && delta.Length > Settings.ConnectionArrowSize) { var brush = palette.GetLineBrush(context.Selected, context.Hover); Drawing.DrawChevron(graphics, lineSegment.Mid.ToPointF(), (float)(Math.Atan2(delta.Y, delta.X) / Math.PI * 180), Settings.ConnectionArrowSize, brush); } context.LinesDrawn.Add(lineSegment); } Annotate(graphics, palette, lineSegments); }
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); } } }
public override void Draw(XGraphics graphics, Palette palette, DrawingContext context) { List<LineSegment> lineSegments; if (context.UseSmartLineSegments) { lineSegments = m_smartSegments; } else { lineSegments = GetSegments(); } var path = palette.Path(); var random = new Random(GetHashCode()); foreach (var lineSegment in lineSegments) { var pen = palette.GetLinePen(context.Selected, context.Hover, Style == ConnectionStyle.Dashed); if (!Settings.DebugDisableLineRendering) { graphics.DrawLine(pen, lineSegment.Start.ToPointF(), lineSegment.End.ToPointF()); } var delta = lineSegment.Delta; if (Flow == ConnectionFlow.OneWay && delta.Length > Settings.ConnectionArrowSize) { var brush = palette.GetLineBrush(context.Selected, context.Hover); Drawing.DrawChevron(graphics, lineSegment.Mid.ToPointF(), (float)(Math.Atan2(delta.Y, delta.X) / Math.PI * 180), Settings.ConnectionArrowSize, brush); } context.LinesDrawn.Add(lineSegment); } Annotate(graphics, palette, lineSegments); }
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); } } }