Esempio n. 1
0
        private async void SelectedLocations_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            try
            {
                SelectedLocations.CollectionChanged -= SelectedLocations_CollectionChanged;

                if (e.NewItems != null)
                {
                    foreach (Location newItem in e.NewItems)
                    {
                        SelectedLocations.Add(newItem);
                        await _settingsService.AddLocationAsync(newItem);
                    }
                }

                if (e.OldItems != null)
                {
                    foreach (Location oldtem in e.OldItems)
                    {
                        SelectedLocations.Remove(oldtem);
                        await _settingsService.RemoveLocationAsync(oldtem);
                    }
                }

                SelectedLocations.CollectionChanged += SelectedLocations_CollectionChanged;
            }
            catch (Exception exeption)
            {
                _loggingService?.WriteError(exeption);
            }
        }
Esempio n. 2
0
        private void OnNotSelectedLocationDoubleClickCommand()
        {
            var location = SelectedNotSelectedLocation;

            if (location == null)
            {
                return;
            }
            NotSelectedLocations.Remove(location);
            SelectedLocations.Add(location);
            RaisePropertyChanged(() => SelectedLocations);
            RaisePropertyChanged(() => NotSelectedLocations);
        }
Esempio n. 3
0
        private void InitializeLocations()
        {
            SelectedLocations.CollectionChanged -= SelectedLocations_CollectionChanged;
            SelectedLocations.Clear();

            foreach (var location in User.Locations)
            {
                if (_settingsService.Settings.Locations.Any(l => l.Id == location.Id))
                {
                    SelectedLocations.Add(location);
                }
            }

            SelectedLocations.CollectionChanged += SelectedLocations_CollectionChanged;
        }