protected override async void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); NetworkInformation.NetworkStatusChanged += ViewBase_NetworkStatusChanged; await _dispatcherService.RunAsync(HandleNetworkStatus); if (ViewModelBase != null) { if (!_isLoaded) { _isLoaded = true; await ViewModelBase.OnLoadedAsync(e.Parameter); } if (!ViewModelBase.IsLoading) { if (BottomAppBar != null) { BottomAppBar.Visibility = Visibility.Visible; } if (TopAppBar != null) { TopAppBar.Visibility = Visibility.Visible; } } var navigationMode = Core.NavigationMode.New; switch (e.NavigationMode) { case Windows.UI.Xaml.Navigation.NavigationMode.Back: navigationMode = Core.NavigationMode.Back; break; case Windows.UI.Xaml.Navigation.NavigationMode.Forward: navigationMode = Core.NavigationMode.Forward; break; case Windows.UI.Xaml.Navigation.NavigationMode.New: navigationMode = Core.NavigationMode.New; break; case Windows.UI.Xaml.Navigation.NavigationMode.Refresh: navigationMode = Core.NavigationMode.Refresh; break; } ViewModelBase.PropertyChanged += ViewModel_PropertyChanged; await ViewModelBase.OnNavigatedToAsync(navigationMode, e.Parameter); } }
public async void OpenTab(Tab tab, bool switchToTab = true, params object?[] args) { Type type; if (!Tabs.TryGetValue(tab, out type)) { return; } var newTab = (ICustomTab)Activator.CreateInstance(type, args); var current = GetTabFromId(newTab.CustomTabId); if (current != null) { if (switchToTab) { CurrentTab = current; } } else { TabItems.Add(newTab); if (switchToTab) { await Dispatcher.RunAsync(() => CurrentTab = newTab); } } }
public async Task Reload(bool animate = true) { if (_internalLoadingArchives) { return; } _internalLoadingArchives = true; RefreshOnErrorButton = false; ArchiveList.Clear(); if (animate) { LoadingArchives = true; } if (Archives.Archives.Count > 0) { await Task.Run(async() => { foreach (var b in Settings.Profile.Bookmarks) { var archive = Archives.GetArchive(b.archiveID); if (archive != null) { await Dispatcher.RunAsync(() => ArchiveList.Add(archive)); } } }); OnPropertyChanged("Empty"); } else { RefreshOnErrorButton = true; } if (animate) { LoadingArchives = false; } _internalLoadingArchives = false; }