Exemple #1
0
        private bool HandleNavigationAction(Rover rover, NavigationAction navigationAction)
        {
            var originalCoordinates = rover.CurrentCoordinates;
            var originalHeading     = rover.CurrentHeading;

            switch (navigationAction)
            {
            case NavigationAction.L:
                rover.Turn(TurnDirection.Left);
                break;

            case NavigationAction.R:
                rover.Turn(TurnDirection.Right);
                break;

            case NavigationAction.M:
                rover.Move();
                break;
            }

            if (TryValidateRoverOnPlateau(rover))
            {
                RoverActionsCache[rover].Add(navigationAction);
                return(true);
            }

            rover.CurrentCoordinates = originalCoordinates;
            rover.CurrentHeading     = originalHeading;

            return(false);
        }
 public virtual void Update()
 {
     if (Input.GetKeyDown(this.frameKey))
     {
         NavigationAction frameAction = this.frameCamera;
         frameAction();
     }
 }
Exemple #3
0
        /// <summary>
        /// Hints the creation navigation.
        /// </summary>
        /// <param name="navigationAction">The navigation action.</param>
        internal void HintCreationNavigation(NavigationAction navigationAction)
        {
            if (CreationNavigation != null)
            {
                return;
            }

            CreationNavigation = navigationAction;
        }
Exemple #4
0
 /// <summary>
 /// Uninvoke navigation on an object with a given action (navigation action)
 /// </summary>
 /// <param name="a"></param>
 public void UninvokeNavigation(NavigationAction a)
 {
     foreach (Control c in this.Controls)
     {
         f0t0NavPanel f = c as f0t0NavPanel;
         if (f != null && f.Action == a && f.IsInvoked)
         {
             f.EndInvoke();
             break;
         }
     }
 }
Exemple #5
0
 /// <summary>
 /// Invoke navigation on an object with a given action (navigation action)
 /// </summary>
 /// <param name="a"></param>
 public void InvokeNavigation(NavigationAction a)
 {
     foreach (Control c in this.Controls)
     {
         f0t0NavPanel f = c as f0t0NavPanel;
         if (f != null && f.Action == a)
         {
             if (!f.IsInvoked)
             {
                 f.PerformInvoke();
             }
             break;
         }
     }
 }
        public static bool TryParse(string value, out NavigationAction action)
        {
            switch (value.ToLowerInvariant())
            {
            case "push": action = NavigationAction.Push; return(true);

            case "modal": action = NavigationAction.Modal; return(true);

            case "pop": action = NavigationAction.Pop; return(true);

            case "mainpage": action = NavigationAction.MainPage; return(true);
            }
            action = default(NavigationAction);
            return(false);
        }
        // --------------------------------------------------------------------

        #region Mouse Interaction

        public void OnMouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Middle)
            {
                CurrentAction = NavigationAction.Dragging;
            }
            else if (e.Button == MouseButtons.Right)
            {
                CurrentAction = NavigationAction.Rotating;
            }
            else
            {
                CurrentAction = NavigationAction.None;
            }
        }
Exemple #8
0
 public static void Navigate <TArgs>(
     this ViewStack viewStack,
     NavigationAction action,
     string newScreenId,
     TArgs args,
     ViewStack.ViewTransition transition = null,
     Action onComplete = null)
 {
     viewStack.Navigate <IViewBehaviour <TArgs> >(
         action,
         newScreenId,
         v => v.Init(args),
         transition,
         onComplete
         );
 }
Exemple #9
0
 public static void Navigate <TViewBehaviour, TArgs>(
     this ViewStack viewStack,
     NavigationAction action,
     string viewId,
     TArgs args,
     ViewStack.ViewTransition transition = null,
     Action onComplete = null) where TViewBehaviour : IViewBehaviour <TArgs>
 {
     viewStack.Navigate <TViewBehaviour>(
         action,
         viewId,
         v => v.Init(args),
         transition,
         onComplete
         );
 }
