Beispiel #1
0
        private void RenderItem(int index, object[] data, System.Drawing.Color backColor, System.Drawing.Color fontColor)
        {
            int x = 0;
            int y = index * RowHeight;

            _items.DrawRectangle(new Glide.Geom.Rectangle(x, y, Width, RowHeight), backColor, 255);

            //_items.DrawRectangle(0, 0, x, y, Width, RowHeight, 0, 0, backColor.ToNativeColor(), 0, 0, 0, 0, 0, 255);

            DataGridColumn dataGridColumn;

            for (int i = 0; i < _columns.Count; i++)
            {
                dataGridColumn = (DataGridColumn)_columns[i];

                //0
                _items.DrawTextInRect(data[i].ToString(), x + 5, y + (RowHeight - Font.Height) / 2, dataGridColumn.Width, RowHeight, new StringFormat(), fontColor, Font);
                _items.DrawLine(GridColor, 1, x, y, x, y + RowHeight);

                x += dataGridColumn.Width;
            }
        }
        /// <summary>
        /// Renders the List onto it's parent container's graphics.
        /// </summary>
        public override void OnRender(DrawingContext dc)
        {
            // Only render the child bitmap if children change
            if (NumChildren > 0) // && _renderedWithNumChildren < NumChildren
            {
                //_renderedWithNumChildren = NumChildren;
                var start = PageIndex * PageSize;
                var end   = (PageIndex + 1) * PageSize;
                if (end > NumChildren)
                {
                    end = NumChildren;
                }
                _bitmap = new GlideGraphics(_rect.Width, (end - start) * firstHeight);
                _bitmap.DrawRectangle(new Glide.Geom.Rectangle()
                {
                    X = 0, Y = 0, Width = _bitmap.GetBitmap().Width, Height = _bitmap.GetBitmap().Height
                }, System.Drawing.Color.White, 100);                                                                                                                                     //Glide.Ext.Colors.White,1, 0, 0, _bitmap.GetBitmap().Width, _bitmap.GetBitmap().Height, 0, 0, Glide.Ext.Colors.White, 0, 0, Glide.Ext.Colors.White, 0, 0, Alpha);

                int counter = 0;
                for (int i = start; i < end; i++)
                {
                    var item = GetItem(i);
                    item.Render(_bitmap, counter * item.Height);
                    counter++;
                }

                _listMaxY = _bitmap.GetBitmap().Height - Height;
            }
            Media.Brush brush = new SolidColorBrush(Media.Colors.Black);
            var         pen   = new Media.Pen(Media.Colors.Black, 1);

            //dc.DrawRectangle(brush,pen, 0, 0, LCDWidth, LCDHeight);
            dc.DrawImage(BitmapImage.FromGraphics(System.Drawing.Graphics.FromImage(_bitmap.GetBitmap())), X, Y, 0, _listY, _rect.Width, Height);
            Media.Brush buttonBrush = new SolidColorBrush(Media.Colors.Gray);
            //draw button up and down
            dc.DrawRectangle(buttonBrush, pen, _rect.Width, 0, ButtonUp.Width, ButtonUp.Height);
            dc.DrawRectangle(buttonBrush, pen, _rect.Width, ButtonUp.Height, ButtonDown.Width, ButtonDown.Height);
            dc.DrawText("Up", _font, Media.Colors.White, _rect.Width + 5, ButtonUp.Height / 2);
            dc.DrawText("Down", _font, Media.Colors.White, _rect.Width + 5, (ButtonUp.Height) + (ButtonDown.Height / 2));
        }
Beispiel #3
0
        private void RenderHeaders()
        {
            int x = 0;

            _headers.DrawRectangle(new Glide.Geom.Rectangle(x, 0, Width, _headers.GetBitmap().Height), HeadersBackColor, 255);

            //_headers.DrawRectangle(0, 0, x, 0, Width, _headers.Height, 0, 0, HeadersBackColor.ToNativeColor(), 0, 0, 0, 0, 0, 255);

            DataGridColumn dataGridColumn;

            for (int j = 0; j < _columns.Count; j++)
            {
                dataGridColumn = (DataGridColumn)_columns[j];

                // Draw text
                //0
                _headers.DrawTextInRect(dataGridColumn.Label, x + 5, (_headers.GetBitmap().Height - Font.Height) / 2, dataGridColumn.Width, _headers.GetBitmap().Height, new StringFormat(), HeadersFontColor, Font);

                // If we're on the selected column draw the icon.
                if (j == _selectedDataGridColumnIndex)
                {
                    int width = 0, height = 0;
                    //Font.ComputeExtent(dataGridColumn.Label, out width, out height);
                    var size = _headers.GetGraphic().MeasureString(dataGridColumn.Label, Font);
                    width  = (int)size.Width;
                    height = (int)size.Height;
                    if (dataGridColumn.Order == Order.ASC)
                    {
                        _headers.DrawImage(x + 10 + width, 5, _DataGridIcon_Asc, 0, 0, _DataGridIcon_Asc.Width, _DataGridIcon_Asc.Height, 0xff);
                    }
                    else
                    {
                        _headers.DrawImage(x + 10 + width, 5, _DataGridIcon_Desc, 0, 0, _DataGridIcon_Desc.Width, _DataGridIcon_Desc.Height, 0xff);
                    }
                }

                x += dataGridColumn.Width;
            }
        }