/// <summary> /// Handles the touch down event. /// </summary> /// <param name="e">Touch event arguments.</param> /// <returns>Touch event arguments.</returns> protected override void OnTouchDown(TouchEventArgs e) { var x = e.Touches[0].X; var y = e.Touches[0].Y; if (Rect.Contains(x, y) || ButtonUp.Contains(x, y) || ButtonDown.Contains(x, y)) { //e.StopPropagation(); _lastPressY = y; _lastListY = _listY; _pressed = true; } //return e; var evt = new RoutedEvent("TouchDownEvent", RoutingStrategy.Bubble, typeof(RoutedEventHandler)); var args = new RoutedEventArgs(evt, this); //this.Click?.Invoke(this, args); e.Handled = args.Handled; if (this.Parent != null) { this.Invalidate(); } }
/// <summary> /// Handles the touch down event. /// </summary> /// <param name="e">Touch event arguments.</param> /// <returns>Touch event arguments.</returns> protected override void OnTouchDown(TouchEventArgs e) { var x = e.Touches[0].X; var y = e.Touches[0].Y; //e.GetPosition(this.Parent, 0, out int x, out int y); if (Rect.Contains(x, y) && _rows.Count > 0) { _pressed = true; _lastTouchY = y; _lastListY = _listY; //e.StopPropagation(); } var evt = new RoutedEvent("TouchDownEvent", RoutingStrategy.Bubble, typeof(RoutedEventHandler)); var args = new RoutedEventArgs(evt, this); //this.Click?.Invoke(this, args); e.Handled = args.Handled; if (this.Parent != null) { this.Invalidate(); } //return e; }
/// <summary> /// Handles the touch down event. /// </summary> /// <param name="e">Touch event arguments.</param> /// <returns>Touch event arguments.</returns> protected override void OnTouchDown(TouchEventArgs e) { var x = e.Touches[0].X; var y = e.Touches[0].Y; //e.GetPosition(this.Parent, 0, out int x, out int y); // Global coordinates to local coordinates GHIElectronics.TinyCLR.UI.Glide.Geom.Point localPoint = new GHIElectronics.TinyCLR.UI.Glide.Geom.Point(x - Rect.X, 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; } if (Rect.Contains(x, y)) { _lastTouchX = x; _lastTouchY = y; RenderKnob(new Point(x, y)); //e.StopPropagation(); } var evt = new RoutedEvent("TouchDownEvent", RoutingStrategy.Bubble, typeof(RoutedEventHandler)); var args = new RoutedEventArgs(evt, this); //this.Click?.Invoke(this, args); e.Handled = args.Handled; if (this.Parent != null) { this.Invalidate(); } //return e; }
/// <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(); } }