Example #1
0
        /// <summary>
        /// Handles the touch down event.
        /// </summary>
        /// <param name="e">Touch event arguments.</param>
        /// <returns>Touch event arguments.</returns>
        public override TouchEventArgs OnTouchDown(TouchEventArgs e)
        {
            // Global coordinates to local coordinates
            Point localPoint = new Point(e.Point.X - Rect.X, e.Point.Y - Rect.Y);

            if (_knob.Contains(localPoint))
            {
                _dragging = true;
                Invalidate();

                if (_touchThread == null || (_touchThread != null && !_touchThread.IsAlive))
                {
                    GlideTouch.IgnoreAllEvents = true;
                    _touchThread          = new Thread(TouchThread);
                    _touchThread.Priority = ThreadPriority.Highest;
                    _touchThread.Start();
                }

                e.StopPropagation();
                return(e);
            }

            if (Rect.Contains(e.Point))
            {
                RenderKnob(e.Point);
                e.StopPropagation();
            }

            return(e);
        }
        /// <summary>
        /// Handles the touch up event.
        /// </summary>
        /// <param name="e">Touch event arguments.</param>
        /// <returns>Touch event arguments.</returns>
        public override TouchEventArgs OnTouchUp(TouchEventArgs e)
        {
            if (_pressed && Rect.Contains(e.Point))
            {
                _pressed = false;

                if (For != null)
                {
                    if (For is CheckBox)
                    {
                        CheckBox checkBox = (CheckBox)For;
                        checkBox.Checked = !checkBox.Checked;
                        checkBox.TriggerTapEvent(checkBox);
                    }
                    else if (For is RadioButton)
                    {
                        // Radio buttons have rules for changing their selected
                        // value so we must call a toggle function.
                        ((RadioButton)For).Toggle();
                    }
                }
                else
                {
                    TriggerTapEvent(this);
                }

                e.StopPropagation();
            }

            return(e);
        }
Example #3
0
        /// <summary>
        /// Handles the touch down event.
        /// </summary>
        /// <param name="e">Touch event arguments.</param>
        /// <returns>Touch event arguments.</returns>
        public override TouchEventArgs OnTouchDown(TouchEventArgs e)
        {
            Rectangle keyCoord;

            for (int i = 0; i < _keyCoords.Length; i++)
            {
                keyCoord = _keyCoords[i];

                if (keyCoord.Contains(e.Point) && _keyActive[i] && (_keyValues[i] != null && _keyValues[i] != ""))
                {
                    _downIndex = i;

                    DrawKeyDown(i);

                    if (_keyValues[i] == ActionKey.Backspace)
                    {
                        _touchEventArgs = e;
                    }

                    e.StopPropagation();
                    break;
                }
            }
            return(e);
        }
        /// <summary>
        /// Handles the touch up event.
        /// </summary>
        /// <param name="e">Touch event arguments.</param>
        /// <returns>Touch event arguments.</returns>
        public override TouchEventArgs OnTouchUp(TouchEventArgs e)
        {
            if (!_pressed)
            {
                TriggerCloseEvent(this);
                _ignoredTouchMoves = 0;
                return(e);
            }

            if (!_moving)
            {
                int      index  = (int)System.Math.Floor(((_listY + e.Point.Y) - Y) / this[0].Height);
                ListItem option = (ListItem)this[index];
                TriggerTapOptionEvent(this, new TapOptionEventArgs(index, option.Label, option.Value));
            }
            else
            {
                _moving = false;
            }

            _pressed           = false;
            _ignoredTouchMoves = 0;
            e.StopPropagation();
            return(e);
        }
