Пример #1
0
        /// <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 height, int rowHeight, int rowCount)
        {
            this.ID      = name;
            Width        = width;
            Height       = height;
            Alpha        = 255;
            X            = 0;
            Y            = 0;
            _rect.X      = x;
            _rect.Y      = y;
            _rect.Width  = Width;
            _rect.Height = Height;

            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 GlideGraphics(Width, rowHeight);

            Clear();
        }
Пример #2
0
        /// <summary>
        /// Handles the touch move event.
        /// </summary>
        /// <param name="e">Touch event arguments.</param>
        /// <returns>Touch event arguments.</returns>
        //protected override void OnTouchMove(TouchEventArgs e)
        //{
        //    /*
        //    var x = e.Touches[0].X;
        //    var y = e.Touches[0].Y;
        //    // The pressed state only triggers when touches occur within this UI element's boundaries.
        //    // This check guarantees whether we need to process move events or not.
        //    if (!_pressed)
        //        return;

        //    if (!_moving)
        //    {
        //        if (_ignoredTouchMoves < _maxIgnoredTouchMoves)
        //            _ignoredTouchMoves++;
        //        else
        //            _moving = true;
        //    }
        //    else
        //    {
        //        int dragDistance = y - _lastPressY;
        //        _listY = _lastListY - dragDistance;
        //        _listY = GlideUtils.Math.MinMax(_listY, 0, _listMaxY);

        //        //Graphics.DrawImage(X, Y, _bitmap.GetBitmap(), 0, _listY, Width, Height);
        //        //Glide.Flush(this);
        //    }
        //    */

        //    //e.StopPropagation();
        //    //return e;
        //    var evt = new RoutedEvent("TouchMoveEvent", RoutingStrategy.Bubble, typeof(RoutedEventHandler));
        //    var args = new RoutedEventArgs(evt, this);

        //    //this.Click?.Invoke(this, args);

        //    e.Handled = args.Handled;

        //    //this.isPressed = false;

        //    if (this.Parent != null)
        //        this.Invalidate();
        //}

        /// <summary>
        /// Disposes all disposable objects in this object.
        /// </summary>
        public void  Dispose()
        {
            if (_bitmap != null)
            {
                _bitmap.Dispose();
                _bitmap = null;
            }
        }
Пример #3
0
 public void Render(GlideGraphics bitmap, int Ay)
 {
     Width = Parent.Rect.Width;
     //Bitmaps.DT_AlignmentCenter
     bitmap.DrawTextInRect(Label, X, Ay + (Height - _font.Height) / 2, Width, _font.Height, new StringFormat()
     {
         Alignment = StringAlignment.Center
     }, Glide.Ext.Colors.Black, _font);
     bitmap.DrawLine(System.Drawing.Color.Gray, 1, 0, Ay + Height, Width, Ay + Height);
 }
Пример #4
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));
        }
Пример #5
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);
                }
            }
        }