Esempio n. 1
0
        private void Init()
        {
            if (_direction == SliderDirection.Horizontal)
            {
                _knob     = new Glide.Geom.Rectangle(0, 0, _knobSize, (int)((double)Height / 1.2));
                _lineSize = Width - _knobSize;
            }
            else
            {
                _knob     = new Glide.Geom.Rectangle(0, 0, (int)((double)Width / 1.2), _knobSize);
                _lineSize = Height - _knobSize;
            }

            if (_tickInterval < 0)
            {
                _tickInterval = 0;
            }
            else if (_tickInterval > _lineSize)
            {
                _tickInterval = _lineSize;
            }

            if (_tickInterval > 0)
            {
                _tickSize = (double)_lineSize / TickInterval;
            }
            else
            {
                _tickSize = (double)_lineSize / _lineSize;
            }

            if (_snapInterval < 0)
            {
                _snapInterval = 0;
            }
            else if (_snapInterval > _lineSize)
            {
                _snapInterval = _lineSize;
            }

            if (_snapInterval > 0)
            {
                _snapSize = (double)_lineSize / _snapInterval;
            }
            else
            {
                _snapSize = (double)_lineSize / _lineSize;
            }

            if (_max > 0)
            {
                _pixelsPerValue = _lineSize / (_max - _min);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Creates a new List component.
        /// </summary>
        /// <param name="options">Array of options.</param>
        /// <param name="width">Width</param>
        /// <remarks>The list cannot be smaller than 100 or greater than the LCD size. We recommend keeping the size to a minimum; only use what you need.</remarks>
        public List(ArrayList options, int width, int LcdWidth, int LcdHeight, Window mainWindow)
        {
            Items          = options;
            this.LCDHeight = LcdHeight;
            this.LCDWidth  = LcdWidth;
            object[] option;
            ListItem item;

            firstHeight = 0;
            for (int i = 0; i < options.Count; i++)
            {
                option = (object[])options[i];
                item   = new ListItem(this, option[0].ToString(), option[1]);

                item.Y  = i * item.Height;
                item.ID = "listItem_" + i;
                if (mainWindow != null && mainWindow.Child != null)
                {
                    parent     = mainWindow.Child as Canvas;
                    item.Width = LcdWidth / 2;
                    Children.Add(item.ID, item);
                }
                if (i == 0)
                {
                    firstHeight = item.Height;
                }
            }

            int itemHeight = firstHeight;
            int numItems   = (int)(Math.Floor((double)LCDHeight / itemHeight)) - 1;

            PageSize  = numItems;
            PageIndex = 0;
            MaxPage   = Math.Ceiling((double)NumChildren / PageSize);
            //ID = "list";
            if (width < 100)
            {
                width = 100;
            }
            else if (width > LcdWidth)
            {
                width = LcdWidth;
            }
            Width  = width;
            Height = numItems * itemHeight;
            //Height = NumChildren * itemHeight;

            _rect.X      = (LcdWidth - Width) / 2;
            _rect.Y      = (LcdHeight - Height) / 2;
            _rect.Width  = Width;
            _rect.Height = Height;

            ButtonUp   = new Glide.Geom.Rectangle(_rect.X + _rect.Width, _rect.Y, ButtonWidth, _rect.Height / 2);
            ButtonDown = new Glide.Geom.Rectangle(_rect.X + _rect.Width, _rect.Y + (_rect.Height / 2), ButtonWidth, _rect.Height / 2);
            Width     += ButtonWidth;
            _font      = Resources.GetFont(Resources.FontResources.droid_reg12);

            X = 0;
            Y = 0;

            Canvas.SetLeft(this, _rect.X);
            Canvas.SetTop(this, _rect.Y);
        }
Esempio n. 3
0
        /// <summary>
        /// Handles the touch up event.
        /// </summary>
        /// <param name="e">Touch event arguments.</param>
        /// <returns>Touch event arguments.</returns>
        protected override void OnTouchUp(TouchEventArgs e)//public override TouchEventArgs OnTouchUp(TouchEventArgs e)
        {
            if (!_pressed)
            {
                return;
            }
            var ax = e.Touches[0].X;
            var ay = e.Touches[0].Y;

            //e.GetPosition(this.Parent, 0, out int ax, out int ay);
            if (!_moving && Rect.Contains(ax, ay))
            {
                int x        = Rect.X; ///*parent x*/0 + X;
                int y        = Rect.Y; ///*parent y*/0 + Y;
                int index    = ((_listY + ay) - y) / RowHeight;
                int rowIndex = index;
                // If headers are present the rowIndex needs to be offset
                if (ShowHeaders)
                {
                    rowIndex--;
                }

                int                  columnIndex = 0;
                DataGridColumn       dataGridColumn;
                Glide.Geom.Rectangle rect;

                for (int i = 0; i < _columns.Count; i++)
                {
                    dataGridColumn = (DataGridColumn)_columns[i];
                    rect           = new Glide.Geom.Rectangle(x, y, dataGridColumn.Width, Height);

                    if (rect.Contains(ax, ay))
                    {
                        columnIndex = i;
                        break;
                    }

                    x += dataGridColumn.Width;
                }

                if (index == 0 && ShowHeaders && SortableHeaders)
                {
                    Sort(columnIndex);
                    Invalidate();
                }
                else
                {
                    if (TappableCells)
                    {
                        SelectedIndex = rowIndex;
                        TriggerTapCellEvent(this, new TapCellEventArgs(columnIndex, rowIndex));
                    }
                }
            }

            _pressed           = false;
            _moving            = false;
            _ignoredTouchMoves = 0;
            //return e;
            var evt  = new RoutedEvent("TouchUpEvent", 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();
            }
        }