コード例 #1
0
        // Disable all options on the Map node's View tab, so that the user can
        // still see the Map's zoom width, etc., but the user cannot type in
        // new values.
        private void DisableMapViewTab()
        {
            // Call a method on LayerControl class that returns the
            // collection of PropertiesUserControl objects currently
            // associated with the Map class.  This collection of
            // PropertiesUserControl objects is what populates the
            // TabControl whenever the Map node is selected.
            IList controlList =
                layerControl1.GetLayerTypeControls(typeof(MapInfo.Mapping.Map));

            // Determine which of the controls in the collection is
            // the View control.
            foreach (object obj in controlList)
            {
                // Try to cast to a MapViewControl class, which might not work
                MapViewControl mvc = obj as MapViewControl;
                if (mvc != null)
                {
                    // The current control is the one shown on the View tab.
                    // Disable everything on the tab.
                    mvc.Enabled = false;

                    // The MapViewControl has an Apply button; there is no
                    // point showing a button that is disabled.
                    // So hide the button:
                    mvc.ShowApplyButton = false;

                    break;
                }
            }
        }
コード例 #2
0
        public void CreateZone(List <LatitudeLongitude> coordonates
                               , bool isInAlert
                               , bool isLastMarker = false
                               , int index         = 0)
        {
            if (coordonates?.Count < 1)
            {
                return;
            }
            DeleteZone();

            var listLocation = new List <CLLocationCoordinate2D>();

            coordonates.ForEach(coord => listLocation.Add(new CLLocationCoordinate2D {
                Latitude = coord.Latitude, Longitude = coord.Longitude
            }));

            // Create an array of coordinates from allPins
            var finalCoordonates = new CLLocationCoordinate2D[listLocation.Count + 1];

            int i = 0;

            foreach (var currentPin in listLocation)
            {
                finalCoordonates[i] = currentPin;
                i++;
            }
            finalCoordonates[i] = finalCoordonates[0];

            // Add an overlay of the Zone
            ZonePolygon = MKPolygon.FromCoordinates(finalCoordonates);
            MapViewControl.AddOverlay(ZonePolygon);
        }
コード例 #3
0
 public void CenterOnZone()
 {
     if (ZonePolygon != null && ZonePolygon.Points != null)
     {
         MapViewControl.SetVisibleMapRect(ZonePolygon.BoundingMapRect, new UIEdgeInsets(50, 20, 100, 20), true);
     }
 }
コード例 #4
0
        public void CreateSeekiosMarkerAsync(string seekiosId
                                             , string title
                                             , string imageBase64
                                             , DateTime?lastLocationDate
                                             , double latitude
                                             , double longitude
                                             , double accuracy
                                             , bool isDontMove = false
                                             , bool isInAlert  = false)
        {
            var seekiosLocation = new CLLocationCoordinate2D(latitude, longitude);
            var seekiosImg      = CreateSeekiosBitmap(imageBase64, accuracy, isInAlert, isDontMove);

            var seekiosAnnotation = new SeekiosAnnotation(seekiosLocation, seekiosImg);

            seekiosAnnotation.IdSeekios = int.Parse(seekiosId);
            MapViewControl.AddAnnotations(seekiosAnnotation);
            SelectedAnnotation = seekiosAnnotation;
            CreateAccuracyArea(latitude, longitude, accuracy);
            seekiosAnnotation.IsAlert = isInAlert;

            _annotations.Add(seekiosAnnotation);
            _annotationIdAssociation.Add(new SeekiosMarkerIdAssociation(seekiosId, seekiosAnnotation.Id));

            if (App.Locator.ModeZone.IsOnEditMode && App.Locator.ModeZone.IsActivityFocused)
            {
            }
            else
            {
                MapViewControl.SelectAnnotation(seekiosAnnotation, true);
            }
        }
コード例 #5
0
 public void DeleteZone()
 {
     if (ZonePolygon != null)
     {
         MapViewControl.RemoveOverlay(ZonePolygon);
     }
     ZonePolygon = null;
 }
コード例 #6
0
 public void RemoveSelectedHistoryMarker()
 {
     if (SelectedLocationHistory == null)
     {
         return;
     }
     MapViewControl.RemoveAnnotation(SelectedLocationHistory);
 }
