Esempio n. 1
0
            protected override void OnTouchUp(TouchEventArgs e)
            {
                base.OnTouchUp(e);
#endif

                // Set the flag to draw a circle.
                drawCircle = true;
                int x;
                int y;

#if MF_FRAMEWORK_VERSION_V3_0
                e.GetPosition((UIElement)this, out x, out y);
#else
                e.GetPosition((UIElement)this, 0, out x, out y);
#endif

                cx = x;
                cy = y;

                // Add the last point to the array.
                AddPoint(x, y);

                r = 6;

                // Change the text to show touch up and location.
                text.TextContent = "TouchUp (" + x.ToString() + "," +
                                   y.ToString() + ")";

#if MF_FRAMEWORK_VERSION_V3_0
                Invalidate();
#else
                InvalidateRect(cx - r, cy - r, 2 * r, 2 * r);
#endif
            }
Esempio n. 2
0
        protected override void OnTouchDown(TouchEventArgs e)
        {
            try {
                if (_draggingPointer != -1)
                {
                    return;
                }
                if (e.Pointer == 0 && e.Button != 0)
                {
                    return;
                }

                Vector2 position = e.GetPosition(this);

                if (_handleBounds.Contains(position.X, position.Y))
                {
                    _draggingPointer = e.Pointer;
                    _lastPoint       = position;
                    _handlePosition  = new Vector2(_handleBounds.X, _handleBounds.Y);

                    if (Stage != null)
                    {
                        CaptureTouch(e.Pointer);
                    }

                    e.Handled = true;
                }
            }
            finally {
                base.OnTouchDown(e);
            }
        }
Esempio n. 3
0
        protected override void OnTouchDown(TouchEventArgs e)
        {
            do
            {
                if (e.Pointer == 0 && e.Button != 0)
                {
                    break;
                }
                if (IsDisabled)
                {
                    e.Handled = true;
                    break;
                }

                Vector2 position = e.GetPosition(this);

                ClearSelection();
                SetCursorPosition(position.X);
                _selectionStart = _cursor;

                Stage stage = Stage;
                if (stage != null)
                {
                    stage.SetKeyboardFocus(this);
                }

                OnscreenKeyboard.Show(true);
                //e.Handled = true;
            } while (false);

            base.OnTouchDown(e);
        }
Esempio n. 4
0
        protected override void OnTouchUp(TouchEventArgs e)
        {
            base.OnTouchUp(e);

            int x, y;

            e.GetPosition(this, 0, out x, out y);

            CalibrationManager.CalibrationPoints.TouchX[idx] = (short)x;
            CalibrationManager.CalibrationPoints.TouchY[idx] = (short)y;

            idx++;

            if (idx == CalibrationManager.CalibrationPoints.Count)
            {
                // The last point has been reached.
                CalibrationManager.ApplyCalibrationPoints();
                CalibrationManager.SaveCalibrationPoints();

                Close();

                if (CalibrationComplete != null)
                {
                    CalibrationComplete(this, EventArgs.Empty);
                }
            }

            Invalidate();
        }
Esempio n. 5
0
        protected override void OnTouchDrag(TouchEventArgs e)
        {
            base.OnTouchDrag(e);

            Vector2 position = e.GetPosition(this);

            CalculatePositionAndValue(position.X, position.Y);
        }
Esempio n. 6
0
        /// <summary>
        /// Handles the OnTouchDown event.
        /// </summary>
        /// <param name="e"></param>
        protected override void OnTouchDown(TouchEventArgs e)
        {
            int x = 0;
            int y = 0;

            e.GetPosition(this, 0, out x, out y);

            try
            {
                // Figure out which section of the screen was clicked.
                if (y <= _columnHeaderHeight)
                {
                    // Ignore clicks on column headers.
                }
                else if (y >= (Height - _scrollbarDimension))
                {
                    // The horizontal scrollbar was clicked.
                    OnHorizontalScrollStylusDown(x);
                }
                else if (x >= (Width - _scrollbarDimension))
                {
                    // The vertical scrollbar was clicked.
                    OnVerticalScrollStylusDown(y);
                }
                else
                {
                    // Main section; an item was clicked.

                    int previousIndex = Items.IndexOf(SelectedItem);

                    // Calculate which item was clicked.
                    int index = ((y - _columnHeaderHeight) + _verticalScroll) / _itemHeight;

                    // No item is selected, so select this one.
                    if ((index >= 0) && (index < Items.Count))
                    {
                        SelectedItem = (ListViewItem)Items[index];
                    }
                    else
                    {
                        SelectedItem = null;
                        index        = -1;
                    }

                    // Refresh the list view.
                    Invalidate();

                    if (SelectionChanged != null)
                    {
                        SelectionChanged(this, new SelectionChangedEventArgs(previousIndex, index));
                    }
                }
            }
            catch (IOException ex)
            {
                Debug.Print(ex.ToString());
            }
        }