Exemple #10
0
    private void check3FingerNavigation()
    {
        // Currently we only support 3 finger dragging.
        Touch            touch0  = Input.GetTouch(0);
        Touch            touch1  = Input.GetTouch(1);
        Touch            touch2  = Input.GetTouch(2);
        Vector2          average = ((touch0.deltaPosition + touch1.deltaPosition) + touch2.deltaPosition) / 3;
        NavigationAction func    = this.touchNavigationLookup[((int)this.drag3FingerNavigation)];

        if (func == (NavigationAction)this.dolly)
        {
            func(average.y, 0);
        }
        else
        {
            func(average.x, average.y);
        }
    }
Exemple #11
0
    private void check1FingerNavigation()
    {
        // Currently we only support 1 finger dragging.
        if (Vector2.Distance(this.touchSpot, Input.GetTouch(0).position) < this.longPressRadius)
        {
            return;
        }
        this.touchSpot = new Vector2(-50, -50);
        Touch            touch0 = Input.GetTouch(0);
        NavigationAction func   = this.touchNavigationLookup[((int)this.drag1FingerNavigation)];

        if (func == (NavigationAction)this.dolly)
        {
            func(touch0.deltaPosition.y, 0);
        }
        else
        {
            func(touch0.deltaPosition.x, touch0.deltaPosition.y);
        }
    }
Exemple #12
0
        public static void Navigate(
            this ViewStack viewStack,
            NavigationAction action,
            string newScreenId,
            Action <GameObject> initView,
            ViewStack.ViewTransition transition = null,
            Action onComplete = null)
        {
            // this would contain a switch to call the appropriate function
            switch (action)
            {
            case NavigationAction.Push:
                viewStack.Push(newScreenId, initView, transition, onComplete);
                break;

            case NavigationAction.Pop:
                viewStack.Pop(transition, onComplete);
                break;
            }
        }