コード例 #7
0
        public void ChangeSelectedLocationHistory(LocationDTO coordonate)
        {
            // remove the old position if its exist
            if (SelectedLocationHistory != null)
            {
                MapViewControl.RemoveAnnotation(SelectedLocationHistory);
            }

            // if we don't need to select, exit
            if (coordonate == null)
            {
                return;
            }

            // remplacing with the new annotation
            var location = new CLLocationCoordinate2D(coordonate.Latitude, coordonate.Longitude);

            SelectedLocationHistory = new HistoricAnnotation(location
                                                             , " "
                                                             , string.Empty);
            ((HistoricAnnotation)SelectedLocationHistory).Content = coordonate.DateLocationCreation.FormatDateFromNow();
            MapViewControl.AddAnnotation(SelectedLocationHistory);

            // display accuracy if necessary
            CreateAccuracyArea(coordonate.Latitude
                               , coordonate.Longitude
                               , coordonate.Accuracy);

            //// center the new annotation on the map
            //if (!App.Locator.ModeZone.IsOnEditMode)
            //{
            //    if (coordonate.Accuracy == 0)
            //    {
            //        CenterInLocalisation(coordonate.Latitude
            //            , coordonate.Longitude
            //            , 0
            //            , true);
            //    }
            //    else
            //    {
            //        CenterInLocalisation(coordonate.Latitude
            //            , coordonate.Longitude
            //            , 0
            //            , true);
            //        //// display the annotation with accurency and focus on the circle
            //        //_mapViewControl.MapRectThatFits(CreateAccuracyArea(coordonate.Latitude
            //        //, coordonate.Longitude
            //        //, coordonate.Accuracy).BoundingMapRect);
            //    }
            //}

            // display the annotation view
            MapViewControl.SelectAnnotation(SelectedLocationHistory, true);
            //CreateAccuracyArea(coordonate.Latitude
            //    , coordonate.Longitude
            //    , coordonate.Accuracy);
        }
コード例 #8
0
 public override void ViewDidUnload()
 {
     base.ViewDidUnload();
     if (MapViewControl != null)
     {
         MapViewControl.MapType  = MapKit.MKMapType.Hybrid;
         MapViewControl.Delegate = null;
         MapViewControl.RemoveFromSuperview();
         MapViewControl.Dispose();
         MapViewControl = null;
     }
 }
コード例 #9
0
        public void CenterOnLocations(List <LatitudeLongitude> locations
                                      , bool with_animation = false)
        {
            if (locations == null || locations.Count == 0)
            {
                return;
            }

            var minLat  = locations.Select(el => el.Latitude).Min();
            var minLong = locations.Select(el => el.Longitude).Min();

            var maxLat  = locations.Select(el => el.Latitude).Max();
            var maxLong = locations.Select(el => el.Longitude).Max();

            var coordinateMin = new CLLocationCoordinate2D(minLat, minLong);
            var coordinateMax = new CLLocationCoordinate2D(maxLat, maxLong);

            var upperLeft  = MKMapPoint.FromCoordinate(coordinateMin);
            var lowerRight = MKMapPoint.FromCoordinate(coordinateMax);

            var mapRect = new MKMapRect(upperLeft.X
                                        , upperLeft.Y
                                        , lowerRight.X - upperLeft.X
                                        , lowerRight.Y - upperLeft.Y);

            var region = MKCoordinateRegion.FromMapRect(mapRect);

            MapViewControl.SetVisibleMapRect(mapRect
                                             , new UIEdgeInsets(50, 20, 100, 20)
                                             , true);

            try
            {
                if (region.Center.Latitude > -89 && region.Center.Latitude < 89 && region.Center.Longitude > -179 && region.Center.Longitude < 179)
                {
                    if (region.Span.LatitudeDelta < 0)
                    {
                        region.Span.LatitudeDelta = 0.0;
                    }
                    if (region.Span.LongitudeDelta < 0)
                    {
                        region.Span.LongitudeDelta = 0.0;
                    }

                    MapViewControl.SetRegion(region, with_animation);
                }
            }
            catch (Exception)
            {
                //UIAlertView alert = new UIAlertView("Exception", String.Format("{0} \n {1}?", e.Message, e.StackTrace), null, "Cancel");
                //alert.Show();
            }
        }