Esempio n. 7
0
        protected override void OnTouchDrag(TouchEventArgs e)
        {
            base.OnTouchDrag(e);
            Vector2 position = e.GetPosition(this);

            if (_dragging)
            {
                Translate(position.X - _dragOffset.X, position.Y - _dragOffset.Y);
            }
        }
Esempio n. 8
0
        protected override void OnTouchDrag(TouchEventArgs e)
        {
            Vector2 position = e.GetPosition(this);

            _lastBlink = 0;
            _cursorOn  = false;
            SetCursorPosition(position.X);
            _hasSelection = true;

            base.OnTouchDrag(e);
        }
Esempio n. 9
0
            protected override void OnTouchUp(TouchEventArgs e)
            {
                Vector2 position = e.GetPosition(this);

                if (Hit(position.X, position.Y, true) == _list)
                {
                    _selectBox.SelectionIndex = _list.SelectedIndex;
                    _selectBox.HideList();
                }

                base.OnTouchUp(e);
            }
Esempio n. 10
0
            protected override void OnTouchUp(TouchEventArgs e)
            {
                base.OnTouchUp(e);

                TouchCapture.Capture(this, CaptureMode.None);
#endif
                int x;
                int y;

                // Get the position of the event.
#if MF_FRAMEWORK_VERSION_V3_0
                e.GetPosition(this, out x, out y);
#else
                e.GetPosition(this, 0, out x, out y);
#endif

                int r = 0;
                int c = 0;

                // Calculate the row and column.
                r = y / _itemHeight;
                c = x / _itemWidth;

                // Validate the row and column.
                if ((r >= 0) && (r < _row) && (c >= 0) && (c < _column))
                {
                    // Calculate the item.
                    int item = c + r * _column;

                    // Make sure the item is the same one that the touch down
                    // event occurred on.
                    if (item == _pressedItem)
                    {
                        // Trigger a palette event.
                        PaletteEventArg arg = new PaletteEventArg(item);
                        OnItemClick(arg);
                    }
                }
            }
Esempio n. 11
0
            protected override void OnTouchDown(TouchEventArgs e)
            {
                base.OnTouchDown(e);

                TouchCapture.Capture(this);
#endif

                int x;
                int y;

                // Get the position of the event.
#if MF_FRAMEWORK_VERSION_V3_0
                e.GetPosition(this, out x, out y);
#else
                e.GetPosition(this, 0, out x, out y);
#endif

                int r = 0;
                int c = 0;

                // Calculate the row and column.
                r = y / _itemHeight;
                c = x / _itemWidth;

                // Validate the row and column.
                if ((r >= 0) && (r < _row) && (c >= 0) && (c < _column))
                {
                    // Set the item pressed value.
                    _pressedItem = c + r * _column;
                }
                else
                {
                    // Reset the item pressed value.
                    _pressedItem = -1;
                }

                Invalidate();
            }
Esempio n. 12
0
 protected override void OnTouchDown(TouchEventArgs e)
 {
     if (IsEnabled && TouchCapture.Captured != this)
     {
         int x, y;
         e.GetPosition(this, 0, out x, out y);
         if (Utils.IsWithinRectangle(x, y, ActualWidth, ActualHeight))
         {
             TouchCapture.Capture(this);
             pressed = true;
             Invalidate();
         }
     }
 }
Esempio n. 13
0
File: Button.cs Progetto: radtek/MFE
 protected override void OnTouchMove(TouchEventArgs e)
 {
     if (pressed)
     {
         int x, y;
         e.GetPosition(this, 0, out x, out y); // uses UIElement.PointToClient
         if (!Utils.IsWithinRectangle(x, y, ActualWidth, ActualHeight))
         {
             pressed = false;
             Invalidate();
             TouchCapture.Capture(this, CaptureMode.None);
         }
     }
 }
