Inheritance: ILauncherOptions
		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 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);
        }
Beispiel #3
0
		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();
					}
				}
			}
		}
		public async void OpenUrl(string url)
		{
			var uri = new Uri(url);
			var options = new LauncherOptions();
			options.TreatAsUntrusted = false;
			var success = await Launcher.LaunchUriAsync(uri, options);
		}
Beispiel #5
0
        private async void word_Click(object sender, RoutedEventArgs e)
        {
            Button on      = (Button)sender;
            string nameDoc = on.Content.ToString();
            var    file    = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(nameDoc);

            if (file != null)
            {
                // Set the option to show the picker
                var options = new Windows.System.LauncherOptions();
                options.DisplayApplicationPicker = true;

                // Launch the retrieved file
                bool success = await Windows.System.Launcher.LaunchFileAsync(file, options);

                if (success)
                {
                    // File launched
                }
                else
                {
                    // File launch failed
                }
            }
            else
            {
                // Could not find file
            }
        }
        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 void pfnLink_Click(object sender, RoutedEventArgs e)
 {            
     Uri uri = new Uri("bingmaps:?rtp=adr.Mountain%20View,%20CA~adr.San%20Francisco,%20CA&mode=d&trfc=1");
     var launcherOptions = new LauncherOptions();
     launcherOptions.TargetApplicationPackageFamilyName = "Microsoft.WindowsMaps_8wekyb3d8bbwe";
     await Launcher.LaunchUriAsync(uri, launcherOptions);
 }
 private static async void LaunchSpecific()
 {
     var options = new LauncherOptions();
     options.TargetApplicationPackageFamilyName = "23d8f929-1d97-426a-9f07-67babe333ec6_e7qah2kqbxs60";
     var uri = new Uri("");
     await Launcher.LaunchUriAsync(uri, options);
 }
Beispiel #9
0
        private async void Buy(string productName, string price, string filename)
        {

            var woodgroveUri = new Uri("woodgrove-pay:");

            var options = new LauncherOptions();
            options.TargetApplicationPackageFamilyName = "111055f1-4e28-4634-b304-e76934e91e53_876gvmnfevegr";

            var inputData = new ValueSet();
            inputData["ProductName"] = productName;
            inputData["Amount"] = price;


            StorageFolder assetsFolder = await Package.Current.InstalledLocation.GetFolderAsync("Assets\\ProductImages");
            StorageFile imgFile = await assetsFolder.GetFileAsync(filename);
            inputData["ImageFileToken"] = SharedStorageAccessManager.AddFile(imgFile);


            LaunchUriResult result = await Launcher.LaunchUriForResultsAsync(woodgroveUri, options, inputData);
            if (result.Status == LaunchUriStatus.Success &&
                result.Result["Status"] != null &&
                (result.Result["Status"] as string) == "Success")
            {
                this.Frame.Navigate(typeof(OrderPlacedPage), result.Result);
            }
           
        }
Beispiel #10
0
        private async void LaunchForResultButton_Click(object sender, RoutedEventArgs e)
        {
            var options = new LauncherOptions();
            options.TargetApplicationPackageFamilyName = "dae4aecf-5aae-497c-97b6-4122dec5af28_nsf9e2fmhb1sj";

            await Windows.System.Launcher.LaunchUriForResultsAndContinueAsync(
                new Uri("w10jumpstart:/this_bit_is_not_used_in_this_demo"), 
                options, 
                null);
        }
        /// <summary>
        /// Launches the Blob using the registered Url display app
        /// </summary>
        public IAsyncOperation<bool> DisplayAsync()
        {
            Validate();

            var options = new LauncherOptions();
            options.ContentType = Info.ContentType;
            var uri = new Uri(Url);

            return Launcher.LaunchUriAsync(uri, options);
        }
        private async void OpenExcelButtonWithWarning_Click(object sender, RoutedEventArgs e)
        {
            Uri uri = new Uri("ms-appx:///Assets/PeriodicTable.xls");
            StorageFile sf = await StorageFile.GetFileFromApplicationUriAsync(uri);

            LauncherOptions options = new LauncherOptions();
            options.TreatAsUntrusted = true;

            bool action = await Launcher.LaunchFileAsync(sf, options);
        }