コード例 #10
0
        private void ZoomInButton_TouchUpInside(object sender, EventArgs e)
        {
            _zoomInButton.UserInteractionEnabled = false;
            var region = MapViewControl.Region;
            var span   = MapViewControl.Region.Span;

            region.Center       = MapViewControl.Region.Center;
            span.LatitudeDelta  = MapViewControl.Region.Span.LatitudeDelta / 2.0002;
            span.LongitudeDelta = MapViewControl.Region.Span.LongitudeDelta / 2.0002;
            region.Span         = span;

            MapViewControl.SetRegion(region, true);
            _zoomInButton.UserInteractionEnabled = true;
        }
コード例 #11
0
        public override void ViewDidUnload()
        {
            base.ViewDidUnload();

            App.Locator.ModeZone.IsOnEditMode      = false;
            App.Locator.ModeZone.IsActivityFocused = false;

            if (MapViewControl != null)
            {
                MapViewControl.MapType  = MapKit.MKMapType.Hybrid;
                MapViewControl.Delegate = null;
                MapViewControl.RemoveFromSuperview();
                MapViewControl.Dispose();
                MapViewControl = null;
            }
        }
コード例 #12
0
        public bool CenterInMarker(string seekiosId
                                   , bool showAnnotation = false
                                   , bool withAnimation  = false)
        {
            var idAnnotationAsso = _annotationIdAssociation.FirstOrDefault(id => id.SeekiosId == seekiosId);

            if (idAnnotationAsso == null)
            {
                return(false);
            }
            var seekiosAnnotation = _annotations.FirstOrDefault(annotation => annotation.Id.Equals(idAnnotationAsso.MarkerId));

            if (seekiosAnnotation == null)
            {
                return(false);
            }

            var seekios = App.CurrentUserEnvironment.LsSeekios.FirstOrDefault(f => f.Idseekios.ToString() == seekiosId);

            if (seekios != null)
            {
                if (seekios.LastKnownLocation_accuracy > 0)
                {
                    var centerPostion = new CLLocationCoordinate2D(seekios.LastKnownLocation_latitude
                                                                   , seekios.LastKnownLocation_longitude);
                    var circle = MKCircle.Circle(centerPostion
                                                 , seekios.LastKnownLocation_accuracy);
                    MapViewControl.SetVisibleMapRect(circle.BoundingMapRect, new UIEdgeInsets(50, 20, 100, 20), true);
                }
                else
                {
                    CenterInLocalisation(seekios.LastKnownLocation_latitude
                                         , seekios.LastKnownLocation_longitude
                                         , (float)ZoomLevelEnum.BigZoom
                                         , withAnimation);
                }
            }

            if (showAnnotation)
            {
                SelectedAnnotation = seekiosAnnotation;
                MapViewControl.SelectAnnotation(seekiosAnnotation, withAnimation);
            }

            return(true);
        }
コード例 #13
0
        public void CreateRouteBackground(List <LocationDTO> coordonates)
        {
            _controller.InvokeOnMainThread(() =>
            {
                // Clean the map
                if (RoutePolyline != null)
                {
                    MapViewControl.RemoveOverlay(RoutePolyline);
                }
                if (PointsOfRoute.Count > 0)
                {
                    MapViewControl.RemoveAnnotations(PointsOfRoute.ToArray());
                    PointsOfRoute.Clear();
                }
                if (SelectedPointsOfRoute != null)
                {
                    MapViewControl.RemoveAnnotation(SelectedPointsOfRoute);
                }
            });

            if (coordonates.Count != 0)
            {
                foreach (var coordonate in coordonates)
                {
                    if (IsOutOf)
                    {
                        var trackingAnnotation = new TrackingAnnotation(new CLLocationCoordinate2D(coordonate.Latitude, coordonate.Longitude)
                                                                        , " ", string.Empty);
                        trackingAnnotation.Content   = coordonate.DateLocationCreation.FormatDateFromNow();
                        trackingAnnotation.IsInAlert = IsOutOf;
                        PointsOfRoute.Add(trackingAnnotation);
                    }
                    else
                    {
                        var trackingAnnotation = new TrackingAnnotation(new CLLocationCoordinate2D(coordonate.Latitude, coordonate.Longitude)
                                                                        , " ", string.Empty);
                        trackingAnnotation.Content   = coordonate.DateLocationCreation.FormatDateFromNow();
                        trackingAnnotation.IsInAlert = IsOutOf;
                        PointsOfRoute.Add(trackingAnnotation);
                    }
                }
            }
            OnInitTrackingRouteComplete?.Invoke(null, null);
        }
