Esempio n. 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);
            }
        }
Esempio n. 2
0
        void AddLocation_Click(object sender, EventArgs e)
        {
            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
            {
                locationLinearlayout.Visibility = ViewStates.Visible;
                tvbLatitude.Text     = "Lat: " + location.Latitude.ToString();
                tvbLongitude.Text    = "Long: " + location.Longitude.ToString();
                accuracyMessage.Text = String.Format("Accurate to {0} Meters", location.Accuracy.ToString());
                _GPSCoordinates      = new GPSCoordinate()
                {
                    Latitude  = location.Latitude.ToString(),
                    Longitude = location.Longitude.ToString()
                };

                building.GPSCoordinates = _GPSCoordinates;
            }
        }
Esempio n. 3
0
        private void GPSLocationButton_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
            {
                tvfLatLong.Text         = "Lat: " + location.Latitude.ToString() + " Long: " + location.Longitude.ToString();
                accuracyMessage.Text    = String.Format("Accurate to {0} Meters", location.Accuracy.ToString());
                Location.GPSCoordinates = new GPSCoordinate()
                {
                    Longitude = location.Longitude.ToString(),
                    Latitude  = location.Latitude.ToString()
                };
            }
        }
Esempio n. 4
0
        private void RefashAccuracy_Click(object sender, EventArgs e)
        {
            GPSTracker GPSTracker = new GPSTracker();

            Android.Locations.Location location = GPSTracker.GPSCoordinate();
            if (location != null)
            {
                accuracyMessage.Text = String.Format("Accurate to {0} Meters", location.Accuracy.ToString());
            }
        }
Esempio n. 5
0
        public void CheckIfAStartShortestPathIsCorrect_ShouldGiveCorrectNodesAndLength()
        {
            // Arrange

            // ----- Creating the points ------
            Point start  = new Point(0, 0);
            Point p2     = new Point(200, 300);
            Point p3     = new Point(150, 200);
            Point p4     = new Point(500, 100);
            Point p5     = new Point(50, 500);
            Point target = new Point(200, 200);

            // ----------- Adding the points to nodes --------------
            Node startNode = new Node(start);
            Node endNode   = new Node(target);
            Node n2        = new Node(p2);
            Node n3        = new Node(p3);
            Node n4        = new Node(p4);
            Node n5        = new Node(p5);

            //------ Adding nodes to the tracker -------
            GPSTracker tracker = new GPSTracker();

            tracker.End   = endNode;
            tracker.Start = startNode;
            tracker.Nodes.Add(startNode);
            tracker.Nodes.Add(endNode);
            tracker.Nodes.Add(n2);
            tracker.Nodes.Add(n3);
            tracker.Nodes.Add(n4);
            tracker.Nodes.Add(n5);

            // -------- Connecting the nodes -------------
            foreach (Node N in tracker.Nodes)
            {
                N.ConnectClosestNodes(tracker.Nodes, 1);
            }


            // Act

            List <Node> shortestPath       = tracker.GetShortestPathAstar();
            List <Node> actualShortestPath = new List <Node>();

            actualShortestPath.Add(startNode);
            actualShortestPath.Add(n3);
            actualShortestPath.Add(endNode);

            // Assert

            Assert.AreEqual(actualShortestPath.Count, shortestPath.Count);
            Assert.AreEqual(actualShortestPath[0], shortestPath[0]);
            Assert.AreEqual(actualShortestPath[1], shortestPath[1]);
            Assert.AreEqual(actualShortestPath[2], shortestPath[2]);
        }