Beispiel #13
0
        private async void OnNavigationStarting(WebView sender, WebViewNavigationStartingEventArgs args)
        {

            if (args.Uri != null)
            {
                args.Cancel = true;
                var options = new LauncherOptions() { TreatAsUntrusted = false };
                await Windows.System.Launcher.LaunchUriAsync(args.Uri, options);
            }
        }
        private async void OnOpenAnotherAppWithDataClicked(object sender, RoutedEventArgs e)
        {
            LauncherOptions options = new LauncherOptions();
            options.TargetApplicationPackageFamilyName = "8a1341de-3acd-4d5a-91f2-98d9cd2c1c6e_e8f4dqfvn1be6";

            ValueSet data = new ValueSet();
            data.Add("Customer", "Contoso");
            data.Add("Price", "25");

            await Launcher.LaunchUriAsync(new Uri("invoice:"), options, data);
        }
        public static async Task<bool> Launch(string filename, StorageFolder folder)
        {
            IStorageFile file = await folder.GetFileAsync(filename);

            LauncherOptions options = new LauncherOptions();
            //options.DisplayApplicationPicker = true;
            //options.FallbackUri = GetUri(cole_protocol);

            bool result = await Launcher.LaunchFileAsync(file, options);
            return result;
        }
        private async void btnLaunch_Click(object sender, RoutedEventArgs e)
        {
            var options = new LauncherOptions();
            options.TargetApplicationPackageFamilyName = "5082b433-03c4-4db0-abf6-d2d63493f851_e7qah2kqbxs60";
            var res = await Windows.System.Launcher.LaunchUriForResultsAsync(
                new Uri("demoking102040:/key=val"), options);
            
            var msg = res.Result["Result"] as string;
            await new MessageDialog(msg).ShowAsync();

        }
Beispiel #17
0
        private async void Website_pressed(object sender, TappedRoutedEventArgs e)
        {
            string uriToLaunch = @current_spot.Contact.Website;
            var    uri         = new Uri(uriToLaunch);
            // Set the option to show a warning
            var options = new Windows.System.LauncherOptions();

            options.TreatAsUntrusted = true;

            // Launch the URI with a warning prompt
            var success = await Windows.System.Launcher.LaunchUriAsync(uri, options);
        }
        private async void OpenExcelButtonWithOpenWithMenu_Click(object sender, RoutedEventArgs e)
        {
            Uri uri = new Uri("ms-appx:///Assets/PeriodicTable.xls");
            StorageFile sf = await StorageFile.GetFileFromApplicationUriAsync(uri);

            LauncherOptions options = new LauncherOptions();
            options.DisplayApplicationPicker = true;
            options.UI.InvocationPoint = GetPosition(sender as FrameworkElement);
            options.UI.PreferredPlacement = Placement.Below;

            bool action = await Launcher.LaunchFileAsync(sf, options);
        }
        private async void OnOpenAnotherAppWithFileClicked(object sender, RoutedEventArgs e)
        {
            StorageFile textfile = await Package.Current.InstalledLocation.GetFileAsync("textfile.txt");
            string token = SharedStorageAccessManager.AddFile(textfile);

            ValueSet data = new ValueSet();
            data.Add("token", token);

            LauncherOptions options = new LauncherOptions();
            options.TargetApplicationPackageFamilyName = "a29b22b7-2ea6-424d-8c3b-4f6112d9caef_e8f4dqfvn1be6";

            await Launcher.LaunchUriAsync(new Uri("textfile:"), options, data);
        }
 private async void LaunchForResultsButton_OnClick(object sender, RoutedEventArgs e)
 {
     var uri = new Uri("uwpddmainapp:");
     var options = new LauncherOptions
     {
         TargetApplicationPackageFamilyName = "11fc3805-6c54-417b-916c-a4f6e89876b2_2eqywga5gg4gm"
     };
     var launchUriResult = await Launcher.LaunchUriForResultsAsync(uri, options);
     if (launchUriResult.Status == LaunchUriStatus.Success)
     {
         _resultsTextBox.Text = (launchUriResult.Result?.FirstOrDefault().Value as string) ?? "no response";
     }
 }
