Ejemplo n.º 1
0
 public void Draw(Canvas canvas, XGraphics graphics, Palette palette, DrawingContext context)
 {
     Drawing.DrawHandle(canvas, graphics, palette, bounds, context, false, false);
 }
Ejemplo n.º 2
0
        private void RegionListBox_DrawItem(object sender, DrawItemEventArgs e)
        {
            using (var palette = new Palette())
              {
            e.DrawBackground();

            var colorBounds = new Rectangle(e.Bounds.Left + HORIZONTAL_MARGIN, e.Bounds.Top + VERTICAL_MARGIN, WIDTH, e.Bounds.Height - VERTICAL_MARGIN*2);
            var textBounds = new Rectangle(colorBounds.Right + HORIZONTAL_MARGIN, e.Bounds.Top, e.Bounds.Width - colorBounds.Width - HORIZONTAL_MARGIN*2, e.Bounds.Height);
            var firstOrDefault = Settings.Regions.FirstOrDefault(p => p.RegionName == cboRegion.Items[e.Index].ToString());
            if (firstOrDefault != null) e.Graphics.FillRectangle(palette.Brush(firstOrDefault.RColor), colorBounds);
            e.Graphics.DrawRectangle(palette.Pen(e.ForeColor, 0), colorBounds);
            e.Graphics.DrawString(cboRegion.Items[e.Index].ToString(), e.Font, palette.Brush(e.ForeColor), textBounds, StringFormats.Left);
              }
        }
Ejemplo n.º 3
0
        private static void Annotate(XGraphics graphics, Palette palette, LineSegment lineSegment, TextBlock text, StringAlignment alignment, RoomShape? shape = RoomShape.SquareCorners)
        {
            Vector point;
              var delta = lineSegment.Delta;
              switch (alignment)
              {
            case StringAlignment.Near:
            default:
              point = lineSegment.Start;
              delta.Negate();
              break;
            case StringAlignment.Center:
              point = lineSegment.Mid;
              break;
            case StringAlignment.Far:
              point = lineSegment.End;
              break;
              }

              var bounds = new Rect(point, Vector.Zero);
              bounds.Inflate(Settings.TextOffsetFromConnection);

              var angle = (float) -(Math.Atan2(delta.Y, delta.X)/Math.PI*180.0);
              var compassPoint = CompassPoint.East;
              if (Numeric.InRange(angle, 0, 45))
              {
            compassPoint = CompassPoint.NorthWest;
              }
              else if (Numeric.InRange(angle, 45, 90))
              {
            compassPoint = CompassPoint.SouthEast;
              }
              else if (Numeric.InRange(angle, 90, 135))
              {
            compassPoint = CompassPoint.SouthWest;
              }
              else if (Numeric.InRange(angle, 135, 180))
              {
            compassPoint = CompassPoint.NorthEast;
              }
              else if (Numeric.InRange(angle, 0, -45))
              {
            compassPoint = CompassPoint.NorthEast;
              }
              else if (Numeric.InRange(angle, -45, -90))
              {
            compassPoint = CompassPoint.NorthEast;
              }
              else if (Numeric.InRange(angle, -90, -135))
              {
            compassPoint = CompassPoint.NorthWest;
              }
              else if (Numeric.InRange(angle, -135, -180))
              {
            compassPoint = CompassPoint.SouthEast;
              }

              var pos = bounds.GetCorner(compassPoint);
              var format = new XStringFormat();
              Drawing.SetAlignmentFromCardinalOrOrdinalDirection(format, compassPoint);
              if (alignment == StringAlignment.Center && Numeric.InRange(angle, -10, 10))
              {
            // HACK: if the line segment is pretty horizontal and we're drawing mid-line text,
            // move text below the line to get it out of the way of any labels at the ends,
            // and center the text so it fits onto a line between two proximal rooms.
            pos = bounds.GetCorner(CompassPoint.South);
            format.Alignment = XStringAlignment.Center;
            format.LineAlignment = XLineAlignment.Near;
              }

              if (!Settings.DebugDisableTextRendering)
            text.Draw(graphics, Settings.LineFont, palette.LineTextBrush, pos, Vector.Zero, format);
        }