Esempio n. 6
0
        public GPSTrackerFeature(GPSTracker tracker)
        {
            Tracker       = tracker;
            this["Label"] = tracker.displayName;
            imgStyle      = new MarkerIconStyle
            {
                SymbolRotation = 0,
                Opacity        = 1,
                size           = new float[] { 32, 32 },
                typeSize       = 1,
                color          = SKColors.Black,
                shadow         = false,
                text           = tracker.displayName
            };


            Styles.Add(imgStyle);

            var markerType  = GameState.Instance.marker.markerTypes["hd_join"];
            var markerColor = GameState.Instance.marker.markerColors["ColorBlack"];

            MarkerCache.Instance.GetImage(markerType, markerColor)
            .ContinueWith(
                (image) =>
            {
                imgStyle.markerIcon = image.Result;
            });



            lblStyle = new MarkerLabelStyle(tracker.displayName, markerType, markerColor);
            Styles.Add(lblStyle);

            heightStyle        = new MarkerLabelStyle(tracker.displayName, markerType, markerColor);
            heightStyle.Offset = new Offset(0, markerType.size, false);
            Styles.Add(heightStyle);


            velStyle = new VelocityIndicatorStyle {
                velocity = new Vector3(tracker.vel[0], tracker.vel[1], 0f)
            };
            Styles.Add(velStyle);

            Geometry = new Point(tracker.pos[0], tracker.pos[1]);
        }
Esempio n. 7
0
    public void UpdateUI(GPSTracker gps, float goalDistance)
    {
        speedDisplay.text = gps.GetCurrentSpeedFormatted();

        double currentBaseSpeed = gps.CalculateCurrentSpeedWithoutUnits();
        int    speedIndex       = 0;

        foreach (float threshold in speedThresholds)
        {
            if (currentBaseSpeed >= threshold)
            {
                speedIndex++;
            }
        }

        speedImage.sprite = speedIcons[Mathf.Min(speedIndex, speedIcons.Length - 1)];

        LocationInfo?location = gps.GetPreviousLocationData();

        if (location.HasValue)
        {
            LocationInfo locationObj = location.Value;
            positionDisplay.text = $"Latitude: {locationObj.latitude.ToString("f3")}  Longitude: {locationObj.longitude.ToString("f3")}";
        }

        double distance = gps.GetTotalDistance();
        float  progress = Mathf.Clamp01((float)distance / goalDistance);

        distanceProgress.UpdateProgress(progress);
        if (progress >= 0.5f)
        {
            halfGoalFlag.RotateFlag();
        }
        if (progress >= 1f)
        {
            goalFlag.RotateFlag();
        }

        GPSUnit distanceUnit = gps.GetDistanceUnit();

        goalText.text     = distanceUnit.Format(goalDistance);
        halfGoalText.text = distanceUnit.Format(goalDistance / 2);
    }
Esempio n. 8
0
        public static async Task <HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequestMessage req, TraceWriter log)
        {
            log.Info("C# HTTP trigger function processed a request.");

            // parse query parameter
            string MacId = req.GetQueryNameValuePairs()
                           .FirstOrDefault(q => string.Compare(q.Key, "MacId", true) == 0)
                           .Value;

            if (string.IsNullOrEmpty(MacId))
            {
                return(req.CreateErrorResponse(HttpStatusCode.BadRequest, "Input is Null or Empty"));
            }


            var connectionString = Environment.GetEnvironmentVariable("SQLConnectionString");
            var selectQry        = "SELECT d.[MacId] as TrackerId FROM [DeviceInfo] d" +
                                   " INNER JOIN[VW_Gateway_Pallet_ShipmentAssociation] v ON d.[DeviceId] = v.[Tracker_Id]" +
                                   " WHERE v.MacId = @MacId ";


            SqlConnection conn    = new SqlConnection(connectionString);
            SqlCommand    command = new SqlCommand(selectQry, conn);

            command.Parameters.Clear();
            command.Parameters.Add("@MacId", SqlDbType.NVarChar).Value = MacId;
            conn.Open();
            var trackerDeviceId = command.ExecuteScalar();

            conn.Close();

            GPSTracker objTracker = new GPSTracker();

            objTracker.TarackerId = trackerDeviceId.ToString();

            return(new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(JsonConvert.SerializeObject(objTracker, Formatting.Indented), Encoding.UTF8, "application/json")
            });
        }
Esempio n. 9
0
        public ApplicationContext(BaseScreen baseActivity, Settings settings, System.Action loadComplete)
        {
            GlobalVariables = new Dictionary <string, object>();

            _baseActivity = baseActivity;
            _settings     = settings;
            _loadComplete = loadComplete;

            LocationProvider = new GpsProvider(baseActivity);

            LocationTracker = new GPSTracker(baseActivity);

            GalleryProvider = new GalleryProvider(baseActivity);

            CameraProvider = new CameraProvider(baseActivity, this);

            DialogProvider = new DialogProvider(baseActivity, this);

            ClipboardProvider = new ClipboardProvider(baseActivity, this);

            Application.ApplicationContext.InitContext(this);
        }