Beispiel #21
0
        private async void btnSearchWeb_Click(object sender, RoutedEventArgs e)
        {
            string genre       = (cbxGenre.SelectedItem as ComboBoxItem).Content.ToString();
            string queryString = Uri.EscapeDataString($"{genre} in {txtLocation.Text}");
            var    searchUri   = $"https://www.bing.com/search?q={queryString}";

            var uriBing = new Uri(searchUri);

            var promptOptions = new Windows.System.LauncherOptions();

            promptOptions.TreatAsUntrusted         = true;
            promptOptions.DisplayApplicationPicker = true;
            var success = await Windows.System.Launcher.LaunchUriAsync(uriBing, promptOptions);
        }
        private async void button1_Click(object sender, RoutedEventArgs e)
        {
            //Launches the target app with protocol activation and returns a result
            var options = new LauncherOptions();
            options.TargetApplicationPackageFamilyName = "eb819cd2-07bc-4048-9cf7-c438f2b6f290_vx85t7qpa6fm0";

            var launcherUri = new Uri("mytestprotocol:");

            var res = await Launcher.LaunchUriForResultsAsync(launcherUri, options);
                        
            var msgDialog = new MessageDialog("result: " + res.Result["Result"].ToString());
            await msgDialog.ShowAsync();

        }
        private async Task LaunchAppAsync(string uriStr)
        {
            Uri uri           = new Uri(uriStr);
            var promptOptions = new Windows.System.LauncherOptions();

            promptOptions.TreatAsUntrusted = false;

            bool isSuccess = await Windows.System.Launcher.LaunchUriAsync(uri, promptOptions);

            if (!isSuccess)
            {
                string msg = "Launch failed";
                await new MessageDialog(msg).ShowAsync();
            }
        }
Beispiel #24
0
        private async void btnLaunchUriSpecific_Click(object sender, RoutedEventArgs e)
        {
            string uriString = "demoking102040:key=value123";
            var opt = new LauncherOptions();

            // PFN
            opt.TargetApplicationPackageFamilyName = "5082b433-03c4-4db0-abf6-d2d63493f851_e7qah2kqbxs60";

            // token
            var file = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///images/DMX.jpg"));
            string tok = SharedStorageAccessManager.AddFile(file);
            uriString = uriString += "&file=" + tok;

            await Launcher.LaunchUriAsync(new Uri(uriString),opt);
        }
        private async void OnOpenAnotherAppWithResultsClicked(object sender, RoutedEventArgs e)
        {
            ValueSet data = new ValueSet();
            data.Add("num1", 10);

            LauncherOptions options = new LauncherOptions();
            options.TargetApplicationPackageFamilyName = "467a521c-d93f-4c82-bfab-d18f4a8482f0_e8f4dqfvn1be6";

            LaunchUriResult result = await Launcher.LaunchUriForResultsAsync(new Uri("sum:"), options, data);
            if (result.Status == LaunchUriStatus.Success)
            {
                ValueSet resultData = result.Result;
                int sum = (int)resultData["sum"];
                MessageDialog dialog = new MessageDialog($"The sum is {sum}");
                await dialog.ShowAsync();
            }
        }
        public static async void SubmitChargeRequest(ChargeRequest chargeRequest)
        {
            Uri launchURL = chargeRequest.GenerateLaunchURL();

            // Set the launch options in case user doesn't have Credit Card Terminal installed
            var launchOptions = new Windows.System.LauncherOptions();

            launchOptions.PreferredApplicationDisplayName       = ChargeRequest.CCTERMINAL_DISPLAY_NAME;
            launchOptions.PreferredApplicationPackageFamilyName = ChargeRequest.CCTERMINAL_WINDOWS_PFN;
            launchOptions.DesiredRemainingView = ViewSizePreference.UseNone;

            var success = await Launcher.LaunchUriAsync(launchURL, launchOptions);

            if (!success)
            {
                throw new ChargeException("Could not launch Credit Card Terminal. Please ensure it has been installed.");
            }
        }
Beispiel #27
0
        private async void AddButton_Click(object sender, RoutedEventArgs e)
        {
            var options = new Windows.System.LauncherOptions();


            var dialog = new DoroDialog();
            var result = await dialog.ShowAsync();

            if (result == ContentDialogResult.Primary)
            {
                var doro = dialog.Doro;
                DoroList.Add(doro);
            }

            if (DoroList.Count > 0)
            {
                EmptyStateTextBlock.Visibility = Visibility.Collapsed;
            }
        }
        /// <summary>
        // Launch a .png file that came with the package. Show a warning prompt.
        /// </summary>
        private async void LaunchFileWithWarning()
        {
            // First, get the image file from the package's image directory.
            var file = await GetFileToLaunch();

            // Next, configure the warning prompt.
            var options = new LauncherOptions() { TreatAsUntrusted = true };

            // Finally, launch the file.
            bool success = await Launcher.LaunchFileAsync(file, options);
            if (success)
            {
                rootPage.NotifyUser("File launched: " + file.Name, NotifyType.StatusMessage);
            }
            else
            {
                rootPage.NotifyUser("File launch failed.", NotifyType.ErrorMessage);
            }
        }
        /// <summary>
        // Launch a URI. Show a warning prompt.
        /// </summary>
        private async void LaunchUriWithWarning()
        {
            // Create the URI to launch from a string.
            var uri = new Uri(UriToLaunch.Text);

            // Configure the warning prompt.
            var options = new LauncherOptions() { TreatAsUntrusted = true };

            // 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);
            }
        }
		public async void OpenFile(string fileName)
		{
			var uri = new Uri(string.Format("ms-appx:///{0}", fileName));
			var file = await StorageFile.GetFileFromApplicationUriAsync(uri);

			if (file != null)
			{
				var options = new Windows.System.LauncherOptions();
				//options.DisplayApplicationPicker = true;
				bool success = await Launcher.LaunchFileAsync(file, options);
				//if (success)
				//{
				//	// File launched
				//}
				//else
				//{
				//	// File launch failed
				//}
			}
		}
