/// <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) { return(e); } if (!_moving && Rect.Contains(e.Point)) { int x = Parent.X + X; int y = Parent.Y + Y; int index = ((_listY + e.Point.Y) - y) / RowHeight; int rowIndex = index; // If headers are present the rowIndex needs to be offset if (ShowHeaders) { rowIndex--; } int columnIndex = 0; DataGridColumn dataGridColumn; Geom.Rectangle rect; for (int i = 0; i < _columns.Count; i++) { dataGridColumn = (DataGridColumn)_columns[i]; rect = new Geom.Rectangle(x, y, dataGridColumn.Width, Height); if (rect.Contains(e.Point)) { 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); }