Esempio n. 14
0
            protected override void OnTouchDown(TouchEventArgs e)
            {
                base.OnTouchDown(e);
#endif

                // Start at the beginning of the array and set the flag to draw
                // a circle.
                pointIndex = 0;
                drawCircle = true;

                int x;
                int y;

#if MF_FRAMEWORK_VERSION_V3_0
                e.GetPosition((UIElement)this, out x, out y);
#else
                e.GetPosition((UIElement)this, 0, out x, out y);
#endif

                cx = x;
                cy = y;

                // Add the first point to the array.
                AddPoint(x, y);

                r = 10;

                // Change the text to show touch down and location.
                text.TextContent = "TouchDown (" + x.ToString() + "," +
                                   y.ToString() + ")";

                // Clear the entire screen because we've erased the previous
                // line (if any).
                Invalidate();

                e.Handled = true;
            }
Esempio n. 15
0
            protected override void OnTouchUp(TouchEventArgs e)
            {
                base.OnTouchUp(e);

                int x;
                int y;

                e.GetPosition((UIElement)this, 0, out x, out y);
#endif
                r = 6;

                text.TextContent = x.ToString() + "," + y.ToString();

                Invalidate();
            }
Esempio n. 16
0
File: Button.cs Progetto: radtek/MFE
        protected override void OnTouchUp(TouchEventArgs e)
        {
            if (pressed)
            {
                pressed = false;
                Invalidate();
                TouchCapture.Capture(this, CaptureMode.None);

                int x, y;
                e.GetPosition(this, 0, out x, out y);
                if (Utils.IsWithinRectangle(x, y, ActualWidth, ActualHeight))
                {
                    OnClick(EventArgs.Empty);
                }
            }
        }
Esempio n. 17
0
            protected override void OnTouchMove(TouchEventArgs e)
            {
                base.OnTouchMove(e);

                int x = 0;
                int y = 0;

                for (int i = 0; i < e.Touches.Length; i++)
                {
                    e.GetPosition((UIElement)this, i, out x, out y);

                    // Add this point to the array.
                    AddPoint(x, y);
                }

                text.TextContent = "TouchMove (" + x.ToString() + "," + y.ToString() + ")";
            }
Esempio n. 18
0
        protected override void OnPreviewTouchDrag(TouchEventArgs e)
        {
            base.OnTouchDrag(e);

            if (e.Pointer != _draggingPointer)
            {
                return;
            }

            Vector2 position = e.GetPosition(this);

            if (_touchScrollH)
            {
                float delta   = position.X - _lastPoint.X;
                float scrollH = _handlePosition + delta;
                _handlePosition = scrollH;

                scrollH = Math.Max(_hScrollBounds.X, scrollH);
                scrollH = Math.Min(_hScrollBounds.X + _hScrollBounds.Width - _hKnobBounds.Width, scrollH);

                float total = _hScrollBounds.Width - _hKnobBounds.Width;
                if (total != 0)
                {
                    ScrollPercentX = (scrollH - _hScrollBounds.X) / total;
                }

                _lastPoint = position;
            }
            else if (_touchScrollV)
            {
                float delta   = position.Y - _lastPoint.Y;
                float scrollV = _handlePosition + delta;
                _handlePosition = scrollV;

                scrollV = Math.Max(_vScrollBounds.Y, scrollV);
                scrollV = Math.Min(_vScrollBounds.Y + _vScrollBounds.Height - _vKnobBounds.Height, scrollV);

                float total = _vScrollBounds.Height - _vKnobBounds.Height;
                if (total != 0)
                {
                    ScrollPercentY = 1 - (scrollV - _vScrollBounds.Y) / total;
                }

                _lastPoint = position;
            }
        }
Esempio n. 19
0
        protected override void OnTouchDown(TouchEventArgs e)
        {
            if (e.Button == 0)
            {
                Vector2 position = e.GetPosition(this);

                _dragging   = IsMovable && (Height - position.Y) <= PadTop && position.Y < Height && position.X > 0 && position.X < Width;
                _dragOffset = position;
            }

            if (_dragging || IsModal)
            {
                e.Handled = true;
            }

            base.OnTouchDown(e);
        }