Beispiel #31
0
        /// <summary>
        /// Creates the async operation that enables the user to view the app details.
        /// </summary>
        /// <returns></returns>
        public static Task<bool> RequestDetailsAsync()
        {
#if WINDOWS_APP || WINDOWS_UWP
            LauncherOptions options = new LauncherOptions();
            options.DesiredRemainingView = Windows.UI.ViewManagement.ViewSizePreference.UseMinimum;
            return Launcher.LaunchUriAsync(new Uri("ms-windows-store:PDP?PFN=" + Windows.ApplicationModel.Package.Current.Id.FamilyName), options).AsTask<bool>();
#elif WINDOWS_PHONE_APP
            if (_on10)
            {
                return Launcher.LaunchUriAsync(new Uri("ms-windows-store://pdp/?PhoneAppId=" + Windows.ApplicationModel.Package.Current.Id.ProductId)).AsTask<bool>();
            }
            else
            {
                return Launcher.LaunchUriAsync(new Uri("ms-windows-store:navigate?appid=" + AppId)).AsTask<bool>();
            }
#elif WINDOWS_PHONE
            return Windows.System.Launcher.LaunchUriAsync(new Uri("zune:navigate?appid=" + AppId)).AsTask<bool>();
#else
            return Task.Run<bool>(() => { return false; });
#endif
        }
Beispiel #32
0
        private async void btnResults_Tapped(object sender, TappedRoutedEventArgs e)
        {
            var rrUri = new Uri("result-returner:"); // the protocol handled by the app to launch for results
            var options = new LauncherOptions();
            options.TargetApplicationPackageFamilyName = "f274aa5a-c4b0-4fa8-9e53-41adbb2ab535_gzxgteedtvpx2";

            var inputData = new ValueSet();
            inputData["Question"] = "What do you want to know?";

            string theResult = "";
            LaunchUriResult result = await Launcher.LaunchUriForResultsAsync(rrUri, options, inputData);
            if (result.Status == LaunchUriStatus.Success &&
                result.Result != null &&
                result.Result.ContainsKey("Answer"))
            {
                ValueSet theValues = result.Result;
                theResult = theValues["Answer"] as string;
            }

            MessageDialog md = new MessageDialog(theResult);
            await md.ShowAsync();
        }
 private async void OpenItemAppBarBtn_Click(object sender, RoutedEventArgs e)
 {
     MediaViewModel media = MyListView.SelectedItem as MediaViewModel;
     
     if (media.VidOrPic)
     {
         var options = new Windows.System.LauncherOptions();
         options.DisplayApplicationPicker = true;
         string temp = media.Name;
         var uriString = "ms-appdata:///local/" + temp + ".mp4";
         Uri muUri = new Uri(uriString);
         Launcher.LaunchUriAsync(new Uri(uriString, UriKind.RelativeOrAbsolute),options);
     }
     else
     {
         var options = new Windows.System.LauncherOptions();
         options.DisplayApplicationPicker = true;
         string temp = media.Name;
         var uriString = "ms-appdata:///local/" + temp + ".jpeg";
         
         Uri muUri = new Uri(uriString);
         Launcher.LaunchUriAsync(new Uri(uriString, UriKind.RelativeOrAbsolute),options);
     }   
 }
Beispiel #34
0
    private async static Task <bool> SaveStreamTo3MF(Windows.Storage.Streams.IRandomAccessStream stream)
    {
        // set back
        stream.Seek(0);
        using (var dataReader = new Windows.Storage.Streams.DataReader(stream))
        {
            var dataLoad = await dataReader.LoadAsync((uint)stream.Size);

            if (dataLoad > 0)
            {
                var buffer = dataReader.ReadBuffer((uint)stream.Size);

                StorageFolder localFolder = ApplicationData.Current.LocalFolder;
                var           outputfile  = await localFolder.CreateFileAsync("output.3mf", CreationCollisionOption.ReplaceExisting);

                await Windows.Storage.FileIO.WriteBufferAsync(outputfile, buffer);

                var options = new Windows.System.LauncherOptions();
                options.TargetApplicationPackageFamilyName = "Microsoft.3DBuilder_8wekyb3d8bbwe";
            }
        }

        return(true);
    }