Exemple #13
0
            public void MoveExercice1(NavigationAction action)
            {
                switch (action.Order)
                {
                case Order.West:
                    East -= action.Value;
                    break;

                case Order.North:
                    North += action.Value;
                    break;

                case Order.East:
                    East += action.Value;
                    break;

                case Order.South:
                    North -= action.Value;
                    break;

                case Order.Forward:
                    MoveExercice1(new NavigationAction(FacingDirection, action.Value));
                    break;

                case Order.RotateRight:
                    FacingDirection = (Order)(((int)FacingDirection + action.Value / 90) % 4);
                    break;

                case Order.RotateLeft:
                    var val = ((int)FacingDirection - action.Value / 90);
                    if (val < 0)
                    {
                        val += 4;
                    }
                    FacingDirection = (Order)(val % 4);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
Exemple #14
0
 // Calls the appropirate function for the current double tap gesture.
 // The count parameter indicates the number of fingers involved in the current double tap.
 private void doubleTap(int count)
 {
     if (count == 0)
     {
         NavigationAction tapAction = this.doubleTapMethodLookup[((int)this.doubleTap1Finger)];
         tapAction();
     }
     if (count == 1)
     {
         NavigationAction tapAction = this.doubleTapMethodLookup[((int)this.doubleTap2Finger)];
         tapAction();
     }
     else
     {
         if (count >= 2)
         {
             NavigationAction tapAction = this.doubleTapMethodLookup[((int)this.doubleTap3Finger)];
             tapAction();
         }
     }
 }
Exemple #15
0
        public static void Navigate <TViewBehaviour>(
            this ViewStack viewStack,
            NavigationAction action,
            string viewId,
            Action <TViewBehaviour> initView    = null,
            ViewStack.ViewTransition transition = null,
            Action onComplete = null)
        {
            viewStack.Navigate(action, viewId, view =>
            {
                var viewBehaviour = view.GetComponent <TViewBehaviour>();
                if (viewBehaviour == null)
                {
                    throw new Exception("View behaviour is missing from view: " + typeof(TViewBehaviour));
                }

                if (initView != null)
                {
                    initView(viewBehaviour);
                }
            }, transition, onComplete);
        }
Exemple #16
0
    // Used to look up which navigation function should be used in place of the function requested.
    // By default the given function will be the one returned, however is defaultMouseNavigation has been
    // set to something other than Orbit then the new function is returned.
    private NavigationAction getNavigateFunction(NavigationAction func)
    {
        if (this.defaultMouseNavigation == NavigationMode.None)
        {
            return(this.nullNav);
        }
        // Defaults to orbit at 1.
        int offset = 0;

        if (func == (NavigationAction)this.pan)
        {
            offset = 1;
        }
        if (func == (NavigationAction)this.look)
        {
            offset = 2;
        }
        if (func == (NavigationAction)this.dolly)
        {
            offset = 3;
        }
        return(this.navigationLookup[((int)(this.defaultMouseNavigation - 1))][offset]);
    }
 public NavigationActionViewModel(IViewModelDependencies dependencies, IZetboxContext dataCtx, ViewModel parent, NavigationAction screen)
     : base(dependencies, dataCtx, parent, screen)
 {
 }
Exemple #18
0
 public ShowCalendarNavigationActionViewModel(IViewModelDependencies appCtx, Func <IZetboxContext> ctxFactory,
                                              IZetboxContext dataCtx, ViewModel parent, NavigationAction screen)
     : base(appCtx, dataCtx, parent, screen)
 {
     _ctxFactory = ctxFactory;
 }
 public DocumentDetailNavigationParameter(string dokumentTitle, NavigationAction action, string command)
 {
     Action        = action;
     Command       = command;
     DokumentTitel = dokumentTitle;
 }
Exemple #20
0
 public LinkedEventFilter(NavigationAction navigationAction, NavigationGroup navigationGroup, Color colorGroup)
 {
     _navigationAction = navigationAction;
     _navigationGroup  = navigationGroup;
     _colorGroup       = colorGroup;
 }
 public static string CreateNavigationParameter(string dokumentTitle, NavigationAction action, string command)
 {
     var parameter = new DocumentDetailNavigationParameter(dokumentTitle, action, command);
     return SerializationHelper.SerializeToString(parameter);
 }
 public DocumentDetailNavigationParameter(string dokumentTitle, NavigationAction action, string command)
 {
     Action = action;
     Command = command;
     DokumentTitel = dokumentTitle;
 }
Exemple #23
0
    // Performs the recognition and nagivation for 2 fingured inputs.
    private void check2FingerNavigation()
    {
        Vector2 delta0   = default(Vector2);
        Vector2 delta1   = default(Vector2);
        Touch   touch0   = Input.GetTouch(0);
        Touch   touch1   = Input.GetTouch(1);
        float   diffTime = (touch0.deltaTime + touch1.deltaTime) * 0.5f;

        // If the user has not moved their fingers in 0.6 seconds we assume that we should
        // attempt to recognise the gesture. This allows the user to keep their fingers
        // on the screen and start a new gesture.
        if (diffTime > this.touchPauseTimeout)
        {
            this.clearTouchInput();
        }
        if (this.touchInputCount < this.touchInputDelay)
        {
            this.touchInputCount++;
            return;
        }
        else
        {
            if (this.touchInputCount == this.touchInputDelay)
            {
                this.touchInputCount++;
                delta0 = touch0.position - this.initialInputs[0];
                delta1 = touch1.position - this.initialInputs[1];
            }
            else
            {
                delta0 = touch0.deltaPosition;
                delta1 = touch1.deltaPosition;
            }
        }
        if ((this.touchNavigation == TouchNavigation.None) || (this.touchNavigation == TouchNavigation.Drag2Fingers))
        {
            float angleDifference = Vector2.Angle(delta0, delta1);
            // If the angle between the difference vectors is less than 60 then it is likely the two fingers
            // are moving in the same direction which indicates a drag.
            if (((Mathf.Abs(angleDifference) < 60) || (this.touchNavigation == TouchNavigation.Drag2Fingers)) || ((this.pinch2FingerNavigation == NavigationMode.None) && (this.rotate2FingerNavigation == NavigationMode.None)))
            {
                // Dragging.
                // While averaging should be just 0.5, often this results in movement that's much faster
                // that what a normal drag with the mouse would be.
                Vector2 averageMove = (touch0.deltaPosition + touch1.deltaPosition) * 0.5f;
                //var averageMove:Vector2 = delta0 * 0.5;
                this.touchNavigation = TouchNavigation.Drag2Fingers;
                NavigationAction touchAction = this.touchNavigationLookup[((int)this.drag2FingerNavigation)];
                touchAction(averageMove.x, averageMove.y);
                return;
            }
        }
        // Makes use of the average vectors. These are used to actually calculate
        // the gesture being executed.
        Vector2 oldVectorAverage = (touch0.position - delta0) - (touch1.position - delta1);
        // These always use the most recent deltaPosition
        Vector2 newVector    = touch0.position - touch1.position;
        float   newMagnitude = newVector.magnitude;
        Vector2 oldVector    = (touch0.position - touch0.deltaPosition) - (touch1.position - touch1.deltaPosition);
        float   diffAverage  = newMagnitude - oldVectorAverage.magnitude;
        Vector3 curlAverage  = Vector3.Cross(oldVectorAverage.normalized, newVector.normalized);
        // Find the ratio between the curl of the vectors and the difference in
        // maginutde. When this is over 1000 this usually indicates that the difference
        // is greater which indicates a pinch, otherwise it indicates that the curl is
        // greater and that the user is rotating.
        float ratioAverage = Mathf.Abs(diffAverage / curlAverage.z);

        if ((this.touchNavigation == TouchNavigation.None) || (this.touchNavigation == TouchNavigation.Rotating))
        {
            if (((ratioAverage < 1000) || (this.touchNavigation == TouchNavigation.Rotating)) || (this.pinch2FingerNavigation == NavigationMode.None))
            {
                Vector3 curl = Vector3.Cross(oldVector.normalized, newVector.normalized);
                this.touchNavigation = TouchNavigation.Rotating;
                NavigationAction touchAction = this.touchNavigationLookup[((int)this.rotate2FingerNavigation)];
                touchAction(curl.z * 400, 0);
            }
        }
        if ((this.touchNavigation == TouchNavigation.None) || (this.touchNavigation == TouchNavigation.Pinching))
        {
            if ((((ratioAverage >= 1000) && (Mathf.Abs(diffAverage) > 20)) || (this.touchNavigation == TouchNavigation.Pinching)) || (this.rotate2FingerNavigation == NavigationMode.None))
            {
                float diff = newMagnitude - oldVector.magnitude;
                this.touchNavigation = TouchNavigation.Pinching;
                float diffLog = 0;
                if (Mathf.Abs(diff) > 1)
                {
                    diffLog = Mathf.Log(Mathf.Abs(diff)) / 1.25f;
                }
                float            d           = 0.1f + diffLog;
                NavigationAction touchAction = this.touchNavigationLookup[((int)this.pinch2FingerNavigation)];
                touchAction(diff > 0 ? d : -d, 0);
            }
        }
    }
        // --------------------------------------------------------------------

        public void OnMouseUp(object sender, MouseEventArgs e)
        {
            CurrentAction = NavigationAction.None;
        }
Exemple #25
0
 public NavigationActionArgs(NavigationAction action, EventArgs e)
 {
     this.action = action;
     this.e      = e;
 }
 public ShowCalendarNavigationActionViewModel(IViewModelDependencies appCtx, Func<IZetboxContext> ctxFactory,
     IZetboxContext dataCtx, ViewModel parent, NavigationAction screen)
     : base(appCtx, dataCtx, parent, screen)
 {
     _ctxFactory = ctxFactory;
 }
        //CURRENTLY UNUSED
        public IFilter <LinkedNavigationEvent> GetLinkedNavigationFilter(NavigationAction navigationAction, NavigationDestination navigationDestination)
        {
            var _colorGroup = _colorService.GetDefaultColorGroup();

            return(GetLinkedNavigationFilter(navigationAction, navigationDestination, _colorGroup));
        }
        public static string CreateNavigationParameter(string dokumentTitle, NavigationAction action, string command)
        {
            var parameter = new DocumentDetailNavigationParameter(dokumentTitle, action, command);

            return(SerializationHelper.SerializeToString(parameter));
        }
Exemple #29
0
            public void MoveExercice2(NavigationAction action)
            {
                switch (action.Order)
                {
                case Order.West:
                    WayPointEast -= action.Value;
                    break;

                case Order.North:
                    WayPointNorth += action.Value;
                    break;

                case Order.East:
                    WayPointEast += action.Value;
                    break;

                case Order.South:
                    WayPointNorth -= action.Value;
                    break;

                case Order.Forward:
                    East  += WayPointEast * action.Value;
                    North += WayPointNorth * action.Value;
                    break;

                case Order.RotateRight:
                    var tempNorth = WayPointNorth;
                    var tempEast  = WayPointEast;
                    if (action.Value == 90)
                    {
                        WayPointEast  = tempNorth;
                        WayPointNorth = -tempEast;
                    }
                    else if (action.Value == 180)
                    {
                        WayPointEast  = -tempEast;
                        WayPointNorth = -tempNorth;
                    }
                    else
                    {
                        WayPointEast  = -tempNorth;
                        WayPointNorth = tempEast;
                    }
                    break;

                case Order.RotateLeft:
                    var tn = WayPointNorth;
                    var te = WayPointEast;
                    if (action.Value == 90)
                    {
                        WayPointEast  = -tn;
                        WayPointNorth = te;
                    }
                    else if (action.Value == 180)
                    {
                        WayPointEast  = -te;
                        WayPointNorth = -tn;
                    }
                    else
                    {
                        WayPointEast  = tn;
                        WayPointNorth = -te;
                    }
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
 public ShowCalendarNavigationActionViewModel(IViewModelDependencies appCtx,
     IZetboxContext dataCtx, ViewModel parent, NavigationAction screen)
     : base(appCtx, dataCtx, parent, screen)
 {
 }
Exemple #31
0
 public Navigation(NavigationAction action, GameComponent gameElement)
 {
     Action        = action;
     GameComponent = gameElement;
 }
Exemple #32
0
    public virtual void LateUpdate()
    {
        if (this.supressNavigation == true)
        {
            return;
        }
        float dx     = 0;
        float dy     = 0;
        int   tCount = Input.touchCount;

        // Calculates when a double click has occured.
        if (Input.GetMouseButtonDown(0) && (tCount == 0))
        {
            this.touchSpot = Input.mousePosition;
            if ((Time.time - this.touchTimes[0]) < 0.3f)
            {
                this.doubleTap(0);
            }
            this.touchTimes[0] = Time.time;
        }
        // Calculates when a double tap of any number of fingers has occured.
        if (tCount > 0)
        {
            int t = tCount - 1;
            if ((Input.GetTouch(t).phase == TouchPhase.Began) && (t < this.touchTimes.Length))
            {
                float diff = Time.time - this.touchTimes[t];
                if (diff < 0.3f)
                {
                    this.doubleTap(t);
                }
                this.touchTimes[t] = Time.time;
            }
        }
        dx = Input.GetAxis("Mouse X");
        dy = Input.GetAxis("Mouse Y");
        if ((dx != 0f) || (dy != 0f))
        {
            // Checks if the mouse button is down and that there are no fingers touching the screen.
            if (Input.GetMouseButton(0) && (tCount == 0))
            {
                // If the mouse cursor has not moved at least 'longPressRadius' pixels away from
                // its inital clicked location, then noting happens.
                if (Vector2.Distance(Input.mousePosition, this.touchSpot) < this.longPressRadius)
                {
                    return;
                }
                this.touchSpot = new Vector2(-50, -50);
                if (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl))
                {
                    if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift))
                    {
                        this.getNavigateFunction(this.look)(dx, dy);
                    }
                    else
                    {
                        this.getNavigateFunction(this.pan)(dx, dy);
                    }
                }
                else
                {
                    if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift))
                    {
                        this.getNavigateFunction(this.dolly)(dx, dy);
                    }
                    else
                    {
                        this.getNavigateFunction(this.orbit)(dx, dy);
                    }
                }
            }
            else
            {
                // Right click
                if (Input.GetMouseButton(1))
                {
                    this.getNavigateFunction(this.look)(dx, dy);
                }
                else
                {
                    // Middle click
                    if (Input.GetMouseButton(2))
                    {
                        this.getNavigateFunction(this.pan)(dx, dy);
                    }
                }
            }
        }
        //if (Input.GetAxis("Mouse ScrollWheel"))
        if (this.mouseWheelScrollAmount != 0)
        {
            float            scrollAmount = Mathf.Log10(Mathf.Abs(this.mouseWheelScrollAmount) + 1);
            NavigationAction dollyAction  = this.dolly;
            dollyAction(this.mouseWheelScrollAmount < 0 ? scrollAmount : -scrollAmount);
            this.mouseWheelScrollAmount = 0;
        }
        if (tCount != this.oldTouchCount)
        {
            int i = 0;
            while (i < Mathf.Min(this.initialInputs.Length, tCount))
            {
                this.initialInputs[i] = Input.GetTouch(i).position;
                i++;
            }
            this.oldTouchCount = tCount;
            this.clearTouchInput();
        }
        // Sets the touchSpot for one finger press on the screen.
        if ((tCount == 1) && (Input.GetTouch(0).phase == TouchPhase.Began))
        {
            this.touchSpot = Input.GetTouch(0).position;
        }
        if ((tCount > 0) && (Input.GetTouch(0).phase == TouchPhase.Moved))
        {
            if ((tCount == 1) && (Vector2.Distance(Input.mousePosition, this.touchSpot) < this.longPressRadius))
            {
                return;
            }
            else
            {
                if (tCount == 1)
                {
                    this.check1FingerNavigation();
                }
                else
                {
                    if (tCount == 2)
                    {
                        this.check2FingerNavigation();
                    }
                    else
                    {
                        if (tCount == 3)
                        {
                            this.check3FingerNavigation();
                        }
                        else
                        {
                            if (tCount > 3)
                            {
                                this.check4FingerNavigation();
                            }
                        }
                    }
                }
            }
            this.touchSpot = new Vector2(-50, -50);
        }
        if (this.firstUpdate < 3)
        {
            this.firstUpdate++;
            if (this.firstUpdate == 3)
            {
                NavigationAction frameAction = this.frameCamera;
                frameAction();
            }
        }
    }
 public IFilter <LinkedNavigationEvent> GetLinkedNavigationFilter(NavigationAction navigationAction, NavigationGroup navigationGroup, Color colorGroup)
 {
     return(new LinkedEventFilter(navigationAction, navigationGroup, colorGroup));
 }
Exemple #34
0
 /// <summary>
 /// Uninvoke navigation on an object with a given action (navigation action)
 /// </summary>
 /// <param name="a"></param>
 public void UnInvokeNavigation(NavigationAction a)
 {
     this.mainPicBox.UninvokeNavigation(a);
 }