private void Current_VisibilityChanged(object sender, Windows.UI.Core.VisibilityChangedEventArgs e) { if (e.Visible) { WhirlPoolAPIClient.ClearToast(); if (WhirlPoolAPIClient.APIKey == "") { ShowConfig(); } } }
/// <summary> /// Invoked when application execution is being suspended. Application state is saved /// without knowing whether the application will be terminated or resumed with the contents /// of memory still intact. /// </summary> /// <param name="sender">The source of the suspend request.</param> /// <param name="e">Details about the suspend request.</param> private void OnSuspending(object sender, SuspendingEventArgs e) { var deferral = e.SuspendingOperation.GetDeferral(); try { WhirlMonData.WhirlPoolAPIClient.SaveConfig(); } catch (Exception x) { WhirlPoolAPIClient.ShowErrorToast("App.OnSuspending", x); } deferral.Complete(); }
private async void mnuUnsubscribe_Click(object sender, RoutedEventArgs e) { FrameworkElement fe = sender as FrameworkElement; if (fe == null) { return; } if (fe.Tag is WhirlPoolAPIData.WATCHED) { WhirlPoolAPIData.WATCHED watched = (WhirlPoolAPIData.WATCHED)fe.Tag; await WhirlPoolAPIClient.UnsubscribeThreadAsync(watched.ID, true); } }
public async void Run(IBackgroundTaskInstance taskInstance) { BackgroundTaskDeferral _deferral = taskInstance.GetDeferral(); try { WhirlPoolAPIClient.LoadConfig(); await WhirlPoolAPIClient.GetDataAsync(WhirlPoolAPIClient.EWhirlPoolData.wpAll); } catch (Exception x) { WhirlPoolAPIClient.ShowErrorToast("MainBackground", x); } _deferral.Complete(); }
/// <summary> /// Initializes the singleton application object. This is the first line of authored code /// executed, and as such is the logical equivalent of main() or WinMain(). /// </summary> public App() { Microsoft.ApplicationInsights.WindowsAppInitializer.InitializeAsync( Microsoft.ApplicationInsights.WindowsCollectors.Metadata | Microsoft.ApplicationInsights.WindowsCollectors.Session); this.InitializeComponent(); this.Suspending += OnSuspending; try { WhirlMonData.WhirlPoolAPIClient.LoadConfig(); WhirlMonWatchedTask.BackgroundTasks.Register(); } catch (Exception x) { WhirlPoolAPIClient.ShowErrorToast("App", x); } }
protected async override void OnActivated(IActivatedEventArgs args) { try { InitRoot(null, ""); if (args.Kind == ActivationKind.ToastNotification) { var toastArgs = args as ToastNotificationActivatedEventArgs; var argument = toastArgs.Argument; string[] arguments = argument.Split(','); string sid = arguments.Length > 0 ? arguments[0] : ""; string lastpage = arguments.Length > 1 ? arguments[1] : ""; string lastread = arguments.Length > 2 ? arguments[2] : ""; int id = 0; int.TryParse(sid, out id); if (lastpage != "") { String url = string.Format(@"http://forums.whirlpool.net.au/forum-replies.cfm?t={0}&p={1}&#r{2}", sid, lastpage, lastread); var uri = new Uri(url); var success = await Windows.System.Launcher.LaunchUriAsync(uri); if (success) { await WhirlMonData.WhirlPoolAPIClient.MarkThreadReadAsync(id, false); } } else { await WhirlMonData.WhirlPoolAPIClient.MarkThreadReadAsync(id, false); await WhirlPoolAPIClient.GetWatchedAsync(); } } } catch (Exception x) { WhirlPoolAPIClient.ShowErrorToast("App.OnActivated", x); } }
public async void Run(IBackgroundTaskInstance taskInstance) { _deferral = taskInstance.GetDeferral(); try { WhirlPoolAPIClient.LoadConfig(); var details = taskInstance.TriggerDetails as ToastNotificationActionTriggerDetail; var arguments = details.Argument; string[] args = arguments.Split(','); string sid = args.Length > 0 ? args[0] : ""; string lastpage = args.Length > 1 ? args[1] : ""; string lastread = args.Length > 2 ? args[2] : ""; int id = 0; int.TryParse(sid, out id); if (lastpage != "") { String url = string.Format(@"http://forums.whirlpool.net.au/forum-replies.cfm?t={0}&p={1}&#r{2}", sid, lastpage, lastread + 1); var uri = new Uri(url); var success = await Windows.System.Launcher.LaunchUriAsync(uri); if (success) { await WhirlPoolAPIClient.MarkThreadReadAsync(id, false); } } else { await WhirlPoolAPIClient.MarkThreadReadAsync(id, false); } } catch (Exception x) { WhirlPoolAPIClient.ShowErrorToast("ToastBackground", x); } _deferral.Complete(); }
private async void Watched_Tapped(object sender, TappedRoutedEventArgs e) { FrameworkElement fe = e.OriginalSource as FrameworkElement; if (fe == null) { return; } if (fe.DataContext is WhirlPoolAPIData.WATCHED) { WhirlPoolAPIData.WATCHED watched = (WhirlPoolAPIData.WATCHED)fe.DataContext; String url = string.Format(@"http://forums.whirlpool.net.au/forum-replies.cfm?t={0}&p={1}&#r{2}", watched.ID, watched.LASTPAGE, watched.LASTREAD); var uri = new Uri(url); var success = await Windows.System.Launcher.LaunchUriAsync(uri); if (success) { await WhirlPoolAPIClient.MarkThreadReadAsync(watched.ID, true); } } else if (fe.DataContext is WhirlPoolAPIData.RECENT) { WhirlPoolAPIData.RECENT recent = fe.DataContext as WhirlPoolAPIData.RECENT; String url = string.Format(@"http://forums.whirlpool.net.au/forum-replies.cfm?t={0}&p=-1&#bottom", recent.ID); var uri = new Uri(url); var success = await Windows.System.Launcher.LaunchUriAsync(uri); } else if (fe.Tag != null) { // Forum Header Click String url = String.Format(@"https://forums.whirlpool.net.au/forum/{0}", fe.Tag); var uri = new Uri(url); var success = await Windows.System.Launcher.LaunchUriAsync(uri); } }
public async void DoRefresh() { synchronizationContext.Post(new SendOrPostCallback(o => { pbNetwork.Visibility = Visibility.Visible; pbNetwork.IsIndeterminate = true; bnRefresh.IsEnabled = false; }), null); try { await WhirlPoolAPIClient.GetDataAsync(); } finally { synchronizationContext.Post(new SendOrPostCallback(o => { pbNetwork.Visibility = Visibility.Collapsed; pbNetwork.IsIndeterminate = false; bnRefresh.IsEnabled = true; }), null); } }
static public async void Register() { try { UnregisterBackgroundTasks(); // Internet Availble if (!IsRegistered(whirlMonWatchedTaskName)) { var builder = new BackgroundTaskBuilder(); builder.Name = whirlMonWatchedTaskName; builder.TaskEntryPoint = "WhirlMonWatchedTask.MainBackground"; builder.SetTrigger(new SystemTrigger(SystemTriggerType.InternetAvailable, false)); builder.AddCondition(new SystemCondition(SystemConditionType.InternetAvailable)); await Windows.ApplicationModel.Background.BackgroundExecutionManager.RequestAccessAsync(); backTask = builder.Register(); } // Timer if (!IsRegistered(whirlMonWatchedTaskName2)) { var builder = new BackgroundTaskBuilder(); builder.Name = whirlMonWatchedTaskName2; builder.TaskEntryPoint = "WhirlMonWatchedTask.MainBackground"; TimeTrigger minTrigger = new TimeTrigger(15, false); builder.SetTrigger(minTrigger); builder.AddCondition(new SystemCondition(SystemConditionType.InternetAvailable)); await Windows.ApplicationModel.Background.BackgroundExecutionManager.RequestAccessAsync(); backTask = builder.Register(); } // Toast Task if (!IsRegistered(whirlMonToastTaskName)) { var builder = new BackgroundTaskBuilder(); builder.Name = whirlMonToastTaskName; builder.TaskEntryPoint = "WhirlMonWatchedTask.ToastBackground"; builder.SetTrigger(new ToastNotificationActionTrigger()); builder.AddCondition(new SystemCondition(SystemConditionType.InternetAvailable)); await Windows.ApplicationModel.Background.BackgroundExecutionManager.RequestAccessAsync(); backTask = builder.Register(); } } catch (Exception x) { WhirlPoolAPIClient.ShowToast("Register Background Task:" + x.Message); } return; }
/// <summary> /// Invoked when Navigation to a certain page fails /// </summary> /// <param name="sender">The Frame which failed navigation</param> /// <param name="e">Details about the navigation failure</param> void OnNavigationFailed(object sender, NavigationFailedEventArgs e) { WhirlPoolAPIClient.ShowToast("App.OnNavigationFailed: Failed to load Page " + e.SourcePageType.FullName); }