Esempio n. 10
0
        private void InitializeLocation(AlertDialog dialog)
        {
            int listViewMinimumHeight = 25;

            streetAddress        = dialog.FindViewById <EditText>(Resource.Id.etf_streetAddress);
            suburb               = dialog.FindViewById <EditText>(Resource.Id.etf_suburb);
            region               = dialog.FindViewById <EditText>(Resource.Id.etf_region);
            province             = dialog.FindViewById <Spinner>(Resource.Id.sf_province);
            localmunicipality    = dialog.FindViewById <Spinner>(Resource.Id.sf_localmunicipality);
            locationCancelButton = dialog.FindViewById <Button>(Resource.Id.dfil_cancelbutton);
            locationDoneButton   = dialog.FindViewById <Button>(Resource.Id.dfil_donebutton);
            gpsLocationButton    = dialog.FindViewById <FloatingActionButton>(Resource.Id.gpscaddlocation_button);
            bpLocationButton     = dialog.FindViewById <FloatingActionButton>(Resource.Id.bpaddlocation_button);
            refashAccuracy       = dialog.FindViewById <FloatingActionButton>(Resource.Id.refreshaccuracy_button);
            tvfLatitude          = dialog.FindViewById <TextView>(Resource.Id.tvf_latitude);
            tvfLongitude         = dialog.FindViewById <TextView>(Resource.Id.tvf_longitude);
            boundaryPolygonsText = dialog.FindViewById <TextView>(Resource.Id.boundaryPolygonsText);
            accuracyMessage      = dialog.FindViewById <TextView>(Resource.Id.accuracy_message);
            bpListView           = dialog.FindViewById <ListView>(Resource.Id.bplistView1);
            itemList             = new List <string>();
            bpListView.SetMinimumHeight(listViewMinimumHeight);
            refashAccuracy.Click += RefashAccuracy_Click;
            if (facility.Location != null)
            {
                streetAddress.Text = facility.Location.StreetAddress;
                suburb.Text        = facility.Location.Suburb;
                region.Text        = facility.Location.Region;
                province.SetSelection(GetIndex(province, facility.Location.Province));
                localmunicipality.SetSelection(GetIndex(localmunicipality, facility.Location.LocalMunicipality));
                listViewMinimumHeight = listViewMinimumHeight * facility.Location.BoundryPolygon.Count();
                if (facility.Location.GPSCoordinates != null)
                {
                    tvfLatitude.Text  = "Lat: " + facility.Location.GPSCoordinates.Latitude;
                    tvfLongitude.Text = " Long: " + facility.Location.GPSCoordinates.Longitude;
                }


                if (facility.Location.BoundryPolygon != null)
                {
                    bpListView.SetMinimumHeight(listViewMinimumHeight);
                    _BoundryPolygons = new List <BoundryPolygon>();
                    foreach (var BoundaryPolygon in facility.Location.BoundryPolygon)
                    {
                        _BoundryPolygons.Add(BoundaryPolygon);
                        itemList.Add("Lat: " + BoundaryPolygon.Latitude.ToString() + " Long: " + BoundaryPolygon.Longitude.ToString());
                    }

                    arrayAdapter              = new ArrayAdapter <string>(Activity, Resource.Layout.list_item, itemList);
                    bpListView.Adapter        = arrayAdapter;
                    bpListView.ItemLongClick += Adapter_ItemSwipe;
                }
                boundaryPolygonsText.Text = String.Format("Boundary Polygons {0}", itemList.Count);
            }


            locationCancelButton.Click += LocationCancelButton_Click;
            locationDoneButton.Click   += LocationDoneButton_Click;
            bpLocationButton.Click     += BPLocationButton_Click;
            gpsLocationButton.Click    += GPSLocationButton_Click;

            Android.Content.Res.ColorStateList csl  = new Android.Content.Res.ColorStateList(new int[][] { new int[0] }, new int[] { Android.Graphics.Color.ParseColor("#008000") }); bpLocationButton.BackgroundTintList = csl;
            Android.Content.Res.ColorStateList cslf = new Android.Content.Res.ColorStateList(new int[][] { new int[0] }, new int[] { Android.Graphics.Color.ParseColor("#008000") }); gpsLocationButton.BackgroundTintList = cslf;

            if (isEdit)
            {
                streetAddress.Enabled      = true;
                suburb.Enabled             = true;
                region.Enabled             = true;
                province.Enabled           = true;
                localmunicipality.Enabled  = true;
                locationDoneButton.Enabled = true;
                gpsLocationButton.Enabled  = true;
                bpLocationButton.Enabled   = true;
            }
            else
            {
                streetAddress.Enabled      = false;
                suburb.Enabled             = false;
                region.Enabled             = false;
                province.Enabled           = false;
                localmunicipality.Enabled  = false;
                locationDoneButton.Enabled = false;
                gpsLocationButton.Enabled  = false;
                bpLocationButton.Enabled   = false;
            }

            GPSTracker GPSTracker = new GPSTracker();

            Android.Locations.Location location = GPSTracker.GPSCoordinate();
            if (location != null)
            {
                accuracyMessage.Text = String.Format("Accurate to {0} Meters", location.Accuracy.ToString());
            }
        }
