示例#1
0
 protected override void TouchMoveMessage(object sender, point point, ref bool handled)
 {
     // Check Controls
     if (ActiveChild != null && ActiveChild.Touching)
     {
         ActiveChild.SendTouchMove(this, new point(point.X - ActiveChild.Left, point.Y - ActiveChild.Top));
     }
     else if (Children != null)
     {
         if (Children[_selIndex].HitTest(point))
         {
             Children[_selIndex].SendTouchMove(this, point);
         }
     }
     base.TouchMoveMessage(sender, point, ref handled);
 }
示例#2
0
文件: Tab.cs 项目: piwi1263/Tinkr
        protected override void TouchMoveMessage(object sender, point point, ref bool handled)
        {
            if (_touch)
            {
                bool bUpdated = false;

                int diffY = 0;
                int diffX = 0;

                // Scroll Y
                if (_maxY > Height)
                {
                    diffY = point.Y - LastTouch.Y;

                    if (diffY > 0 && _minY < Top)
                    {
                        diffY    = Math.Min(diffY, _minY + Top);
                        bUpdated = true;
                    }
                    else if (diffY < 0 && _maxY > Height)
                    {
                        diffY    = Math.Min(-diffY, _maxY - _minY - Height);
                        bUpdated = true;
                    }
                    else
                    {
                        diffY = 0;
                    }

                    _moving = true;
                }

                // Scroll X
                if (_maxX > Width)
                {
                    diffX = point.X - LastTouch.X;

                    if (diffX > 0 && _minX < Left)
                    {
                        diffX    = Math.Min(diffX, _minX + Left);
                        bUpdated = true;
                    }
                    else if (diffX < 0 && _maxX > Width)
                    {
                        diffX    = Math.Min(-diffX, _maxX - _minX - Width);
                        bUpdated = true;
                    }
                    else
                    {
                        diffX = 0;
                    }

                    _moving = true;
                    handled = true;
                }

                LastTouch = point;
                if (bUpdated)
                {
                    var ptOff = new point(diffX, diffY);
                    for (int i = 0; i < Children.Length; i++)
                    {
                        Children[i].UpdateOffsets(ptOff);
                    }
                    Render(true);
                    handled = true;
                }
                else if (_moving)
                {
                    Render(true);
                }
            }
            else
            {
                // Check Controls
                if (ActiveChild != null && ActiveChild.Touching)
                {
                    ActiveChild.SendTouchMove(this, point);
                    handled = true;
                }
                else if (Children != null)
                {
                    for (int i = Children.Length - 1; i >= 0; i--)
                    {
                        if (Children[i].Touching || Children[i].HitTest(point))
                        {
                            Children[i].SendTouchMove(this, point);
                        }
                    }
                }
            }
            base.TouchMoveMessage(sender, point, ref handled);
        }
示例#3
0
        /// <summary>
        /// Override this message to handle touch events internally.
        /// </summary>
        /// <param name="sender">Object sending the event</param>
        /// <param name="point">Point on screen touch event is occurring</param>
        /// <param name="handled">true if the event is handled. Set to true if handled.</param>
        /// <remarks>
        /// Moves the form if touch down was on the form.
        /// If no then forwards the message to <see cref="Container.ActiveChild"/> or if null, to the child under point
        /// </remarks>
        protected override void TouchMoveMessage(object sender, point point, ref bool handled)
        {
            if (Touching)
            {
                var bUpdated = false;

                var diffY = 0;
                var diffX = 0;

                // Scroll Y
                if (_maxY > _h)
                {
                    diffY = point.Y - LastTouch.Y;

                    if (diffY > 0 && _minY < Top)
                    {
                        diffY    = System.Math.Min(diffY, _minY + Top);
                        bUpdated = true;
                    }
                    else if (diffY < 0 && _maxY > _h)
                    {
                        diffY    = System.Math.Min(-diffY, _maxY - _minY - _h);
                        bUpdated = true;
                    }
                    else
                    {
                        diffY = 0;
                    }

                    _moving = true;
                    //handled = true; //TODO: check why not handled
                }

                // Scroll X
                if (_maxX > _w)
                {
                    diffX = point.X - LastTouch.X;

                    if (diffX > 0 && _minX < Left)
                    {
                        diffX    = System.Math.Min(diffX, _minX + Left);
                        bUpdated = true;
                    }
                    else if (diffX < 0 && _maxX > _w)
                    {
                        diffX    = System.Math.Min(-diffX, _maxX - _minX - _w);
                        bUpdated = true;
                    }
                    else
                    {
                        diffX = 0;
                    }

                    _moving = true;
                    handled = true;
                }

                LastTouch = point;
                if (bUpdated)
                {
                    var ptOff = new point(diffX, diffY);
                    for (var i = 0; i < Children.Length; i++)
                    {
                        Children[i].UpdateOffsets(ptOff);
                    }
                    Render(true);
                    handled = true;
                }
                else if (_moving)
                {
                    Render(true);
                }
            }
            else
            {
                //TODO: check if this code shouldn't go to Container (or may be even the whole method?)
                // Check Controls
                if (ActiveChild != null && ActiveChild.Touching)
                {
                    ActiveChild.SendTouchMove(this, point);
                    handled = true;
                    return;
                }
                if (Children != null)
                {
                    for (var i = Children.Length - 1; i >= 0; i--)
                    {
                        if (Children[i].Touching || Children[i].HitTest(point))
                        {
                            Children[i].SendTouchMove(this, point);
                        }
                    }
                }
            }
        }