Ejemplo n.º 4
0
        private void Annotate(XGraphics graphics, Palette palette, List<LineSegment> lineSegments)
        {
            if (lineSegments.Count == 0)
            return;

              if (!string.IsNullOrEmpty(StartText))
              {
            Annotate(graphics, palette, lineSegments[0], m_startText, StringAlignment.Near, GetSourceRoom()?.Shape);
              }

              if (!string.IsNullOrEmpty(EndText))
              {
            Annotate(graphics, palette, lineSegments[lineSegments.Count - 1], m_endText, StringAlignment.Far, GetTargetRoom()?.Shape);
              }

              if (!string.IsNullOrEmpty(MidText))
              {
            var totalLength = lineSegments.Sum(lineSegment => lineSegment.Length);
            var middle = totalLength/2;
            foreach (var lineSegment in lineSegments)
            {
              var length = lineSegment.Length;
              if (middle > length)
              {
            middle -= length;
              }
              else
              {
            middle /= length;
            var pos = lineSegment.Start + lineSegment.Delta*middle;
            var fakeSegment = new LineSegment(pos - lineSegment.Delta*Numeric.Small, pos + lineSegment.Delta*Numeric.Small);
            Annotate(graphics, palette, fakeSegment, m_midText, StringAlignment.Center);
            break;
              }
            }
              }
        }
Ejemplo n.º 5
0
        protected override void OnPaint(PaintEventArgs e)
        {
            if (DesignMode)
            {
                e.Graphics.Clear(Settings.Color[Colors.Canvas]);
                return;
            }

            foreach (var element in Project.Current.Elements)
            {
                element.Flagged = false;
            }
            foreach (var element in Canvas.SelectedElements)
            {
                element.Flagged = true;
            }

            using (var nativeGraphics = Graphics.FromHdc(e.Graphics.GetHdc()))
            {
                using (var graphics = XGraphics.FromGraphics(nativeGraphics, new XSize(Width, Height)))
                {
                    using (var palette = new Palette())
                    {
                        var clientArea = new Rectangle(0, 0, Width, Height);

                        ControlPaint.DrawBorder3D(nativeGraphics, clientArea, Border3DStyle.Raised);
                        clientArea.Inflate(-OuterBorderSize, -OuterBorderSize);
                        nativeGraphics.FillRectangle(SystemBrushes.Control, clientArea);
                        clientArea.Inflate(-OuterPadding, -OuterPadding);
                        ControlPaint.DrawBorder3D(nativeGraphics, clientArea, Border3DStyle.SunkenOuter);
                        clientArea.Inflate(-InnerBorderSize, -InnerBorderSize);

                        nativeGraphics.FillRectangle(palette.CanvasBrush, clientArea);
                        clientArea.Inflate(-InnerPadding, -InnerPadding);

                        //nativeGraphics.FillRectangle(Brushes.Cyan, clientArea);

                        var canvasBounds = Canvas != null?Canvas.ComputeCanvasBounds(false) : Rect.Empty;

                        var borderPen = palette.Pen(Settings.Color[Colors.Border], 0);
                        foreach (var element in Project.Current.Elements)
                        {
                            if (element is Room)
                            {
                                var room       = (Room)element;
                                var roomBounds = CanvasToClient(room.InnerBounds.ToRectangleF(), canvasBounds, clientArea);
                                graphics.DrawRectangle(borderPen, room.Flagged ? palette.BorderBrush : palette.FillBrush, roomBounds);
                            }
                        }

                        if (Canvas != null)
                        {
                            // draw the viewport area as a selectable "handle"
                            var viewportBounds = CanvasToClient(Canvas.Viewport.ToRectangleF(), canvasBounds, clientArea);
                            viewportBounds.Intersect(clientArea);
                            if (Project.Current.Elements.Count > 0)
                            {
                                var context = new DrawingContext(1f);
                                context.Selected = m_draggingViewport;
                                Drawing.DrawHandle(Canvas, graphics, palette, new Rect(viewportBounds), context, true, false);
                            }
                        }
                    }
                }
            }
            e.Graphics.ReleaseHdc();

            base.OnPaint(e);
        }
