Exemplo n.º 1
0
        async Task ExecuteSaveCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                var newItem = new PlugEVMeEntry
                {
                    Title     = Title,
                    Latitude  = Latitude,
                    Longitude = Longitude,
                    Date      = Date,
                    Rating    = Rating,
                    Notes     = Notes
                };

                await Task.Delay(3000);

                await NavService.GoBack();
            }
            finally
            {
                IsBusy = false;
            }
        }
Exemplo n.º 2
0
        async Task LoadEntries()
        {
            try
            {
                if (IsBusy)
                {
                    return;
                }

                IsBusy = true;

                LogEntries.Clear();

                ReadLibraries readLibraries = new ReadLibraries();
                List <string> libraries     = readLibraries.libraries;

                var tempEntries = new List <PlugEVMeEntry>();

                tempEntries.Add(homeEntry);

                foreach (string library in libraries)
                {
                    PlugEVMeEntry _entry = new PlugEVMeEntry();

                    string[] libs = library.Split(',');

                    _entry.Longitude = Convert.ToDouble(libs[libs.Length - 1]);
                    _entry.Latitude  = Convert.ToDouble(libs[libs.Length - 2]);
                    libs.Take(libs.Length - 1);
                    libs.Take(libs.Length - 2);

                    _entry.Title = libs[0];
                    _entry.Date  = DateTime.Now;
                    _entry.Title = string.Join(" ", libs);
                    _entry.Notes = _entry.Latitude + " " + _entry.Longitude;
                    tempEntries.Add(_entry);
                }

                // AddRange() in ObservableRangeCollection differs from Add() in ObservableCollection in that it fires a single
                // CollectionChanged notification when all the items are added to the collection at once, instead of many individual
                // CollectionChanged notifications from calling Add() over and over.
                LogEntries.AddRange(tempEntries);
            }
            finally
            {
                IsBusy = false;
            }

            await Task.CompletedTask;
        }
Exemplo n.º 3
0
        void LoadEntries()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = false;
            LogEntries.Clear();

            try
            {
                ReadLibraries readLibraries = new ReadLibraries();
                List <string> libraries     = readLibraries.libraries;

                // Load the current position homeentry and test values
                LogEntries.Insert(0, homeEntry);
                foreach (string library in libraries)
                {
                    PlugEVMeEntry _entry = new PlugEVMeEntry();

                    string[] libs = library.Split(',');

                    _entry.Longitude = Convert.ToDouble(libs[libs.Length - 1]);
                    _entry.Latitude  = Convert.ToDouble(libs[libs.Length - 2]);
                    libs.Take(libs.Length - 1);
                    libs.Take(libs.Length - 2);

                    _entry.Title = libs[0];
                    _entry.Date  = DateTime.Now;
                    _entry.Title = string.Join(" ", libs);
                    _entry.Notes = _entry.Latitude + " " + _entry.Longitude;
                    LogEntries.Add(_entry);
                }
            }
            finally
            {
                IsBusy = false;
            }
        }
Exemplo n.º 4
0
        public async Task LoadHomeEntry()
        {
            try
            {
                if (IsBusy)
                {
                    return;
                }

                IsBusy = true;


                Position position;

                if (!Plugin.Geolocator.CrossGeolocator.IsSupported)
                {
                    position = new Position();
                }
                if (!Plugin.Geolocator.CrossGeolocator.Current.IsGeolocationEnabled)
                {
                    position = new Position();
                }
                if (!Plugin.Geolocator.CrossGeolocator.Current.IsGeolocationAvailable)
                {
                    position = new Position();
                }

                // perhaps use a flag variable to enable/disable returning locations
                var locator = Plugin.Geolocator.CrossGeolocator.Current;
                locator.DesiredAccuracy = 100;
                position = await locator.GetPositionAsync(TimeSpan.FromSeconds(120));

                PlugEVMeEntry entry = new PlugEVMeEntry();

                entry.Latitude  = position.Latitude;
                entry.Longitude = position.Longitude;
                entry.Title     = "Me";
                entry.Date      = DateTime.Now;
                entry.Id        = "1";


                if (position.Latitude != 0.0 && position.Longitude != 0.0)
                {
                    Double lat        = Convert.ToDouble(position.Latitude);
                    Double lon        = Convert.ToDouble(position.Longitude);
                    var    placemarks = await Geocoding.GetPlacemarksAsync(lat, lon);

                    var placemark = placemarks?.FirstOrDefault();
                    entry.Notes   = placemark.ToString();
                    entry.Address = placemark;
                }
                homeEntry = entry;
            }

            catch (NullReferenceException e)
            {
                Debug.WriteLine("NullReferenceException is thrown ! " + e.ToString());
            }
            catch (Exception e)
            {
                Debug.WriteLine("Something is thrown ! " + e.ToString());
            }
            finally
            {
                IsBusy = false;
            }
        }
Exemplo n.º 5
0
 async Task ExecuteViewCommand(PlugEVMeEntry entry)
 {
     await NavService.NavigateTo <DetailViewModel, PlugEVMeEntry>(entry);
 }