protected override void OnNavigatedTo(NavigationEventArgs e) { if (e.Parameter != null) { args = e.Parameter as ProtocolForResultsActivatedEventArgs; } }
protected override void OnNavigatedTo(NavigationEventArgs e) { // 获取 ProtocolForResultsActivatedEventArgs 对象(从 App.xaml.cs 传来的) _protocolForResultsArgs = e.Parameter as ProtocolForResultsActivatedEventArgs; // 显示协议的详细信息 if (_protocolForResultsArgs != null) { _protocolForResultsOperation = _protocolForResultsArgs.ProtocolForResultsOperation; grid.Background = new SolidColorBrush(Colors.Blue); lblMsg.Foreground = new SolidColorBrush(Colors.White); lblMsg.Text = "激活程序的自定义协议为: " + _protocolForResultsArgs.Uri.AbsoluteUri; lblMsg.Text += Environment.NewLine; if (_protocolForResultsArgs.Data.ContainsKey("InputData")) { string inputData = _protocolForResultsArgs.Data["InputData"] as string; lblMsg.Text += $"收到了数据:{inputData}"; lblMsg.Text += Environment.NewLine; } btnOpenProtocol.Visibility = Visibility.Collapsed; } else { btnBack.Visibility = Visibility.Collapsed; } }
protected override void OnNavigatedTo(NavigationEventArgs e) { if (e.Parameter != null) { args = e.Parameter as ProtocolForResultsActivatedEventArgs; } }
public LaunchResponsePage(ProtocolForResultsActivatedEventArgs args) { this.InitializeComponent(); _args = args; var request = _args.Data["request"] as string; txt_message.Text = $"request is \"{ request}\""; }
protected override void OnNavigatedTo(NavigationEventArgs e) { pfrArgs = e.Parameter as ProtocolForResultsActivatedEventArgs; if (pfrArgs != null) { twitterId = pfrArgs.Data["TwitterId"] as string; IdBlock.Text = twitterId; } }
protected override void OnNavigatedTo(NavigationEventArgs e) { pfrArgs = e.Parameter as ProtocolForResultsActivatedEventArgs; if (pfrArgs != null) { twitterId = pfrArgs.Data["TwitterId"] as string; IdBlock.Text = twitterId; } }
async protected override void OnActivated(IActivatedEventArgs args) { if (args.Kind == ActivationKind.ProtocolForResults) { ProtocolForResultsActivatedEventArgs ea = args as ProtocolForResultsActivatedEventArgs; mem["ResultsOperation"] = ea.ProtocolForResultsOperation; NavigateToMain(); } }
private async Task CheckLaunchedForResultsActivated(object parameter) { _forResultsOperation = parameter as ProtocolForResultsActivatedEventArgs; if (_forResultsOperation != null && _forResultsOperation.Data != null) { var token = _forResultsOperation.Data["FileToken"] as string; var file = await SharedStorageAccessManager.RedeemTokenForFileAsync(token); SetNewImage(file); } }
protected override async void OnNavigatedTo(NavigationEventArgs e) { protocolForResultsArgs = e.Parameter as ProtocolForResultsActivatedEventArgs; if (protocolForResultsArgs != null) { PickImageButton.Visibility = Visibility.Collapsed; // In the data there should be a file token if (protocolForResultsArgs.Data.Keys.Count == 1 && protocolForResultsArgs.Data.ContainsKey("Token")) { string fileToken = protocolForResultsArgs.Data["Token"] as string; // Get the file for the token protocolForResultsImageFile = await SharedStorageAccessManager.RedeemTokenForFileAsync(fileToken); if (protocolForResultsImageFile.ContentType.Contains("image")) { while (m_renderer == null) { await Task.Delay(200); } await ApplyEffectAsync(protocolForResultsImageFile); SaveButton.IsEnabled = true; return; } } // When we can't handle the Protocol For Results operation, just end the operation var operation = protocolForResultsArgs.ProtocolForResultsOperation; var result = new ValueSet(); result["Success"] = false; result["Reason"] = "Invalid payload"; operation.ReportCompleted(result); } }
public async Task LoadForProtocolActivationAsync(ProtocolForResultsActivatedEventArgs protocolForResultsArgs) { _protocolOperation = protocolForResultsArgs.ProtocolForResultsOperation; // In the data there should be a file token if (protocolForResultsArgs.Data.ContainsKey("Photo")) { string dataFromCaller = protocolForResultsArgs.Data["Photo"] as string; string tokenFromCaller = protocolForResultsArgs.Data["DestinationToken"] as string; if (!string.IsNullOrEmpty(tokenFromCaller)) { // Get the file for the token StorageFile imageFile = await SharedStorageAccessManager.RedeemTokenForFileAsync(tokenFromCaller); if (imageFile.ContentType.Contains("image")) { // Try copying to local storage // var copy = await imageFile.CopyAsync(ApplicationData.Current.LocalFolder, imageFile.Name, NameCollisionOption.ReplaceExisting); // Wait until renderer has loaded while (m_renderer == null) { await Task.Delay(200); } await LoadPhotoAsync(imageFile); return; } } } // When we can't handle the Protocol For Results operation, just end the operation var result = new ValueSet(); result["Success"] = false; result["Reason"] = "Invalid payload"; _protocolOperation.ReportCompleted(result); }
protected override void OnActivated(IActivatedEventArgs args) { // 通过协议激活应用程序时(参见 AssociationLaunching/ProtocolAssociation.xaml.cs 中的示例) if (args.Kind == ActivationKind.Protocol) { ProtocolActivatedEventArgs protocolArgs = args as ProtocolActivatedEventArgs; Frame rootFrame = new Frame(); rootFrame.Navigate(typeof(Windows10.AssociationLaunching.ProtocolAssociation), protocolArgs); Window.Current.Content = rootFrame; } // 通过可返回结果的协议激活应用程序时(参见 App2AppCommunication/LaunchUriForResults.xaml.cs 中的示例) if (args.Kind == ActivationKind.ProtocolForResults) { ProtocolForResultsActivatedEventArgs protocolForResultsArgs = args as ProtocolForResultsActivatedEventArgs; Frame rootFrame = new Frame(); rootFrame.Navigate(typeof(Windows10.App2AppCommunication.LaunchUriForResults), protocolForResultsArgs); Window.Current.Content = rootFrame; Window.Current.Activate(); } // 通过 toast 激活应用程序时(前台方式激活) if (args.Kind == ActivationKind.ToastNotification) { ToastNotificationActivatedEventArgs toastArgs = args as ToastNotificationActivatedEventArgs; Frame rootFrame = new Frame(); rootFrame.Navigate(typeof(Windows10.Notification.Toast.Demo), toastArgs); Window.Current.Content = rootFrame; Window.Current.Activate(); } }
public void InitProtocolResponse(ProtocolForResultsActivatedEventArgs args) { _args = args; _callerNameTextBlock.Text = args.CallerPackageFamilyName; }
public void InitProtocolResponse(ProtocolForResultsActivatedEventArgs args) { _args = args; _callerNameTextBlock.Text = args.CallerPackageFamilyName; }
public virtual Task HandleActivation(ProtocolForResultsActivatedEventArgs args) { return(Task.CompletedTask); }