Esempio n. 20
0
        private void TouchUpHandler(Actor sender, TouchEventArgs e)
        {
            if (e.Pointer == PressedPointer)
            {
                if (!_cancelled)
                {
                    Vector2 position    = e.GetPosition(sender);
                    bool    touchUpOver = IsOverActor(sender, position.X, position.Y);

                    if (touchUpOver && e.Pointer == 0 && Button != -1 && e.Button != Button)
                    {
                        touchUpOver = false;
                    }
                    if (touchUpOver)
                    {
                        long time = DateTime.Now.Ticks * 100;
                        if (time - _lastTapTime > _tapCountInterval)
                        {
                            TapCount = 0;
                        }
                        TapCount     = TapCount + 1;
                        _lastTapTime = time;

                        if (ClickHandler != null)
                        {
                            ClickHandler(e);
                        }
                    }

                    if (_actor.Stage != null)
                    {
                        _actor.ReleaseTouchCapture(e.Pointer);
                    }
                    else if (e.Stage != null)
                    {
                        e.Stage.ReleaseTouchCapture(e.Pointer);
                    }
                }

                _pressed       = false;
                PressedPointer = -1;
                PressedButton  = -1;
                _cancelled     = false;
            }
        }
Esempio n. 21
0
            protected override void OnTouchUp(TouchEventArgs e)
            {
                base.OnTouchUp(e);

                int x;
                int y;

                e.GetPosition((UIElement)this, 0, out x, out y);
#endif
                // Set the flag to draw a circle.
                drawCircle = true;

                cx = x;
                cy = y;

                r = 6;
                Invalidate();
            }
Esempio n. 22
0
            protected override void OnTouchDown(TouchEventArgs e)
            {
                base.OnTouchDown(e);

                int x;
                int y;

                e.GetPosition((UIElement)this, 0, out x, out y);
#endif
                // Start at the beginning of the array and set the flag to draw
                // a circle.
                pointIndex = 0;
                drawCircle = true;

                cx = x;
                cy = y;

                r = 10;
                Invalidate();
            }
Esempio n. 23
0
        private void TouchDraggedHandler(Actor sender, TouchEventArgs e)
        {
            if (e.Pointer != PressedPointer || _cancelled)
            {
                return;
            }

            Vector2 position = e.GetPosition(sender);

            _pressed = IsOverActor(sender, position.X, position.Y);

            if (_pressed && e.Pointer == 0 && Button != -1 && !Mouse.GetState().IsButtonPressed(Button))
            {
                _pressed = false;
            }

            if (!_pressed)
            {
                InvalidateTapSquare();
            }
        }
Esempio n. 24
0
        protected override void OnTouchDrag(TouchEventArgs e)
        {
            base.OnTouchDrag(e);

            if (e.Pointer != _draggingPointer)
            {
                return;
            }

            Vector2 position = e.GetPosition(this);

            ISceneDrawable handle = _style.Handle;

            if (!IsVertical)
            {
                float delta      = position.X - _lastPoint.X;
                float availWidth = Width - handle.MinWidth;
                float dragX      = _handlePosition.X + delta;
                _handlePosition.X = dragX;

                dragX        = MathHelper.Clamp(dragX, 0, availWidth);
                _splitAmount = dragX / availWidth;
                _splitAmount = MathHelper.Clamp(_splitAmount, _minAmount, _maxAmount);
                _lastPoint   = position;
            }
            else
            {
                float delta       = position.Y - _lastPoint.Y;
                float availHeight = Height - handle.MinHeight;
                float dragY       = _handlePosition.Y + delta;
                _handlePosition.Y = dragY;

                dragY        = MathHelper.Clamp(dragY, 0, availHeight);
                _splitAmount = 1 - (dragY / availHeight);
                _splitAmount = MathHelper.Clamp(_splitAmount, _minAmount, _maxAmount);
                _lastPoint   = position;
            }

            Invalidate();
        }
Esempio n. 25
0
        protected override void OnTouchDown(TouchEventArgs e)
        {
            try {
                Vector2 position = e.GetPosition(this);

                if (e.Pointer == 0 && e.Button != 0)
                {
                    return;
                }
                if (!IsSelectable)
                {
                    return;
                }

                DoTouchDown(position.Y);

                e.Handled = true;
            }
            finally {
                base.OnTouchDown(e);
            }
        }
Esempio n. 26
0
        protected override void OnTouchUp(TouchEventArgs e)
        {
            base.OnTouchUp(e);

            if (e.Pointer != _draggingPointer)
            {
                return;
            }

            _draggingPointer = -1;
            ReleaseTouchCapture(e.Pointer);

            Vector2 position = e.GetPosition(this);

            if (!CalculatePositionAndValue(position.X, position.Y))
            {
                // TODO: Raise event for end of dragging control.

                //ChangeEvent changeEvent = Pools<ChangeEvent>.Obtain();
                //Fire(changeEvent);
                //Pools<ChangeEvent>.Release(changeEvent);
            }
        }