コード例 #14
0
        public void CenterInLocalisation(double latitude
                                         , double longitude
                                         , float zoomLevel
                                         , bool withAnimation = false)
        {
            var mapCenter = new CLLocationCoordinate2D(latitude, longitude);

            if (zoomLevel != 0)
            {
                var span      = new MKCoordinateSpan(0, 360 / Math.Pow(2, zoomLevel) * MapViewControl.Frame.Size.Width / 256);
                var mapRegion = new MKCoordinateRegion(mapCenter, span);
                MapViewControl.CenterCoordinate = mapCenter;
                MapViewControl.SetRegion(mapRegion, withAnimation);
            }
            else
            {
                MapViewControl.CenterCoordinate = mapCenter;
            }
        }
コード例 #15
0
        public void CreateRouteForeground(List <LocationDTO> coordonates)
        {
            if (PointsOfRoute != null && PointsOfRoute.Count != 0)
            {
                foreach (var annotation in PointsOfRoute)
                {
                    MapViewControl.AddAnnotation(annotation);
                }

                var positionWithSeekios = PointsOfRoute.Select(s => s.Coordinate).ToList();
                if (SelectedAnnotation != null && !positionWithSeekios.Contains(SelectedAnnotation.Coordinate))
                {
                    positionWithSeekios.Add(SelectedAnnotation.Coordinate);
                }
                var polygon = MKPolyline.FromCoordinates(positionWithSeekios.ToArray());
                MapViewControl.AddOverlay(polygon);
                MapViewControl.SetVisibleMapRect(polygon.BoundingMapRect, new UIEdgeInsets(50, 40, 100, 40), true);
            }
        }
コード例 #16
0
        private void ZoomOutButton_TouchUpInside(object sender, EventArgs e)
        {
            _zoomOutButton.UserInteractionEnabled = false;
            var region = MapViewControl.Region;
            var span   = MapViewControl.Region.Span;

            region.Center       = MapViewControl.Region.Center;
            span.LatitudeDelta  = MapViewControl.Region.Span.LatitudeDelta * 2;
            span.LongitudeDelta = MapViewControl.Region.Span.LongitudeDelta * 2;
            region.Span         = span;

            if (span.LatitudeDelta > 200 || span.LongitudeDelta > 200)
            {
                return;
            }
            MapViewControl.SetRegion(region, true);

            _zoomOutButton.UserInteractionEnabled = true;
        }
コード例 #17
0
        public void ChangeAnnotationLocation(string seekiosId
                                             , double latitude
                                             , double longitude
                                             , double accuracy)
        {
            var idMarkerAsso = _annotationIdAssociation.FirstOrDefault(id => id.SeekiosId == seekiosId);

            if (idMarkerAsso != null)
            {
                var annotation = _annotations.FirstOrDefault(m => m.Id.Equals(idMarkerAsso.MarkerId));
                if (annotation != null)
                {
                    var mapCenter = new CLLocationCoordinate2D(latitude, longitude);
                    annotation.SetCoordinate(mapCenter);
                    MapViewControl.SelectAnnotation(annotation, true);
                    MapViewControl.SetCenterCoordinate(mapCenter, true);
                }
            }
        }
コード例 #18
0
        void ReleaseDesignerOutlets()
        {
            if (MapViewControl != null)
            {
                MapViewControl.Dispose();
                MapViewControl = null;
            }

            if (MapZoomInButton != null)
            {
                MapZoomInButton.Dispose();
                MapZoomInButton = null;
            }

            if (MapZoomOutButton != null)
            {
                MapZoomOutButton.Dispose();
                MapZoomOutButton = null;
            }
        }
