Ejemplo n.º 1
0
        private async void ButtonMarkClick(object sender, RoutedEventArgs e)
        {
            await _mapLocationAccess.Add(
                DataSourceType.Sqlite,
                new MapLocationModel
            {
                ID          = Guid.NewGuid(),
                Name        = _focusedMapPin.Name,
                Description = _focusedMapPin.Description,
                Latitude    = _focusedMapPin.Latitude.ToString(),
                Longitude   = _focusedMapPin.Longitude.ToString(),
                MapId       = _map.ID
            });

            MapLocationModel addedLocation = _mapLocations.FirstOrDefault(location =>
                                                                          location.Latitude == _focusedMapPin.Latitude.ToString() &&
                                                                          location.Longitude == location.Longitude);

            if (addedLocation != null)
            {
                _focusedMapPin.ID = addedLocation.ID;
            }

            _mapPins.Add(_focusedMapPin);
            _focusedMapPin.Mark();
            _mapLocationFolderAccess.MapLocationId = addedLocation.ID;
            _mapLocationFolders = await _mapLocationFolderAccess.GetSources(DataSourceType.Sqlite);

            DefaultViewModel["MapLocationFolders"] = _mapLocationFolders;
            DefaultViewModel["Linkable"]           = (bool)DefaultViewModel["Focused"] && _focusedMapPin.Marked;
            DefaultViewModel["Markable"]           = (bool)DefaultViewModel["Focused"] && !(bool)DefaultViewModel["Linkable"];
            DefaultViewModel["UnMarkable"]         = (bool)DefaultViewModel["Linkable"];
        }
Ejemplo n.º 2
0
        private async void MapPinElementMapPinTapped(object sender,
                                                     MapPinTappedEventArgs e)
        {
            MapPin mapPinElement = (MapPin)sender;

            if (mapPinElement.Focused)
            {
                if (e.Marked)
                {
                    await _mapLocationAccess.Add(
                        DataSourceType.Sqlite,
                        new MapLocationModel
                    {
                        ID          = Guid.NewGuid(),
                        Name        = mapPinElement.Name,
                        Description = mapPinElement.Description,
                        Latitude    = mapPinElement.Latitude.ToString(),
                        Longitude   = mapPinElement.Longitude.ToString(),
                        MapId       = _map.ID
                    });

                    MapLocationModel addedLocation = _mapLocations.FirstOrDefault(location =>
                                                                                  location.Latitude == mapPinElement.Latitude.ToString() &&
                                                                                  location.Longitude == location.Longitude);
                    if (addedLocation != null)
                    {
                        mapPinElement.ID = addedLocation.ID;
                    }

                    _mapPins.Add(mapPinElement);
                }
                else
                {
                    MapLocationModel deleteLocation = _mapLocations.FirstOrDefault(location =>
                                                                                   location.ID.Equals(mapPinElement.ID));
                    if (deleteLocation != null)
                    {
                        await _mapLocationAccess.Remove(DataSourceType.Sqlite, deleteLocation);
                    }

                    _mapPins.Remove(mapPinElement);
                }
            }

            _lastFocusedMapPin = _focusedMapPin;
            _focusedMapPin     = mapPinElement;

            if (_lastFocusedMapPin != null)
            {
                _lastFocusedMapPin.UnFocus();
            }

            if (!_focusedMapPin.Focused)
            {
                _focusedMapPin.Focus();
            }
        }
Ejemplo n.º 3
0
        public Task RemoveLocation(MapLocationModel mapLocation)
        {
            SQLiteAsyncConnection connection = new SQLiteAsyncConnection(SQLiteConfiguration.ConnectionString);

            _locations.Remove(mapLocation);

            connection.ExecuteAsync("DELETE FROM MapLocationFolders WHERE MapLocationId = ?", mapLocation.ID);

            return(connection.DeleteAsync(mapLocation));
        }