Example #5
0
        /// <summary>
        /// Handles the touch move event.
        /// </summary>
        /// <param name="e">Touch event arguments.</param>
        /// <returns>Touch event arguments.</returns>
        public override TouchEventArgs OnTouchMove(TouchEventArgs e)
        {
            if (!Draggable || !_pressed || _rows.Count <= RowCount)
            {
                return(e);
            }

            if (!_moving)
            {
                if (_ignoredTouchMoves < _maxIgnoredTouchMoves)
                {
                    _ignoredTouchMoves++;
                }
                else
                {
                    _ignoredTouchMoves = 0;
                    _moving            = true;
                }
            }
            else
            {
                _listY = _lastListY - (e.Point.Y - _lastTouchY);
                _listY = GlideUtils.Math.MinMax(_listY, 0, _listMaxY);

                _scrollIndex = (int)System.Math.Ceiling(_listY / RowHeight);

                Invalidate();
                e.StopPropagation();
            }

            return(e);
        }
        /// <summary>
        /// Handles the touch move event.
        /// </summary>
        /// <param name="e">Touch event arguments.</param>
        /// <returns>Touch event arguments.</returns>
        public override TouchEventArgs OnTouchMove(TouchEventArgs e)
        {
            // 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(e);
            }

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

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

            e.StopPropagation();
            return(e);
        }
 /// <summary>
 /// Handles the touch down event.
 /// </summary>
 /// <param name="e">Touch event arguments.</param>
 /// <returns>Touch event arguments.</returns>
 public override TouchEventArgs OnTouchDown(TouchEventArgs e)
 {
     if (Rect.Contains(e.Point))
     {
         _pressed = true;
         e.StopPropagation();
     }
     return(e);
 }
        /// <summary>
        /// Handles the touch up event.
        /// </summary>
        /// <param name="e">Touch event arguments.</param>
        /// <returns>Touch event arguments.</returns>
        public override TouchEventArgs OnTouchUp(TouchEventArgs e)
        {
            if (Rect.Contains(e.Point) && _pressed)
            {
                Toggle();
                e.StopPropagation();
            }

            return(e);
        }
 /// <summary>
 /// Handles the touch down event.
 /// </summary>
 /// <param name="e">Touch event arguments.</param>
 /// <returns>Touch event arguments.</returns>
 public override TouchEventArgs OnTouchDown(TouchEventArgs e)
 {
     if (Rect.Contains(e.Point))
     {
         _pressed = true;
         Invalidate();
         TriggerPressEvent(this);
         e.StopPropagation();
     }
     return(e);
 }
Example #10
0
 /// <summary>
 /// Handles the touch up event.
 /// </summary>
 /// <param name="e">Touch event arguments.</param>
 /// <returns>Touch event arguments.</returns>
 public override TouchEventArgs OnTouchUp(TouchEventArgs e)
 {
     if (Rect.Contains(e.Point) && _pressed)
     {
         _pressed = false;
         Checked  = !Checked;
         TriggerTapEvent(this);
         e.StopPropagation();
     }
     return(e);
 }
        /// <summary>
        /// Handles the touch down event.
        /// </summary>
        /// <param name="e">Touch event arguments.</param>
        /// <returns>Touch event arguments.</returns>
        public override TouchEventArgs OnTouchDown(TouchEventArgs e)
        {
            // Only register a press if our tap event has listeners.
            if (!TapEventIsNull() && Rect.Contains(e.Point))
            {
                _pressed = true;
                e.StopPropagation();
            }

            return(e);
        }
        /// <summary>
        /// Handles the touch down event.
        /// </summary>
        /// <param name="e">Touch event arguments.</param>
        /// <returns>Touch event arguments.</returns>
        public override TouchEventArgs OnTouchDown(TouchEventArgs e)
        {
            if (Rect.Contains(e.Point))
            {
                e.StopPropagation();
                _lastPressY = e.Point.Y;
                _lastListY  = _listY;
                _pressed    = true;
            }

            return(e);
        }
Example #13
0
        /// <summary>
        /// Handles the touch down event.
        /// </summary>
        /// <param name="e">Touch event arguments.</param>
        /// <returns>Touch event arguments.</returns>
        public override TouchEventArgs OnTouchDown(TouchEventArgs e)
        {
            if (Rect.Contains(e.Point) && _rows.Count > 0)
            {
                _pressed    = true;
                _lastTouchY = e.Point.Y;
                _lastListY  = _listY;
                e.StopPropagation();
            }

            return(e);
        }
Example #14
0
 /// <summary>
 /// Handles the touch up event.
 /// </summary>
 /// <param name="e">Touch event arguments.</param>
 /// <returns>Touch event arguments.</returns>
 public override TouchEventArgs OnTouchUp(TouchEventArgs e)
 {
     if (Rect.Contains(e.Point))
     {
         if (_pressed)
         {
             _pressed = false;
             Invalidate();
             TriggerTapEvent(this);
             e.StopPropagation();
         }
     }
     else
     {
         if (_pressed)
         {
             _pressed = false;
             Invalidate();
         }
     }
     return(e);
 }
Example #15
0
        /// <summary>
        /// Handles the touch up event.
        /// </summary>
        /// <param name="e">Touch event arguments.</param>
        /// <returns>Touch event arguments.</returns>
        public override TouchEventArgs OnTouchUp(TouchEventArgs e)
        {
            Point localPoint = new Point(e.Point.X - Rect.X, e.Point.Y - Rect.Y);

            if (_knob.Contains(localPoint))
            {
                if (_dragging)
                {
                    _dragging = false;
                    Invalidate();
                    e.StopPropagation();
                }
            }
            else
            {
                if (_dragging)
                {
                    _dragging = false;
                    Invalidate();
                }
            }
            return(e);
        }
