Exemplo n.º 1
0
        private void CreateRoute(object sender, EventArgs e)
        {
            StopRoute();

            NCDeviceInfo  res               = navigineCore.DeviceInfo;
            NCSublocation sublocation       = navigineCore.Location.Sublocations.GetItem <NCSublocation>(currentSublocationIndex);
            CGSize        imageSizeInMeters = new CGSize(sublocation.Width, sublocation.Height);
            double        xPoint            = pressedRoutePin.CenterX() / (mapView.Width() / scrollView.ZoomScale) * imageSizeInMeters.Width;
            double        yPoint            = (1.0f - pressedRoutePin.CenterY() / (mapView.Height() / scrollView.ZoomScale)) * imageSizeInMeters.Height;

            NCLocationPoint point = NCLocationPoint.PointWithLocation(res.Location, res.Sublocation, xPoint, yPoint);

            activeRoutePin = new RouteMapPin();
            activeRoutePin.SetImage(UIImage.FromBundle("MapUser"), UIControlState.Normal);
            activeRoutePin.SetImage(UIImage.FromBundle("MapUser"), UIControlState.Highlighted);
            activeRoutePin.SizeToFit();
            mapView.AddSubview(activeRoutePin);
            scrollView.BringSubviewToFront(activeRoutePin);
            activeRoutePin.Center = pressedRoutePin.Center;

            if (pressedRoutePin != null)
            {
                pressedRoutePin.PopUp.RemoveFromSuperview();
                pressedRoutePin.RemoveFromSuperview();
            }

            navigineCore.AddTatget(point);

            isRouting = true;
            cancelRouteButton.Hidden = false;
        }
Exemplo n.º 2
0
        private void AdjustDevice()
        {
            // Check if location is loaded
            if (location == null)
            {
                return;
            }


            // Check if navigation is available
            if (!deviceInfo.IsValid())
            {
                return;
            }

            // Check if device belongs to the location loaded
            if (deviceInfo.Location != location.Id)
            {
                return;
            }

            DateTime timeNow = DateTime.Now;

            // Adjust map, if necessary
            if (timeNow >= adjustTime)
            {
                // Firstly, set the correct sublocation
                NCSublocation sublocation = navigineCore.Location.Sublocations.GetItem <NCSublocation>(currentSublocationIndex);
                if (deviceInfo.Sublocation != sublocation.Id)
                {
                    for (nuint i = 0; i < location.Sublocations.Count; ++i)
                    {
                        NCSublocation subLoc = navigineCore.Location.Sublocations.GetItem <NCSublocation>(i);
                        if (subLoc.Id == deviceInfo.Sublocation)
                        {
                            SetCurrentSublocation(i);
                        }
                    }
                }

                deviceView.Hidden = false;

                // Secondly, adjust device to the center of the screen
                var deviceCenterPoint = new CGPoint(
                    mapView.Frame.Width / scrollView.ZoomScale * deviceInfo.Kx,
                    mapView.Frame.Height / scrollView.ZoomScale * (1.0f - deviceInfo.Ky));

                var offsetX = Math.Max((scrollView.Bounds.Size.Width - scrollView.ContentSize.Width) * 0.5, 0.0);
                var offsetY = Math.Max((scrollView.Bounds.Size.Height - scrollView.ContentSize.Height) * 0.5, 0.0);

                var x = deviceCenterPoint.X * scrollView.ZoomScale - scrollView.Bounds.Size.Width / 2 + offsetX;
                var y = deviceCenterPoint.Y * scrollView.ZoomScale - scrollView.Bounds.Size.Height / 2 + offsetY;

                scrollView.SetContentOffset(new CGPoint(x, y), true);

                adjustTime = timeNow;
            }
        }
Exemplo n.º 3
0
        private bool SetCurrentSublocation(nuint index)
        {
            if (navigineCore == null)
            {
                return(false);
            }

            if (location == null || index < 0 || index >= location.Sublocations.Count)
            {
                return(false);
            }

            scrollView.SetZoomScale(1.0f, true);

            adjustTime = DateTime.MinValue;

            currentSublocationIndex = index;
            currentSublocation      = location.Sublocations.GetItem <NCSublocation>(index);
            currentFloorLabel.Text  = $"{currentSublocationIndex}";

            if (currentSublocationIndex > 0)
            {
                prevFloorButton.Enabled         = true;
                prevFloorButton.BackgroundColor = UIColor.FromRGBA(170, 170, 170, 90);
            }
            else
            {
                prevFloorButton.Enabled         = false;
                prevFloorButton.BackgroundColor = UIColor.FromRGBA(221, 221, 221, 90);
            }

            if (currentSublocationIndex + 1 < location.Sublocations.Count)
            {
                nextFloorButton.Enabled         = true;
                nextFloorButton.BackgroundColor = UIColor.FromRGBA(170, 170, 170, 90);
            }
            else
            {
                nextFloorButton.Enabled         = false;
                nextFloorButton.BackgroundColor = UIColor.FromRGBA(221, 221, 221, 90);
            }

            RefreshMap();

            return(true);
        }
Exemplo n.º 4
0
        private void PopUpPressed(object sender, EventArgs e)
        {
            StopRoute();
            NCDeviceInfo  res               = navigineCore.DeviceInfo;
            NCSublocation sublocation       = navigineCore.Location.Sublocations.GetItem <NCSublocation>(currentSublocationIndex);
            CGSize        imageSizeInMeters = new CGSize(sublocation.Width, sublocation.Height);
            double        xPoint            = pressedPin.CenterX() / (mapView.Width() / scrollView.ZoomScale) * imageSizeInMeters.Width;
            double        yPoint            = (1.0f - pressedPin.CenterY() / (mapView.Height() / scrollView.ZoomScale)) * imageSizeInMeters.Height;

            NCLocationPoint point = NCLocationPoint.PointWithLocation(res.Location, res.Sublocation, xPoint, yPoint);

            navigineCore.AddTatget(point);

            pressedPin.PopUp.RemoveFromSuperview();
            pressedPin.PopUp.Hidden = true;
            isRouting = true;
            cancelRouteButton.Hidden = false;
        }