Esempio n. 27
0
        /// <summary>
        /// Handling user input
        /// </summary>
        /// <param name="e"></param>
        /// <param name="ue"></param>
        public void HandleTouch(TouchEventArgs e, UIElement ue)
        {
            int x, y;

            e.GetPosition(ue, 0, out x, out y);
            if (y > WindowConsts.WindowHeight / 2)
            {
                RapidFall = true;
            }
            else
            {
                bool rotate = button.Read();
                if (x >= WindowConsts.WindowWidth / 2)
                {
                    if (rotate)
                    {
                        RotateLeft = true;
                    }
                    else
                    {
                        MoveLeft = true;
                    }
                }
                else
                {
                    if (rotate)
                    {
                        RotateRight = true;
                    }
                    else
                    {
                        MoveRight = true;
                    }
                }
            }
        }
Esempio n. 28
0
        protected override void OnTouchDown(TouchEventArgs e)
        {
            try {
                if (IsDisabled)
                {
                    return;
                }
                if (_draggingPointer != -1)
                {
                    return;
                }

                Vector2 position = e.GetPosition(this);

                _draggingPointer = e.Pointer;
                CalculatePositionAndValue(position.X, position.Y);

                CaptureTouch(e.Pointer);
                e.Handled = true;
            }
            finally {
                base.OnTouchDown(e);
            }
        }
Esempio n. 29
0
        protected override void OnPreviewTouchDrag(TouchEventArgs e)
        {
            base.OnTouchDrag(e);

            if (e.Pointer != _draggingPointer)
                return;

            Vector2 position = e.GetPosition(this);

            if (_touchScrollH) {
                float delta = position.X - _lastPoint.X;
                float scrollH = _handlePosition + delta;
                _handlePosition = scrollH;

                scrollH = Math.Max(_hScrollBounds.X, scrollH);
                scrollH = Math.Min(_hScrollBounds.X + _hScrollBounds.Width - _hKnobBounds.Width, scrollH);

                float total = _hScrollBounds.Width - _hKnobBounds.Width;
                if (total != 0)
                    ScrollPercentX = (scrollH - _hScrollBounds.X) / total;

                _lastPoint = position;
            }
            else if (_touchScrollV) {
                float delta = position.Y - _lastPoint.Y;
                float scrollV = _handlePosition + delta;
                _handlePosition = scrollV;

                scrollV = Math.Max(_vScrollBounds.Y, scrollV);
                scrollV = Math.Min(_vScrollBounds.Y + _vScrollBounds.Height - _vKnobBounds.Height, scrollV);

                float total = _vScrollBounds.Height - _vKnobBounds.Height;
                if (total != 0)
                    ScrollPercentY = 1 - (scrollV - _vScrollBounds.Y) / total;

                _lastPoint = position;
            }
        }
Esempio n. 30
0
        protected override void OnPreviewTouchDown(TouchEventArgs e)
        {
            try {
                if (_draggingPointer != -1)
                    return;
                if (e.Pointer == 0 && e.Button != 0)
                    return;
                Stage.SetScrollFocus(this);

                if (!_flickScroll)
                    ResetFade();

                if (_fadeAlpha == 0)
                    return;

                Vector2 position = e.GetPosition(this);

                if (IsScrollX && _hScrollBounds.Contains(position.X, position.Y)) {
                    e.Stopped = true;
                    ResetFade();
                    if (_hKnobBounds.Contains(position.X, position.Y)) {
                        _lastPoint = position;
                        _handlePosition = _hKnobBounds.X;
                        _touchScrollH = true;
                        _draggingPointer = e.Pointer;

                        e.Handled = true;
                        return;
                    }

                    SetScrollX(ScrollX + Math.Max(_areaWidth * .9f, MaxX * .1f) * (position.X < _hKnobBounds.X ? -1 : 1));
                    e.Handled = true;
                    return;
                }

                if (IsScrollY && _vScrollBounds.Contains(position.X, position.Y)) {
                    e.Stopped = true;
                    ResetFade();
                    if (_vKnobBounds.Contains(position.X, position.Y)) {
                        _lastPoint = position;
                        _handlePosition = _vKnobBounds.Y;
                        _touchScrollV = true;
                        _draggingPointer = e.Pointer;

                        e.Handled = true;
                        return;
                    }

                    SetScrollY(ScrollY + Math.Max(_areaHeight * .9f, MaxY * .1f) * (position.Y < _vKnobBounds.Y ? 1 : -1));
                    e.Handled = true;
                    return;
                }
            }
            finally {
                base.OnPreviewTouchDown(e);
            }
        }