Example #16
0
        /// <summary>
        /// Handles the touch down event.
        /// </summary>
        /// <param name="e">Touch event arguments.</param>
        /// <returns>Touch event arguments.</returns>
        public override TouchEventArgs OnTouchDown(TouchEventArgs e)
        {
            if (Rect.Contains(e.Point) && _rows.Count > 0)
            {
                _pressed = true;
                _lastTouchY = e.Point.Y;
                _lastListY = _listY;
                e.StopPropagation();
            }

            return e;
        }
Example #17
0
        /// <summary>
        /// Handles the touch down event.
        /// </summary>
        /// <param name="e">Touch event arguments.</param>
        /// <returns>Touch event arguments.</returns>
        public override TouchEventArgs OnTouchDown(TouchEventArgs e)
        {
            // Only register a press if our tap event has listeners.
            if (!TapEventIsNull() && Rect.Contains(e.Point))
            {
                _pressed = true;
                e.StopPropagation();
            }

            return e;
        }
Example #18
0
 /// <summary>
 /// Handles the touch up event.
 /// </summary>
 /// <param name="e">Touch event arguments.</param>
 /// <returns>Touch event arguments.</returns>
 public override TouchEventArgs OnTouchUp(TouchEventArgs e)
 {
     if (Rect.Contains(e.Point) && _pressed)
     {
         _pressed = false;
         Checked = !Checked;
         TriggerTapEvent(this);
         e.StopPropagation();
     }
     return e;
 }
Example #19
0
 /// <summary>
 /// Handles the touch up event.
 /// </summary>
 /// <param name="e">Touch event arguments.</param>
 /// <returns>Touch event arguments.</returns>
 public override TouchEventArgs OnTouchUp(TouchEventArgs e)
 {
     if (Rect.Contains(e.Point))
     {
         if (_pressed)
         {
             _pressed = false;
             Invalidate();
             TriggerReleaseEvent(this);
             TriggerTapEvent(this);
             e.StopPropagation();
         }
     }
     else
     {
         if (_pressed)
         {
             _pressed = false;
             TriggerReleaseEvent(this);
             Invalidate();
         }
     }
     return e;
 }
Example #20
0
 /// <summary>
 /// Handles the touch down event.
 /// </summary>
 /// <param name="e">Touch event arguments.</param>
 /// <returns>Touch event arguments.</returns>
 public override TouchEventArgs OnTouchDown(TouchEventArgs e)
 {
     if (Rect.Contains(e.Point))
     {
         _pressed = true;
         Invalidate();
         TriggerPressEvent(this);
         e.StopPropagation();
     }
     return e;
 }
Example #21
0
        /// <summary>
        /// Handles the touch up event.
        /// </summary>
        /// <param name="e">Touch event arguments.</param>
        /// <returns>Touch event arguments.</returns>
        public override TouchEventArgs OnTouchUp(TouchEventArgs e)
        {
            if (_pressed && Rect.Contains(e.Point))
            {
                _pressed = false;

                if (For != null)
                {
                    if (For is CheckBox)
                    {
                        CheckBox checkBox = (CheckBox)For;
                        checkBox.Checked = !checkBox.Checked;
                        checkBox.TriggerTapEvent(checkBox);
                    }
                    else if (For is RadioButton)
                    {
                        // Radio buttons have rules for changing their selected
                        // value so we must call a toggle function.
                        ((RadioButton)For).Toggle();
                    }
                }
                else
                {
                    TriggerTapEvent(this);
                }

                e.StopPropagation();
            }

            return e;
        }
Example #22
0
 /// <summary>
 /// Handles the touch down event.
 /// </summary>
 /// <param name="e">Touch event arguments.</param>
 /// <returns>Touch event arguments.</returns>
 public override TouchEventArgs OnTouchDown(TouchEventArgs e)
 {
     if (Rect.Contains(e.Point))
     {
         _pressed = true;
         e.StopPropagation();
     }
     return e;
 }
Example #23
0
        /// <summary>
        /// Handles the touch up event.
        /// </summary>
        /// <param name="e">Touch event arguments.</param>
        /// <returns>Touch event arguments.</returns>
        public override TouchEventArgs OnTouchUp(TouchEventArgs e)
        {
            if (Rect.Contains(e.Point) && _pressed)
            {
                Toggle();
                e.StopPropagation();
            }

            return e;
        }