Ejemplo n.º 6
0
        public override void Draw(XGraphics graphics, Palette palette, DrawingContext context)
        {
            var lineSegments = context.UseSmartLineSegments ? m_smartSegments : GetSegments();

              foreach (var lineSegment in lineSegments)
              {
            var pen = palette.GetLinePen(context.Selected, context.Hover, Style == ConnectionStyle.Dashed);
            Pen specialPen = null;

            if (!context.Hover)
              if ((ConnectionColor != Color.Transparent) && !context.Selected)
              {
            specialPen = (Pen) pen.Clone();
            specialPen.Color = ConnectionColor;
              }

            if (!Settings.DebugDisableLineRendering)
            {
              graphics.DrawLine(specialPen ?? pen, lineSegment.Start.ToPointF(), lineSegment.End.ToPointF());
            }
            var delta = lineSegment.Delta;
            if (Flow == ConnectionFlow.OneWay && delta.Length > Settings.ConnectionArrowSize)
            {
              SolidBrush brush = (SolidBrush) palette.GetLineBrush(context.Selected, context.Hover);
              SolidBrush specialBrush = null;

              if (!context.Hover)
            if ((ConnectionColor != Color.Transparent) && !context.Selected)
            {
              specialBrush = (SolidBrush) brush.Clone();
              specialBrush.Color = ConnectionColor;
            }

              Drawing.DrawChevron(graphics, lineSegment.Mid.ToPointF(), (float) (Math.Atan2(delta.Y, delta.X)/Math.PI*180), Settings.ConnectionArrowSize, specialBrush ?? brush);
            }
            context.LinesDrawn.Add(lineSegment);
              }

              Annotate(graphics, palette, lineSegments);
        }
Ejemplo n.º 7
0
        private void ColorListBox_DrawItem(object sender, DrawItemEventArgs e)
        {
            using (var palette = new Palette())
              {
            e.DrawBackground();

            const int horizontalMargin = 2;
            const int verticalMargin = 2;
            const int width = 24;
            var colorBounds = new Rectangle(e.Bounds.Left + horizontalMargin, e.Bounds.Top + verticalMargin, width, e.Bounds.Height - verticalMargin * 2);
            var textBounds = new Rectangle(colorBounds.Right + horizontalMargin, e.Bounds.Top, e.Bounds.Width - colorBounds.Width - horizontalMargin * 2, e.Bounds.Height);
            e.Graphics.FillRectangle(palette.Brush(Color[e.Index]), colorBounds);
            e.Graphics.DrawRectangle(palette.Pen(e.ForeColor, 0), colorBounds);
            StringFormat format = new StringFormat {Trimming = StringTrimming.EllipsisCharacter};
            e.Graphics.DrawString(m_colorListBox.Items[e.Index].ToString(), e.Font, palette.Brush(e.ForeColor), textBounds, format);
              }
        }