コード例 #19
0
        public MKCircle CreateAccuracyArea(double latitude
                                           , double longitude
                                           , double accuracy)
        {
            if (_accuracyArea != null)
            {
                MapViewControl.RemoveOverlay(_accuracyArea);
            }
            if (accuracy <= 0)
            {
                return(null);
            }
            var centerPostion = new CLLocationCoordinate2D(latitude, longitude);
            var circle        = MKCircle.Circle(centerPostion, accuracy);

            MapViewControl.AddOverlay(circle);
            MapViewControl.SetVisibleMapRect(circle.BoundingMapRect, new UIEdgeInsets(50, 20, 100, 20), true);
            _accuracyArea = circle;

            return(_accuracyArea);
        }
コード例 #20
0
        // Remove the Map node's View tab, so that when the user selects
        // the Map node, the TabControl will not contain a View tab.
        // The same technique could be used to remove any or all of the tabs
        // associated with any type of node in the layers tree.
        private void RemoveMapViewTab()
        {
            // Call a method on LayerControl class that returns the
            // collection of PropertiesUserControl objects currently
            // associated with the Map class.
            IList controlList =
                layerControl1.GetLayerTypeControls(typeof(MapInfo.Mapping.Map));

            // Determine which of the controls in the collection is
            // the View control.
            foreach (object obj in controlList)
            {
                MapViewControl mvc = obj as MapViewControl;
                if (mvc != null)
                {
                    // The current control is the one shown on the View tab.
                    // Remove it from the collection.
                    controlList.Remove(obj);
                    break;
                }
            }
        }
コード例 #21
0
        public MapControlManager(MKMapView mapViewControl
                                 , UIViewController controller
                                 , UIButton focusOnSeekiosButton
                                 , UIButton focusOnZoneButton
                                 , UIButton changeMapTypeButton
                                 , UIButton zoomInButton
                                 , UIButton zoomOutButton
                                 , UIButton editZoneButton
                                 , UIButton undoButton
                                 , UIButton nextButton
                                 , string idSeekios)
            : this(mapViewControl
                   , controller
                   , focusOnSeekiosButton
                   , changeMapTypeButton
                   , zoomInButton
                   , zoomOutButton
                   , idSeekios)
        {
            _focusOnZoneButton = focusOnZoneButton;
            //_editZoneButton = editZoneButton;
            _undoButton = undoButton;
            _nextButton = nextButton;
            _recognizer = new UILongPressGestureRecognizer(AddPointToZone);
            MapViewControl.AddGestureRecognizer(_recognizer);
            _recognizer.MinimumPressDuration = 0.08;

            try
            {
                //SetShadows(_editZoneButton);
                SetShadows(_undoButton);
                SetShadows(_focusOnZoneButton);
            }
            catch (Exception) { }

            PointsOfZone = new List <MKAnnotation>();
            UndoActions  = new ObservableCollection <Action>();
        }
コード例 #22
0
        private void SelectAnnotation()
        {
            MapViewControl.RemoveAnnotations(MapViewControl.Annotations);

            if (ViewModel.Annotation != null &&
                ViewModel.Annotation.Addresses != null &&
                ViewModel.Annotation.Addresses.Length > 0)
            {
                var annotations = ViewModel.Annotation.Addresses
                                  .Select(address => new MapViewAnnotation(
                                              ViewModel.Annotation.Pin,
                                              ViewModel.Annotation.Title,
                                              address)).ToArray();
                var coordinates = MapUtil.GetAnnotationsCoordinates(annotations);

                MapViewControl.SetRegion(
                    MapUtil.CoordinateRegionForCoordinates(
                        coordinates,
                        new MKMapSize(5000, 5000)),
                    false);
                MapViewControl.AddAnnotations(annotations);
                MapViewControl.SelectAnnotation(annotations[0], false);
            }
        }