Example #24
0
        /// <summary>
        /// Handles the touch up event.
        /// </summary>
        /// <param name="e">Touch event arguments.</param>
        /// <returns>Touch event arguments.</returns>
        public override TouchEventArgs OnTouchUp(TouchEventArgs e)
        {
            Point localPoint = new Point(e.Point.X - Rect.X, e.Point.Y - Rect.Y);

            if (_knob.Contains(localPoint))
            {
                if (_dragging)
                {
                    _dragging = false;
                    Invalidate();
                    e.StopPropagation();
                }
            }
            else
            {
                if (_dragging)
                {
                    _dragging = false;
                    Invalidate();
                }
            }
            return e;
        }
Example #25
0
        /// <summary>
        /// Handles the touch up event.
        /// </summary>
        /// <param name="e">Touch event arguments.</param>
        /// <returns>Touch event arguments.</returns>
        public override TouchEventArgs OnTouchUp(TouchEventArgs e)
        {
            // A key must be down
            if (_downIndex == -1)
                return e;

            _touchEventArgs = null;

            // If we just finished holding backspace down
            // avoid doing more logic than needed.
            if (_tapHold)
            {
                _tapHold = false;
                _downIndex = -1;
                Invalidate();
                e.StopPropagation();
                return e;
            }

            Rectangle keyCoord;
            for (int i = 0; i < _keyCoords.Length; i++)
            {
                keyCoord = _keyCoords[i];

                if (keyCoord.Contains(e.Point) && _downIndex == i)
                {
                    switch (_keyValues[i])
                    {
                        case ActionKey.ToggleCase:
                            Uppercase = !Uppercase;
                            if (Uppercase)
                                _bitmapIndex = 0;
                            else
                                _bitmapIndex = 1;

                            _downIndex = -1;
                            Invalidate();
                            e.StopPropagation();
                            return e;

                        case ActionKey.ToSymbols:
                            _view = View.Symbols;
                            CalculateKeys();
                            _bitmapIndex = 3;

                            _downIndex = -1;
                            Invalidate();
                            e.StopPropagation();
                            return e;

                        case ActionKey.ToNumbers:
                            _view = View.Numbers;
                            CalculateKeys();
                            _bitmapIndex = 2;

                            _downIndex = -1;
                            Invalidate();
                            e.StopPropagation();
                            return e;

                        case ActionKey.ToLetters:
                            _view = View.Letters;
                            CalculateKeys();
                            Uppercase = true;
                            _bitmapIndex = 0;

                            _downIndex = -1;
                            Invalidate();
                            e.StopPropagation();
                            return e;

                        default:
                            if (_keyValues[i] != ActionKey.Return)
                            {
                                _downIndex = -1;
                                Invalidate();
                            }

                            // Triggering a TapKeyEvent will reset the keyboard and make the current index (i) out of range.
                            // Switching to numbers makes keyValues 34 length
                            // Tapping done is index 33 causing the keyboard to close and reset.
                            // When reset, we switch back to letters and keyValues becomes 33 length
                            // Now our index (33) is out of range.
                            TriggerTapKeyEvent(this, new TapKeyEventArgs((Uppercase) ? _keyValues[i].ToUpper() : _keyValues[i], i));

                            e.StopPropagation();
                            return e;
                    }
                }
            }

            // Released outside of keyboard
            _downIndex = -1;
            Invalidate();

            return e;
        }
Example #26
0
        /// <summary>
        /// Handles the touch move event.
        /// </summary>
        /// <param name="e">Touch event arguments.</param>
        /// <returns>Touch event arguments.</returns>
        public override TouchEventArgs OnTouchMove(TouchEventArgs e)
        {
            if (!Draggable || !_pressed || _rows.Count <= RowCount)
                return e;

            if (!_moving)
            {
                if (_ignoredTouchMoves < _maxIgnoredTouchMoves)
                    _ignoredTouchMoves++;
                else
                {
                    _ignoredTouchMoves = 0;
                    _moving = true;
                }
            }
            else
            {
                _listY = _lastListY - (e.Point.Y - _lastTouchY);
                _listY = GlideUtils.Math.MinMax(_listY, 0, _listMaxY);

                _scrollIndex = (int)System.Math.Ceiling((double)_listY / RowHeight);

                Invalidate();
                e.StopPropagation();
            }

            return e;
        }
