/// <summary> /// Pins and updates the secondary tile /// </summary> /// <param name="account"></param> /// <param name="data"></param> /// <returns></returns> public static async Task PinTile(AccountDataItem account, AccountDataStore data) { string args = new ViewScheduleArguments() { LocalAccountId = account.LocalAccountId }.SerializeToString(); SecondaryTile tile = new SecondaryTile(GenerateScheduleTileId(account.LocalAccountId), "Schedule", args, new Uri("ms-appx:///Assets/Square150x150Logo.png"), TileSize.Default); tile.VisualElements.Square71x71Logo = new Uri("ms-appx:///Assets/Square71x71Logo.png"); tile.VisualElements.Wide310x150Logo = new Uri("ms-appx:///Assets/Wide310x150Logo.png"); tile.VisualElements.Square310x310Logo = new Uri("ms-appx:///Assets/Square310x310Logo.png"); tile.VisualElements.Square44x44Logo = new Uri("ms-appx:///Assets/Square44x44Logo.png"); tile.LockScreenBadgeLogo = new Uri("ms-appx:///Assets/LockScreenLogo.png"); tile.LockScreenDisplayBadgeAndTileText = true; tile.VisualElements.ShowNameOnSquare150x150Logo = true; tile.VisualElements.ShowNameOnSquare310x310Logo = true; tile.VisualElements.ShowNameOnWide310x150Logo = true; if (!await tile.RequestCreateAsync()) { return; } await UpdateScheduleTile(tile.TileId, account, data); }
protected override async System.Threading.Tasks.Task OnLaunchedOrActivated(IActivatedEventArgs e) { try { #if DEBUG //if (System.Diagnostics.Debugger.IsAttached) //{ // this.DebugSettings.EnableFrameRateCounter = true; //} #endif // Register background tasks if (!_registeredBackgroundTasks) { try { // Make sure none are registered (they should have already been unregistered) UnregisterAllBackgroundTasks(); RegisterInfrequentBackgroundTask(); RegisterRawPushBackgroundTask(); RegisterToastBackgroundTask(); } catch (Exception ex) { if (UWPExceptionHelper.TrackIfRpcServerUnavailable(ex, "RegisterBgTasks")) { } else if (UWPExceptionHelper.TrackIfPathInvalid(ex, "RegisterBgTasks")) { } else { TelemetryExtension.Current?.TrackException(ex); } } _registeredBackgroundTasks = true; } // Wait for initialization to complete, to ensure we don't accidently add multiple windows // Although right now we don't even do any async tasks, so this will be useless await PowerPlannerApp.InitializeTask; MainAppWindow mainAppWindow; // If no windows, need to register window mainAppWindow = PowerPlannerApp.Current.Windows.OfType <MainAppWindow>().FirstOrDefault(); if (mainAppWindow == null) { // This configures the view models, does NOT call Activate yet var nativeWindow = new NativeUwpAppWindow(); mainAppWindow = new MainAppWindow(); await PowerPlannerApp.Current.RegisterWindowAsync(mainAppWindow, nativeWindow); if (PowerPlannerApp.Current.Windows.Count > 1) { throw new Exception("There are more than 1 windows registered"); } } if (e is LaunchActivatedEventArgs) { var launchEventArgs = e as LaunchActivatedEventArgs; var launchContext = !object.Equals(launchEventArgs.TileId, "App") ? LaunchSurface.SecondaryTile : LaunchSurface.Normal; if (launchContext == LaunchSurface.Normal) { // Track whether was launched from primary tile if (ApiInformation.IsPropertyPresent(typeof(LaunchActivatedEventArgs).FullName, nameof(LaunchActivatedEventArgs.TileActivatedInfo))) { if (launchEventArgs.TileActivatedInfo != null) { launchContext = LaunchSurface.PrimaryTile; } } } await HandleArguments(mainAppWindow, launchEventArgs.Arguments, launchContext); } else if (e is ToastNotificationActivatedEventArgs) { var args = e as ToastNotificationActivatedEventArgs; await HandleArguments(mainAppWindow, args.Argument, LaunchSurface.Toast); } else if (e is ProtocolActivatedEventArgs) { var protocolEventArgs = e as ProtocolActivatedEventArgs; if (!string.IsNullOrWhiteSpace(protocolEventArgs.Uri.PathAndQuery) && protocolEventArgs.Uri.PathAndQuery.StartsWith("?")) { await HandleArguments(mainAppWindow, protocolEventArgs.Uri.PathAndQuery.Substring(1), LaunchSurface.Uri); } } else if (e is AppointmentsProviderShowAppointmentDetailsActivatedEventArgs) { // Note that this code is essentially deprecated and doesn't get hit... Uri launch happens instead var showDetailsArgs = e as AppointmentsProviderShowAppointmentDetailsActivatedEventArgs; try { AppointmentsHelper.RoamingIdData data = AppointmentsHelper.RoamingIdData.FromString(showDetailsArgs.RoamingId); string finalArgs = null; switch (data.ItemType) { case ItemType.Schedule: finalArgs = new ViewScheduleArguments() { LocalAccountId = data.LocalAccountId }.SerializeToString(); break; case ItemType.MegaItem: finalArgs = new ViewTaskArguments() { LocalAccountId = data.LocalAccountId, ItemId = data.Identifier }.SerializeToString(); break; } if (finalArgs != null) { await HandleArguments(mainAppWindow, finalArgs, LaunchSurface.Calendar); } } catch (Exception ex) { TelemetryExtension.Current?.TrackException(ex); } } if (mainAppWindow.GetViewModel().Content == null) { await mainAppWindow.GetViewModel().HandleNormalLaunchActivation(); } Window.Current.Activate(); // Listen to window activation changes Window.Current.Activated += Current_Activated; // Set up the default window properties ConfigureWindowProperties(); // Set up the sharing support ConfigureDataTransferManager(); // Display updates HandleVersionChange(); } catch (Exception ex) { TelemetryExtension.Current?.TrackException(ex); } }
public static BaseArguments Parse(string queryString) { QueryString qs = QueryString.Parse(queryString); string val; ArgumentsAction action = ArgumentsAction.Unknown; if (!(qs.TryGetValue(KEY_ACTION, out val) && Enum.TryParse(val, out action))) { return(null); } BaseArguments answer = null; switch (action) { case ArgumentsAction.ViewPage: answer = new ViewPageArguments(); break; case ArgumentsAction.ViewSchedule: answer = new ViewScheduleArguments(); break; case ArgumentsAction.ViewClass: answer = new ViewClassArguments(); break; case ArgumentsAction.QuickAdd: answer = new QuickAddArguments(); break; case ArgumentsAction.QuickAddToCurrentAccount: answer = new QuickAddToCurrentAccountArguments(); break; case ArgumentsAction.QuickAddHomeworkToCurrentAccount: answer = new QuickAddHomeworkToCurrentAccountArguments(); break; case ArgumentsAction.QuickAddExamToCurrentAccount: answer = new QuickAddExamToCurrentAccountArguments(); break; case ArgumentsAction.OpenAccount: answer = new OpenAccountArguments(); break; case ArgumentsAction.ViewHomework: answer = new ViewHomeworkArguments(); break; case ArgumentsAction.ViewExam: answer = new ViewExamArguments(); break; case ArgumentsAction.ViewHoliday: answer = new ViewHolidayArguments(); break; } if (answer != null) { if (answer.TryParse(qs)) { return(answer); } } return(null); }