Beispiel #1
0
        /// <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 #2
0
        /// <summary>
        /// Renders the DataGrid onto it's parent container's graphics.
        /// </summary>
        public override void OnRender(DrawingContext dc)
        {
            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 GlideGraphics(Width, _rowCount * RowHeight);

                        RenderEmpty();
                    }
                    else
                    {
                        _items = new GlideGraphics(Width, _rows.Count * RowHeight);
                    }
                }
                else
                {
                    _items.DrawRectangle(Glide.Ext.Colors.Black, 1, 0, 0, Width, _items.GetBitmap().Height, 0, 0, Glide.Ext.Colors.Transparent, 0, 0, Glide.Ext.Colors.Transparent, 0, 0, 255);
                }

                if (_rows.Count > 0)
                {
                    for (int i = 0; i < _rows.Count; i++)
                    {
                        UpdateItem(i, false);
                    }
                }
            }

            int x = /*this.Parent._finalX +*/ X;
            int y = /*this.Parent._finalY +*/ Y;

            if (_showHeaders)
            {
                //BitmapImage.FromGraphics(System.Drawing.Graphics.FromImage(x))
                dc.DrawImage(BitmapImage.FromGraphics(System.Drawing.Graphics.FromImage(_headers.GetBitmap())), x, y, 0, 0, Width, RowHeight);
                y += RowHeight;
            }

            dc.DrawImage(BitmapImage.FromGraphics(System.Drawing.Graphics.FromImage(_items.GetBitmap())), x, y, 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*/ 0 + Y;

                //dc.DrawRectangle(Glide.Ext.Colors.Black, 0, x, y, ScrollbarWidth, Height, 0, 0, ScrollbarBackColor, 0, 0, Glide.Ext.Colors.Black, 0, 0, 255);
                var pen = new Media.Pen(Media.Colors.Black, 0);
                dc.DrawRectangle(new SolidColorBrush(Media.Colors.Black), pen, x, y, ScrollbarWidth, Height);

                // Only show the scrollbar scrubber if it's smaller than the Height
                if (_scrollbarHeight < Height)
                {
                    //dc.DrawRectangle(Glide.Ext.Colors.Black, 0, x, y + (_scrollIndex * _scrollbarTick), ScrollbarWidth, _scrollbarHeight, 0, 0, ScrollbarScrubberColor, 0, 0, Glide.Ext.Colors.Black, 0, 0, 255);
                    pen = new Media.Pen(Media.Colors.Black, 0);
                    dc.DrawRectangle(new SolidColorBrush(Media.Colors.Black), pen, x, y + (_scrollIndex * _scrollbarTick), ScrollbarWidth, _scrollbarHeight);
                }
            }
        }
        /// <summary>
        /// Renders the Button onto it's parent container's graphics.
        /// </summary>
        public override void OnRender(DrawingContext dc)
        {
            int x = 0; //Rect.X;
            int y = 0; //Rect.Y;

            // HACK: To prevent image/color retention.
            //Parent.Graphics.DrawRectangle(Rect, TinyCLR2.Glide.Ext.Colors.Black, 255);
            var pen   = new Media.Pen(Media.Colors.Black, 0);
            var brush = new SolidColorBrush(Media.Colors.Black);

            dc.DrawRectangle(brush, pen, Rect.X, Rect.Y, Rect.Width, Rect.Height);

            //FillRect(dc,Rect);
            dc.DrawRectangle(base.Background, pen, Rect.X, Rect.Y, Rect.Width, Rect.Height);

            if (_direction == SliderDirection.Horizontal)
            {
                int lineY   = y + (Height / 2);
                int offsetX = _knob.Width / 2;
                int knobY   = Height - _knob.Height;
                int tickX;
                int tickHeight = (int)System.Math.Ceiling(Height * 0.05);
                pen = new Media.Pen(TickColor, 1);
                dc.DrawLine(pen, x + offsetX, lineY, x + offsetX + _lineSize, lineY);

                if (TickInterval > 1)
                {
                    for (int i = 0; i < TickInterval + 1; i++)
                    {
                        tickX = x + offsetX + (int)(i * _tickSize);
                        pen   = new Media.Pen(TickColor, 1);
                        dc.DrawLine(pen, tickX, y, tickX, y + tickHeight);
                    }
                }

                if (_dragging)
                {
                    dc.Scale9Image(x + _knob.X, y + knobY, _knob.Width, _knob.Height, BitmapImage.FromGraphics(System.Drawing.Graphics.FromImage(_Button_Down)), 5, 5, 5, 5, Alpha);
                }
                else
                {
                    dc.Scale9Image(x + _knob.X, y + knobY, _knob.Width, _knob.Height, BitmapImage.FromGraphics(System.Drawing.Graphics.FromImage(_Button_Up)), 5, 5, 5, 5, Alpha);
                }
            }
            else
            {
                int lineX   = x + (Width / 2);
                int offsetY = _knob.Height / 2;
                int knobX   = Width - _knob.Width;
                int tickY;
                int tickWidth = (int)System.Math.Ceiling(Width * 0.05);
                pen = new Media.Pen(TickColor, 1);
                dc.DrawLine(pen, lineX, y + offsetY, lineX, y + offsetY + _lineSize);

                if (TickInterval > 1)
                {
                    for (int i = 0; i < TickInterval + 1; i++)
                    {
                        tickY = y + offsetY + (int)(i * _tickSize);
                        pen   = new Media.Pen(TickColor, 1);
                        dc.DrawLine(pen, x, tickY, x + tickWidth, tickY);
                    }
                }

                if (_dragging)
                {
                    dc.Scale9Image(x + knobX, y + _knob.Y, _knob.Width, _knob.Height, BitmapImage.FromGraphics(System.Drawing.Graphics.FromImage(_Button_Down)), 5, 5, 5, 5, Alpha);
                }
                else
                {
                    dc.Scale9Image(x + knobX, y + _knob.Y, _knob.Width, _knob.Height, BitmapImage.FromGraphics(System.Drawing.Graphics.FromImage(_Button_Up)), 5, 5, 5, 5, Alpha);
                }
            }
        }