Esempio n. 31
0
        protected override void OnTouchDown(TouchEventArgs e)
        {
            try {
                if (IsDisabled)
                    return;
                if (_draggingPointer != -1)
                    return;

                Vector2 position = e.GetPosition(this);

                _draggingPointer = e.Pointer;
                CalculatePositionAndValue(position.X, position.Y);

                CaptureTouch(e.Pointer);
                e.Handled = true;
            }
            finally {
                base.OnTouchDown(e);
            }
        }
Esempio n. 32
0
            protected override void OnTouchUp(TouchEventArgs e)
            {
                Vector2 position = e.GetPosition(this);

                if (Hit(position.X, position.Y, true) == _list) {
                    _selectBox.SelectionIndex = _list.SelectedIndex;
                    _selectBox.HideList();
                }

                base.OnTouchUp(e);
            }
Esempio n. 33
0
        protected override void OnTouchDown(TouchEventArgs e)
        {
            try {
                Vector2 position = e.GetPosition(this);

                if (e.Pointer == 0 && e.Button != 0)
                    return;
                if (!IsSelectable)
                    return;

                DoTouchDown(position.Y);

                e.Handled = true;
            }
            finally {
                base.OnTouchDown(e);
            }
        }
Esempio n. 34
0
 protected override void OnTouchDrag(TouchEventArgs e)
 {
     base.OnTouchDrag(e);
     Vector2 position = e.GetPosition(this);
     if (_dragging)
         Translate(position.X - _dragOffset.X, position.Y - _dragOffset.Y);
 }
Esempio n. 35
0
            protected override void OnTouchDown(TouchEventArgs e)
            {
                base.OnTouchDown(e);

                int x;
                int y;

                e.GetPosition((UIElement)this, 0, out x, out y);
#endif

                // If we are in calibrating mode...
                ++currentCalPoint;
                if (calibrating)
                {
                    // Cycle through all of the calibration points.
                    int index = currentCalPoint - 1;

                    cx[index] = (short)x;
                    cy[index] = (short)y;

                    text.TextContent = "{(" +
                                       sx[index].ToString() + "," +
                                       sy[index].ToString() + ")=(" +
                                       cx[index].ToString() + "," +
                                       cy[index].ToString() + ")}";

                    if (currentCalPoint == calPoints.Length)
                    {
                        // The last point has been reached , so set the
                        // calibration.
                        Microsoft.SPOT.Touch.Touch.ActiveTouchPanel.SetCalibration(
                            calPoints.Length,
                            sx,
                            sy,
                            cx,
                            cy);

                        // Show the calibration points.
                        int    i   = 0;
                        string str = "";
                        for (i = 0; i < calPoints.Length; i++)
                        {
                            str += i.ToString() + "=" + cx[i].ToString() + "," + cy[i].ToString() + " ";
                        }
                        text.TextContent = str;

                        calibrating = false;
                    }
                }
                else
                {
                    // We are not calibrating, so just show the point.
                    r       = 10;
                    centerx = x;
                    centery = y;

                    text.TextContent = x.ToString() + "," + y.ToString();
                }

                Invalidate();
            }
Esempio n. 36
0
        protected override void OnTouchDown(TouchEventArgs e)
        {
            try {
                if (_draggingPointer != -1)
                    return;
                if (e.Pointer == 0 && e.Button != 0)
                    return;

                Vector2 position = e.GetPosition(this);

                if (_handleBounds.Contains(position.X, position.Y)) {
                    _draggingPointer = e.Pointer;
                    _lastPoint = position;
                    _handlePosition = new Vector2(_handleBounds.X, _handleBounds.Y);

                    if (Stage != null)
                        CaptureTouch(e.Pointer);

                    e.Handled = true;
                }
            }
            finally {
                base.OnTouchDown(e);
            }
        }
