public override void DrawFrame(Rectangle rect, FrameOptions opts = null) { var style = opts?.Style ?? FrameStyle.Single; var rectOpts = new RectangleOptions { Attributes = opts?.Attributes ?? CharAttribute.None, Background = opts?.Background ?? CharColor.Black, Foreground = opts?.Foreground ?? CharColor.White }; DrawRectangle(new Rectangle(rect.X + 1, rect.Y, rect.Width - 2, 1), Piece(FramePiece.Horizontal, style), rectOpts); DrawRectangle(new Rectangle(rect.X + 1, rect.Y + rect.Height - 1, rect.Width - 2, 1), Piece(FramePiece.Horizontal, style), rectOpts); DrawRectangle(new Rectangle(rect.X, rect.Y + 1, 1, rect.Height - 2), Piece(FramePiece.Vertical, style), rectOpts); DrawRectangle(new Rectangle(rect.X + rect.Width - 1, rect.Y + 1, 1, rect.Height - 2), Piece(FramePiece.Vertical, style), rectOpts); PutChar(new Point(rect.X, rect.Y), Piece(FramePiece.Bottom | FramePiece.Right, style), rectOpts.Foreground, rectOpts.Background, rectOpts.Attributes); PutChar(new Point(rect.X + rect.Width - 1, rect.Y), Piece(FramePiece.Bottom | FramePiece.Left, style), rectOpts.Foreground, rectOpts.Background, rectOpts.Attributes); PutChar(new Point(rect.X, rect.Y + rect.Height - 1), Piece(FramePiece.Top | FramePiece.Right, style), rectOpts.Foreground, rectOpts.Background, rectOpts.Attributes); PutChar(new Point(rect.X + rect.Width - 1, rect.Y + rect.Height - 1), Piece(FramePiece.Top | FramePiece.Left, style), rectOpts.Foreground, rectOpts.Background, rectOpts.Attributes); }
public override void DrawRectangle(Rectangle rect, char fill, RectangleOptions opts = null) { var clippedRect = rect.Clip(0, 0, _width, _height); if (clippedRect.Width == 0 || clippedRect.Height == 0) { return; } for (var x = clippedRect.X; x < clippedRect.X + clippedRect.Width; x++) { for (var y = clippedRect.Y; y < clippedRect.Y + clippedRect.Height; y++) { PutChar(new Point(x, y), fill, opts?.Foreground ?? CharColor.White, opts?.Background ?? CharColor.Black, opts?.Attributes ?? CharAttribute.None); } } }
public SCMap AddRectangle(double[] location, double width, double height, RectangleOptions options = null) { options ??= new RectangleOptions(); var mapItem = new MapRectangle(); if (location == null || location.Length != 2) { throw new Exception("Location must be double array with 2 elements."); } mapItem.Location = CreateCoordPoint(location[0], location[1]); mapItem.Height = height; mapItem.Width = width; options.ConfigureMapItem(this, mapItem); return(this); }
public abstract void DrawRectangle(Rectangle rect, char fill, RectangleOptions opts = null);
/// <summary> /// The set options. /// </summary> /// <param name="options"> /// The options. /// </param> public extern void SetOptions(RectangleOptions options);
/// <summary> /// Create a rectangle using the passed RectangleOptions, which specify /// the bounds and style. /// </summary> /// <param name="opts">The options.</param> public extern Rectangle(RectangleOptions opts = null);
protected override void OnRender(DrawingContext context) { var style = Console.Focused == this ? FrameStyle.Double : FrameStyle.Single; var wpt = (ActualWidth - 1) / Children.Count - 1; if (wpt < 2) { return; } context.DrawFrame(new Rectangle(0, 0, ActualWidth, ActualHeight), new FrameOptions { Style = Console.Focused == this ? FrameStyle.Double : FrameStyle.Single, Foreground = Foreground, Background = Background }); var txo = new TextOptions { Background = Background, Foreground = Foreground }; context.PutChar(new Point(0, 2), Piece(FramePiece.Vertical | FramePiece.Right, style), Foreground, Background, CharAttribute.None); context.PutChar(new Point(ActualWidth - 1, 2), Piece(FramePiece.Vertical | FramePiece.Left, style), Foreground, Background, CharAttribute.None); var ro = new RectangleOptions { Foreground = Foreground, Background = Background }; context.DrawRectangle(new Rectangle(1, 0, ActualWidth - 2, 1), Piece(FramePiece.Horizontal, style), ro); context.DrawRectangle(new Rectangle(1, 2, ActualWidth - 2, 1), Piece(FramePiece.Horizontal, style), ro); const int padding = 2; var strPadding = new string(' ', padding); var lengths = Children.Select(x => ((Tab)x).Title.Length + 2 * padding); var selectedOffset = lengths.Take(SelectedIndex).Sum(x => x + 1); var selectedLen = (SelectedTab?.Title.Length ?? 0) + 2 * padding; if (selectedOffset + _scroll < 0) { _scroll = -selectedOffset; } if (selectedOffset + selectedLen + _scroll > ActualWidth - 2) { _scroll = ActualWidth - 2 - selectedOffset - selectedLen; } var headerContext = context.Shrink(new Rectangle(1, 0, ActualWidth - 2, 3)).Scroll(new Point(-1 + _scroll, 0)); for (int i = 0, ofs = 0; i < Children.Count; i++) { var tab = (Tab)Children[i]; var len = Math.Max(tab.Title.Length, 1); headerContext.DrawText( new Point(ofs + 1, 1), $"{strPadding}{tab.Title}{strPadding}", i == SelectedIndex ? new TextOptions { Foreground = Background, Background = Foreground } : txo); ofs += len + 1 + 2 * padding; headerContext.PutChar(new Point(ofs, 1), Piece(FramePiece.Vertical, style), Foreground, Background, CharAttribute.None); headerContext.PutChar(new Point(ofs, 0), Piece(FramePiece.Horizontal | FramePiece.Bottom, style), Foreground, Background, CharAttribute.None); headerContext.PutChar(new Point(ofs, 2), Piece(FramePiece.Horizontal | FramePiece.Top, style), Foreground, Background, CharAttribute.None); } }
public override void DrawRectangle(Rectangle rect, char fill, RectangleOptions opts = null) { }