Esempio n. 11
0
        protected async override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            building  = new Building();
            ViewModel = new BuildingsViewModel();
            AppPreferences ap = new AppPreferences(Android.App.Application.Context);

            facilityId = Convert.ToInt32(ap.GetFacilityId());
            userId     = Convert.ToInt32(ap.GetUserId());

            var data = Intent.GetStringExtra("data");

            // Create your application here

            saveButton            = FindViewById <FloatingActionButton>(Resource.Id.save_button);
            occupationYear        = FindViewById <EditText>(Resource.Id.etb_occupationyear);
            occupationyearLayout  = FindViewById <TextInputLayout>(Resource.Id.occupationyear_layout);
            gpscAddLocationButton = FindViewById <FloatingActionButton>(Resource.Id.gpscaddlocation_button);
            locationLinearlayout  = FindViewById <LinearLayout>(Resource.Id.blocation_linearlayout);
            tvbLatitude           = FindViewById <TextView>(Resource.Id.tvb_latitude);
            tvbLongitude          = FindViewById <TextView>(Resource.Id.tvb_longitude);
            buildingPhoto         = FindViewById <ImageView>(Resource.Id.imgb_buildingphoto);
            _GPSCoordinates       = new GPSCoordinate();
            buildingName          = FindViewById <EditText>(Resource.Id.etb_name);
            buildingType          = FindViewById <Spinner>(Resource.Id.sf_buildingtype);
            buildingstandard      = FindViewById <Spinner>(Resource.Id.sf_buildingstandard);
            utilisationStatus     = FindViewById <EditText>(Resource.Id.etb_utilisationstatus);
            nooOfFoors            = FindViewById <EditText>(Resource.Id.etb_nooffloors);
            totalFootprintAream2  = FindViewById <EditText>(Resource.Id.etb_totalfootprintaream2);
            totalImprovedaAeam2   = FindViewById <EditText>(Resource.Id.etb_totalimprovedaream2);
            heritage                = FindViewById <Switch>(Resource.Id.sf_heritage);
            disabledAccesss         = FindViewById <Spinner>(Resource.Id.sf_disabledaccesss);
            disabledComment         = FindViewById <EditText>(Resource.Id.etb_disabledcomment);
            constructionDescription = FindViewById <EditText>(Resource.Id.etb_constructiondescription);
            accuracyMessage         = FindViewById <TextView>(Resource.Id.accuracy_message);
            refashAccuracy          = FindViewById <FloatingActionButton>(Resource.Id.refreshaccuracy_button);
            refashAccuracy.Click   += RefashAccuracy_Click;


            _dir = ap.CreateDirectoryForPictures();
            Android.Content.Res.ColorStateList csl = new Android.Content.Res.ColorStateList(new int[][] { new int[0] }, new int[] { Android.Graphics.Color.ParseColor("#008000") }); gpscAddLocationButton.BackgroundTintList = csl;
            locationLinearlayout.Visibility = ViewStates.Gone;

            if (data != null)
            {
                building = Newtonsoft.Json.JsonConvert.DeserializeObject <Building>(data);
                isEdit   = true;
                SupportActionBar.Title = "Edit Building";
                occupationYear.Text    = building.OccupationYear;
                if (building.GPSCoordinates != null)
                {
                    tvbLatitude.Text  = "Lat: " + building.GPSCoordinates.Latitude;
                    tvbLongitude.Text = "Long: " + building.GPSCoordinates.Longitude;
                    _GPSCoordinates   = building.GPSCoordinates;
                    locationLinearlayout.Visibility = ViewStates.Visible;
                }
                buildingName.Text = building.BuildingName;
                buildingType.SetSelection(GetIndex(buildingType, building.BuildingType));
                buildingstandard.SetSelection(GetIndex(buildingstandard, building.BuildingStandard));
                disabledAccesss.SetSelection(GetIndex(disabledAccesss, building.DisabledAccess));
                utilisationStatus.Text       = building.Status;
                nooOfFoors.Text              = Convert.ToString(building.NumberOfFloors);
                totalFootprintAream2.Text    = Convert.ToString(building.FootPrintArea);
                totalImprovedaAeam2.Text     = Convert.ToString(building.ImprovedArea);
                heritage.Checked             = building.Heritage;
                disabledComment.Text         = building.DisabledComment;
                constructionDescription.Text = building.ConstructionDescription;

                Bitmap bit = SetImageBitmap(_dir + "/" + building.Photo);
                if (bit != null)
                {
                    buildingPhoto.SetImageBitmap(bit);
                }
                else if (bit == null && !String.IsNullOrEmpty(building.Photo))
                {
                    PictureViewModel pictureViewModel = new PictureViewModel();
                    Models.Picture   picture          = await pictureViewModel.ExecuteGetPictureCommand(building.Photo);

                    if (picture != null)
                    {
                        var _bit = ap.StringToBitMap(picture.File);
                        if (_bit != null)
                        {
                            SaveImage(_bit, building.Photo);
                        }
                        buildingPhoto.SetImageBitmap(_bit);
                    }
                }
            }
            else
            {
                SupportActionBar.Title = "Add New Building";
            }
            saveButton.Click += SaveButton_Click;
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            SupportActionBar.SetHomeButtonEnabled(true);
            gpscAddLocationButton.Click += AddLocation_Click;
            buildingPhoto.Click         += (sender, e) => { ShowImage_Click(); };

            GPSTracker GPSTracker = new GPSTracker();

            Android.Locations.Location location = GPSTracker.GPSCoordinate();
            if (location != null)
            {
                accuracyMessage.Text = String.Format("Accurate to {0} Meters", location.Accuracy.ToString());
            }
        }
        protected async override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            building       = new Building();
            ViewModel      = new BuildingsViewModel();
            appPreferences = new AppPreferences(Application.Context);
            facilityId     = Convert.ToInt32(appPreferences.GetFacilityId());
            userId         = Convert.ToInt32(appPreferences.GetUserId());
            helpers        = new UIHelpers();
            var data = Intent.GetStringExtra("data");

            occupationYear        = FindViewById <EditText>(Resource.Id.etb_occupationyear);
            occupationyearLayout  = FindViewById <TextInputLayout>(Resource.Id.occupationyear_layout);
            gpscAddLocationButton = FindViewById <ImageView>(Resource.Id.gpscaddlocation_button);
            tvblatLang            = FindViewById <TextView>(Resource.Id.tvf_latLang);
            buildingPhoto         = FindViewById <ImageView>(Resource.Id.imgb_buildingphoto);
            _GPSCoordinates       = new GPSCoordinate();
            buildingName          = FindViewById <EditText>(Resource.Id.etb_name);
            buildingType          = FindViewById <Spinner>(Resource.Id.sf_buildingtype);
            buildingstandard      = FindViewById <Spinner>(Resource.Id.sf_buildingstandard);
            utilisationStatus     = FindViewById <EditText>(Resource.Id.etb_utilisationstatus);
            nooOfFoors            = FindViewById <EditText>(Resource.Id.etb_nooffloors);
            totalFootprintAream2  = FindViewById <EditText>(Resource.Id.etb_totalfootprintaream2);
            totalImprovedaAeam2   = FindViewById <EditText>(Resource.Id.etb_totalimprovedaream2);
            heritage                = FindViewById <Switch>(Resource.Id.sf_heritage);
            disabledAccesss         = FindViewById <Spinner>(Resource.Id.sf_disabledaccesss);
            disabledComment         = FindViewById <EditText>(Resource.Id.etb_disabledcomment);
            constructionDescription = FindViewById <EditText>(Resource.Id.etb_constructiondescription);
            accuracyMessage         = FindViewById <TextView>(Resource.Id.accuracy_message);
            refashAccuracy          = FindViewById <ImageView>(Resource.Id.refreshaccuracy_button);
            refashAccuracy.Click   += RefashAccuracy_Click;

            _dir = appPreferences.CreateDirectoryForPictures();

            if (data != null)
            {
                building = Newtonsoft.Json.JsonConvert.DeserializeObject <Building>(data);
                isEdit   = true;
                SupportActionBar.Title = "Edit Building";
                occupationYear.Text    = building.OccupationYear;
                if (building.GPSCoordinates != null)
                {
                    tvblatLang.Text = "Lat: " + building.GPSCoordinates.Latitude + " Long: " + building.GPSCoordinates.Longitude;
                    _GPSCoordinates = building.GPSCoordinates;
                }
                buildingName.Text = building.BuildingName;
                buildingType.SetSelection(helpers.GetSpinnerIndex(buildingType, building.BuildingType));
                buildingstandard.SetSelection(helpers.GetSpinnerIndex(buildingstandard, building.BuildingStandard));
                disabledAccesss.SetSelection(helpers.GetSpinnerIndex(disabledAccesss, building.DisabledAccess));
                utilisationStatus.Text       = building.Status;
                nooOfFoors.Text              = Convert.ToString(building.NumberOfFloors);
                totalFootprintAream2.Text    = Convert.ToString(building.FootPrintArea);
                totalImprovedaAeam2.Text     = Convert.ToString(building.ImprovedArea);
                heritage.Checked             = building.Heritage;
                disabledComment.Text         = building.DisabledComment;
                constructionDescription.Text = building.ConstructionDescription;

                Bitmap bit = SetImageBitmap(_dir + "/" + building.Photo);
                if (bit != null)
                {
                    buildingPhoto.SetImageBitmap(bit);
                }
                else if (bit == null && !String.IsNullOrEmpty(building.Photo))
                {
                    PictureViewModel pictureViewModel = new PictureViewModel();
                    Models.Picture   picture          = await pictureViewModel.ExecuteGetPictureCommand(building.Photo);

                    if (picture != null)
                    {
                        var _bit = appPreferences.StringToBitMap(picture.File);
                        if (_bit != null)
                        {
                            SaveImage(_bit, building.Photo);
                        }
                        buildingPhoto.SetImageBitmap(_bit);
                    }
                }
            }
            else
            {
                SupportActionBar.Title = "Add New Building";
            }
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            SupportActionBar.SetHomeButtonEnabled(true);
            gpscAddLocationButton.Click += AddLocation_Click;
            buildingPhoto.Click         += (sender, e) => { ShowImage_Click(); };

            GPSTracker GPSTracker = new GPSTracker();

            Android.Locations.Location location = GPSTracker.GPSCoordinate();
            if (location != null)
            {
                accuracyMessage.Text = String.Format("Accurate to {0} Meters", location.Accuracy.ToString());
            }

            Toolbar.MenuItemClick += (sender, e) =>
            {
                var itemTitle = e.Item.TitleFormatted;
                switch (itemTitle.ToString())
                {
                case "Log Out":
                    var intent = new Intent(this, typeof(LoginActivity));
                    appPreferences.SaveUserId("0");
                    StartActivity(intent);
                    break;

                case "Save":
                    SaveBuilding();
                    break;
                }
            };
        }