Ejemplo n.º 4
0
        public Task UpdateLocation(MapLocationModel mapLocation)
        {
            SQLiteAsyncConnection connection = new SQLiteAsyncConnection(SQLiteConfiguration.ConnectionString);

            _locations.Remove(_locations.First(location => location.ID == mapLocation.ID));

            _locations.Add(mapLocation);

            return(connection.UpdateAsync(mapLocation));
        }
Ejemplo n.º 5
0
        public async Task<int> AddLocation(MapLocationModel mapLocation, Guid mapId)
        {
            SQLiteAsyncConnection connection = new SQLiteAsyncConnection(SQLiteConfiguration.ConnectionString);

            int count = await connection.ExecuteScalarAsync<int>("SELECT COUNT(*) FROM MapLocations WHERE MapId = ? AND Latitude = ? AND Longitude = ?", mapId, mapLocation.Latitude, mapLocation.Longitude);

            if (count > 0)
                return 0;

            mapLocation.MapId = mapId;

            _locations.Add(mapLocation);

            return await connection.InsertAsync(mapLocation);
        }
Ejemplo n.º 6
0
        private async void ButtonUnMarkClick(object sender, RoutedEventArgs e)
        {
            MapLocationModel deleteLocation = _mapLocations.FirstOrDefault(location =>
                                                                           location.ID.Equals(_focusedMapPin.ID));

            if (deleteLocation != null)
            {
                await _mapLocationAccess.Remove(DataSourceType.Sqlite, deleteLocation);
            }

            _mapPins.Remove(_focusedMapPin);
            _focusedMapPin.UnMark();
            DefaultViewModel["Linkable"]   = (bool)DefaultViewModel["Focused"] && _focusedMapPin.Marked;
            DefaultViewModel["Markable"]   = (bool)DefaultViewModel["Focused"] && !(bool)DefaultViewModel["Linkable"];
            DefaultViewModel["UnMarkable"] = (bool)DefaultViewModel["Linkable"];
        }
Ejemplo n.º 7
0
        public async Task <int> AddLocation(MapLocationModel mapLocation, Guid mapId)
        {
            SQLiteAsyncConnection connection = new SQLiteAsyncConnection(SQLiteConfiguration.ConnectionString);

            int count = await connection.ExecuteScalarAsync <int>("SELECT COUNT(*) FROM MapLocations WHERE MapId = ? AND Latitude = ? AND Longitude = ?", mapId, mapLocation.Latitude, mapLocation.Longitude);

            if (count > 0)
            {
                return(0);
            }

            mapLocation.MapId = mapId;

            _locations.Add(mapLocation);

            return(await connection.InsertAsync(mapLocation));
        }
Ejemplo n.º 8
0
 public Task UpdateLocation(MapLocationModel mapLocation)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 9
0
 public Task<int> AddLocation(MapLocationModel mapLocation, Guid mapId)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 10
0
        public Task RemoveLocation(MapLocationModel mapLocation)
        {
            SQLiteAsyncConnection connection = new SQLiteAsyncConnection(SQLiteConfiguration.ConnectionString);

            _locations.Remove(mapLocation);

            connection.ExecuteAsync("DELETE FROM MapLocationFolders WHERE MapLocationId = ?", mapLocation.ID);

            return connection.DeleteAsync(mapLocation);
        }
Ejemplo n.º 11
0
        public Task UpdateLocation(MapLocationModel mapLocation)
        {
            SQLiteAsyncConnection connection = new SQLiteAsyncConnection(SQLiteConfiguration.ConnectionString);

            _locations.Remove(_locations.First(location => location.ID == mapLocation.ID));

            _locations.Add(mapLocation);

            return connection.UpdateAsync(mapLocation);
        }
Ejemplo n.º 12
0
 public Task UpdateLocation(MapLocationModel mapLocation)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 13
0
 public Task <int> AddLocation(MapLocationModel mapLocation, Guid mapId)
 {
     throw new NotImplementedException();
 }