示例#1
0
        private void BPLocationButton_Click(object sender, EventArgs eventArgs)
        {
            GPSTracker GPSTracker = new GPSTracker();

            Android.Locations.Location location = GPSTracker.GPSCoordinate();
            if (!GPSTracker.isLocationGPSEnabled)
            {
                ShowSettingsAlert();
            }
            if (location == null)
            {
                MessageDialog messageDialog = new MessageDialog();
                messageDialog.SendToast("Unable to get location");
            }
            else
            {
                BoundryPolygon BoundryPolygon = new BoundryPolygon()
                {
                    Latitude  = location.Latitude.ToString(),
                    Longitude = location.Longitude.ToString()
                };
                _BoundryPolygons.Add(BoundryPolygon);
                itemList.Add("Lat: " + location.Latitude.ToString() + " Long: " + location.Longitude.ToString());

                boundaryPolygonsText.Text = String.Format("Boundary Polygons {0}", itemList.Count);
                arrayAdapter              = new ArrayAdapter <string>(Activity, Resource.Layout.list_item, itemList);
                bpListView.Adapter        = arrayAdapter;
                bpListView.ItemLongClick += Adapter_ItemSwipe;
                int listViewMinimumHeight = 25 * _BoundryPolygons.Count();
                bpListView.SetMinimumHeight(listViewMinimumHeight);
            }
        }