Esempio n. 13
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            SupportActionBar.SetHomeButtonEnabled(true);
            streetAddress         = FindViewById <EditText>(Resource.Id.etf_streetAddress);
            suburb                = FindViewById <EditText>(Resource.Id.etf_suburb);
            region                = FindViewById <EditText>(Resource.Id.etf_region);
            province              = FindViewById <Spinner>(Resource.Id.sf_province);
            localmunicipality     = FindViewById <Spinner>(Resource.Id.sf_localmunicipality);
            gpsLocationButton     = FindViewById <ImageView>(Resource.Id.gpscaddlocation_button);
            bpLocationButton      = FindViewById <ImageView>(Resource.Id.bpaddlocation_button);
            refashAccuracy        = FindViewById <ImageView>(Resource.Id.refreshaccuracy_button);
            tvfLatLong            = FindViewById <TextView>(Resource.Id.tvf_latLang);
            boundaryPolygonsText  = FindViewById <TextView>(Resource.Id.boundaryPolygonsText);
            accuracyMessage       = FindViewById <TextView>(Resource.Id.accuracy_message);
            bpListView            = FindViewById <ListView>(Resource.Id.bplistView1);
            itemList              = new List <string>();
            refashAccuracy.Click += RefashAccuracy_Click;
            _BoundryPolygons      = new List <BoundryPolygon>();
            ViewModel             = new LocationViewModel();
            appPreferences        = new AppPreferences(Application.Context);
            helpers               = new UIHelpers();
            Location              = new Models.Location();
            var data = Intent.GetStringExtra("data");

            if (data != null)
            {
                Facility = Newtonsoft.Json.JsonConvert.DeserializeObject <Facility>(data);
                Location = Facility.Location;
                if (Location != null)
                {
                    streetAddress.Text = Location.StreetAddress;
                    suburb.Text        = Location.Suburb;
                    region.Text        = Location.Region;
                    province.SetSelection(helpers.GetSpinnerIndex(province, Location.Province));
                    localmunicipality.SetSelection(helpers.GetSpinnerIndex(localmunicipality, Location.LocalMunicipality));
                    if (Location.GPSCoordinates != null)
                    {
                        tvfLatLong.Text = "Lat: " + Location.GPSCoordinates.Latitude + " Long: " + Location.GPSCoordinates.Longitude;
                    }
                    if (Location.BoundryPolygon != null)
                    {
                        foreach (var BoundaryPolygon in Location.BoundryPolygon)
                        {
                            _BoundryPolygons.Add(BoundaryPolygon);
                            itemList.Add("Lat: " + BoundaryPolygon.Latitude.ToString() + " Long: " + BoundaryPolygon.Longitude.ToString());
                        }

                        arrayAdapter              = new ArrayAdapter <string>(this, Resource.Layout.list_item, itemList);
                        bpListView.Adapter        = arrayAdapter;
                        bpListView.ItemLongClick += Adapter_ItemSwipe;
                        ViewGroup.LayoutParams param = bpListView.LayoutParameters;
                        param.Height = 80 * _BoundryPolygons.Count();
                        bpListView.LayoutParameters = param;
                    }
                    boundaryPolygonsText.Text = String.Format("Boundary Polygons {0}", itemList.Count);
                }
            }
            bpLocationButton.Click  += BPLocationButton_Click;
            gpsLocationButton.Click += GPSLocationButton_Click;
            Toolbar.MenuItemClick   += (sender, e) =>
            {
                var itemTitle = e.Item.TitleFormatted;
                switch (itemTitle.ToString())
                {
                case "Log Out":
                    var intent = new Intent(this, typeof(LoginActivity));
                    appPreferences.SaveUserId("0");
                    StartActivity(intent);
                    break;

                case "Save":
                    SaveLocation();
                    break;
                }
            };

            GPSTracker GPSTracker = new GPSTracker();

            Android.Locations.Location location = GPSTracker.GPSCoordinate();
            if (location != null)
            {
                accuracyMessage.Text = String.Format("Accurate to {0} Meters", location.Accuracy.ToString());
            }
        }
 // Use this for initialization
 void Start()
 {
     Instance = this;
     DontDestroyOnLoad(gameObject);
     StartCoroutine(StartLocationService());
 }