Beispiel #35
0
        private async void OpenItemAppBarBtn_Click(object sender, RoutedEventArgs e)
        {
            MediaViewModel media = MyListView.SelectedItem as MediaViewModel;

            if (media.VidOrPic)
            {
                var options = new Windows.System.LauncherOptions();
                options.DisplayApplicationPicker = true;
                string temp      = media.Name;
                var    uriString = "ms-appdata:///local/" + temp + ".mp4";
                Uri    muUri     = new Uri(uriString);
                Launcher.LaunchUriAsync(new Uri(uriString, UriKind.RelativeOrAbsolute), options);
            }
            else
            {
                var options = new Windows.System.LauncherOptions();
                options.DisplayApplicationPicker = true;
                string temp      = media.Name;
                var    uriString = "ms-appdata:///local/" + temp + ".jpeg";

                Uri muUri = new Uri(uriString);
                Launcher.LaunchUriAsync(new Uri(uriString, UriKind.RelativeOrAbsolute), options);
            }
        }
        public static async Task EditVCD()
        {
            //string directory = StorageFolders.FlawlessCowboy.Path;
            //ClipboardHelper.CopyToClipboard(directory);
            //await Launch("Open_File_Explorer.ahk", StorageFolders.LocalFolder);

            const string filename = Cortana.Cortana.vcdFilename;

            StorageFolder folder = StorageFolders.FlawlessCowboy;
            IStorageFile file = await folder.GetFileAsync(filename);

            LauncherOptions options = new LauncherOptions();
            options.DisplayApplicationPicker = true;

            bool result = await Launcher.LaunchFileAsync(file, options);
        }
Beispiel #37
0
 private async void LaunchTargetApp_Click(object sender, RoutedEventArgs e)
 {
     var options = new LauncherOptions { TargetApplicationPackageFamilyName = TargetPackageFamilyName };
     bool success = await Launcher.LaunchUriAsync(uri, options);
     Close();
 }
    private async static Task<bool> SaveStreamTo3MF(Windows.Storage.Streams.IRandomAccessStream stream)
    {
        // set back
        stream.Seek(0);
        using (var dataReader = new Windows.Storage.Streams.DataReader(stream))
        {

            var dataLoad = await dataReader.LoadAsync((uint)stream.Size);
            if (dataLoad > 0)
            {
                var buffer = dataReader.ReadBuffer((uint)stream.Size);                    

                StorageFolder localFolder = ApplicationData.Current.LocalFolder;
                var outputfile = await localFolder.CreateFileAsync("output.3mf", CreationCollisionOption.ReplaceExisting);
                await Windows.Storage.FileIO.WriteBufferAsync(outputfile, buffer);
                var options = new Windows.System.LauncherOptions();
                options.TargetApplicationPackageFamilyName = "Microsoft.3DBuilder_8wekyb3d8bbwe";
            }
        }

        return true;
    }
Beispiel #39
0
        public async Task ActivateFile(StorageFile storageFile)
        {
            try
            {
                Debug.WriteLine(storageFile.Path + "\t" + storageFile.DisplayType);
                if (storageFile.Path.Split('.')[1] == "exe")
                {
                    ProcessStartInfo psi = new ProcessStartInfo();
                    psi.FileName = storageFile.Path;
                    bool admin = IsAdmin();

                    if (!admin)
                    {
                        psi.Verb = "runas";
                    }


                    try
                    {
                        Process.Start(psi);
                    }
                    catch (Exception ex)
                    {
                        if (admin) //админские права уже были, что-то испортилось
                        {
                            //return false;
                        }
                        MessageDialog messageDialog = new MessageDialog(ex.Message);
                        await messageDialog.ShowAsync();

                        //иначе может быть просто нажали отмену в UAC
                    }
                }
                else
                {
                    var success = await Windows.System.Launcher.LaunchFileAsync(storageFile);

                    if (success)
                    {
                        // File launched
                    }
                    else
                    {
                        var options = new Windows.System.LauncherOptions();
                        options.DisplayApplicationPicker = true;

                        // Launch the retrieved file
                        bool success1 = await Windows.System.Launcher.LaunchFileAsync(storageFile, options);

                        if (success1)
                        {
                            // File launched
                        }
                        else
                        {
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                await new MessageDialog(ex.Message).ShowAsync();
            }
        }