private async Task StartupAsync() { await WhatsNewDisplayService.ShowIfAppropriateAsync(); await FirstRunDisplayService.ShowIfAppropriateAsync(); ThemeSelectorService.SetRequestedTheme(); await Task.CompletedTask; }
private async void MainPage_Loaded(object sender, RoutedEventArgs e) { ConfigureWindowBlur(); await ConfigureHamburgerMenuBlur(); await ViewModel.Initialize(); if (WhatsNewDisplayService.IsNewVersion() && ViewModel.isLoggedin) { await ShowWhatsNewPopup(); } }
private void Application_Startup(object sender, StartupEventArgs e) { var assembly = Assembly.GetExecutingAssembly(); var mutexName = string.Format(CultureInfo.InvariantCulture, "Local\\{{{0}}}{{{1}}}", assembly.GetType().GUID, assembly.GetName().Name); _mMutex = new Mutex(true, mutexName, out bool mutexCreated); if (!mutexCreated) { _mMutex = null; Current.Shutdown(); return; } WhatsNewDisplayService.ShowIfAppropriate(); FirstRunDisplayService.ShowIfAppropriate(); new MainWindow(); }
private async void MainPage_Loaded(object sender, RoutedEventArgs e) { ConfigureWindowBlur(); await ConfigureHamburgerMenuBlur(); await ViewModel.Initialize(AppFrame); if (ViewModel.isLoggedin) { await SimpleIoc.Default.GetInstance <IAsyncNavigationService>().NavigateAsync(typeof(FeedView), "News Feed"); if (IsInternet()) { await ViewModel.CheckForUnreadNotifications(); } if (WhatsNewDisplayService.IsNewVersion()) { await ShowWhatsNewPopup(); } } }
private async void MainPage_Loaded(object sender, RoutedEventArgs e) { await ViewModel.Initialize(AppFrame); if (ViewModel.isLoggedin) { await SimpleIoc.Default.GetInstance <IAsyncNavigationService>().NavigateAsync(typeof(FeedView), "News Feed"); await ViewModel.CheckForUnreadNotifications(); if (WhatsNewDisplayService.IsNewVersion()) { ViewModel.isLoading = true; WhatsNewPopup.SetVisualOpacity(0); WhatsNewPopup.Visibility = Visibility.Visible; await WhatsNewPopup.StartCompositionFadeScaleAnimationAsync(0, 1, 1.1f, 1, 150, null, 0, EasingFunctionNames.SineEaseInOut); } } notifManager = new LocalNotificationManager(NotificationGrid); ConfigureWindowBlur(); await ConfigureHamburgerMenuBlur(); }
/// <summary> /// Invoked when the application is launched normally by the end user. Other entry points /// will be used such as when the application is launched to open a specific file. /// </summary> /// <param name="e">Details about the launch request and process.</param> protected override async void OnLaunched(LaunchActivatedEventArgs e) { // Set the application minimum window size var applicationView = Windows.UI.ViewManagement.ApplicationView.GetForCurrentView(); applicationView.SetPreferredMinSize( new Size( width: 270, height: 400 )); if (this.IsXBox) // Only do this on XBox, on phone the ui will be behind system app bar otherwise. { applicationView.SetDesiredBoundsMode(Windows.UI.ViewManagement.ApplicationViewBoundsMode.UseCoreWindow); } MicrosoftGraphService.Instance.AuthenticationModel = MicrosoftGraphEnums.AuthenticationModel.V2; MicrosoftGraphService.Instance.Initialize(SecureConstents.API, MicrosoftGraphEnums.ServicesToInitialize.UserProfile, new[] { "User.Read", "Files.Read", "Files.ReadWrite.AppFolder", //"profile", "email", "UserActivity.ReadWrite.CreatedByApp" }); var rootFrame = Window.Current.Content as Pages.ShellPage; // Do not repeat app initialization when the Window already has content, // just ensure that the window is active if (rootFrame == null) { // Create a Frame to act as the navigation context and navigate to the first page rootFrame = new Pages.ShellPage(); //rootFrame.NavigationFailed += OnNavigationFailed; //if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) //{ // //TODO: Load state from previously suspended application //} // Place the frame in the current Window Window.Current.Content = rootFrame; } Shell = rootFrame; if (e.PrelaunchActivated == false) { if (Services.NavigationService.Frame.Content == null) { // When the navigation stack isn't restored navigate to the first page, // configuring the new page by passing required information as a navigation // parameter Services.NavigationService.Navigate <Pages.MainPage>(); //rootFrame.Navigate(typeof(MainPage), e.Arguments); } // Ensure the current window is active Window.Current.Activate(); Window.Current.SizeChanged += this.WindowSizeChanged; this.UpdateIsTouch(); await FirstRunDisplayService.ShowIfAppropriateAsync(); await WhatsNewDisplayService.ShowIfAppropriateAsync(); } }
public MainPageViewModel(ICommonLogging iocCommonLogging, IEventAggregator iocEventAggregator, INavigationService iocNavigationService, FirstRunDisplayService iocFirstRunDisplayService, WhatsNewDisplayService iocWhatsNewDisplayService, DatabaseReloadDisplayService iocDatabaseReloadDisplayService, IDialogService dialogService) : base(iocCommonLogging, iocEventAggregator, iocNavigationService) { localWhatsNewDisplayService = iocWhatsNewDisplayService; localFirstRunDisplayService = iocFirstRunDisplayService; localDatabaseReloadDisplayService = iocDatabaseReloadDisplayService; _dialogService = dialogService; BaseEventAggregator.GetEvent <AppStartFirstRunEvent>().Subscribe(ServiceFirstRun, ThreadOption.UIThread); BaseEventAggregator.GetEvent <AppStartLoadDataEvent>().Subscribe(ServiceLoadData, ThreadOption.UIThread); BaseEventAggregator.GetEvent <AppStartReloadDatabaseEvent>().Subscribe(ServiceReloadDatabase, ThreadOption.UIThread); BaseEventAggregator.GetEvent <AppStartWhatsNewEvent>().Subscribe(ServiceWhatsNew, ThreadOption.UIThread); BaseEventAggregator.GetEvent <DataLoadCompleteEvent>().Subscribe(LoadHubPage, ThreadOption.UIThread); BaseEventAggregator.GetEvent <DialogBoxEvent>().Subscribe(ActionDialog, ThreadOption.UIThread); BaseEventAggregator.GetEvent <PageNavigateEvent>().Subscribe(OnNavigateCommandExecuted, ThreadOption.UIThread); BaseEventAggregator.GetEvent <PageNavigateParmsEvent>().Subscribe(OnNavigateParmsCommandExecuted, ThreadOption.UIThread); // Build the Menu NavigateCommand = new DelegateCommand <string>(OnNavigateCommandExecuted); MainMenuItems = new List <MainMenuItem>() { new MainMenuItem() { Title = "Hub", Icon = CommonConstants.IconHub, TargetType = nameof(HubPage) }, new MainMenuItem() { Title = "Bookmarks", Icon = CommonConstants.IconBookMark, TargetType = nameof(BookMarkListPage) }, new MainMenuItem() { Title = "Citations", Icon = CommonConstants.IconCitation, TargetType = nameof(CitationListPage) }, new MainMenuItem() { Title = "Events", Icon = CommonConstants.IconEvents, TargetType = nameof(EventListPage) }, new MainMenuItem() { Title = "Families", Icon = CommonConstants.IconFamilies, TargetType = nameof(FamilyListPage) }, new MainMenuItem() { Title = "Media", Icon = CommonConstants.IconMedia, TargetType = nameof(MediaListPage) }, new MainMenuItem() { Title = "Notes", Icon = CommonConstants.IconNotes, TargetType = nameof(NoteListPage) }, new MainMenuItem() { Title = "People", Icon = CommonConstants.IconPeople, TargetType = nameof(PersonListPage) }, new MainMenuItem() { Title = "Places", Icon = CommonConstants.IconPlace, TargetType = nameof(PlaceListPage) }, new MainMenuItem() { Title = "Repositories", Icon = CommonConstants.IconRepository, TargetType = nameof(RepositoryListPage) }, new MainMenuItem() { Title = "Sources", Icon = CommonConstants.IconSource, TargetType = nameof(SourceListPage) }, new MainMenuItem() { Title = "Tags", Icon = CommonConstants.IconTag, TargetType = nameof(TagListPage) }, //<!-- // new NavigationViewItemSeparator // { // }, //--> new MainMenuItem() { Title = "PeopleGraph", Icon = CommonConstants.IconPeopleGraph, TargetType = nameof(PeopleGraphPage) }, //<!-- // new NavigationViewItemSeparator // { // }, //--> new MainMenuItem() { Title = "Search", Icon = CommonConstants.IconSearch, TargetType = nameof(SearchPage) }, new MainMenuItem() { Title = "Choose data file", Icon = CommonConstants.IconChooseDataFile, TargetType = nameof(FileInputHandlerPage) }, new MainMenuItem() { Title = "Settings", Icon = CommonConstants.IconSettings, TargetType = nameof(SettingsPage) }, new MainMenuItem() { Title = "About", Icon = CommonConstants.IconAbout, TargetType = nameof(AboutPage) }, }; }
/// <summary> /// Gets all the feeds from database (with-in limits in settings) /// the try to gets all the new stuff from your sources /// add the new ones to the database if there is any /// then show the latest (with-in limits in settings) /// </summary> /// <param name="progress"></param> /// <param name="token"></param> /// <returns>Task Type</returns> public async Task LoadDataAsync(IProgress <int> progress, CancellationToken token) { IsLoadingData = true; FilterSources.Clear(); Feeds.Clear(); ProgressCurrent = 0; bool hasLoadedFeedNewItems = false; // Shows the user what's new in this version await WhatsNewDisplayService.ShowIfAppropriateAsync(); // Set Httpclient userAgent to the user selected one await RssRequest.SetCustomUserAgentAsync(); foreach (var rss in await RSSDataService.GetFeedsDataAsync(await ApplicationData.Current.LocalSettings.ReadAsync <int>("FeedsLimit"))) { Feeds.Add(rss); } SyndicationFeed feed = null; var sourcesDataList = await SourceDataService.GetSourcesDataAsync(); ProgressMax = sourcesDataList.Count(); int progressCount = 0; foreach (var source in sourcesDataList) { FilterSources.Add(source); if (token.IsCancellationRequested) { IsLoadingData = false; TokenSource = new CancellationTokenSource(); MarkAsReadCommand.OnCanExecuteChanged(); return; } } // if there is no internet just cut our loses and get out of here we already loaded the local data if (!new NetworkInformationHelper().HasInternetAccess) { await new MessageDialog("CheckInternetMessageDialog".GetLocalized()).ShowAsync(); return; } var WaitAfterLastCheckInMinutes = await ApplicationData.Current.LocalSettings.ReadAsync <int>("WaitAfterLastCheck"); foreach (var sourceItem in FilterSources) { bool isFirstItemInFeed = true; if (token.IsCancellationRequested) { IsLoadingData = false; TokenSource = new CancellationTokenSource(); MarkAsReadCommand.OnCanExecuteChanged(); return; } // don't get source feed if x number of minutes haven't passed since the last one - default is 2 hours var checkSourceAfter = sourceItem.LastBuildCheck.AddMinutes(WaitAfterLastCheckInMinutes); if (checkSourceAfter >= DateTimeOffset.Now) { continue; } if (!new NetworkInformationHelper().HasInternetAccess) { continue; } progress.Report(++progressCount); //if getting the feed crushed for (internet - not xml rss - other reasons) //move to the next source on the list to try it instead of stopping every thing try { var feedString = await RssRequest.GetFeedAsStringAsync(sourceItem.RssUrl, token); feed = new SyndicationFeed(); if (string.IsNullOrWhiteSpace(feedString)) { continue; } else { feed.Load(feedString); // Saves rss items count and last check time to source sourceItem.CurrentRssItemsCount = feed.Items.Count; sourceItem.LastBuildCheck = DateTimeOffset.Now; await SourceDataService.UpdateSourceAsync(sourceItem); } } catch (Exception ex) { Debug.WriteLine(ex); continue; } // Iterate through each feed item. foreach (SyndicationItem syndicationItem in feed.Items) { if (token.IsCancellationRequested) { IsLoadingData = false; TokenSource = new CancellationTokenSource(); MarkAsReadCommand.OnCanExecuteChanged(); return; } //handle edge cases like when they don't send that stuff or misplace them like freaking reddit r/worldnews if (syndicationItem.Title == null) { syndicationItem.Title = new SyndicationText("MainViewModelNoTitleFound".GetLocalized()); } if (syndicationItem.Summary == null) { syndicationItem.Summary = new SyndicationText("MainViewModelNoSummaryFound".GetLocalized()); } if (syndicationItem.PublishedDate.Year < 2000) { syndicationItem.PublishedDate = syndicationItem.LastUpdatedTime.Year > 2000 ? syndicationItem.LastUpdatedTime : DateTimeOffset.Now; } Uri itemNewUri = syndicationItem.ItemUri; if (itemNewUri == null) { if (syndicationItem.Links.Count > 0) { itemNewUri = syndicationItem.Links.FirstOrDefault().Uri; } } if (string.IsNullOrWhiteSpace(syndicationItem.Id)) { syndicationItem.Id = itemNewUri.ToString(); } var rss = new RSS { PostTitle = syndicationItem.Title.Text, Description = syndicationItem.Summary.Text, Authors = new List <Author>(), URL = itemNewUri, CreatedAt = syndicationItem.PublishedDate.DateTime, Guid = syndicationItem.Id, PostSource = sourceItem }; foreach (var author in syndicationItem.Authors) { rss.Authors.Add(new Author { Name = author.Name, Email = author.Email, Uri = author.Uri }); } if (!await RSSDataService.FeedExistAsync(rss)) { var newRss = await RSSDataService.AddNewFeedAsync(rss); Feeds.Add(newRss); hasLoadedFeedNewItems = true; // Add first item in each source feed to Windows Live Tiles if (isFirstItemInFeed) { Singleton <LiveTileService> .Instance.SampleUpdate(newRss.PostSource.SiteTitle, ShortenText(newRss.PostTitle, 80), ShortenText(newRss.Description, 95)); } isFirstItemInFeed = false; } } } if (hasLoadedFeedNewItems) { Feeds.Clear(); foreach (var rss in await RSSDataService.GetFeedsDataAsync(await ApplicationData.Current.LocalSettings.ReadAsync <int>("FeedsLimit"))) { Feeds.Add(rss); } } IsLoadingData = false; MarkAsReadCommand.OnCanExecuteChanged(); }
private async Task StartupAsync() { await WhatsNewDisplayService.ShowIfAppropriateAsync(); }