コード例 #23
0
        void ReleaseDesignerOutlets()
        {
            if (ChangeMapTypeButton != null)
            {
                ChangeMapTypeButton.Dispose();
                ChangeMapTypeButton = null;
            }

            if (FocusOnSeekiosButton != null)
            {
                FocusOnSeekiosButton.Dispose();
                FocusOnSeekiosButton = null;
            }

            if (FocusOnZoneButton != null)
            {
                FocusOnZoneButton.Dispose();
                FocusOnZoneButton = null;
            }

            if (MapViewControl != null)
            {
                MapViewControl.Dispose();
                MapViewControl = null;
            }

            if (MapZoomInButton != null)
            {
                MapZoomInButton.Dispose();
                MapZoomInButton = null;
            }

            if (MapZoomOutButton != null)
            {
                MapZoomOutButton.Dispose();
                MapZoomOutButton = null;
            }

            if (NextButton != null)
            {
                NextButton.Dispose();
                NextButton = null;
            }

            if (NumberOfPointsLabel != null)
            {
                NumberOfPointsLabel.Dispose();
                NumberOfPointsLabel = null;
            }

            if (RefreshInProgressButton != null)
            {
                RefreshInProgressButton.Dispose();
                RefreshInProgressButton = null;
            }

            if (SurfaceLabel != null)
            {
                SurfaceLabel.Dispose();
                SurfaceLabel = null;
            }

            if (TimerLabel != null)
            {
                TimerLabel.Dispose();
                TimerLabel = null;
            }

            if (UndoButton != null)
            {
                UndoButton.Dispose();
                UndoButton = null;
            }
        }
コード例 #24
0
 private void InitializeStyle()
 {
     MapViewControl.TintColor = ThemeColors.Metadata;
     MapViewControl.FixLegalLabel();
 }
コード例 #25
0
 internal MapPresenter(Map map, MapViewControl mapView)
     : base(map, mapView) { }
コード例 #26
0
        void ReleaseDesignerOutlets()
        {
            if (actionSheetDatePicker != null)
            {
                actionSheetDatePicker.Dispose();
                actionSheetDatePicker = null;
            }

            if (ChangeMapTypeButton != null)
            {
                ChangeMapTypeButton.Dispose();
                ChangeMapTypeButton = null;
            }

            if (FocusOnSeekiosButton != null)
            {
                FocusOnSeekiosButton.Dispose();
                FocusOnSeekiosButton = null;
            }

            if (LoadingIndicator != null)
            {
                LoadingIndicator.Dispose();
                LoadingIndicator = null;
            }

            if (LowerDateLabel != null)
            {
                LowerDateLabel.Dispose();
                LowerDateLabel = null;
            }

            if (MapViewControl != null)
            {
                MapViewControl.Dispose();
                MapViewControl = null;
            }

            if (MapZoomInButton != null)
            {
                MapZoomInButton.Dispose();
                MapZoomInButton = null;
            }

            if (MapZoomOutButton != null)
            {
                MapZoomOutButton.Dispose();
                MapZoomOutButton = null;
            }

            if (NextPositionButton != null)
            {
                NextPositionButton.Dispose();
                NextPositionButton = null;
            }

            if (OldDateLabel != null)
            {
                OldDateLabel.Dispose();
                OldDateLabel = null;
            }

            if (PositionLabel != null)
            {
                PositionLabel.Dispose();
                PositionLabel = null;
            }

            if (PreviousPositionButton != null)
            {
                PreviousPositionButton.Dispose();
                PreviousPositionButton = null;
            }

            if (RecentDateLabel != null)
            {
                RecentDateLabel.Dispose();
                RecentDateLabel = null;
            }

            if (Slider != null)
            {
                Slider.Dispose();
                Slider = null;
            }

            if (UpperDateLabel != null)
            {
                UpperDateLabel.Dispose();
                UpperDateLabel = null;
            }
        }