Ejemplo n.º 8
0
        private static void Annotate(XGraphics graphics, Palette palette, LineSegment lineSegment, TextBlock text, StringAlignment alignment)
        {
            Vector point;
            var    delta = lineSegment.Delta;

            switch (alignment)
            {
            case StringAlignment.Near:
            default:
                point = lineSegment.Start;
                delta.Negate();
                break;

            case StringAlignment.Center:
                point = lineSegment.Mid;
                break;

            case StringAlignment.Far:
                point = lineSegment.End;
                break;
            }

            var bounds = new Rect(point, Vector.Zero);

            bounds.Inflate(Settings.TextOffsetFromConnection);

            var angle        = (float)-(Math.Atan2(delta.Y, delta.X) / Math.PI * 180.0);
            var compassPoint = CompassPoint.East;

            if (Numeric.InRange(angle, 0, 45))
            {
                compassPoint = CompassPoint.NorthWest;
            }
            else if (Numeric.InRange(angle, 45, 90))
            {
                compassPoint = CompassPoint.SouthEast;
            }
            else if (Numeric.InRange(angle, 90, 135))
            {
                compassPoint = CompassPoint.SouthWest;
            }
            else if (Numeric.InRange(angle, 135, 180))
            {
                compassPoint = CompassPoint.NorthEast;
            }
            else if (Numeric.InRange(angle, 0, -45))
            {
                compassPoint = CompassPoint.NorthEast;
            }
            else if (Numeric.InRange(angle, -45, -90))
            {
                compassPoint = CompassPoint.NorthEast;
            }
            else if (Numeric.InRange(angle, -90, -135))
            {
                compassPoint = CompassPoint.NorthWest;
            }
            else if (Numeric.InRange(angle, -135, -180))
            {
                compassPoint = CompassPoint.SouthEast;
            }

            var           pos    = bounds.GetCorner(compassPoint);
            XStringFormat format = new XStringFormat();

            Drawing.SetAlignmentFromCardinalOrOrdinalDirection(format, compassPoint);
            if (alignment == StringAlignment.Center && Numeric.InRange(angle, -10, 10))
            {
                // HACK: if the line segment is pretty horizontal and we're drawing mid-line text,
                // move text below the line to get it out of the way of any labels at the ends,
                // and center the text so it fits onto a line between two proximal rooms.
                pos = bounds.GetCorner(CompassPoint.South);
                format.Alignment     = XStringAlignment.Center;
                format.LineAlignment = XLineAlignment.Near;
            }
            text.Draw(graphics, Settings.LineFont, palette.LineBrush, pos, Vector.Zero, format);
        }
Ejemplo n.º 9
0
        public static void DrawHandle(Canvas canvas, XGraphics graphics, Palette palette, Rect bounds, DrawingContext context, bool alwaysAlpha, bool round)
        {
            if (bounds.Width <= 0 || bounds.Height <= 0)
              {
            return;
              }

              using (var quality = new Smoothing(graphics, XSmoothingMode.Default))
              {
            XBrush brush;
            Pen pen;
            var alpha = 180;

            if (context.Selected)
            {
              if (!alwaysAlpha)
              {
            alpha = 255;
              }
              brush = palette.Gradient(bounds, Color.FromArgb(alpha, Color.LemonChiffon), Color.FromArgb(alpha, Color.DarkOrange));
              pen = palette.Pen(Color.FromArgb(alpha, Color.Chocolate), 0);
            }
            else
            {
              brush = palette.Gradient(bounds, Color.FromArgb(alpha, Color.LightCyan), Color.FromArgb(alpha, Color.SteelBlue));
              pen = palette.Pen(Color.FromArgb(alpha, Color.Navy), 0);
            }

            if (round)
            {
              graphics.DrawEllipse(brush, bounds.ToRectangleF());
              graphics.DrawEllipse(pen, bounds.ToRectangleF());
            }
            else
            {
              graphics.DrawRectangle(brush, bounds.ToRectangleF());
              graphics.DrawRectangle(pen, bounds.ToRectangleF());
            }
              }
        }
Ejemplo n.º 10
0
 public void Draw(Canvas canvas, XGraphics graphics, Palette palette, DrawingContext context)
 {
     Drawing.DrawHandle(canvas, graphics, palette, bounds, context, false, false);
 }
Ejemplo n.º 11
0
        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);
                }
            }
        }
Ejemplo n.º 12
0
 public virtual void Draw(Canvas canvas, XGraphics graphics, Palette palette, DrawingContext context)
 {
     Drawing.DrawHandle(canvas, graphics, palette, VisualBounds, context, false, true);
 }
Ejemplo n.º 13
0
        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);
        }
Ejemplo n.º 14
0
 public virtual void Draw(Canvas canvas, XGraphics graphics, Palette palette, DrawingContext context)
 {
     Drawing.DrawHandle(canvas, graphics, palette, visualBounds, context, false, true);
 }
