protected override void OnActivated(IActivatedEventArgs args) { if (args.Kind == ActivationKind.Protocol) { ProtocolActivatedEventArgs eventArgs = args as ProtocolActivatedEventArgs; // TODO: Handle URI activation // The received URI is eventArgs.Uri.AbsoluteUri Frame rootFrame = Window.Current.Content as Frame; if (rootFrame == null) { // Create a Frame to act as the navigation context and navigate to the first page rootFrame = new Frame(); rootFrame.NavigationFailed += OnNavigationFailed; // Place the frame in the current Window Window.Current.Content = rootFrame; } if (rootFrame.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 rootFrame.Navigate(typeof(MainPage), null); } // Ensure the current window is active Window.Current.Activate(); } }
private static async Task OnProtocolActivatedAsync(ProtocolActivatedEventArgs protocol) { if (protocol.Uri.IsAbsoluteUri) { Analytics.TrackEvent("Unicord_LaunchForProtocol", new Dictionary <string, string>() { ["protocol"] = protocol.Uri.GetLeftPart(UriPartial.Authority) }); } if (protocol.Uri.AbsolutePath.Trim('/').StartsWith("channels")) { var path = protocol.Uri.AbsolutePath.Split('/').Skip(1).ToArray(); if (path.Length > 1 && ulong.TryParse(path[2], out var channel)) { if (!(Window.Current.Content is Frame rootFrame)) { rootFrame = new Frame(); Window.Current.Content = rootFrame; } rootFrame.Navigate(typeof(MainPage), new MainPageArgs() { ChannelId = channel, FullFrame = false, IsUriActivation = true }); Window.Current.Activate(); return; } } await Launcher.LaunchUriAsync(protocol.Uri, new LauncherOptions() { IgnoreAppUriHandlers = true }); }
protected override void OnActivated(IActivatedEventArgs e) { if (e.Kind == ActivationKind.Protocol) { ProtocolActivatedEventArgs protocolArgs = e as ProtocolActivatedEventArgs; Frame rootFrame = CreateRootFrame(); RestoreStatus(e.PreviousExecutionState); if (rootFrame.Content == null) { if (!rootFrame.Navigate(typeof(CapturePhoto))) { throw new Exception("Failed to create initial page"); } try { ConstParameters.VideoStreamReceiverHost = protocolArgs.Uri.Host; ConstParameters.VideoStreamReceiverPort = protocolArgs.Uri.Port; } catch { throw new Exception("Invalid start protocol."); } } Window.Current.Activate(); } }
protected override void OnActivated(IActivatedEventArgs args) { Frame rootFrame = Window.Current.Content as Frame; // ウィンドウに既にコンテンツが表示されている場合は、アプリケーションの初期化を繰り返さずに、 // ウィンドウがアクティブであることだけを確認してください if (rootFrame == null) { // ナビゲーション コンテキストとして動作するフレームを作成し、最初のページに移動します rootFrame = new Frame(); rootFrame.NavigationFailed += OnNavigationFailed; // フレームを現在のウィンドウに配置します Window.Current.Content = rootFrame; rootFrame.Navigate(typeof(MainPage)); // 現在のウィンドウがアクティブであることを確認します Window.Current.Activate(); } if (args.Kind == ActivationKind.Protocol) { ProtocolActivatedEventArgs eventArgs = args as ProtocolActivatedEventArgs; var frame = Window.Current.Content as Frame; var mainPage = frame?.Content as MainPage; mainPage?.OpenNewPage(eventArgs.Uri.PathAndQuery); } }
protected override void OnActivated(IActivatedEventArgs args) { if (args.Kind == ActivationKind.Protocol) { ProtocolActivatedEventArgs eventArgs = args as ProtocolActivatedEventArgs; var uri = eventArgs.Uri.ToString(); Frame rootFrame = Window.Current.Content as Frame; if (rootFrame == null) { // Create a Frame to act as the navigation context and navigate to the first page rootFrame = new Frame(); // Set the default language rootFrame.Language = Windows.Globalization.ApplicationLanguages.Languages[0]; rootFrame.NavigationFailed += OnNavigationFailed; // Place the frame in the current Window Window.Current.Content = rootFrame; } if (rootFrame.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 rootFrame.Navigate(typeof(MainPage), uri); } // Ensure the current window is active Window.Current.Activate(); } }
protected override void OnActivated(IActivatedEventArgs args) { CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true; var viewTitleBar = ApplicationView.GetForCurrentView().TitleBar; viewTitleBar.ButtonBackgroundColor = Colors.Transparent; viewTitleBar.ButtonInactiveBackgroundColor = Colors.Transparent; viewTitleBar.ButtonForegroundColor = (Color)Resources["SystemBaseHighColor"]; if (!(Window.Current.Content is Frame)) { if (args.Kind == ActivationKind.Protocol) { ProtocolActivatedEventArgs ProtocalArgs = args as ProtocolActivatedEventArgs; if (!string.IsNullOrWhiteSpace(ProtocalArgs.Uri.LocalPath)) { ExtendedSplash extendedSplash = new ExtendedSplash(args.SplashScreen, false, $"PathActivate||{ProtocalArgs.Uri.LocalPath}"); Window.Current.Content = extendedSplash; } else { ExtendedSplash extendedSplash = new ExtendedSplash(args.SplashScreen); Window.Current.Content = extendedSplash; } } else { ExtendedSplash extendedSplash = new ExtendedSplash(args.SplashScreen); Window.Current.Content = extendedSplash; } } Window.Current.Activate(); }
protected override void OnActivated(IActivatedEventArgs args) { if (args.Kind == ActivationKind.Protocol) { ProtocolActivatedEventArgs eventArgs = args as ProtocolActivatedEventArgs; // TODO: Handle URI activation // The received URI is eventArgs.Uri.AbsoluteUri Uri uri = eventArgs.Uri; if (uri.Scheme == "com.microsoft.knowzy.protocol.3d") { Frame rootFrame = new Frame(); Window.Current.Content = rootFrame; rootFrame.Navigate(typeof(MainPage), uri.Query); Window.Current.Activate(); } else if (uri.Scheme == "com.microsoft.knowzy.protocol.test") { Frame rootFrame = new Frame(); Window.Current.Content = rootFrame; rootFrame.Navigate(typeof(AppServiceTest), uri.Query); Window.Current.Activate(); } } }
/// <summary> /// Handle protocol activations. /// </summary> /// <param name="e">Details about the activate request and process.</param> protected override async void OnActivated(IActivatedEventArgs e) { if (e.Kind == ActivationKind.Protocol) { // Handle URI activation ProtocolActivatedEventArgs eventArgs = e as ProtocolActivatedEventArgs; // Initialize the links information LinkInformationService.Reset(); bool validUri = true; Exception exception = null; try { validUri = eventArgs.Uri.IsWellFormedOriginalString(); if (validUri) { // Use OriginalString to keep uppercase and lowercase letters LinkInformationService.ActiveLink = UriService.ReformatUri(eventArgs.Uri.OriginalString); } } catch (UriFormatException ex) { validUri = false; exception = ex; } finally { if (!validUri) { LogService.Log(MLogLevel.LOG_LEVEL_ERROR, "Invalid URI detected during app activation", exception); await DialogService.ShowAlertAsync(ResourceService.AppMessages.GetString("AM_InvalidUri_Title"), ResourceService.AppMessages.GetString("AM_InvalidUri")); } } Frame rootFrame = CreateRootFrame(); if (eventArgs.PreviousExecutionState == ApplicationExecutionState.Terminated) { //TODO: Load state from previously suspended application } // When the navigation stack isn't restored navigate to the first page, configuring // the new page by passing required information as a navigation parameter if (rootFrame.Content == null) { rootFrame.Navigate(typeof(MainPage), eventArgs); } // Ensure the current window is active Window.Current.Activate(); // Check session and special navigation await AppService.CheckActiveAndOnlineSessionAsync(); // Validate product subscription license on background thread Task.Run(() => LicenseService.ValidateLicensesAsync()); } }
/*private IBackgroundTaskRegistration GetRegisteredTask() * { * foreach (var task in BackgroundTaskRegistration.AllTasks.Values) * { * if (task.Name == "UpdateChannel") * { * return task; * } * } * return null; * } * * private async Task<bool> init() * { * if (channel == null) * { * var response = await PushHelper.getInstance().OpenChannelAndUpload(); * channel = response.Channel; * * channel.PushNotificationReceived += OnPushNotificationReceived; * } * * if (GetRegisteredTask() == null) * { * BackgroundTaskBuilder taskBuilder = new BackgroundTaskBuilder(); * MaintenanceTrigger trigger = new MaintenanceTrigger(24*60, false); * taskBuilder.SetTrigger(trigger); * taskBuilder.TaskEntryPoint = "MaintenanceTask"; * taskBuilder.Name = "UpdateChannel"; * * SystemCondition internetCondition = new SystemCondition(SystemConditionType.InternetAvailable); * taskBuilder.AddCondition(internetCondition); * * try * { * * * taskBuilder.Register(); * //rootPage.NotifyUser("Task registered", NotifyType.StatusMessage); * } * catch (Exception ex) * { * //rootPage.NotifyUser("Error registering task: " + ex.Message, NotifyType.ErrorMessage); * } * } * else * { * //rootPage.NotifyUser("Task already registered", NotifyType.ErrorMessage); * } * * //var response = await PushHelper.getInstance().OpenChannelAndUpload(); * * return true; * }*/ /*private void OnPushNotificationReceived(PushNotificationChannel sender, PushNotificationReceivedEventArgs e) * { * * string typeString = String.Empty; * string notificationContent = String.Empty; * switch (e.NotificationType) * { * case PushNotificationType.Badge: * typeString = "Badge"; * notificationContent = e.BadgeNotification.Content.GetXml(); * break; * case PushNotificationType.Tile: * notificationContent = e.TileNotification.Content.GetXml(); * typeString = "Tile"; * break; * case PushNotificationType.Toast: * notificationContent = e.ToastNotification.Content.GetXml(); * typeString = "Toast"; * // Setting the cancel property prevents the notification from being delivered. It's especially important to do this for toasts: * // if your application is already on the screen, there's no need to display a toast from push notifications. * e.Cancel = true; * break; * case PushNotificationType.Raw: * notificationContent = e.RawNotification.Content; * typeString = "Raw"; * break; * } * * Debug.WriteLine($"Notification recieved: {typeString}"); * }*/ protected override void OnActivated(IActivatedEventArgs args) { if (args.Kind == ActivationKind.Protocol) { ProtocolActivatedEventArgs eventArgs = args as ProtocolActivatedEventArgs; // TODO: Handle URI activation // The received URI is eventArgs.Uri.AbsoluteUri var uri = eventArgs.Uri.Query; try { var test = eventArgs.Uri; WwwFormUrlDecoder decoder = new WwwFormUrlDecoder(uri); var param = decoder.ToDictionary(x => x.Name, x => x.Value); var uuid = param["uuid"]; var pubKey = param["pub_key"]; Debug.WriteLine($"UUID: {uuid}, PubKey: {pubKey}"); if (uuid.Equals(string.Empty) || pubKey.Equals(string.Empty)) { } } catch (Exception e) { Debug.WriteLine($"Error while parsing protocol uri tsdevice://{uri}"); } } }
// launch by protocol protected override void OnActivated(IActivatedEventArgs args) { base.OnActivated(args); if (args.Kind == ActivationKind.Protocol) { ProtocolActivatedEventArgs protocolArgs = (ProtocolActivatedEventArgs)args; WwwFormUrlDecoder decoder = new WwwFormUrlDecoder(protocolArgs.Uri.Query); string s_port = decoder.GetFirstValueByName("port"); int.TryParse(s_port, out int port); Controller.Connect(port); Frame rootFrame = Window.Current.Content as Frame; if (rootFrame == null) { rootFrame = new Frame(); rootFrame.NavigationFailed += OnNavigationFailed; Window.Current.Content = rootFrame; } if (rootFrame.Content == null) { rootFrame.Navigate(typeof(MainPage)); } } Window.Current.Activate(); }
protected override void OnActivated(IActivatedEventArgs args) { base.OnActivated(args); if (args.Kind == ActivationKind.Protocol) { ProtocolActivatedEventArgs eventArgs = args as ProtocolActivatedEventArgs; this.InitializeComponent(); Frame rootFrame = Window.Current.Content as Frame; // 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 Frame(); rootFrame.NavigationFailed += OnNavigationFailed; // Place the frame in the current Window Window.Current.Content = rootFrame; } if (rootFrame.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 rootFrame.Navigate(typeof(MainPage), eventArgs.Uri.AbsolutePath); } // Ensure the current window is active Window.Current.Activate(); } }
protected override void OnActivated(IActivatedEventArgs args) { if (args.Kind == ActivationKind.Protocol) { ProtocolActivatedEventArgs eventArgs = args as ProtocolActivatedEventArgs; } }
private void InvalidateLayout() { if (this.ActualWidth < 768) { Grid.SetRow(DescriptionText, 3); Grid.SetColumn(DescriptionText, 0); Grid.SetRow(InputSection, 4); Grid.SetColumn(InputSection, 0); Grid.SetRow(FooterPanel, 2); Grid.SetColumn(FooterPanel, 0); } else { Grid.SetRow(DescriptionText, 1); Grid.SetColumn(DescriptionText, 1); Grid.SetRow(InputSection, 2); Grid.SetColumn(InputSection, 1); Grid.SetRow(FooterPanel, 1); Grid.SetColumn(FooterPanel, 1); } // Since we don't load the scenario page in the traditional manner (we just pluck out the // input and output sections from the page) we need to ensure that any VSM code used // by the scenario's input and output sections is fired. VisualStateManager.GoToState((Control)InputSection, "Input" + DetermineVisualState(this.ActualWidth), false); VisualStateManager.GoToState((Control)OutputSection, "Output" + DetermineVisualState(this.ActualWidth), false); FileEvent = null; ProtocolEvent = null; }
protected override void OnActivated(IActivatedEventArgs args) { Frame rootFrame = Window.Current.Content as Frame; // 不要在窗口已包含内容时重复应用程序初始化, // 只需确保窗口处于活动状态 if (rootFrame == null) { // 创建要充当导航上下文的框架,并导航到第一页 rootFrame = new Frame(); rootFrame.NavigationFailed += OnNavigationFailed; // 将框架放在当前窗口中 Window.Current.Content = rootFrame; } if (rootFrame.Content == null) { // 当导航堆栈尚未还原时,导航到第一页, // 并通过将所需信息作为导航参数传入来配置 // 参数 rootFrame.Navigate(typeof(MainPage)); } // 确保当前窗口处于活动状态 Window.Current.Activate(); if (args.Kind == ActivationKind.Protocol) { ProtocolActivatedEventArgs eventArgs = args as ProtocolActivatedEventArgs; // TODO: Handle URI activation // The received URI is eventArgs.Uri.AbsoluteUri MainPage.Instance.GetTextBox().Text += eventArgs.Uri.AbsoluteUri + '\n'; } }
protected override void OnActivated(IActivatedEventArgs args) { if (args.Kind == ActivationKind.Protocol) { ProtocolActivatedEventArgs eventArgs = args as ProtocolActivatedEventArgs; ProtocolUri = eventArgs.Uri.Query; } Frame rootFrame = Window.Current.Content as Frame; if (rootFrame == null) { rootFrame = new Frame(); rootFrame.NavigationFailed += OnNavigationFailed; Window.Current.Content = rootFrame; } if (rootFrame.Content == null) { Edi.UWP.Helpers.UI.SetWindowsMobileStatusBarColor(Colors.White, Color.FromArgb(255, 7, 153, 252)); if (Class.UserManager.islogin) { if (!Windows.Storage.ApplicationData.Current.LocalSettings.Values.ContainsKey("coursebg")) { Windows.Storage.ApplicationData.Current.LocalSettings.Values["coursebg"] = "ms-appx:///Assets/images/CoursePics/1.png"; } rootFrame.Navigate(typeof(MainPage)); } else { rootFrame.Navigate(typeof(Views.UserPages.LoginPage)); } } SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible; SystemNavigationManager.GetForCurrentView().BackRequested += App_BackRequested; Window.Current.Activate(); }
/// <summary> /// 从URL唤醒程序 /// </summary> /// <param name="args"></param> protected override void OnActivated(IActivatedEventArgs args) { if (args.Kind == ActivationKind.Protocol) { ProtocolActivatedEventArgs urlArgs = args as ProtocolActivatedEventArgs; string sid = Regex.Match(urlArgs.Uri.AbsoluteUri, @"(?<=anime/)\d*").Value; string aid = Regex.Match(urlArgs.Uri.AbsoluteUri, @"(?<=/video/av)\d*").Value; if (!string.IsNullOrEmpty(sid)) { Frame rootFrame = Window.Current.Content as Frame; if (rootFrame == null) { rootFrame = new Frame(); Window.Current.Content = rootFrame; } rootFrame.Navigate(typeof(Views.Detail), sid); Window.Current.Activate(); return; } if (!string.IsNullOrEmpty(aid)) { Frame rootFrame = Window.Current.Content as Frame; if (rootFrame == null) { rootFrame = new Frame(); Window.Current.Content = rootFrame; } rootFrame.Navigate(typeof(Views.Detail_P), aid); Window.Current.Activate(); return; } } }
protected override void OnActivated(IActivatedEventArgs args) { ProtocolActivatedEventArgs protocolArgs = args as ProtocolActivatedEventArgs; if (args != null) { Frame rootFrame = Window.Current.Content as Frame; // 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 Frame(); // Set the default language rootFrame.Language = Windows.Globalization.ApplicationLanguages.Languages[0]; rootFrame.NavigationFailed += OnNavigationFailed; // Place the frame in the current Window Window.Current.Content = rootFrame; } if (rootFrame.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 rootFrame.Navigate(typeof(MainPage), null); } // Ensure the current window is active Window.Current.Activate(); } }
protected override void OnActivated(IActivatedEventArgs args) { if (args.Kind == ActivationKind.Protocol) { ProtocolActivatedEventArgs protocolArgs = args as ProtocolActivatedEventArgs; Frame content = Window.Current.Content as Frame; if (content == null) { content = new Frame(); Harness.SetAutoConfigQueryString(protocolArgs.Uri.Query); if (Harness.Settings.ManualMode) { content.Navigate(typeof(MainPage)); } else { content.Navigate(typeof(TestPage)); } Window.Current.Content = content; } if (content.Content == null) { content.Navigate(typeof(MainPage), args); } } Window.Current.Activate(); base.OnActivated(args); }
private void ProtocolActivated(ProtocolActivatedEventArgs e) { Frame rootFrame = Window.Current.Content as Frame; // 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 Frame(); 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; } if (rootFrame.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 var query = HttpUtility.ParseQueryString(e.Uri.Query); rootFrame.Navigate(typeof(MainPage), query["text"]); } // Ensure the current window is active Window.Current.Activate(); _rootFrameDispatcher = rootFrame.Dispatcher; }
protected override void OnActivated(IActivatedEventArgs args) { Frame rootFrame = Window.Current.Content as Frame; if (rootFrame == null) { rootFrame = new Frame(); rootFrame.NavigationFailed += OnNavigationFailed; Window.Current.Content = rootFrame; } switch (args.Kind) { case ActivationKind.Protocol: ProtocolActivatedEventArgs eventArgs = args as ProtocolActivatedEventArgs; rootFrame.Navigate(typeof(MainPage), eventArgs.Uri.LocalPath); break; default: rootFrame.Navigate(typeof(InCallUI)); break; } Window.Current.Activate(); }
private static ActivationInfo GetProtocolActivationInfo(ProtocolActivatedEventArgs args) { //if (args != null) //{ // switch (args.Uri.AbsolutePath.ToLowerInvariant()) // { // case "student": // case "students": // long studentID = args.Uri.GetInt64Parameter("id"); // if (studentID > 0) // { // return ActivationInfo.Create<StudentDetailsViewModel>(new StudentDetailsArgs { StudentID = studentID }); // } // return ActivationInfo.Create<StudentsViewModel>(new StudentListArgs()); // case "teacher": // case "teachers": // long teacherID = args.Uri.GetInt64Parameter("id"); // if (teacherID > 0) // { // return ActivationInfo.Create<TeacherDetailsViewModel>(new TeacherDetailsArgs { TeacherID = teacherID }); // } // return ActivationInfo.Create<TeachersViewModel>(new TeacherListArgs()); // case "course": // case "courses": // string courseID = args.Uri.GetParameter("id"); // if (courseID != null) // { // return ActivationInfo.Create<CourseDetailsViewModel>(new CourseDetailsArgs { CourseID = courseID }); // } // return ActivationInfo.Create<CoursesViewModel>(new CourseListArgs()); // } //} return(ActivationInfo.CreateDefault()); }
/* * protected async override void OnLaunched(LaunchActivatedEventArgs args) * { * try * { * * var rootFrame = await InitializeFrameAsync(args); * * string tileId = AppManifestHelper.GetApplicationId(); * * if (rootFrame != null) * { * await OnLaunchApplicationAsync(args); * } * * // Ensure the current window is active * //Window.Current.Activate(); * * //base.OnLaunched(args); * } * catch (Exception ex) * { * string message = ex.Message; * } * } */ protected async override void OnActivated(IActivatedEventArgs args) { try { var rootFrame = await InitializeFrameAsync(args); string tileId = AppManifestHelper.GetApplicationId(); if (rootFrame != null) { ProtocolActivatedEventArgs activatedargs = (ProtocolActivatedEventArgs)args; if (args.PreviousExecutionState != ApplicationExecutionState.Running) { await this.LoadAppResources(); } NavigationService.Navigate("Main", null); } //base.OnActivated(args); } catch (Exception ex) { string message = ex.Message; } }
protected override void OnActivated(IActivatedEventArgs args) { D($"Application activated by {args.Kind}"); switch (args.Kind) { case ActivationKind.ToastNotification: var argument = (args as ToastNotificationActivatedEventArgs)?.Argument; ToastManager.HandleToastActivation(argument); break; case ActivationKind.Protocol: try { ProtocolActivatedEventArgs protocalArgs = args as ProtocolActivatedEventArgs; D($"Activated by URI <{protocalArgs.Uri.OriginalString}>"); StupActionManager.Register(() => MainPage.Current.NavigateNewTaskPage(protocalArgs.Uri)); } catch (Exception e) { D($"Handling protocol activation failed: {e.Message}"); StupActionManager.Register(() => MainPage.Current.NavigateNewTaskPage()); ToastManager.ProtocolActivationErrorToast(e); } break; } if (!EnsurePageCreatedAndActivate()) { D($"Exist UI content, navigate to new task page"); StupActionManager.Do(); } base.OnActivated(args); }
protected override async void OnActivated(IActivatedEventArgs args) { SetupShell(args); // we need to wait for the shell to load while (AppShell.Current == null) { await Task.Delay(200); } switch (args.Kind) { case ActivationKind.Protocol: ProtocolActivatedEventArgs protocolArgs = args as ProtocolActivatedEventArgs; Windows.Foundation.WwwFormUrlDecoder decoder = new Windows.Foundation.WwwFormUrlDecoder(protocolArgs.Uri.Query); var siteId = decoder.GetFirstValueByName("LaunchContext"); var parameter = new TripNavigationParameter { TripId = AppSettings.LastTripId, SightId = Guid.ParseExact(siteId, "D") }.GetJson(); AppShell.Current.NavigateToPage(typeof(TripDetailPage), parameter); break; // Insert the M2_VoiceActivation snippet here case ActivationKind.VoiceCommand: VoiceCommandActivatedEventArgs voiceArgs = args as VoiceCommandActivatedEventArgs; HandleVoiceCommand(args); break; // Insert the M2_ToastActivation snippet here case ActivationKind.ToastNotification: var toast = args as ToastNotificationActivatedEventArgs; var props = toast.Argument.Split(':'); if (props[0] == "View") { var tripParam = new TripNavigationParameter { TripId = AppSettings.LastTripId, SightId = Guid.ParseExact(props[1], "D") }.GetJson(); AppShell.Current.NavigateToPage(typeof(TripDetailPage), tripParam); } else if (props[0] == "Remove") { var tripParam = new TripNavigationParameter { TripId = AppSettings.LastTripId, SightId = Guid.ParseExact(props[1], "D"), DeleteSight = true }.GetJson(); AppShell.Current.NavigateToPage(typeof(TripDetailPage), tripParam); } break; default: break; } // Ensure the current window is active Window.Current.Activate(); }
private static ActivationInfo GetProtocolActivationInfo(ProtocolActivatedEventArgs args) { //if (args != null) //{ // switch (args.Uri.AbsolutePath.ToLowerInvariant()) // { // case "Company": // case "Companys": // long CompanyID = args.Uri.GetInt64Parameter("id"); // if (CompanyID > 0) // { // return ActivationInfo.Create<CompanyDetailsViewModel>(new CompanyDetailsArgs { CompanyID = CompanyID }); // } // return ActivationInfo.Create<CompanysViewModel>(new CompanyListArgs()); // case "order": // case "orders": // long orderID = args.Uri.GetInt64Parameter("id"); // if (orderID > 0) // { // return ActivationInfo.Create<OrderDetailsViewModel>(new OrderDetailsArgs { OrderID = orderID }); // } // return ActivationInfo.Create<OrdersViewModel>(new OrderListArgs()); // case "product": // case "products": // string productID = args.Uri.GetParameter("id"); // if (productID != null) // { // return ActivationInfo.Create<ProductDetailsViewModel>(new ProductDetailsArgs { ProductID = productID }); // } // return ActivationInfo.Create<ProductsViewModel>(new ProductListArgs()); // } //} return(ActivationInfo.CreateDefault()); }
protected override void OnActivated(IActivatedEventArgs args) { //由Uri启动时 if (args.Kind == ActivationKind.Protocol) { ProtocolActivatedEventArgs eventArgs = args as ProtocolActivatedEventArgs; //储存Uri Data.OverAll.AppUri = eventArgs.Uri; //按照正常流程启动应用 Frame rootFrame = Window.Current.Content as Frame; if (rootFrame == null) { rootFrame = new Frame(); rootFrame.NavigationFailed += OnNavigationFailed; if (eventArgs.PreviousExecutionState == ApplicationExecutionState.Terminated) { //TODO: 从之前挂起的应用程序加载状态 } Window.Current.Content = rootFrame; } if (rootFrame.Content == null) { rootFrame.Navigate(typeof(LoginPage)); } else if (rootFrame.Content is MainPage) { (rootFrame.Content as MainPage).HandleUri(); } Window.Current.Activate(); } }
protected override void OnActivated(IActivatedEventArgs args) { LogMessage("OnActivated"); Frame rootFrame = Window.Current.Content as Frame; if (rootFrame == null) { rootFrame = new Frame(); Window.Current.Content = rootFrame; } // Protocol activation is the only type of activation that this app handles if (args.Kind == ActivationKind.Protocol) { LogMessage("OnProtocolActivated"); ProtocolActivatedEventArgs protocolArgs = args as ProtocolActivatedEventArgs; var p = rootFrame.Content as MainPage; if (p == null) { if (protocolArgs != null) { rootFrame.Navigate(typeof(MainPage), args); } else { rootFrame.Navigate(typeof(MainPage)); } } } Window.Current.Activate(); }
protected override void OnActivated(IActivatedEventArgs args) { string additionParameter = ""; switch (args.Kind) { case ActivationKind.CommandLineLaunch: CommandLineActivatedEventArgs cmdLineArgs = args as CommandLineActivatedEventArgs; CommandLineActivationOperation operation = cmdLineArgs.Operation; string cmdLineString = operation.Arguments; string activationPath = operation.CurrentDirectoryPath; break; case ActivationKind.Protocol: ProtocolActivatedEventArgs uriArg = args as ProtocolActivatedEventArgs; additionParameter = GetParameterURI(uriArg.Uri.OriginalString); break; } //Navigate Frame rootFrame = Window.Current.Content as Frame; if (rootFrame == null) { rootFrame = new Frame(); Window.Current.Content = rootFrame; } rootFrame.Navigate(typeof(MainPage), additionParameter); Window.Current.Activate(); }
/// <summary> /// Invoked when the application is launched through a custom URI scheme, such as /// is the case in an OAuth 2.0 authorization flow. /// </summary> /// <param name="args">Details about the URI that activated the app.</param> protected override void OnActivated(IActivatedEventArgs args) { // When the app was activated by a Protocol (custom URI scheme), forwards // the URI to the MainPage through a Navigate event. if (args.Kind == ActivationKind.Protocol) { // Extracts the authorization response URI from the arguments. ProtocolActivatedEventArgs protocolArgs = (ProtocolActivatedEventArgs)args; Uri uri = protocolArgs.Uri; Material.Framework.Platform.Current.Protocol(uri); // Gets the current frame, making one if needed. var frame = Window.Current.Content as Frame; if (frame == null) { frame = new Frame(); } // Opens the URI for "navigation" (handling) on the MainPage. frame.Navigate(typeof(MainPage), uri); Window.Current.Content = frame; Window.Current.Activate(); } }
protected override void OnActivated(IActivatedEventArgs args) { if (args == null) { throw new ArgumentNullException(nameof(args)); } base.OnActivated(args); Frame rootFrame = Window.Current.Content as Frame; if (args.Kind == ActivationKind.Protocol) { if (rootFrame == null) { rootFrame = new Frame(); rootFrame.NavigationFailed += OnNavigationFailed; Window.Current.Content = rootFrame; } ProtocolActivatedEventArgs eventArgs = args as ProtocolActivatedEventArgs; rootFrame.Navigate(typeof(UnknownCameraPage), eventArgs.Uri.AbsoluteUri); } Window.Current.Activate(); }