コード例 #27
0
        private void AddPointToZone()
        {
            //if (_recognizer.State == UIGestureRecognizerState.Began)
            //{
            //	_dragStarted = false;
            //             Console.WriteLine("Began !");
            //             return;
            //}
            //else if (_recognizer.State == UIGestureRecognizerState.Changed)
            //{
            //	_dragStarted = true;
            //             Console.WriteLine("Drag !");
            //	// Do dragging stuff here
            //}
            //else if (_recognizer.State == UIGestureRecognizerState.Ended){
            //	if (_dragStarted)
            //	{
            //                 Console.WriteLine("Ended 1!");
            //                 _dragStarted = false;
            //		return;
            //	}
            //	else {
            //             Console.WriteLine("Ended !");
            //             }
            //         }
            if (_recognizer.State == UIGestureRecognizerState.Began)
            {
                //if (_recognizer.State == UIGestureRecognizerState.Began || !IsOnPointAdding) return;
                if (ZonePolygon != null && ZonePolygon.Points.Count() > App.Locator.ModeZone.MAX_NUMBER_OF_POINTS)
                {
                    return;
                }

                // convert touched position to map coordinate
                var userTouch     = _recognizer.LocationInView(MapViewControl);
                var mapPoint      = MapViewControl.ConvertPoint(userTouch, MapViewControl);
                var newAnnotation = new ModeZoneAnnotation(mapPoint, true);

                // change the previous annotation to green
                var lastAnnotation = PointsOfZone.LastOrDefault();
                if (lastAnnotation != null)
                {
                    MapViewControl.RemoveAnnotation(lastAnnotation);
                    ((ModeZoneAnnotation)lastAnnotation).IsLastAnnotation = false;
                    MapViewControl.AddAnnotation(lastAnnotation);
                }

                // refresh the polygone
                List <LatitudeLongitude> zone = PointsOfZone.Select(el => new LatitudeLongitude(el.Coordinate.Latitude, el.Coordinate.Longitude)).ToList();
                zone.Add(new LatitudeLongitude(mapPoint.Latitude, mapPoint.Longitude));
                if (!App.Locator.ModeZone.CheckCorrectAreaFormat(zone))
                {
                    return;
                }

                var pointsToRestore = PointsOfZone.Select(el => el.Coordinate).ToList();
                PointsOfZone.Add(newAnnotation);

                MapViewControl.AddAnnotation(newAnnotation);

                var isInAlert = MapViewModelBase.Mode != null && MapViewModelBase.Mode.StatusDefinition_idstatusDefinition != 1;

                CreateZone(PointsOfZone.Select(s => new LatitudeLongitude(s.Coordinate.Latitude, s.Coordinate.Longitude)).ToList(), isInAlert, true, 0);
                RefreshZone();

                // reverse the action
                UndoActions.Add(new Action(() =>
                {
                    MapViewControl.RemoveAnnotation(newAnnotation);
                    PointsOfZone.Remove(PointsOfZone.Last());
                    var lastAnnotationUndo = PointsOfZone.LastOrDefault();
                    if (lastAnnotationUndo != null)
                    {
                        MapViewControl.RemoveAnnotation(lastAnnotationUndo);
                        ((ModeZoneAnnotation)lastAnnotationUndo).IsLastAnnotation = true;
                        MapViewControl.AddAnnotation(lastAnnotationUndo);
                    }
                    CreateZone(pointsToRestore.Select(s => new LatitudeLongitude(s.Latitude, s.Longitude)).ToList(), isInAlert, true, 0);
                    RefreshZone();
                    if (ZonePolygon == null || ZonePolygon.Points == null || PointsOfZone.Count() < 3)
                    {
                        _nextButton.Enabled = false;
                    }
                    else
                    {
                        _nextButton.Enabled = true;
                    }
                }));

                // if the zone contain 3 points, enable the next button
                if (PointsOfZone.Count < 3)
                {
                    _nextButton.Enabled = false;
                }
                else
                {
                    _nextButton.Enabled = true;
                }
            }
        }
コード例 #28
0
        public void Dispose()
        {
            RemoveAllMarkers();

            if (_focusOnSeekiosButton != null)
            {
                _focusOnSeekiosButton.Dispose();
            }
            if (_focusOnZoneButton != null)
            {
                _focusOnZoneButton.Dispose();
            }
            if (_zoomInButton != null)
            {
                _zoomInButton.Dispose();
            }
            if (_zoomOutButton != null)
            {
                _zoomOutButton.Dispose();
            }
            if (_editZoneButton != null)
            {
                _editZoneButton.Dispose();
            }
            if (_undoButton != null)
            {
                _undoButton.Dispose();
            }
            if (_accuracyArea != null)
            {
                _accuracyArea.Dispose();
            }
            if (_mapDelegate != null)
            {
                _mapDelegate.Dispose();
            }
            if (_controller != null)
            {
                _controller.Dispose();
            }
            if (MapViewControl != null)
            {
                MapViewControl.MapType  = MKMapType.Hybrid;
                MapViewControl.Delegate = null;
                MapViewControl.RemoveFromSuperview();
                MapViewControl = null;
                MapViewControl.Dispose();
            }

            if (SelectedAnnotation != null)
            {
                SelectedAnnotation.Dispose();
            }
            if (SelectedLocationHistory != null)
            {
                SelectedLocationHistory.Dispose();
            }
            if (SelectedPointsOfRoute != null)
            {
                SelectedPointsOfRoute.Dispose();
            }
            if (RoutePolyline != null)
            {
                RoutePolyline.Dispose();
            }
            PointsOfRoute.Clear();
            PointsOfRoute = null;
        }
