/// <summary> // Launch a URI. Show an Open With dialog that lets the user chose the handler to use. /// </summary> private async void LaunchUriOpenWith(object sender, RoutedEventArgs e) { // Create the URI to launch from a string. var uri = new Uri(UriToLaunch.Text); // Calulcate the position for the Open With dialog. // An alternative to using the point is to set the rect of the UI element that triggered the launch. Point openWithPosition = MainPage.GetElementLocation(sender); // Next, configure the Open With dialog. var options = new LauncherOptions(); options.DisplayApplicationPicker = true; options.UI.InvocationPoint = openWithPosition; options.UI.PreferredPlacement = Windows.UI.Popups.Placement.Below; // Launch the URI. bool success = await Launcher.LaunchUriAsync(uri, options); if (success) { rootPage.NotifyUser("URI launched: " + uri.AbsoluteUri, NotifyType.StatusMessage); } else { rootPage.NotifyUser("URI launch failed.", NotifyType.ErrorMessage); } }
private async void FileOpenButton_Click(object sender, RoutedEventArgs e) { // FileOpenPicker // https://msdn.microsoft.com/ja-jp/library/windows/apps/mt186456.aspx var picker = new Windows.Storage.Pickers.FileOpenPicker(); picker.FileTypeFilter.Add(".eml"); var items = await picker.PickMultipleFilesAsync(); if (items.Count > 0) { for (int i = 0; i < items.Count; i++) { StorageFile storageFile = items[i] as StorageFile; if (i == 0) { Frame.Navigate(typeof(MailPage), storageFile); } else { // Open file on this app var options = new LauncherOptions(); options.TargetApplicationPackageFamilyName = Package.Current.Id.FamilyName; await Launcher.LaunchFileAsync(storageFile, options); } } } }
private async Task<LaunchUriResult> CropImageAsync(IStorageFile input, IStorageFile destination, int width, int height) { // Get access tokens to pass input and output files between apps var inputToken = SharedStorageAccessManager.AddFile(input); var destinationToken = SharedStorageAccessManager.AddFile(destination); // Specify an app to launch by using LaunchUriForResultsAsync var options = new LauncherOptions(); options.TargetApplicationPackageFamilyName = "Microsoft.Windows.Photos_8wekyb3d8bbwe"; // Specify protocol launch options var parameters = new ValueSet(); parameters.Add("InputToken", inputToken); parameters.Add("DestinationToken", destinationToken); parameters.Add("CropWidthPixels", width); parameters.Add("CropHeightPixels", height); parameters.Add("EllipticalCrop", false); parameters.Add("ShowCamera", false); // Perform LaunchUriForResultsAsync return await Launcher.LaunchUriForResultsAsync(new Uri("microsoft.windows.photos.crop:"), options, parameters); // See also: // https://frayxrulez.wordpress.com/tag/microsoft-windows-photos-crop/ // https://gist.github.com/c2f1bbfa996ad5751b87 // https://myignite.microsoft.com/videos/2571 }
private async void LaunchUriForResult_Click(object sender, RoutedEventArgs e) { var protocol = "win10demo2://"; var packageFamilyName = "0df93276-6bbb-46fa-96b7-ec223e226505_cb1hhkscw5m06"; var status = await Launcher.QueryUriSupportAsync(new Uri(protocol), LaunchQuerySupportType.UriForResults, packageFamilyName); if (status == LaunchQuerySupportStatus.Available) { var options = new LauncherOptions { TargetApplicationPackageFamilyName = packageFamilyName }; var values = new ValueSet(); values.Add("TwitterId", "danvy"); var result = await Launcher.LaunchUriForResultsAsync(new Uri(protocol), options, values); if (result.Status == LaunchUriStatus.Success) { var authorized = result.Result["Authorized"] as string; if (authorized == true.ToString()) { var dialog = new MessageDialog("You are authorized :)"); await dialog.ShowAsync(); } } } }
private async void Grid_Drop(object sender, DragEventArgs e) { if (e.DataView.Contains(StandardDataFormats.StorageItems)) { var items = await e.DataView.GetStorageItemsAsync(); if (items.Count > 0) { for (int i = 0; i < items.Count; i++) { StorageFile storageFile = items[i] as StorageFile; string filetype = storageFile.FileType.ToLower(); if (filetype.Equals(".eml")) { if (i == 0) { Frame.Navigate(typeof(MailPage), storageFile); } else { // Open file on this app var options = new LauncherOptions(); options.TargetApplicationPackageFamilyName = Package.Current.Id.FamilyName; await Launcher.LaunchFileAsync(storageFile, options); } } } } } }
protected override async Task HandleInternal(ContactPanelActivatedEventArgs args) { var contactService = Singleton <ContactService> .Instance; var contact = await contactService.GetContact(args.Contact.Id); contact.RemoteId = await contactService.GetRemoteId(contact); args.ContactPanel.HeaderColor = HeaderColor; args.ContactPanel.LaunchFullAppRequested += async(contactPanel, e) => { e.Handled = true; await Window.Current.Dispatcher.RunAsync( CoreDispatcherPriority.Normal, async() => { var options = new LauncherOptions { TargetApplicationPackageFamilyName = Package.Current.Id.FamilyName }; var uri = new UriBuilder(ProtocolHeader); uri.Query = new QueryString() { { "id", contact.RemoteId } }.ToString(); await Launcher.LaunchUriAsync(uri.Uri, options); contactPanel.ClosePanel(); }); }; if (Window.Current.Content is Frame frame) { frame.Navigate(ContactView, contact); } }
private async Task InitializeAppServiceConnectionAsync() { const string consoleOutputPackageFamilyName = "49752MichaelS.Scherotter.ConsoleOutput_9eg5g21zq32qm"; var options = new LauncherOptions { PreferredApplicationDisplayName = "Console Output", PreferredApplicationPackageFamilyName = consoleOutputPackageFamilyName, TargetApplicationPackageFamilyName = consoleOutputPackageFamilyName, }; var uri = new Uri("consoleoutput:?Title=Console Output Tester&input=true"); if (!await Launcher.LaunchUriAsync(uri, options)) { return; } var appServiceConnection = new AppServiceConnection { AppServiceName = "consoleoutput", PackageFamilyName = consoleOutputPackageFamilyName }; var status = await appServiceConnection.OpenAsync(); if (status == AppServiceConnectionStatus.Success) { _appServiceConnection = appServiceConnection; // because we want to get messages back from the console, we launched the app with the input=true parameter _appServiceConnection.RequestReceived += _appServiceConnection_RequestReceived; } }
private async void emailButton_Click(object sender, RoutedEventArgs e) { LauncherOptions options = new LauncherOptions(); options.DesiredRemainingView = Windows.UI.ViewManagement.ViewSizePreference.UseHalf; await Launcher.LaunchUriAsync(new Uri("mailto:[email protected]"), options); }
private async void LaunchFileIn3DBuilder() { FileOpenPicker openPicker = new FileOpenPicker(); openPicker.ViewMode = PickerViewMode.Thumbnail; openPicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary; openPicker.FileTypeFilter.Add(".3mf"); openPicker.FileTypeFilter.Add(".stl"); StorageFile file = await openPicker.PickSingleFileAsync(); if (file == null) { return; } var options = new LauncherOptions(); // The target application is 3D Builder. options.TargetApplicationPackageFamilyName = PackageFamilyName3DBuilder; // If 3D Builder is not installed, redirect the user to the Store to install it. options.FallbackUri = new Uri("ms-windows-store:PDP?PFN=" + PackageFamilyName3DBuilder); await Launcher.LaunchFileAsync(file, options); }
public async Task OpenWeb() { var opt = new LauncherOptions(); opt.IgnoreAppUriHandlers = true; await Launcher.LaunchUriAsync(new Uri(_sourceFeed.FeedUrl), opt); }
private async void Button_Click(object sender, RoutedEventArgs e) { var uri = new Uri(@"foodtruck:burgers");//(@"http://www.google.com"); var handlers = await Launcher.FindUriSchemeHandlersAsync("foodtruck"); foreach (var handle in handlers) { System.Diagnostics.Debug.WriteLine(handle.PackageFamilyName); } var lauchOptions = new LauncherOptions { TargetApplicationPackageFamilyName = "27a9d0fb-1063-4d14-907b-fcaa93949825_5gyrq6psz227t" }; var set = new ValueSet(); set.Add("item", "cheese"); //var success = await Launcher.LaunchUriAsync(uri, lauchOptions,set); var launchResult = await Launcher.LaunchUriForResultsAsync(uri, lauchOptions, set); if (launchResult.Status == LaunchUriStatus.Success) { object resultItem = null; if (launchResult.Result?.TryGetValue("price", out resultItem) ?? false) { var dialog = new MessageDialog((string)resultItem); await dialog.ShowAsync(); } } }
// 打开自定义协议 webabcd: 并传递数据给目标程序,然后获取目标程序的返回数据 private async void btnOpenProtocol_Click(object sender, RoutedEventArgs e) { Uri uri = new Uri("webabcd:data"); var options = new LauncherOptions(); // 用 LaunchUriForResultsAsync() 的话必须要指定目标程序的 PackageFamilyName options.TargetApplicationPackageFamilyName = "48c7dd54-1ef2-4db7-a75e-7e02c5eefd40_vsy44gny1fmrj"; ValueSet inputData = new ValueSet(); inputData["InputData"] = "input data"; lblMsg.Text = "打开 webabcd: 协议,并传递数据"; lblMsg.Text += Environment.NewLine; LaunchUriResult result = await Launcher.LaunchUriForResultsAsync(uri, options, inputData); if (result.Status == LaunchUriStatus.Success && result.Result != null && result.Result.ContainsKey("ReturnData")) { ValueSet theValues = result.Result; string returnData = theValues["ReturnData"] as string; lblMsg.Text += $"收到返回数据:{returnData}"; lblMsg.Text += Environment.NewLine; } }
private async void RecentsView_ItemClick(object sender, ItemClickEventArgs e) { var path = (e.ClickedItem as RecentItem).path; try { var file = (await StorageFile.GetFileFromPathAsync(path)); if (file.FileType == "Application") { await Interaction.LaunchExe(path); } else { var options = new LauncherOptions { DisplayApplicationPicker = false }; await Launcher.LaunchFileAsync(file, options); } } catch (System.ArgumentException) { MainPage.accessibleContentFrame.Navigate(typeof(GenericFileBrowser), path); } }
private async void LaunchApp() { var testAppUri = new Uri("weipo:"); // The protocol handled by the launched app var options = new LauncherOptions { TargetApplicationPackageFamilyName = Package.Current.Id.FamilyName }; var inputData = new ValueSet(); var data = _shareArguments.ShareOperation.Data; if (data.Contains(StandardDataFormats.Text)) { var text = await data.GetTextAsync(); inputData["text"] = text; } if (data.Contains(StandardDataFormats.Bitmap)) { var bitmap = await data.GetBitmapAsync(); var file = await bitmap.SaveCacheFile(); inputData["image"] = SharedStorageAccessManager.AddFile(file); } await Launcher.LaunchUriAsync(testAppUri, options, inputData); _shareArguments.ShareOperation.ReportCompleted(); }
protected virtual async void OpenWithExecute() { var item = _selectedItem; if (item == null || !CanOpenWith) { return; } var file = item.GetFile(); if (file != null && file.Local.IsDownloadingCompleted) { try { var temp = await StorageFile.GetFileFromPathAsync(file.Local.Path); var options = new LauncherOptions(); options.DisplayApplicationPicker = true; await Launcher.LaunchFileAsync(temp, options); } catch { } } }
private async Task CheckOut() { var checkoutAppUri = new Uri("checkoutdemo:"); // We want a specific app to perform our checkout operation, not just any that implements the protocol we're using for launch var options = new LauncherOptions(); options.TargetApplicationPackageFamilyName = "7d7072f5-7a53-47f6-9932-97647aad9550_z5jhcbv2wstvg"; var transactionId = Guid.NewGuid().ToString(); var inputData = new ValueSet(); // Our collection is too complicated for ValueSet to understand so we serialize it first var serializedSelectedItems = JsonConvert.SerializeObject(this.AvailableProducts.Where(p => p.IsSelected).Select(p => new { Description = p.Name, UnitPrice = p.Price, Quantity = 1 }).ToList()); inputData["Items"] = serializedSelectedItems; inputData["Transaction"] = transactionId; var response = await Launcher.LaunchUriForResultsAsync(checkoutAppUri, options, inputData); if (response.Status == LaunchUriStatus.Success) { Frame.Navigate(typeof(Receipt), response.Result); } else { // TODO: handle failure to launch... } }
private async Task <string> LaunchAppForResults() { var testAppUri = new Uri("demo-sampleapp:"); // The protocol handled by the launched app var options = new LauncherOptions(); // Remark: This has to be the family name of the launched app! options.TargetApplicationPackageFamilyName = "100a09f7-0848-4e0b-8f5e-b52b18d32783_15q9a6cr6qx7p"; var inputData = new ValueSet(); inputData["TestData"] = this.SendDataTextBlock.Text + " at " + DateTime.Now.ToString(); string theResult = ""; LaunchUriResult result = await Windows.System.Launcher.LaunchUriForResultsAsync(testAppUri, options, inputData); if (result.Status == LaunchUriStatus.Success && result.Result != null && result.Result.ContainsKey("ReturnedData")) { ValueSet theValues = result.Result; theResult = theValues["ReturnedData"] as string; } else { theResult = result.Status.ToString(); } return(theResult); }
private async Task <JsonObject> LaunchAppForResults(JsonObject json) { var appUri = new Uri("app2scanner:"); // The protocol handled by the launched app var options = new LauncherOptions { TargetApplicationPackageFamilyName = "anyline.uwp.testapp_h89hmanpz8x02", DesiredRemainingView = Windows.UI.ViewManagement.ViewSizePreference.UseMore }; var inputData = new ValueSet { ["jsonConfig"] = json.ToString() }; string scanResult = null; LaunchUriResult result = await Windows.System.Launcher.LaunchUriForResultsAsync(appUri, options, inputData); if (result.Status == LaunchUriStatus.Success && result.Result != null) { ValueSet res = result.Result; if (result.Result.ContainsKey("result")) { scanResult = res["result"] as string; } } if (scanResult != null) { var scanResultString = scanResult.ToString(); Debug.WriteLine($"Result received: {scanResultString}"); return(JsonObject.Parse(scanResult)); } return(null); }
public async Task <bool> EmailErrorMessageAsync(string message) { // Need to escape any invalid characters var formattedText = Uri.EscapeUriString(message); // make sure we're not over the 255 character limit for url encoding if (formattedText.Length >= 255) { formattedText = formattedText.Truncate(254); } var uri = new Uri($"mailto:[email protected]?subject=MVP%20Companion%20Error&body={formattedText}", UriKind.Absolute); var options = new LauncherOptions { DesiredRemainingView = ViewSizePreference.UseHalf, DisplayApplicationPicker = true, PreferredApplicationPackageFamilyName = "microsoft.windowscommunicationsapps_8wekyb3d8bbwe", PreferredApplicationDisplayName = "Mail" }; var result = await Launcher.LaunchUriAsync(uri, options); // TODO log success or failure of email compose return(result); }
private async void NavigateToParkingLot(ParkingLot lot) { const string launcherString = "bingmaps:?rtp=~{0}"; const string launcherPosString = "pos.{0}_{1}_{2}"; const string launcherAdrString = "adr.{0}"; if (lot == null) { return; } Uri launcherUri; _tracking.TrackNavigateToParkingLotEvent(SelectedCity, lot); if (lot.Coordinates != null) { launcherUri = new Uri( String.Format( launcherString, String.Format( launcherPosString, lot.Coordinates.Latitude.ToString(CultureInfo.InvariantCulture), lot.Coordinates.Longitude.ToString(CultureInfo.InvariantCulture), String.Format(ResourceService.Instance.DirectionsParkingLotLabel, lot.Name) ) ) ); } else if (!String.IsNullOrEmpty(lot.Address)) { launcherUri = new Uri( String.Format( launcherString, String.Format( launcherAdrString, Uri.EscapeDataString(lot.Address + ", " + SelectedCity.Name) ) ) ); } else { launcherUri = new Uri( String.Format( launcherString, String.Format( launcherAdrString, Uri.EscapeDataString(lot.Name + ", " + SelectedCity.Name) ) ) ); } if (launcherUri != null) { var launcherOptions = new LauncherOptions { TargetApplicationPackageFamilyName = "Microsoft.WindowsMaps_8wekyb3d8bbwe" }; await Launcher.LaunchUriAsync(launcherUri, launcherOptions); } }
private async void OnLaunchUriWithData(object sender, RoutedEventArgs e) { try { string targetUri = @"for-results2:"; string targetUriScheme = @"for-results"; string launcherTargetPfn = @"LaunchUriTargetMultiApp_8wekyb3d8bbwe"; Uri uri = new Uri(targetUri, UriKind.Absolute); LauncherOptions options = new LauncherOptions(); options.TargetApplicationPackageFamilyName = launcherTargetPfn; ValueSet data = new ValueSet(); // Get UTC filetime and reduce resolution from 100ns to 10ms, expecting target to receive data within 10ms long timeSuffix = DateTime.Now.ToFileTimeUtc(); timeSuffix = (timeSuffix / 10000000000L); data.Add("Data", "Hello Target App_" + timeSuffix); data.Add("UriScheme", targetUriScheme); bool success = await Launcher.LaunchUriAsync(uri, options, data); if (success) { status.Log(string.Format(CultureInfo.CurrentCulture, LocalizableStrings.LAUNCHERS_APP_LAUNCH_SUCCESS, targetUri)); } else { status.Log(string.Format(CultureInfo.CurrentCulture, LocalizableStrings.LAUNCHERS_APP_LAUNCH_FAIL, targetUri)); } } catch (Exception ex) { Debug.WriteLine("LaunchersPage.OnLaunchUriWithData: " + ex.ToString()); status.Log(ex.Message); } }
private async void OnLaunchUriForResultsUnsupportedProtocol(object sender, RoutedEventArgs e) { try { string targetUri = @"for-noresults:"; string launcherTargetPfn = @"LaunchUriTargetMultiApp_8wekyb3d8bbwe"; Uri uri = new Uri(targetUri, UriKind.Absolute); LauncherOptions options = new LauncherOptions(); options.TargetApplicationPackageFamilyName = launcherTargetPfn; LaunchUriResult result = await Launcher.LaunchUriForResultsAsync(uri, options); if (result.Status == LaunchUriStatus.ProtocolUnavailable) { status.Log(string.Format(CultureInfo.CurrentCulture, LocalizableStrings.LAUNCHERS_URI_BAD_PROTOCOL_SUCCESS, result.Status)); } else { status.Log(string.Format(CultureInfo.CurrentCulture, LocalizableStrings.LAUNCHERS_URI_BAD_PROTOCOL_SUCCESS, result.Status)); } } catch (Exception ex) { Debug.WriteLine("LaunchersPage.OnLaunchUriForResultsUnsupportedProtocol: " + ex.ToString()); status.Log(ex.Message); } }
private async void OnLaunchUriForResultsInvalidPfn(object sender, RoutedEventArgs e) { try { string targetUri = @"for-results:"; string launcherTargetPfn = @"Microsoft.Windows.Illusion_8wekyb3d8bbwe"; Uri uri = new Uri(targetUri, UriKind.Absolute); LauncherOptions options = new LauncherOptions(); options.TargetApplicationPackageFamilyName = launcherTargetPfn; LaunchUriResult result = await Launcher.LaunchUriForResultsAsync(uri, options); if (result.Status == LaunchUriStatus.AppUnavailable) { status.Log(string.Format(CultureInfo.CurrentCulture, LocalizableStrings.LAUNCHERS_URI_BAD_PFN_SUCCESS, result.Status)); } else { status.Log(string.Format(CultureInfo.CurrentCulture, LocalizableStrings.LAUNCHERS_URI_BAD_PFN_FAIL, result.Status)); } } catch (Exception ex) { Debug.WriteLine("LaunchersPage.OnLaunchUriForResultsInvalidPFN: " + ex.ToString()); status.Log(ex.Message); } }
private async void OnLaunchUriForResults(object sender, RoutedEventArgs e) { try { string targetUri = @"for-results:"; string launcherTargetPfn = @"LaunchUriTargetMultiApp_8wekyb3d8bbwe"; Uri uri = new Uri(targetUri, UriKind.Absolute); LauncherOptions options = new LauncherOptions(); options.TargetApplicationPackageFamilyName = launcherTargetPfn; LaunchUriResult result = await Launcher.LaunchUriForResultsAsync(uri, options); if (result.Status == LaunchUriStatus.Success) { status.Log(string.Format(CultureInfo.CurrentCulture, LocalizableStrings.LAUNCHERS_APP_LAUNCH_SUCCESS, targetUri)); // Change to validation later string dataReceived = result.Result["Result"].ToString() + " : " + result.Result["UriScheme"].ToString() + " : " + result.Result["CallerPfn"].ToString(); status.Log(string.Format(CultureInfo.CurrentCulture, LocalizableStrings.LAUNCHERS_FOR_RESULTS_SUCCESS, dataReceived)); } else { status.Log(string.Format(CultureInfo.CurrentCulture, LocalizableStrings.LAUNCHERS_FOR_RESULTS_FAIL, result.Status)); } } catch (Exception ex) { Debug.WriteLine("LaunchersPage.OnLaunchUriForResults: " + ex.ToString()); status.Log(ex.Message); } }
private async void OnLaunchFallbackUri(object sender, RoutedEventArgs e) { try { string unsupportedTargetUri = "wechat:"; Uri invalidUri = new Uri(unsupportedTargetUri, UriKind.Absolute); LauncherOptions options = new LauncherOptions(); options.FallbackUri = new Uri(@"https://en.wikipedia.org/wiki/Fallback", UriKind.Absolute); bool success = await Launcher.LaunchUriAsync(invalidUri, options); if (success) // Must launch the fallback Uri { status.Log(string.Format(CultureInfo.CurrentCulture, LocalizableStrings.LAUNCHERS_FALLBACK_URI_SUCCESS, options.FallbackUri)); } else { status.Log(string.Format(CultureInfo.CurrentCulture, LocalizableStrings.LAUNCHERS_FALLBACK_URI_FAIL, options.FallbackUri)); } } catch (Exception ex) { Debug.WriteLine("LaunchersPage.OnLaunchFallbackUri: " + ex.ToString()); status.Log(ex.Message); } }
private async void OnLaunchTargetPfnUnsupportedUri(object sender, RoutedEventArgs e) { try { string unsupportedTargetUri = @"ms-cortanaspoof:/StartMode=Proactive"; string cortanaPfn = @"Microsoft.Windows.Cortana_cw5n1h2txyewy"; Uri invalidUri = new Uri(unsupportedTargetUri, UriKind.Absolute); LauncherOptions options = new LauncherOptions(); options.TargetApplicationPackageFamilyName = cortanaPfn; bool success = await Launcher.LaunchUriAsync(invalidUri, options); if (!success) { status.Log(string.Format(CultureInfo.CurrentCulture, LocalizableStrings.LAUNCHERS_TARGET_PFN_BAD_URI_SUCCESS, unsupportedTargetUri, cortanaPfn)); } else { status.Log(string.Format(CultureInfo.CurrentCulture, LocalizableStrings.LAUNCHERS_TARGET_PFN_BAD_URI_FAIL, unsupportedTargetUri, cortanaPfn)); } } catch (Exception ex) { Debug.WriteLine("LaunchersPage.OnLaunchTargetPfnUnsupportedUri: " + ex.ToString()); status.Log(ex.Message); } }
private async void btnLaunchUri_Click(object sender, RoutedEventArgs e) { // 指定需要打开的 Uri Uri uri = new Uri("http://webabcd.cnblogs.com"); // 指定打开 Uri 过程中相关的各种选项 LauncherOptions options = new LauncherOptions(); if (radWarning.IsChecked.Value) { options.TreatAsUntrusted = true; } if (radOpenWith.IsChecked.Value) { Point openWithPosition = GetOpenWithPosition(btnLaunchUri); options.DisplayApplicationPicker = true; options.UI.InvocationPoint = openWithPosition; } // 使用外部程序打开指定的 Uri bool success = await Launcher.LaunchUriAsync(uri, options); if (success) { lblMsg.Text = "打开成功"; } else { lblMsg.Text = "打开失败"; } }
public async static Task <StorageFile> CropImageFileAsync(StorageFile inputFile, int cropWidthPixels, int cropHeightPixels) { var outputFile = await ApplicationData.Current.TemporaryFolder.CreateFileAsync("Cropped_" + inputFile.Name, CreationCollisionOption.ReplaceExisting); var inputToken = SharedStorageAccessManager.AddFile(inputFile); var destinationToken = SharedStorageAccessManager.AddFile(outputFile); var inputData = new ValueSet { { "InputToken", inputToken }, { "DestinationToken", destinationToken }, { "CropWidthPixels", cropWidthPixels }, { "CropHeightPixels", cropHeightPixels }, { "EllipticalCrop", false } }; var launcherOptions = new LauncherOptions { TargetApplicationPackageFamilyName = "Microsoft.Windows.Photos_8wekyb3d8bbwe" }; var launcherResult = await Launcher.LaunchUriForResultsAsync(new Uri("microsoft.windows.photos.crop:"), launcherOptions, inputData); if (launcherResult.Status != LaunchUriStatus.Success) { return(null); } return(outputFile); }
private static Task <bool> LaunchUriAsyncImpl(Uri uri, LauncherOptions options) { return(Task.Run <bool>(() => { return NSWorkspace.SharedWorkspace.OpenUrl(new NSUrl(uri.ToString())); })); }
private async void LaunchUriForResult_Click(object sender, RoutedEventArgs e) { var protocol = "win10demo2://"; var packageFamilyName = "041cdcf9-8ef3-40e4-85e2-8f3de5e06155_ncrzdc1cmma1g"; var status = await Launcher.QueryUriSupportAsync(new Uri(protocol), LaunchQuerySupportType.UriForResults, packageFamilyName); if (status == LaunchQuerySupportStatus.Available) { var options = new LauncherOptions { TargetApplicationPackageFamilyName = packageFamilyName }; var values = new ValueSet(); values.Add("TwitterId", "danvy"); var result = await Launcher.LaunchUriForResultsAsync(new Uri(protocol), options, values); if ((result.Status == LaunchUriStatus.Success) && (result.Result != null)) { var authorized = result.Result["Authorized"] as string; if (authorized == true.ToString()) { var dialog = new MessageDialog("You are authorized :)"); await dialog.ShowAsync(); } } } }
/// <summary> /// Starts the default app associated with the URI scheme name for the specified URI. /// </summary> /// <param name="uri">The URI.</param> /// <param name="options">Ignored on Android and iOS.</param> /// <returns>The launch operation.</returns> /// <remarks> /// <list type="table"> /// <listheader><term>Platform</term><description>Version supported</description></listheader> /// <item><term>iOS</term><description>iOS 9.0 and later</description></item> /// <item><term>macOS</term><description>OS X 10.7 and later</description></item> /// <item><term>tvOS</term><description>tvOS 9.0 and later</description></item> /// <item><term>Windows UWP</term><description>Windows 10</description></item> /// <item><term>Windows Store</term><description>Windows 8.1 or later</description></item> /// <item><term>Windows Phone Store</term><description>Windows Phone 8.1 or later</description></item> /// <item><term>Windows Phone Silverlight</term><description>Windows Phone 8.0 or later</description></item> /// <item><term>Windows (Desktop Apps)</term><description>Windows Vista or later</description></item></list></remarks> internal static Task<bool> LaunchUriAsync(Uri uri, LauncherOptions options) { #if __ANDROID__ return Task.Run<bool>(() => { try { Intent uriIntent = new Intent(Intent.ActionView); uriIntent.SetData(Android.Net.Uri.Parse(uri.ToString())); Plugin.CurrentActivity.CrossCurrentActivity.Current.Activity.StartActivity(uriIntent); return true; } catch { return false; } }); #elif __UNIFIED__ return Task.Run<bool>(() => { #if __MAC__ return NSWorkspace.SharedWorkspace.OpenUrl(new global::Foundation.NSUrl(uri.ToString())); #else return UIApplication.SharedApplication.OpenUrl(new global::Foundation.NSUrl(uri.ToString())); #endif }); #elif WINDOWS_UWP || WINDOWS_APP || WINDOWS_PHONE_APP || WINDOWS_PHONE return Windows.System.Launcher.LaunchUriAsync(uri).AsTask(); #elif WIN32 return Task.FromResult<bool>(Launch(uri.ToString(), null)); #else throw new PlatformNotSupportedException(); #endif }