Beispiel #1
0
        // Get a paint context for this window
        public PaintContext GetPaintContext()
        {
            // Create buffer?
            if (_buf == null)
            {
                _buf = new CharInfo[FrameRectangle.Width * FrameRectangle.Height];
            }

            var ctx = new PaintContext(_buf, FrameRectangle.Size, new Rect(1, 1, FrameRectangle.Width - 2, FrameRectangle.Height - 2));

            ctx.Attributes = _clearAttributes;
            _manager.Invalidate(this);
            return(ctx);
        }
Beispiel #2
0
        // Called by manager to draw this window - including frame
        public virtual CharInfo[] Draw()
        {
            // Create buffer?
            if (_buf == null)
            {
                _buf = new CharInfo[FrameRectangle.Width * FrameRectangle.Height];
                _needsFrameRender  = true;
                _needsClientRender = true;
            }

            // Create paint context for the frame
            var px = new PaintContext(_buf, new Size(FrameRectangle.Width, FrameRectangle.Height), new Rect(0, 0, FrameRectangle.Width, FrameRectangle.Height));

            // Paint frame?
            if (_needsFrameRender || _frameRenderedActive != IsActive)
            {
                _frameRenderedActive = IsActive;

                // Draw border
                if (IsActive)
                {
                    px.ForegroundColor = _manager.ActiveBorderLineColor;
                    px.BackgroundColor = _manager.ActiveBorderBackgroundColor;
                }
                else
                {
                    px.ForegroundColor = _manager.InactiveBorderLineColor;
                    px.BackgroundColor = _manager.InactiveBorderBackgroundColor;
                }
                px.DrawBox(new Rect(0, 0, FrameRectangle.Width, FrameRectangle.Height), IsActive);

                // Draw title
                if (!string.IsNullOrEmpty(Title))
                {
                    var title  = " " + Title + " ";
                    int titleX = (FrameRectangle.Width - title.Length) / 2;
                    if (titleX < 2)
                    {
                        titleX = 2;
                    }

                    for (int i = 0; i < title.Length && i < FrameRectangle.Width - 4; i++)
                    {
                        _buf[titleX + i].Char = title[i];
                    }
                }
            }

            // Paint client area
            if (_needsClientRender)
            {
                var ctx = new PaintContext(_buf, FrameRectangle.Size, new Rect(1, 1, FrameRectangle.Width - 2, FrameRectangle.Height - 2));
                ctx.Attributes = _clearAttributes;
                ctx.Clear();
                OnPaint(ctx);
            }

            _needsClientRender = false;
            _needsFrameRender  = false;

            return(_buf);
        }
Beispiel #3
0
 // Override to paint the context of this window
 public virtual void OnPaint(PaintContext ctx)
 {
 }