コード例 #29
0
        void ReleaseDesignerOutlets()
        {
            if (ArrowImage != null)
            {
                ArrowImage.Dispose();
                ArrowImage = null;
            }

            if (BottomHeadView != null)
            {
                BottomHeadView.Dispose();
                BottomHeadView = null;
            }

            if (BottomView != null)
            {
                BottomView.Dispose();
                BottomView = null;
            }

            if (ChangeMapTypeButton != null)
            {
                ChangeMapTypeButton.Dispose();
                ChangeMapTypeButton = null;
            }

            if (ChronoWaitForStartLabel != null)
            {
                ChronoWaitForStartLabel.Dispose();
                ChronoWaitForStartLabel = null;
            }

            if (DeleteModeButton != null)
            {
                DeleteModeButton.Dispose();
                DeleteModeButton = null;
            }

            if (DisplayTutoButton != null)
            {
                DisplayTutoButton.Dispose();
                DisplayTutoButton = null;
            }

            if (FirstLeftLabel != null)
            {
                FirstLeftLabel.Dispose();
                FirstLeftLabel = null;
            }

            if (FirstRefresh1Image != null)
            {
                FirstRefresh1Image.Dispose();
                FirstRefresh1Image = null;
            }

            if (FirstRightLabel != null)
            {
                FirstRightLabel.Dispose();
                FirstRightLabel = null;
            }

            if (FocusOnSeekiosButton != null)
            {
                FocusOnSeekiosButton.Dispose();
                FocusOnSeekiosButton = null;
            }

            if (FocusOnZoneButton != null)
            {
                FocusOnZoneButton.Dispose();
                FocusOnZoneButton = null;
            }

            if (HistoricButton != null)
            {
                HistoricButton.Dispose();
                HistoricButton = null;
            }

            if (LblRefreshPositionText != null)
            {
                LblRefreshPositionText.Dispose();
                LblRefreshPositionText = null;
            }

            if (MapViewControl != null)
            {
                MapViewControl.Dispose();
                MapViewControl = null;
            }

            if (MapZoomInButton != null)
            {
                MapZoomInButton.Dispose();
                MapZoomInButton = null;
            }

            if (MapZoomOutButton != null)
            {
                MapZoomOutButton.Dispose();
                MapZoomOutButton = null;
            }

            if (ModeImage != null)
            {
                ModeImage.Dispose();
                ModeImage = null;
            }

            if (ModeLabel != null)
            {
                ModeLabel.Dispose();
                ModeLabel = null;
            }

            if (ModePowerSavingImage != null)
            {
                ModePowerSavingImage.Dispose();
                ModePowerSavingImage = null;
            }

            if (RefreshInProgressButton != null)
            {
                RefreshInProgressButton.Dispose();
                RefreshInProgressButton = null;
            }

            if (RefreshPosition != null)
            {
                RefreshPosition.Dispose();
                RefreshPosition = null;
            }

            if (SecondLeftLabel != null)
            {
                SecondLeftLabel.Dispose();
                SecondLeftLabel = null;
            }

            if (SecondRightLabel != null)
            {
                SecondRightLabel.Dispose();
                SecondRightLabel = null;
            }

            if (StepSeekiosLabel != null)
            {
                StepSeekiosLabel.Dispose();
                StepSeekiosLabel = null;
            }

            if (ThirdLeftLabel != null)
            {
                ThirdLeftLabel.Dispose();
                ThirdLeftLabel = null;
            }

            if (ThirdRightLabel != null)
            {
                ThirdRightLabel.Dispose();
                ThirdRightLabel = null;
            }

            if (TimerLabel != null)
            {
                TimerLabel.Dispose();
                TimerLabel = null;
            }
        }