Ejemplo n.º 15
0
        private void RegionListBox_DrawItem(object sender, DrawItemEventArgs e)
        {
            if (e.Index < 0) return;
              Font txtColorFont = new Font("Arial", 6);
              using (var palette = new Palette())
              {
            e.DrawBackground();

            var colorBounds = new Rectangle(e.Bounds.Left + HORIZONTAL_MARGIN, e.Bounds.Top + VERTICAL_MARGIN, WIDTH, e.Bounds.Height - VERTICAL_MARGIN * 2);
            var textBounds = new Rectangle(colorBounds.Right + HORIZONTAL_MARGIN, e.Bounds.Top, e.Bounds.Width - colorBounds.Width - HORIZONTAL_MARGIN * 2, e.Bounds.Height);
            var foundRegion = Regions.FirstOrDefault(p => p.RegionName == m_RegionListing.Items[e.Index].ToString());
            if (foundRegion != null)
            {
              e.Graphics.FillRectangle(palette.Brush(foundRegion.RColor), colorBounds);
              e.Graphics.DrawRectangle(palette.Pen(e.ForeColor, 0), colorBounds);
              e.Graphics.DrawString(m_RegionListing.Items[e.Index].ToString(), e.Font, palette.Brush(e.ForeColor), textBounds, StringFormats.Left);
              e.Graphics.DrawString("123", txtColorFont, palette.Brush(foundRegion.TextColor), colorBounds, StringFormats.Center);
            }
              }
        }
Ejemplo n.º 16
0
        protected override void OnPaint(PaintEventArgs e)
        {
            if (DesignMode)
            {
                e.Graphics.Clear(Settings.Color[Colors.Canvas]);
                return;
            }

            foreach (var element in Project.Current.Elements)
            {
                element.Flagged = false;
            }
            foreach (var element in Canvas.SelectedElements)
            {
                element.Flagged = true;
            }

            using (var nativeGraphics = Graphics.FromHdc(e.Graphics.GetHdc()))
            {
                using (var graphics = XGraphics.FromGraphics(nativeGraphics, new XSize(Width, Height)))
                {
                    using (var palette = new Palette())
                    {
                        var clientArea = new Rectangle(0, 0, Width, Height);

                        ControlPaint.DrawBorder3D(nativeGraphics, clientArea, Border3DStyle.Raised);
                        clientArea.Inflate(-OuterBorderSize, -OuterBorderSize);
                        nativeGraphics.FillRectangle(SystemBrushes.Control, clientArea);
                        clientArea.Inflate(-OuterPadding, -OuterPadding);
                        ControlPaint.DrawBorder3D(nativeGraphics, clientArea, Border3DStyle.SunkenOuter);
                        clientArea.Inflate(-InnerBorderSize, -InnerBorderSize);

                        nativeGraphics.FillRectangle(palette.CanvasBrush, clientArea);
                        clientArea.Inflate(-InnerPadding, -InnerPadding);

                        //nativeGraphics.FillRectangle(Brushes.Cyan, clientArea);

                        var canvasBounds = Canvas != null ? Canvas.ComputeCanvasBounds(false) : Rect.Empty;

                        var borderPen = palette.Pen(Settings.Color[Colors.Border], 0);
                        foreach (var element in Project.Current.Elements)
                        {
                            if (element is Room)
                            {
                                var room = (Room)element;
                                var roomBounds = CanvasToClient(room.InnerBounds.ToRectangleF(), canvasBounds, clientArea);
                                graphics.DrawRectangle(borderPen, room.Flagged ? palette.BorderBrush : palette.FillBrush, roomBounds);
                            }
                        }

                        if (Canvas != null)
                        {
                            // draw the viewport area as a selectable "handle"
                            var viewportBounds = CanvasToClient(Canvas.Viewport.ToRectangleF(), canvasBounds, clientArea);
                            viewportBounds.Intersect(clientArea);
                            if (Project.Current.Elements.Count > 0)
                            {
                                var context = new DrawingContext(1f);
                                context.Selected = m_draggingViewport;
                                Drawing.DrawHandle(Canvas, graphics, palette, new Rect(viewportBounds), context, true, false);
                            }
                        }
                    }
                }
            }
            e.Graphics.ReleaseHdc();

            base.OnPaint(e);
        }
Ejemplo n.º 17
0
        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);
                }
            }
        }