예제 #1
0
        public void setEndPoint(nfloat x, nfloat y, int roomFloor)
        {
            var test = this.pf.FloorGraphs [roomFloor].FindClosestNode((float)x, (float)y, 6);

            if (test == null)
            {
                var okAlertController = UIAlertController.Create("Error!", "Please select a location within the floor plan.", UIAlertControllerStyle.Alert);

                //Add Action
                okAlertController.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Default, null));

                // Present Alert
                PresentViewController(okAlertController, true, null);
                return;
            }

            SearchBar.ShowsCancelButton = false;
            SearchBar.ResignFirstResponder();
            endX = x;
            endY = y;

            directionCount = 0;

            StartNavigationPosition = new GraphLocatable((float)locationArrow.X, (float)locationArrow.Y, floor);
            EndNavgiationPosition   = new GraphLocatable((float)x, (float)y, roomFloor);

            //if (pathDisplayed == true) {
            findUserPath();
            drawUserPath();
            // }
        }
예제 #2
0
        public void setStartPoint(nfloat x, nfloat y, int roomFloor, bool shouldPf = true)
        {
            var test = this.pf.FloorGraphs [roomFloor].FindClosestNode((float)x, (float)y, 6);

            if (test == null)
            {
                var okAlertController = UIAlertController.Create("Error!", "Please select a location within the floor plan.", UIAlertControllerStyle.Alert);

                //Add Action
                okAlertController.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Default, null));

                // Present Alert
                PresentViewController(okAlertController, true, null);
                return;
            }

            locationArrow.setLocation((float)x, (float)y);
            col.SetLocation((float)x, (float)y);
            pathView.RemoveFromSuperview();
            pathView             = new PathView(wallColTest, this);
            pathView.ScaleFactor = floorplanView.ZoomScale;
            pathView.Frame       = new CGRect(new CGPoint(0, 0), floorplanImageNoGrid.Size);
            floorplanImageView.AddSubview(pathView);
            SearchBar.ShowsCancelButton = false;
            SearchBar.ResignFirstResponder();
            directionCount          = 0;
            StartNavigationPosition = new GraphLocatable((float)x, (float)y, roomFloor);
            if (shouldPf)
            {
                findUserPath();
            }
            drawUserPath();
        }
예제 #3
0
        public void redrawPath()
        {
            StartNavigationPosition = new GraphLocatable((float)locationArrow.X, (float)locationArrow.Y, floor);

            findUserPath();
            drawUserPath();
        }
예제 #4
0
        private void removePath(bool removePath = false)
        {
            InvokeOnMainThread(() => {
                Console.Out.WriteLine("DROPPING THE F*****G SHIT");

                foreach (PathView subview in floorplanImageView.Subviews)
                {
                    subview.RemoveFromSuperview();
                }

                if (removePath)
                {
                    CurrentUserPath         = new Dictionary <int, List <UndirEdge> >();
                    StartNavigationPosition = null;
                    EndNavgiationPosition   = null;
                }

                pathView             = new PathView(wallColTest, this);
                pathView.ScaleFactor = floorplanView.ZoomScale;
                pathView.Frame       = new CGRect(new CGPoint(0, 0), floorplanImageNoGrid.Size);
                floorplanImageView.AddSubview(pathView);
                pathDisplayed  = false;
                directionCount = 0;
            });
        }
예제 #5
0
        private void HandleStepsTaken(object s, PositionChangedHandlerEventArgs args)
        {
            GlobalStepCounter++;
            locationArrow.setLocation(args.newX, args.newY);

            if (EndNavgiationPosition != null && floor == EndNavgiationPosition.Floor)
            {
                if (
                    this.pf.FloorGraphs [EndNavgiationPosition.Floor].FindClosestNode(EndNavgiationPosition.X, EndNavgiationPosition.Y, 6).X - 20
                    <= this.pf.FloorGraphs [floor].FindClosestNode(locationArrow.X, locationArrow.Y, 6).X&&
                    this.pf.FloorGraphs [EndNavgiationPosition.Floor].FindClosestNode(EndNavgiationPosition.X, EndNavgiationPosition.Y, 6).X + 20
                    >= this.pf.FloorGraphs [floor].FindClosestNode(locationArrow.X, locationArrow.Y, 6).X&&
                    this.pf.FloorGraphs [EndNavgiationPosition.Floor].FindClosestNode(EndNavgiationPosition.X, EndNavgiationPosition.Y, 6).Y - 20
                    <= this.pf.FloorGraphs [floor].FindClosestNode(locationArrow.X, locationArrow.Y, 6).Y&&
                    this.pf.FloorGraphs [EndNavgiationPosition.Floor].FindClosestNode(EndNavgiationPosition.X, EndNavgiationPosition.Y, 6).Y + 20
                    >= this.pf.FloorGraphs [floor].FindClosestNode(locationArrow.X, locationArrow.Y, 6).Y
                    )
                {
                    var okAlertController = UIAlertController.Create("Arrived!", "You have reached the desired location", UIAlertControllerStyle.Alert);

                    //Add Action
                    okAlertController.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Default, null));

                    // Present Alert
                    PresentViewController(okAlertController, true, null);
                    StartNavigationPosition = null;
                    EndNavgiationPosition   = null;
                    removePath();
                    drawUserPath();
                }
            }



            /*if (GlobalStepCounter % 12 == 0 && pathDisplayed == true) {
             *  drawPathFromUser ((float)endX, (float)endY);
             * }*/
        }