/// <summary> /// Renders the ListItem onto the provided bitmap. /// </summary> /// <param name="bitmap">Bitmap this item will be drawn on.</param> public override void Render(Display.Graphics bitmap) { Width = Parent.Width; bitmap.DrawTextInRect(Label, X, Y + (Height - _font.Height) / 2, Width, _font.Height, Bitmaps.DT_AlignmentCenter, TinyCLR2.Glide.Ext.Colors.Black, _font); bitmap.DrawLine(TinyCLR2.Glide.Ext.Colors.LightGray, 1, 0, Y + Height, Width, Y + Height); }
/// <summary> /// Disposes all disposable objects in this object. /// </summary> public override void Dispose() { if (_bitmap != null) { _bitmap.Dispose(); _bitmap = null; } }
/// <summary> /// Creates a new DataGrid component. /// </summary> /// <param name="name">name</param> /// <param name="alpha">alpha</param> /// <param name="x">x</param> /// <param name="y">y</param> /// <param name="width">width</param> /// <param name="rowHeight">rowHeight</param> /// <param name="rowCount">rowCount</param> public DataGrid(string name, ushort alpha, int x, int y, int width, int rowHeight, int rowCount) { Name = name; Alpha = 255; X = x; Y = y; Width = width; RowHeight = rowHeight; // Setting the RowCount changes the Height. RowCount = rowCount; // Show headers is on by default. // When the headers are shown the row count is decreased by one. ShowHeaders = true; _headers = new Display.Graphics(Width, rowHeight); Clear(); }
/// <summary> /// Renders the List onto it's parent container's graphics. /// </summary> public override void Render() { // Only render the child bitmap if children change if (NumChildren > 0 && _renderedWithNumChildren < NumChildren) { _renderedWithNumChildren = NumChildren; _bitmap = new Display.Graphics(Width, NumChildren * this[0].Height); _bitmap.DrawRectangle(TinyCLR.Glide.Ext.Colors.White, 1, 0, 0, _bitmap.GetBitmap().Width, _bitmap.GetBitmap().Height, 0, 0, Colors.Transparent, 0, 0, Colors.Transparent, 0, 0, Alpha); for (int i = 0; i < NumChildren; i++) { ((ListItem)this[i]).Render(_bitmap); } _listMaxY = _bitmap.GetBitmap().Height - Height; } Graphics.DrawRectangle(TinyCLR.Glide.Ext.Colors.Black, 0, 0, 0, Glide.LCD.Width, Glide.LCD.Height, 0, 0, TinyCLR.Glide.Ext.Colors.Black, 0, 0, TinyCLR.Glide.Ext.Colors.Black, 0, 0, 0xff); Graphics.DrawImage(X, Y, _bitmap.GetBitmap(), 0, _listY, Width, Height); }
/// <summary> /// Renders the DataGrid onto it's parent container's graphics. /// </summary> public override void Render() { if (ShowHeaders && _renderHeaders) { _renderHeaders = false; RenderHeaders(); } if (_renderItems) { _renderItems = false; // Only recreate the items Bitmap if necessary if (_items == null || _items.GetBitmap().Height != _rows.Count * RowHeight) { if (_items != null) { _items.Dispose(); } if (_rows.Count < _rowCount) { _items = new Display.Graphics(Width, _rowCount * RowHeight); RenderEmpty(); } else { _items = new Display.Graphics(Width, _rows.Count * RowHeight); } } else { _items.DrawRectangle(Colors.Black, 1, 0, 0, Width, _items.GetBitmap().Height, 0, 0, TinyCLR2.Glide.Ext.Colors.Transparent, 0, 0, TinyCLR2.Glide.Ext.Colors.Transparent, 0, 0, 255); } if (_rows.Count > 0) { for (int i = 0; i < _rows.Count; i++) { UpdateItem(i, false); } } } int x = Parent.X + X; int y = Parent.Y + Y; if (_showHeaders) { Parent.Graphics.DrawImage(x, y, _headers.GetBitmap(), 0, 0, Width, RowHeight); y += RowHeight; } Parent.Graphics.DrawImage(x, y, _items.GetBitmap(), 0, _listY, Width, _rowCount * RowHeight); if (ShowScrollbar) { _scrollbarHeight = RowHeight; int travel = Height - _scrollbarHeight; if (_rows.Count > 0) { _scrollbarTick = (int)System.Math.Round((double)(travel / _rows.Count)); } else { _scrollbarTick = 0; } _scrollbarHeight = Height - ((_rows.Count - _rowCount) * _scrollbarTick); x += Width - ScrollbarWidth; y = Parent.Y + Y; Parent.Graphics.DrawRectangle(TinyCLR2.Glide.Ext.Colors.Black, 0, x, y, ScrollbarWidth, Height, 0, 0, ScrollbarBackColor, 0, 0, TinyCLR2.Glide.Ext.Colors.Black, 0, 0, 255); // Only show the scrollbar scrubber if it's smaller than the Height if (_scrollbarHeight < Height) { Parent.Graphics.DrawRectangle(TinyCLR2.Glide.Ext.Colors.Black, 0, x, y + (_scrollIndex * _scrollbarTick), ScrollbarWidth, _scrollbarHeight, 0, 0, ScrollbarScrubberColor, 0, 0, TinyCLR2.Glide.Ext.Colors.Black, 0, 0, 255); } } }
/// <summary> /// Renders this display object on a specified bitmap. /// </summary> /// <param name="bitmap"></param> public virtual void Render(Display.Graphics bitmap) { // Do something }