Esempio n. 37
0
        protected override void OnTouchDrag(TouchEventArgs e)
        {
            base.OnTouchDrag(e);

            if (e.Pointer != _draggingPointer)
                return;

            Vector2 position = e.GetPosition(this);

            ISceneDrawable handle = _style.Handle;
            if (!IsVertical) {
                float delta = position.X - _lastPoint.X;
                float availWidth = Width - handle.MinWidth;
                float dragX = _handlePosition.X + delta;
                _handlePosition.X = dragX;

                dragX = MathHelper.Clamp(dragX, 0, availWidth);
                _splitAmount = dragX / availWidth;
                _splitAmount = MathHelper.Clamp(_splitAmount, _minAmount, _maxAmount);
                _lastPoint = position;
            }
            else {
                float delta = position.Y - _lastPoint.Y;
                float availHeight = Height - handle.MinHeight;
                float dragY = _handlePosition.Y + delta;
                _handlePosition.Y = dragY;

                dragY = MathHelper.Clamp(dragY, 0, availHeight);
                _splitAmount = 1 - (dragY / availHeight);
                _splitAmount = MathHelper.Clamp(_splitAmount, _minAmount, _maxAmount);
                _lastPoint = position;
            }

            Invalidate();
        }
Esempio n. 38
0
        protected override void OnTouchDown(TouchEventArgs e)
        {
            if (e.Button == 0) {
                Vector2 position = e.GetPosition(this);

                _dragging = IsMovable && (Height - position.Y) <= PadTop && position.Y < Height && position.X > 0 && position.X < Width;
                _dragOffset = position;
            }

            if (_dragging || IsModal)
                e.Handled = true;

            base.OnTouchDown(e);
        }
Esempio n. 39
0
        protected override void OnTouchUp(TouchEventArgs e)
        {
            base.OnTouchUp(e);

            if (e.Pointer != _draggingPointer)
                return;

            _draggingPointer = -1;
            ReleaseTouchCapture(e.Pointer);

            Vector2 position = e.GetPosition(this);

            if (!CalculatePositionAndValue(position.X, position.Y)) {
                // TODO: Raise event for end of dragging control.

                //ChangeEvent changeEvent = Pools<ChangeEvent>.Obtain();
                //Fire(changeEvent);
                //Pools<ChangeEvent>.Release(changeEvent);
            }
        }
Esempio n. 40
0
        protected override void OnTouchDrag(TouchEventArgs e)
        {
            base.OnTouchDrag(e);

            Vector2 position = e.GetPosition(this);
            CalculatePositionAndValue(position.X, position.Y);
        }
Esempio n. 41
0
        /// <summary>
        /// Handles the OnTouchMove event.
        /// </summary>
        /// <param name="e"></param>
        protected override void OnTouchMove(TouchEventArgs e)
        {
            int x = 0;
            int y = 0;

            e.GetPosition(this, 0, out x, out y);

            // If a slider was tapped...
            if (_moveVerticalSlider)
            {
                // The vertical slider was clicked.

                // Calculate the difference between the old position and the
                // new position.
                int diff = y - _verticalSliderMoveY;

                // Calculate the view difference.
                int realDiff = (diff * _totalViewHeight) / _verticalScrollViewHeight;

                // Set the new position of the slider.
                _verticalSliderMoveY = y;

                // Validate the new position and bound-align it.
                if (_verticalSliderMoveY < _verticalSliderY + _columnHeaderHeight)
                {
                    _verticalSliderMoveY = _verticalSliderY + _columnHeaderHeight;
                }

                // Update the view scroll position.
                ScrollVertical(realDiff);
            }
            else if (_moveHorizontalSlider)
            {
                // The horizontal slider was clicked.

                // Calculate the difference between the old position and the
                // new position.
                int diff = x - _horizontalSliderMoveX;

                // Validate and bound-align the difference.
                if ((x >= _horizontalSliderMoveX) &&
                    (_horizontalSliderX + _horizontalSliderWidth + diff >= Width + _scrollbarDimension))
                {
                    diff -= (Width + _scrollbarDimension) - (_horizontalSliderX + _horizontalSliderWidth + diff);
                }

                // Validate the new position.
                if ((_horizontalSliderX + _horizontalSliderWidth + diff < Width + _scrollbarDimension) ||
                    (x < _horizontalSliderMoveX))
                {
                    // Calculate the view difference.
                    int realDiff = (diff * _totalViewWidth) / _horizontalScrollViewWidth;

                    // Set the new position of the slider.
                    _horizontalSliderMoveX = x;

                    // Update the view scroll position.
                    ScrollHorizontal(realDiff);
                }
            }
        }