コード例 #1
0
ファイル: App.cs プロジェクト: Echolaitoc/FantasyMapProject
 private void OnTouchMove(Event e)
 {
     if (Map != null && e is TouchEvent)
     {
         var te = (TouchEvent)e;
         if (te != null && te.Touches != null)
         {
             if (te.Touches.Length == 1)
             {
                 Touch t = te.Touches[0];
                 LastMousePos.Set(t.ClientX, t.ClientY);
                 Map.OnMove(t.ClientX, t.ClientY);
             }
             else if (te.Touches.Length == 2)
             {
                 Touch  t1       = te.Touches[0];
                 Touch  t2       = te.Touches[1];
                 Vec2i  t1Pos    = new Vec2i(t1.ClientX, t1.ClientY);
                 Vec2i  t2Pos    = new Vec2i(t2.ClientX, t2.ClientY);
                 Vec2i  mid      = (t1Pos + t2Pos) / 2;
                 double distance = Vec2i.Distance(t1Pos, t2Pos);
                 double delta    = LastPinchGestureDistance - distance;
                 LastPinchGestureDistance = distance;
                 Map.ZoomMap(mid.x, mid.y, delta * -ZOOM_SPEED);
             }
             if (te.Touches.Length > 1)
             {
                 e.PreventDefault();
             }
         }
     }
 }
コード例 #2
0
ファイル: App.cs プロジェクト: Echolaitoc/FantasyMapProject
 private void OnTouchStart(Event e)
 {
     if (Map != null && e is TouchEvent)
     {
         var te = (TouchEvent)e;
         if (te != null && te.Touches != null)
         {
             if (te.Touches.Length == 1)
             {
                 Touch t = te.Touches[0];
                 LastMousePos.Set(t.ClientX, t.ClientY);
                 Map.OnPress(t.ClientX, t.ClientY);
             }
             else if (te.Touches.Length == 2)
             {
                 Touch  t1       = te.Touches[0];
                 Touch  t2       = te.Touches[1];
                 Vec2i  t1Pos    = new Vec2i(t1.ClientX, t1.ClientY);
                 Vec2i  t2Pos    = new Vec2i(t2.ClientX, t2.ClientY);
                 double distance = Vec2i.Distance(t1Pos, t2Pos);
                 LastPinchGestureDistance = distance;
             }
         }
     }
 }
コード例 #3
0
        /// <summary>
        /// Checks whether the mouse left or entered this control (or one of its childcontrols)
        /// </summary>
        /// <param name="cursorPoint"></param>
        /// <param name="result"></param>
        protected void CheckMouseEvents(TVector2 cursorPoint, InputUtilities inputUtils, ref MouseEvent result)
        {
            inputUtils.Mouse.CurrentMouseArgs.PosOnForm = cursorPoint;
            foreach (Control <TRenderer, TColor, TVector2, TFont> control in ChildControls)
            {
                if (result.Handled)
                {
                    return;
                }
                if (!control.Visible)
                {
                    continue;
                }
                if (!inputUtils.MouseChanged)
                {
                    continue;
                }
                result.Depth++;
                control.CheckMouseEvents(cursorPoint, inputUtils, ref result);
                result.Depth--;
            }
            if (!result.Handled)
            {
                this.MouseOver = this.CheckMouseOver(cursorPoint);
                if (this.MouseOver)
                {
                    result.Handled = true;
                    if (!inputUtils.MouseChanged)
                    {
                        return;
                    }
                    if ((inputUtils.Mouse.CurrentMouseArgs.Button == MouseButtons.Left ||
                         inputUtils.Mouse.CurrentMouseArgs.Button == MouseButtons.Right ||
                         inputUtils.Mouse.CurrentMouseArgs.Button == MouseButtons.Middle ||
                         inputUtils.Mouse.CurrentMouseArgs.Wheel) &&
                        inputUtils.Mouse.CurrentMouseArgs.UpOrDown == MouseEventExtArgs.UpDown.Down)
                    {
                        OnMouseClickEventDown(inputUtils.Mouse.CurrentMouseArgs);
                    }
                    if ((inputUtils.Mouse.CurrentMouseArgs.Button == MouseButtons.Left ||
                         inputUtils.Mouse.CurrentMouseArgs.Button == MouseButtons.Right ||
                         inputUtils.Mouse.CurrentMouseArgs.Button == MouseButtons.Middle ||
                         inputUtils.Mouse.CurrentMouseArgs.Wheel) &&
                        inputUtils.Mouse.CurrentMouseArgs.UpOrDown == MouseEventExtArgs.UpDown.Up)
                    {
                        OnMouseClickEventUp(inputUtils.Mouse.CurrentMouseArgs);
                    }
                    if (inputUtils.Mouse.CurrentMouseArgs.Wheel)
                    {
                        OnMouseWheelEvent(inputUtils.Mouse.CurrentMouseArgs);
                    }

                    if (!LastMousePos.Equals(cursorPoint))
                    {
                        OnMouseMovedEvent(inputUtils.Mouse.CurrentMouseArgs);
                        LastMousePos = cursorPoint;
                    }
                }
            }
        }
コード例 #4
0
ファイル: App.cs プロジェクト: Echolaitoc/FantasyMapProject
 private void OnMouseMove(Event e)
 {
     if (Map != null && e.IsMouseEvent() && e is MouseEvent)
     {
         var me = (MouseEvent)e;
         LastMousePos.Set(me.ClientX, me.ClientY);
         Map.OnMove(me.ClientX, me.ClientY);
     }
 }