Beispiel #1
0
        public async void RefreshSites()
        {
            await ApplyModelToViewModel();

            FilteredSites.RefreshView();
            NavigationService.GoBack();
            NavigationService.GoForward();
        }
Beispiel #2
0
 public void DeleteItem()
 {
     foreach (var e in Sites.Where(site => site.Identifier == SelectedSite?.Identifier).ToList())
     {
         Sites.Remove(e);
     }
     App.Container.Resolve <ISitePersistor>().Persist(Sites);
     FilteredSites.RefreshView();
 }
Beispiel #3
0
 private async void OnPropertyChanged(object sender, PropertyChangedEventArgs args)
 {
     if (args.PropertyName == nameof(SitesOrder) || args.PropertyName == nameof(SearchString))
     {
         if (args.PropertyName == nameof(SitesOrder))
         {
             ApplySortOrderToFilteredSites();
         }
         FilteredSites.RefreshView();
     }
 }
Beispiel #4
0
        public override async Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary <string, object> suspensionState)
        {
            if (suspensionState.Any())
            {
                //Value = suspensionState[nameof(Value)]?.ToString();
            }

            SitesOrder = Settings.LastSortBy;
            ApplySortOrderToFilteredSites();
            if (Sites == null || Settings.PopPasswordsVisibleChangedFlag())
            {
                await ApplyModelToViewModel();
            }

            if (parameter is SitesPageViewModelParameter)
            {
                var param = parameter as SitesPageViewModelParameter;
                if ((param.ParameterType == SitesPageViewModelParameterType.NewSite || param.ParameterType == SitesPageViewModelParameterType.MergeSite) && param.Parameter is ISite)
                {
                    // the identifier of an edited or new site
                    var detailSite = param.Parameter as ISite;

                    // regenerate password
                    (detailSite as Site).SetGeneratedPassword(GeneratePassword(detailSite), !Settings.PasswordsVisible);

                    var replaceTarget = Sites.FirstOrDefault(site => site.Identifier == detailSite.Identifier);
                    if (replaceTarget != null)
                    {
                        // merge with existing (cause was edit mode)
                        replaceTarget.MergeWith(detailSite);
                    }
                    else
                    {
                        // add as new
                        Sites?.Add(detailSite);
                    }
                    App.Container.Resolve <ISitePersistor>().Persist(Sites);
                    FilteredSites.RefreshView();

                    SelectedSite = replaceTarget;
                }

                if (param.ParameterType == SitesPageViewModelParameterType.RefreshView)
                {
                    await ApplyModelToViewModel();
                }
            }

            // register some listeners
            PropertyChanged += OnPropertyChanged;
        }