コード例 #1
0
        [Export("tableView:didSelectRowAtIndexPath:")] //DismissKeyboard() would block it
        public virtual void RowSelected(UIKit.UITableView tableView, Foundation.NSIndexPath indexPath)
        {
            if (indexPath.Row != selectedPos)
            {
                locationList[selectedPos].isSelected   = false;
                locationList[indexPath.Row].isSelected = true;
                selectedPos = indexPath.Row;

                CLLocationCoordinate2D location = new CLLocationCoordinate2D(locationList[indexPath.Row].latitude, locationList[indexPath.Row].longitude);
                MoveMap(location, false);
                AddCircle(location);
            }
            else
            {
                if (locationList[selectedPos].isSelected == false)
                {
                    locationList[selectedPos].isSelected = true;

                    CLLocationCoordinate2D location = new CLLocationCoordinate2D(locationList[indexPath.Row].latitude, locationList[indexPath.Row].longitude);
                    MoveMap(location, false);
                    AddCircle(location);
                }
                else
                {
                    locationList[selectedPos].isSelected = false;
                    if (!(circle is null))
                    {
                        LocationHistoryMap.RemoveAnnotation(circle);
                    }
                }
            }
            LocationHistoryList.ReloadData();
        }
コード例 #2
0
 private void AddCircle(CLLocationCoordinate2D location)
 {
     if (!(circle is null))
     {
         LocationHistoryMap.RemoveAnnotation(circle);
     }
     circle = new MKPointAnnotation()
     {
         Title = "Center", Coordinate = location
     };
     LocationHistoryMap.AddAnnotation(circle);
 }
コード例 #3
0
        private void AddLine(CLLocationCoordinate2D location1, CLLocationCoordinate2D location2, int red, int green, int blue)
        {
            MKPolyline line1 = MKPolyline.FromCoordinates(new CLLocationCoordinate2D[] { location1, location2 });
            MKPolyline line2 = MKPolyline.FromCoordinates(new CLLocationCoordinate2D[] { location1, location2 }); //subclassing MKPolyline to add a color property would not work. https://forums.xamarin.com/discussion/38410/extend-mkpolyline-to-draw-on-map-with-different-colors

            line2.Title = red + "|" + green + "|" + blue;

            LocationHistoryMap.AddOverlay(line1);
            LocationHistoryMap.AddOverlay(line2);

            lines.Add(line1);
            lines.Add(line2);
        }
コード例 #4
0
        void ReleaseDesignerOutlets()
        {
            if (BottomConstraint != null)
            {
                BottomConstraint.Dispose();
                BottomConstraint = null;
            }

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

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

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

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

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

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

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

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

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

            if (SnackTopConstraint != null)
            {
                SnackTopConstraint.Dispose();
                SnackTopConstraint = null;
            }
        }
コード例 #5
0
        private void LoadList()
        {
            locationList = new List <LocationItem>();
            if (lines != null)
            {
                LocationHistoryMap.RemoveOverlays(lines.ToArray());
            }
            lines = new List <MKPolyline>();

            //File.Delete(c.locationLogFile);

            if (File.Exists(c.locationLogFile))
            {
                string[] fileLines = File.ReadAllLines(c.locationLogFile);

                for (int i = fileLines.Length - 1; i >= 0; i--)
                {
                    string       line = fileLines[i];
                    LocationItem item = new LocationItem();

                    int sep1Pos = line.IndexOf('|');
                    int sep2Pos = line.IndexOf('|', sep1Pos + 1);
                    int sep3Pos = line.IndexOf('|', sep2Pos + 1);

                    if (sep2Pos != -1)
                    {
                        item.time      = long.Parse(line.Substring(0, sep1Pos));
                        item.latitude  = double.Parse(line.Substring(sep1Pos + 1, sep2Pos - sep1Pos - 1), CultureInfo.InvariantCulture);
                        item.longitude = double.Parse(line.Substring(sep2Pos + 1, sep3Pos - sep2Pos - 1), CultureInfo.InvariantCulture);
                        string status = line.Substring(sep3Pos + 1);
                        switch (status)
                        {
                        case "0":
                            item.inApp = false;
                            item.sent  = false;
                            break;

                        case "1":
                            item.inApp = true;
                            item.sent  = false;
                            break;

                        case "2":
                            item.inApp = true;
                            item.sent  = true;
                            break;
                        }
                        item.isSelected = false;
                        locationList.Add(item);
                    }
                }
                locationList[0].isSelected = true;
                selectedPos = 0;
            }
            else
            {
                c.Snack(LangEnglish.NoLocationRecords);
            }

            adapter = new LocationListAdapter(locationList);
            LocationHistoryList.Source = adapter;
            LocationHistoryList.ReloadData();
            LocationHistoryList.Delegate = this;
        }