示例#2
0
        private Location GetLocation(Location location, ref ApplicationUnit unit)
        {
            if (location != null)
            {
                Location loc = unit.Locations.GetAll()
                               .Include(gps => gps.GPSCoordinates)
                               .Include(bp => bp.BoundryPolygon)
                               .FirstOrDefault(p => p.Id == location.Id);

                if (loc != null)
                {
                    if (location.BoundryPolygon != null)
                    {
                        foreach (var newPolygon in location.BoundryPolygon)
                        {
                            BoundryPolygon polygon = loc.BoundryPolygon.FirstOrDefault(d => d.Id == newPolygon.Id);
                            if (polygon != null)
                            {
                                polygon.Latitude  = newPolygon.Latitude;
                                polygon.Longitude = newPolygon.Longitude;
                            }
                        }
                    }
                    foreach (var polygon in loc.BoundryPolygon)
                    {
                        polygon.Location = null;
                    }
                    return(loc);
                }
            }

            return(location);
        }
        private PdfPTable GetFourthTable(Facility updatedfacility, OriginalData originalData)
        {
            //Fourth Table
            PdfPTable table = new PdfPTable(4)
            {
                HorizontalAlignment = Element.ALIGN_CENTER,
                WidthPercentage     = 90
            };

            //Base Infomation
            PdfPCell baseInfoCell = GetCell("BASE INFORMATION", BaseColor.BLACK, BaseColor.LIGHT_GRAY, Font.BOLD);

            baseInfoCell.Colspan       = 2;
            baseInfoCell.MinimumHeight = 15;
            table.AddCell(baseInfoCell);

            //Location/Address Label and Data

            PdfPCell verficationInfoCell = GetCell("VERIFICATION FINDINGS", BaseColor.BLACK, BaseColor.LIGHT_GRAY, Font.BOLD);

            verficationInfoCell.Colspan       = 2;
            verficationInfoCell.MinimumHeight = 15;
            table.AddCell(verficationInfoCell);

            //GPS Co-Ordinates Label and Data

            PdfPCell bGpsLabel = GetCell("GPS Co-Ordinates", BaseColor.BLACK, BaseColor.LIGHT_GRAY, Font.BOLD);
            PdfPCell bGpsData  = GetCell(string.Format("Latitude: {0} \nLongitude: {1}",
                                                       "", ""), BaseColor.BLACK, BaseColor.WHITE);

            table.AddCell(bGpsLabel);
            table.AddCell(bGpsData);

            string   facilityLatitude  = updatedfacility.Location.GPSCoordinates != null ? updatedfacility.Location.GPSCoordinates.Latitude : string.Empty;
            string   facilityLongitude = updatedfacility.Location.GPSCoordinates != null ? updatedfacility.Location.GPSCoordinates.Longitude : string.Empty;
            PdfPCell aGpsLabel         = GetCell("GPS Co-Ordinates", BaseColor.BLACK, BaseColor.LIGHT_GRAY, Font.BOLD);
            PdfPCell aGpsData          = GetCell(string.Format("Latitude: {0} \nLongitude: {1}", facilityLatitude,
                                                               facilityLongitude), BaseColor.BLACK, BaseColor.WHITE);

            table.AddCell(aGpsLabel);
            table.AddCell(aGpsData);

            //Usage Label and Data
            PdfPCell bUsageLabel = GetCell("Usage", BaseColor.BLACK, BaseColor.LIGHT_GRAY, Font.BOLD);
            PdfPCell bUsageData  = GetCell(originalData.Usage_Descrip, BaseColor.BLACK, BaseColor.WHITE);

            table.AddCell(bUsageLabel);
            table.AddCell(bUsageData);

            PdfPCell aUsageLabel = GetCell("Usage", BaseColor.BLACK, BaseColor.LIGHT_GRAY, Font.BOLD);
            PdfPCell aUsageData  = GetCell(originalData.Usage_Descrip, BaseColor.BLACK, BaseColor.WHITE);

            table.AddCell(aUsageLabel);
            table.AddCell(aUsageData);

            //"No. Improvements Label and Data
            PdfPCell bImprovementLabel = GetCell("No. Improvements", BaseColor.BLACK, BaseColor.LIGHT_GRAY, Font.BOLD);
            PdfPCell bImprovementData  = GetCell(string.Format("{0}", ""), BaseColor.BLACK, BaseColor.WHITE);

            table.AddCell(bImprovementLabel);
            table.AddCell(bImprovementData);

            PdfPCell aImprovementLabel = GetCell("No. Improvements", BaseColor.BLACK, BaseColor.LIGHT_GRAY, Font.BOLD);
            PdfPCell aImprovementData  = GetCell(string.Format("{0}", updatedfacility.Buildings.Count), BaseColor.BLACK, BaseColor.WHITE);

            table.AddCell(aImprovementLabel);
            table.AddCell(aImprovementData);

            //Local Municipality Label and Data
            PdfPCell bImproveSizeLabel = GetCell("Improvements Size (M2)", BaseColor.BLACK, BaseColor.LIGHT_GRAY, Font.BOLD);
            PdfPCell bImproveSizeData  = GetCell(string.Format("{0}", ""), BaseColor.BLACK, BaseColor.WHITE);

            table.AddCell(bImproveSizeLabel);
            table.AddCell(bImproveSizeData);

            double   improvedArea      = updatedfacility.Buildings.Sum(b => b.ImprovedArea);
            PdfPCell aImproveSizeLabel = GetCell("Improvements Size (M2)", BaseColor.BLACK, BaseColor.LIGHT_GRAY, Font.BOLD);
            PdfPCell aImproveSizeData  = GetCell(string.Format("{0}", improvedArea), BaseColor.BLACK, BaseColor.WHITE);

            table.AddCell(aImproveSizeLabel);
            table.AddCell(aImproveSizeData);

            //Occupation Status (Capacity) Label and Data
            PdfPCell bOccStatusLabel = GetCell("Occupation Status (Capacity)", BaseColor.BLACK, BaseColor.LIGHT_GRAY, Font.BOLD);
            PdfPCell bOccStatusData  = GetCell("", BaseColor.BLACK, BaseColor.WHITE);

            table.AddCell(bOccStatusLabel);
            table.AddCell(bOccStatusData);

            double   utiliatonStatusTotal = updatedfacility.Buildings.Sum(b => Convert.ToDouble(b.Status));
            double   results         = updatedfacility.Buildings.Count != 0 ? utiliatonStatusTotal / updatedfacility.Buildings.Count : utiliatonStatusTotal;
            PdfPCell aOccStatusLabel = GetCell("Occupation Status (Capacity)", BaseColor.BLACK, BaseColor.LIGHT_GRAY, Font.BOLD);
            PdfPCell aOccStatusData  = GetCell(string.Format("{0} %", results), BaseColor.BLACK, BaseColor.WHITE);

            table.AddCell(aOccStatusLabel);
            table.AddCell(aOccStatusData);


            for (int i = 0; i < 5; i++)
            {
                BoundryPolygon polygon = null;
                if (i < updatedfacility.Location.BoundryPolygon.Count)
                {
                    polygon = updatedfacility.Location.BoundryPolygon[i];
                }

                //string bpolygon = polygon != null ? string.Format("Latitude: {0} \nLongitude: {1}",
                //polygon.Latitude, polygon.Longitude) : "N/A";
                int      count         = i + 1;
                PdfPCell bPolygonLabel = GetCell("Boundary Polygon " + count, BaseColor.BLACK, BaseColor.LIGHT_GRAY, Font.BOLD);
                PdfPCell bPolygonData  = GetCell("N/A", BaseColor.BLACK, BaseColor.WHITE);

                table.AddCell(bPolygonLabel);
                table.AddCell(bPolygonData);

                string apolygon = polygon != null?string.Format("Latitude: {0} \nLongitude: {1}",
                                                                polygon.Latitude, polygon.Longitude) : "N/A";

                PdfPCell aPolygonLabel = GetCell("Boundary Polygon " + count, BaseColor.BLACK, BaseColor.LIGHT_GRAY, Font.BOLD);
                PdfPCell aPolygonData  = GetCell(apolygon, BaseColor.BLACK, BaseColor.WHITE);

                table.AddCell(aPolygonLabel);
                table.AddCell(aPolygonData);
            }

            //Comments
            var commentsCell = new PdfPCell
            {
                VerticalAlignment   = Element.ALIGN_TOP,
                HorizontalAlignment = Element.ALIGN_LEFT,
                BackgroundColor     = BaseColor.WHITE,
                BorderColor         = BaseColor.DARK_GRAY,
                Colspan             = 4,
                MinimumHeight       = 200
            };

            commentsCell.AddElement(new Phrase("Comments",
                                               FontFactory.GetFont(FontFactory.HELVETICA, 10, Font.NORMAL, BaseColor.BLACK)));
            table.AddCell(commentsCell);

            return(table);
        }