Example #27
0
        /// <summary>
        /// Handles the touch down event.
        /// </summary>
        /// <param name="e">Touch event arguments.</param>
        /// <returns>Touch event arguments.</returns>
        public override TouchEventArgs OnTouchDown(TouchEventArgs e)
        {
            // Global coordinates to local coordinates
            Point localPoint = new Point(e.Point.X - Rect.X, e.Point.Y - Rect.Y);

            if (_knob.Contains(localPoint))
            {
                _dragging = true;
                Invalidate();

                if (_touchThread == null || (_touchThread != null && !_touchThread.IsAlive))
                {
                    GlideTouch.IgnoreAllEvents = true;
                    _touchThread = new Thread(TouchThread);
                    _touchThread.Priority = ThreadPriority.Highest;
                    _touchThread.Start();
                }

                e.StopPropagation();
                return e;
            }

            if (Rect.Contains(e.Point))
            {
                RenderKnob(e.Point);
                e.StopPropagation();
            }

            return e;
        }
Example #28
0
        /// <summary>
        /// Handles the touch up event.
        /// </summary>
        /// <param name="e">Touch event arguments.</param>
        /// <returns>Touch event arguments.</returns>
        public override TouchEventArgs OnTouchUp(TouchEventArgs e)
        {
            // A key must be down
            if (_downIndex == -1)
            {
                return(e);
            }

            _touchEventArgs = null;

            // If we just finished holding backspace down
            // avoid doing more logic than needed.
            if (_tapHold)
            {
                _tapHold   = false;
                _downIndex = -1;
                Invalidate();
                e.StopPropagation();
                return(e);
            }

            Rectangle keyCoord;

            for (int i = 0; i < _keyCoords.Length; i++)
            {
                keyCoord = _keyCoords[i];

                if (keyCoord.Contains(e.Point) && _downIndex == i)
                {
                    switch (_keyValues[i])
                    {
                    case ActionKey.ToggleCase:
                        Uppercase = !Uppercase;
                        if (Uppercase)
                        {
                            _bitmapIndex = 0;
                        }
                        else
                        {
                            _bitmapIndex = 1;
                        }

                        _downIndex = -1;
                        Invalidate();
                        e.StopPropagation();
                        return(e);

                    case ActionKey.ToSymbols:
                        _view = View.Symbols;
                        CalculateKeys();
                        _bitmapIndex = 3;

                        _downIndex = -1;
                        Invalidate();
                        e.StopPropagation();
                        return(e);

                    case ActionKey.ToNumbers:
                        _view = View.Numbers;
                        CalculateKeys();
                        _bitmapIndex = 2;

                        _downIndex = -1;
                        Invalidate();
                        e.StopPropagation();
                        return(e);

                    case ActionKey.ToLetters:
                        _view = View.Letters;
                        CalculateKeys();
                        Uppercase    = true;
                        _bitmapIndex = 0;

                        _downIndex = -1;
                        Invalidate();
                        e.StopPropagation();
                        return(e);

                    default:
                        if (_keyValues[i] != ActionKey.Return)
                        {
                            _downIndex = -1;
                            Invalidate();
                        }

                        // Triggering a TapKeyEvent will reset the keyboard and make the current index (i) out of range.
                        // Switching to numbers makes keyValues 34 length
                        // Tapping done is index 33 causing the keyboard to close and reset.
                        // When reset, we switch back to letters and keyValues becomes 33 length
                        // Now our index (33) is out of range.
                        TriggerTapKeyEvent(this, new TapKeyEventArgs((Uppercase) ? _keyValues[i].ToUpper() : _keyValues[i], i));

                        e.StopPropagation();
                        return(e);
                    }
                }
            }

            // Released outside of keyboard
            _downIndex = -1;
            Invalidate();

            return(e);
        }
Example #29
0
        /// <summary>
        /// Handles the touch down event.
        /// </summary>
        /// <param name="e">Touch event arguments.</param>
        /// <returns>Touch event arguments.</returns>
        public override TouchEventArgs OnTouchDown(TouchEventArgs e)
        {
            Rectangle keyCoord;
            for (int i = 0; i < _keyCoords.Length; i++)
            {
                keyCoord = _keyCoords[i];

                if (keyCoord.Contains(e.Point) && _keyActive[i] && (_keyValues[i] != null && _keyValues[i] != ""))
                {
                    _downIndex = i;

                    DrawKeyDown(i);

                    if (_keyValues[i] == ActionKey.Backspace)
                        _touchEventArgs = e;

                    e.StopPropagation();
                    break;
                }
            }
            return e;
        }