Exemple #1
1
        /// <summary>
        // Launch a URI. Show an Open With dialog that lets the user chose the handler to use.
        /// </summary>
        private async void LaunchUriOpenWithButton_Click(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 = GetOpenWithPosition(LaunchUriOpenWithButton);

            // Next, configure the Open With dialog.
            var options = new Windows.System.LauncherOptions();
            options.DisplayApplicationPicker = true;
            options.UI.InvocationPoint = openWithPosition;
            options.UI.PreferredPlacement = Windows.UI.Popups.Placement.Below;

            // Launch the URI.
            bool success = await Windows.System.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 GoToTwitterProfile()
        {
            var options = new Windows.System.LauncherOptions();

            options.FallbackUri = new Uri("http://www.twitter.com/LMESoft");
            await Windows.System.Launcher.LaunchUriAsync(new Uri("twitter:profile?username=LMESoft"), options);
        }
Exemple #3
0
        /// <summary>
        // Launch a URI. Request to share the screen with the launched app.
        /// </summary>
        private async void LaunchUriSplitScreenButton_Click(object sender, RoutedEventArgs e)
        {
            // Create the URI to launch from a string.
            var uri = new Uri(UriToLaunch.Text);

            // Configure the request for split screen launch.
            var options = new Windows.System.LauncherOptions();

            if (!(Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons")))
            {
                options.DesiredRemainingView = (Windows.UI.ViewManagement.ViewSizePreference)SizePreference.SelectedValue;
            }

            // Launch the URI.
            bool success = await Windows.System.Launcher.LaunchUriAsync(uri, options);

            if (success)
            {
                rootPage.NotifyUser("URI launched: " + uri.AbsoluteUri, NotifyType.StatusMessage);
            }
            else
            {
                rootPage.NotifyUser("URI launch failed.", NotifyType.ErrorMessage);
            }
        }
        /// <summary>
        // Launch a .png file that came with the package. Show an Open With dialog that lets the user chose the handler to use.
        /// </summary>
        private async void LaunchFileOpenWithButton_Click(object sender, RoutedEventArgs e)
        {
            // First, get the image file from the package's image directory.
            var file = await GetFileToLaunch();

            // Calculate 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 = GetOpenWithPosition(LaunchFileOpenWithButton);

            // Next, configure the Open With dialog.
            var options = new Windows.System.LauncherOptions();

            options.DisplayApplicationPicker = true;
            options.UI.InvocationPoint       = openWithPosition;
            options.UI.PreferredPlacement    = Windows.UI.Popups.Placement.Below;

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

            if (success)
            {
                rootPage.NotifyUser("File launched: " + file.Name, NotifyType.StatusMessage);
            }
            else
            {
                rootPage.NotifyUser("File launch failed.", NotifyType.ErrorMessage);
            }
        }
Exemple #5
0
        async void DefaultLaunch()
        {
            // Path to the file in the app package to launch
            //string imageFile = @"images\test.contoso";

            // Get the image file from the package's image directory
            var currentFile = file; //await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(imageFile);

            if (file != null)
            {
                var options = new Windows.System.LauncherOptions();
                options.DisplayApplicationPicker = true;
                bool success = await Windows.System.Launcher.LaunchFileAsync(file, options);

                if (success)
                {
                    // File launched
                    var rootFrame = new Frame();
                    rootFrame.Navigate(typeof(MainPage), currentFile);
                    Window.Current.Content = rootFrame;
                    Window.Current.Activate();
                }
                else
                {
                    // File launch failed
                }
            }
            else
            {
                // Could not find file
            }
        }
Exemple #6
0
        public async Task LaunchPlayer(Core.Models.Program program, bool isLaunchedFromTile)
        {
            await ShowSplashScreen(program.Name);

            var zipService = new ZipService();
            var tempFolder = ApplicationData.Current.TemporaryFolder;
            var file       = await tempFolder.CreateFileAsync(TempProgramName,
                                                              CreationCollisionOption.ReplaceExisting);

            var stream = await file.OpenStreamForWriteAsync();

            await zipService.ZipCatrobatPackage(stream, program.BasePath);

            var options = new Windows.System.LauncherOptions {
                DisplayApplicationPicker = false
            };

            //await project.Save(); ??? TODO: this was in the previous version of catrobat --> do we need to save the project at this point?
            await LaunchPlayer(program.Name, isLaunchedFromTile);

            // TODO: manage closing/relaunching of the Player
            // TODO: review ...LaunchFileAsync (1 line underneath) --> seems to be that it never finishes
            //bool success = await Windows.System.Launcher.LaunchFileAsync(file, options);
            //if (success)
            //{
            //    // File launch success
            //}
            //else
            //{
            //    // File launch failed
            //}
        }
Exemple #7
0
        public AboutViewModel()
        {
            PrivacyPolicyCommand = new DelegateCommand(async() =>
            {
                await Windows.System.Launcher.LaunchUriAsync(new Uri("http://w8privacy.azurewebsites.net/privacy?dev=Lancelot%20Software&app=Latte%20Locator&mail=bGFuY2VAb3V0dGFzeXl0ZS5jb20=&lng=En"));
            });

            RateThisAppCommand = new DelegateCommand(async() =>
            {
                await Windows.System.Launcher.LaunchUriAsync(new Uri("ms-windows-store://pdp/?productid=9nblggh0f2cn"));
            });

            SendAnEmailCommand = new DelegateCommand(async() =>
            {
                var uri = new Uri(string.Format("mailto:[email protected]?subject=Latte Locator Feedback"), UriKind.Absolute);

                var options = new Windows.System.LauncherOptions
                {
                    DesiredRemainingView     = ViewSizePreference.UseHalf,
                    DisplayApplicationPicker = true,
                    PreferredApplicationPackageFamilyName = "microsoft.windowscommunicationsapps_8wekyb3d8bbwe",
                    PreferredApplicationDisplayName       = "Mail"
                };

                await Windows.System.Launcher.LaunchUriAsync(uri, options);
            });
        }
Exemple #8
0
        /// <summary>
        // Launch a .png file that came with the package. Request to share the screen with the launched app.
        /// </summary>
        private async void LaunchFileSplitScreenButton_Click(object sender, RoutedEventArgs e)
        {
            if (!(Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons")))
            {
                // First, get a file via the picker.
                var openPicker = new Windows.Storage.Pickers.FileOpenPicker();
                openPicker.FileTypeFilter.Add("*");

                Windows.Storage.StorageFile file = await openPicker.PickSingleFileAsync();

                if (file != null)
                {
                    // Configure the request for split screen launch.
                    var options = new Windows.System.LauncherOptions();
                    options.DesiredRemainingView = (Windows.UI.ViewManagement.ViewSizePreference)SizePreference.SelectedValue;

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

                    if (success)
                    {
                        rootPage.NotifyUser("File launched: " + file.Name, NotifyType.StatusMessage);
                    }
                    else
                    {
                        rootPage.NotifyUser("File launch failed.", NotifyType.ErrorMessage);
                    }
                }
                else
                {
                    rootPage.NotifyUser("No file was picked.", NotifyType.ErrorMessage);
                }
            }
        }
        private async void Contact_Click(object sender, RoutedEventArgs e)
        {
            Uri uri = null;

            if (sender == AboutContactValue)
            {
                uri = new Uri($@"mailto:{(sender as HyperlinkButton).Content}");
            }
            else if (sender == AboutTwitterValue)
            {
                uri = new Uri(@"https://twitter.com/netcharm");
            }

            if (uri is Uri)
            {
                var options = new Windows.System.LauncherOptions();
                options.TreatAsUntrusted = true;
                // Launch the URI
                var success = await Windows.System.Launcher.LaunchUriAsync(uri, options);

                if (success)
                {
                    // URI launched
                }
                else
                {
                    // URI launch failed
                }
            }
        }
Exemple #10
0
        //Clicking on an image will open an eBook of the selected book
        async void ReadBook(object sender, ItemClickEventArgs e)
        {

            string imageFile = @"pdf_file.pdf";

            var file = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(imageFile);

            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
                }
            }
        }
        private async void DisplayApplicationPicker(object sender, RoutedEventArgs e)
        {
            // Path to the file in the app package to launch
            string imageFile = @"data\7.jpg";

            var file = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(imageFile);

            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 void VideoButton_Click(object sender, RoutedEventArgs e)
        {
            this.Frame.Navigate(typeof(Player));
            Series  selectedSeries = this.selectedSeriesDetails.getSeries();
            Episode ep             = selectedSeries.getCurrentEpisode();

            // Start video player process

            /*Process p = new Process();
             * p.EnableRaisingEvents = false;
             * p.StartInfo.FileName = ep.episodeFile.Path;
             * p.Start();*/
            var promptOptions = new Windows.System.LauncherOptions()
            {
                DisplayApplicationPicker = true
            };
            var success = await Windows.System.Launcher.LaunchFileAsync(ep.episodeFile, promptOptions);

            if (success)
            {
            }
            else
            {
                var messageDialog = new MessageDialog("Failed to load Application picker for the episode file " + ep.episodeTitle);
                messageDialog.Commands.Add(new UICommand(
                                               "Close",
                                               new UICommandInvokedHandler(this.CommandInvokedHandler)));
                messageDialog.DefaultCommandIndex = 0;
                messageDialog.CancelCommandIndex  = 1;
                await messageDialog.ShowAsync();
            }
        }
Exemple #13
0
        private async void callButton_Click(object sender, RoutedEventArgs e)
        {
            if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent(
                    "Windows.ApplicationModel.Calls.PhoneLine"))
            {
                var store = await PhoneCallManager.RequestStoreAsync();

                var phoneLineId = await store.GetDefaultLineAsync();

                var phoneLine = await PhoneLine.FromIdAsync(phoneLineId);

                phoneLine.Dial(_translatedNumber, "");
            }
            else
            {
                var uriSkype = new Uri($"Skype:{Regex.Replace(_translatedNumber, @"[-\s]", "")}?call");
                //var uriSkype = new Uri($"Skype:{_translatedNumber}?call");

                // Set the option to show a warning
                var promptOptions = new Windows.System.LauncherOptions {
                    TreatAsUntrusted = false
                };

                // Launch the URI
                await Windows.System.Launcher.LaunchUriAsync(uriSkype, promptOptions);
            }
        }
        private async void DisplayApplicationPicker(object sender, RoutedEventArgs e)
        {
            // Path to the file in the app package to launch
            string imageFile = @"data\7.jpg";

            var file = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(imageFile);

            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
            }
        }
Exemple #15
0
        async void DefaultLaunchWithOptions()
        {
            // Path to the file in the app package to launch
            // string imageFile = @"images\test.png";

            //  var file = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(imageFile);

            StorageFolder storageFolder = KnownFolders.PicturesLibrary;
            StorageFile   file          = await storageFolder.GetFileAsync("sample.mkv");

            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
            }
        }
Exemple #16
0
        /// <summary>
        /// Launches the attached file
        /// </summary>
        /// <param name="fileName"></param>
        private async void LaunchAttachedFile(string fileName)
        {
            StorageFolder storageFolder = ApplicationData.Current.LocalFolder;

            StorageFile file = await storageFolder.GetFileAsync(fileName);

            if (file != null)
            {
                //Sets launching options
                var options = new Windows.System.LauncherOptions();
                options.DisplayApplicationPicker = true;

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

                if (!success)
                {
                    DisplayErrorDialog("Launch file failed", "Launch file failed. Try again!");
                }
            }
            else
            {
                DisplayErrorDialog("Launch file failed", "File not available. Try again!");
            }
        }
        // Launch a URI. Show an Open With dialog that lets the user chose the handler to use.
        private async void LaunchUriOpenWithButton_Click(object sender, RoutedEventArgs e)
        {
            // Create the URI to launch from a string.
            var uri = new Uri(uriToLaunch);

            // 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 = GetOpenWithPosition(LaunchUriOpenWithButton);

            // Next, configure the Open With dialog.
            var options = new Windows.System.LauncherOptions();

            options.DisplayApplicationPicker = true;
            options.UI.InvocationPoint       = openWithPosition;
            options.UI.PreferredPlacement    = Windows.UI.Popups.Placement.Below;

            // Launch the URI.
            bool success = await Windows.System.Launcher.LaunchUriAsync(uri, options);

            if (success)
            {
                rootPage.NotifyUser("URI launched: " + uri.AbsoluteUri, NotifyType.StatusMessage);
            }
            else
            {
                rootPage.NotifyUser("URI launch failed.", NotifyType.ErrorMessage);
            }
        }
Exemple #18
0
        public async Task <bool> LaunchFileAsync(string uri)
        {
            var file = await Windows.Storage.StorageFile.GetFileFromPathAsync(uri);

            bool success = false;

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

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

                if (success)
                {
                    // File launched
                }
                else
                {
                    // File launch failed
                }
            }
            else
            {
                // Could not
            }
            return(success);
        }
Exemple #19
0
        public async Task <bool> View(Stream stream, string filename)
        {
            try
            {
                var temporatyFolder = ApplicationData.Current.TemporaryFolder;

                var file = await temporatyFolder.CreateFileAsync(filename, CreationCollisionOption.ReplaceExisting);

                stream.Seek(0, SeekOrigin.Begin);

                using (var fileStream = await file.OpenAsync(FileAccessMode.ReadWrite))
                {
                    using (var managedFileStream = fileStream.AsStreamForWrite())
                    {
                        stream.CopyTo(managedFileStream);
                    }
                }

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

                // Launch the retrieved file
                return(await Windows.System.Launcher.LaunchFileAsync(file, options));
            }
            catch
            {
                return(false);
            }
        }
        public async Task LaunchPlayer(Core.Models.Program program, bool isLaunchedFromTile)
        {
            await ShowSplashScreen(program.Name);
            
            var zipService = new ZipService();
            var tempFolder = ApplicationData.Current.TemporaryFolder;
            var file = await tempFolder.CreateFileAsync(TempProgramName, 
                                                        CreationCollisionOption.ReplaceExisting);
            var stream = await file.OpenStreamForWriteAsync();

            await zipService.ZipCatrobatPackage(stream, program.BasePath);

            var options = new Windows.System.LauncherOptions { DisplayApplicationPicker = false };

            //await project.Save(); ??? TODO: this was in the previous version of catrobat --> do we need to save the project at this point?
            await LaunchPlayer(program.Name, isLaunchedFromTile);
            // TODO: manage closing/relaunching of the Player 
            // TODO: review ...LaunchFileAsync (1 line underneath) --> seems to be that it never finishes
            //bool success = await Windows.System.Launcher.LaunchFileAsync(file, options);
            //if (success)
            //{
            //    // File launch success
            //}
            //else
            //{
            //    // File launch failed
            //}
        }
Exemple #21
0
        //string fileToLaunch = null;
        /// <summary>
        /// Launches the file open with.
        /// </summary>
        /// <param name="fileName">Name of the file.</param>
        private async void LaunchFileOpenWith(string fileName)
        {
            var file = await KnownFolders.VideosLibrary.GetFileAsync(fileName);

            // First, get the image file from the package's image directory.
            //var file = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(fileToLaunch);

            // Calculate 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 = new Point(600, 500);

            // Next, configure the Open With dialog.
            var options = new Windows.System.LauncherOptions();

            options.DisplayApplicationPicker = true;
            options.UI.InvocationPoint       = openWithPosition;
            options.UI.PreferredPlacement    = Windows.UI.Popups.Placement.Below;

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

            if (success)
            {
                ShowMessageDialog("File launched: " + file.Name);
            }
            else
            {
                ShowMessageDialog("File launch failed.");
            }
        }
Exemple #22
0
 public static async void OpenUrl(this Uri url)
 {
     var options = new Windows.System.LauncherOptions
     {
         TreatAsUntrusted = false
     };
     await Windows.System.Launcher.LaunchUriAsync(url, options);
 }
        private async void myMap_MapDoubleTapped(MapControl sender, MapInputEventArgs args)
        {
            var uriSchool       = new Uri(@"bingmaps:? cp = 51.031359~-3.706420 & lvl = 15");
            var launcherOptions = new Windows.System.LauncherOptions();

            launcherOptions.TargetApplicationPackageFamilyName = "Microsoft.WindowsMaps_8wekyb3d8bbwe";
            var success = await Windows.System.Launcher.LaunchUriAsync(uriSchool, launcherOptions);
        }
Exemple #24
0
        static async Task MainAsync()
        {
            var uri     = new Uri("myuwp:");
            var options = new Windows.System.LauncherOptions();

            // Launch the URI without a warning prompt
            options.TreatAsUntrusted = false;
            var res = await Windows.System.Launcher.LaunchUriAsync(uri, options);
        }
Exemple #25
0
        private async Task Launcher(string UriMaps)
        {
            var uri = new Uri(@"bingmaps:?" + UriMaps);

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

            launcherOptions.TargetApplicationPackageFamilyName = "Microsoft.WindowsMaps_8wekyb3d8bbwe";
            var success = await Windows.System.Launcher.LaunchUriAsync(uri, launcherOptions);
        }
Exemple #26
0
        private async void StackPanel_Tapped(object sender, TappedRoutedEventArgs e)
        {
            var uriBing = new Uri("ms-call:settings");
            var launchOptions = new Windows.System.LauncherOptions();
            launchOptions.TreatAsUntrusted = true;
            launchOptions.DesiredRemainingView = Windows.UI.ViewManagement.ViewSizePreference.UseMore;

            var success = await Windows.System.Launcher.LaunchUriAsync(uriBing, launchOptions);
        }
Exemple #27
0

        
 private async void OnDocumentClick (object sender, ItemClickEventArgs e)
 {
     var document = e.ClickedItem as Document;
     if (document != null) {
         var options = new Windows.System.LauncherOptions { DisplayApplicationPicker = true };
         var file = await Package.Current.InstalledLocation.GetFileAsync (document.Path.Replace ('/', '\\'));
         var success = await Windows.System.Launcher.LaunchFileAsync (file, options);
     }
 }
Exemple #29
0
        private void Share2_Click(object sender, RoutedEventArgs e)
        {
            var url           = string.Format("ms-chat:?Body={0}", Content_TextBox.Text);
            var uriBing       = new Uri(url);
            var promptOptions = new Windows.System.LauncherOptions();

            //promptOptions.DesiredRemainingView = Windows.UI.ViewManagement.ViewSizePreference.UseLess;
            var success = Windows.System.Launcher.LaunchUriAsync(uriBing);
        }
Exemple #30
0
        public static async void OpenUrl(this string url)
        {
            try
            {
                var options = new Windows.System.LauncherOptions
                {
                    TreatAsUntrusted = false
                };
                if (SettingsHelper.Settings.HandleTelegramLinks)
                {
                    if (url.Contains("t.me/") || url.Contains("telegram.org/") || url.Contains("telegram.me/"))
                    {
                        var u     = url;
                        var start = "";
                        if (url.Contains("t.me/"))
                        {
                            start = "t.me/";
                        }
                        else if (url.Contains("telegram.org/"))
                        {
                            start = "telegram.org/";
                        }
                        else if (url.Contains("telegram.me/"))
                        {
                            start = "telegram.me/";
                        }
                        if (!string.IsNullOrEmpty(start))
                        {
                            u = url.Substring(url.IndexOf(start) + start.Length);
                            const string join = "joinchat/";
                            string Replace(string str) => str.Replace("/", "").Replace(" ", "");

                            if (u.ToLower().Contains(join))
                            {
                                u   = u.Substring(u.IndexOf(join) + join.Length);
                                url = $"tg://join?invite={Replace(u)}";
                            }
                            else if (u.ToLower().Contains("socks?"))
                            {
                                url = $"tg://{Replace(u)}";
                            }
                            else if (u.ToLower().Contains("proxy?"))
                            {
                                url = $"tg://{Replace(u)}";
                            }
                            else
                            {
                                url = $"tg://resolve?domain={Replace(u)}";
                            }
                        }
                    }
                }
                await Windows.System.Launcher.LaunchUriAsync(url.ToUri(), options);
            }
            catch { }
        }
Exemple #31
0
        private async void LaunchFiles(IReadOnlyList <IStorageItem> files)
        {
            // The number of files received is args.Files.Size
            // The name of the first file is args.Files[0].Name

#if DEBUG
            if (System.Diagnostics.Debugger.IsAttached)
            {
                this.DebugSettings.EnableFrameRateCounter = false;
            }
#endif

            Frame rootFrame = Window.Current.Content as Frame;

            // ウィンドウに既にコンテンツが表示されている場合は、アプリケーションの初期化を繰り返さずに、
            // ウィンドウがアクティブであることだけを確認してください
            if (rootFrame == null)
            {
                // ナビゲーション コンテキストとして動作するフレームを作成し、最初のページに移動します
                rootFrame = new Frame();

                rootFrame.NavigationFailed += OnNavigationFailed;

                // フレームを現在のウィンドウに配置します
                Window.Current.Content = rootFrame;
            }

            StorageFile file;

            // Launch primary file
            if (rootFrame.Content == null)
            {
                // We always want to navigate to the MainPage, regardless
                // of whether or not this is a redirection.
                file = files[0] as StorageFile;
                rootFrame.Navigate(typeof(MailPage), file);

                // Add to MRU
                // https://docs.microsoft.com/en-us/windows/uwp/files/how-to-track-recently-used-files-and-folders
                var    mru      = Windows.Storage.AccessCache.StorageApplicationPermissions.MostRecentlyUsedList;
                string mruToken = mru.Add(file, file.Name);
            }

            // Launch secondary file
            for (int i = 1; i < files.Count; i++)
            {
                // Open file on this app
                var options = new Windows.System.LauncherOptions();
                options.TargetApplicationPackageFamilyName = Package.Current.Id.FamilyName;
                file = files[i] as StorageFile;
                await Windows.System.Launcher.LaunchFileAsync(file, options);
            }

            // 現在のウィンドウがアクティブであることを確認します
            Window.Current.Activate();
        }
        private void Video_DoubleTapped(object sender, TappedRoutedEventArgs e)
        {
            Image target = (Image)sender;

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

            options.TreatAsUntrusted = true;

            var page = Windows.System.Launcher.LaunchUriAsync(new Uri(target.DataContext.ToString()), options);
        }
        private async void LaunchToolkitButton_Click(object sender, RoutedEventArgs e)
        {
            // Set the recommended app
            var options = new Windows.System.LauncherOptions();

            options.PreferredApplicationPackageFamilyName = "Microsoft.UWPCommunityToolkitSampleApp_8wekyb3d8bbwe";
            options.PreferredApplicationDisplayName       = "Windows Community Toolkit";

            await Windows.System.Launcher.LaunchUriAsync(new Uri("uwpct://controls?sample=datagrid"), options);
        }
        public static async Task <bool> UiTask()
        {
            var uri = new Uri($"{SchemeUi}:");
            var opt = new Windows.System.LauncherOptions()
            {
                TargetApplicationPackageFamilyName = PackageName
            };

            return(await Windows.System.Launcher.LaunchUriAsync(uri, opt));
        }
        /// <summary>
        // Launch a .png file that came with the package. Request to share the screen with the launched app.
        /// </summary>
        private async void LaunchFileSplitScreenButton_Click(object sender, RoutedEventArgs e)
        {
            // First, get a file via the picker.
            var openPicker = new Windows.Storage.Pickers.FileOpenPicker();

            openPicker.FileTypeFilter.Add("*");

            Windows.Storage.StorageFile file = await openPicker.PickSingleFileAsync();

            if (file != null)
            {
                // Configure the request for split screen launch.
                var options = new Windows.System.LauncherOptions();
                if (Default.IsSelected == true)
                {
                    options.DesiredRemainingView = Windows.UI.ViewManagement.ViewSizePreference.Default;
                }
                else if (UseLess.IsSelected == true)
                {
                    options.DesiredRemainingView = Windows.UI.ViewManagement.ViewSizePreference.UseLess;
                }
                else if (UseHalf.IsSelected == true)
                {
                    options.DesiredRemainingView = Windows.UI.ViewManagement.ViewSizePreference.UseHalf;
                }
                else if (UseMore.IsSelected == true)
                {
                    options.DesiredRemainingView = Windows.UI.ViewManagement.ViewSizePreference.UseMore;
                }
                else if (UseMinimum.IsSelected == true)
                {
                    options.DesiredRemainingView = Windows.UI.ViewManagement.ViewSizePreference.UseMinimum;
                }
                else if (UseNone.IsSelected == true)
                {
                    options.DesiredRemainingView = Windows.UI.ViewManagement.ViewSizePreference.UseNone;
                }

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

                if (success)
                {
                    rootPage.NotifyUser("File launched: " + file.Name, NotifyType.StatusMessage);
                }
                else
                {
                    rootPage.NotifyUser("File launch failed.", NotifyType.ErrorMessage);
                }
            }
            else
            {
                rootPage.NotifyUser("No file was picked.", NotifyType.ErrorMessage);
            }
        }
Exemple #36
0
        /// <summary>
        /// Launches the Maps app
        /// </summary>
        /// <param name="query">A query to control which part of the map is shown. Examples can be found in the online docs</param>
        public static void LaunchMapsApp(string query = "")
        {
#if NETFX_CORE || (ENABLE_IL2CPP && UNITY_WSA_10_0)
            UnityEngine.WSA.Application.InvokeOnUIThread(async() =>
            {
                var launcherOptions = new Windows.System.LauncherOptions();
                launcherOptions.TargetApplicationPackageFamilyName = "Microsoft.WindowsMaps_8wekyb3d8bbwe";
                await Windows.System.Launcher.LaunchUriAsync(new Uri("bingmaps:?" + query), launcherOptions);
            }, false);
#endif
        }
Exemple #37
0
        private async void HyperlinkButton_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            var c = CultureHelper.GetCurrentCulture().Substring(0, 2);
            var uri = new Uri("ms-appx:///Assets/AGB_" + c + ".html");
            var options = new Windows.System.LauncherOptions();
            options.DisplayApplicationPicker = false;
            //nav.Navigate(uri);
            var f = await Windows.Storage.StorageFile.GetFileFromApplicationUriAsync(uri);

            Windows.System.Launcher.LaunchFileAsync(f);
        }
        async private void DisplayApplicationPicker(object sender, RoutedEventArgs e)
        {
            // 获取要打开的文件
            var file = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync("Gof.pdf");

            // 设置显示程序列表
            var options = new Windows.System.LauncherOptions();
            options.DisplayApplicationPicker = true;

            // 打开文件 
            bool success = await Windows.System.Launcher.LaunchFileAsync(file, options);

        }
Exemple #39
0
 /*
 参数:  protocolname是调用者应用(外部商户应用)的protocolname,如何获取protocolname请参考章节3.1.1.2
         Callback是应用接收支付结果的异步回调委托;
 返回值:无。
 功能:  如果快捷支付存在,就会调起快捷支付提示用户:支付模块正常,5秒后返回(用户也可以直接点击“返回”)。 5秒(或者点击“返回”)会自动返回到调用程序。
 备注:  如果callback中接收到这样的信息:“resultStatus={7100};memo={当前系统已经安装移动快捷支付应用。}”表明已经安装好移动快捷支付应用。
  */
 public async static void TestFastPayExist(string protocolname, AlipayCallback callback)
 {
     string uristr = "alifastpaywin8:?protocol=";
     mProtCallback = callback;
     uristr += protocolname; //protocolname是用于通知消息的。protocolname是商户传进来的。
     var uri = new Uri(uristr);//创建uri。
     var options = new Windows.System.LauncherOptions();
     options.DisplayApplicationPicker = false;            //为true时,强制显示选择列表。
     options.PreferredApplicationDisplayName = "移动快捷支付";                        //没有找到应用时,会弹出displayName
     options.PreferredApplicationPackageFamilyName = "424203F4.324177B885247_8asrdwhv739xj";  //这是移动快捷支付的packageFamilyName            
     await Windows.System.Launcher.LaunchUriAsync(uri, options);
     return ;
 }
 private async void OpenExtractedFileBeDefaultProgramExecute(FileInfo fileToOpen)
 { 
     if (fileToOpen.FilePath != null)
     { 
         var temp = default(StorageFile);
         try
         {
             temp = await StorageFile.GetFileFromPathAsync(fileToOpen.FilePath);
             var options = new Windows.System.LauncherOptions();
             await Windows.System.Launcher.LaunchFileAsync(temp);
         }
         catch (FileNotFoundException) { };          
     }
 }
        private async void ConfiguraBluetooth()
        {
            var uri = new Uri("ms-settings-bluetooth:");
            var options = new Windows.System.LauncherOptions();
            options.TreatAsUntrusted = true;

            bool success = await Windows.System.Launcher.LaunchUriAsync(uri, options);
            if (success)
            {
                Debug.WriteLine("Acesso a Configuracao Bluetooth Teve Sucesso");
            }
            else
            {
                Debug.WriteLine("Acesso a Configuracao Bluetooth Falhou");
            }
        }
Exemple #42
0
        /// <summary>
        // Launch a URI. Show a warning prompt.
        /// </summary>
        private async void LaunchUriWithWarningButton_Click(object sender, RoutedEventArgs e)
        {
            // Create the URI to launch from a string.
            var uri = new Uri(UriToLaunch.Text);

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

            // Launch the URI.
            bool success = await Windows.System.Launcher.LaunchUriAsync(uri, options);
            if (success)
            {
                rootPage.NotifyUser("URI launched: " + uri.AbsoluteUri, NotifyType.StatusMessage);
            }
            else
            {
                rootPage.NotifyUser("URI launch failed.", NotifyType.ErrorMessage);
            }
        }
        /// <summary>
        // Launch a .png file that came with the package. Show a warning prompt.
        /// </summary>
        private async void LaunchFileWithWarningButton_Click(object sender, RoutedEventArgs e)
        {
            // First, get the image file from the package's image directory.
            var file = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(fileToLaunch);

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

            // Finally, launch the file.
            bool success = await Windows.System.Launcher.LaunchFileAsync(file, options);
            if (success)
            {
                rootPage.NotifyUser("File launched: " + file.Name, NotifyType.StatusMessage);
            }
            else
            {
                rootPage.NotifyUser("File launch failed.", NotifyType.ErrorMessage);
            }
        }
        private async void RecommendedApp(object sender, RoutedEventArgs e)
        {
            // Path to the file in the app package to launch
            string imageFile = @"data\1.BeyondVincent";

            // Get the image file from the package's image directory
            var file = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(imageFile);

            if (file != null)
            {
                // Set the recommended app
                var options = new Windows.System.LauncherOptions();

                // 设置为应用商店中要推荐的应用的程序包系列名称
                options.PreferredApplicationPackageFamilyName = "BeyondVincent格式文件程序";

                // 设置为该应用的名称
                options.PreferredApplicationDisplayName = "BV_Launcher";


                // Launch the retrieved file pass in the recommended app 
                // in case the user has no apps installed to handle the file
                bool success = await Windows.System.Launcher.LaunchFileAsync(file, options);
                if (success)
                {
                    // File launched
                }
                else
                {
                    // File launch failed
                }
            }
            else
            {
                // Could not find file
            }
        }
        /// <summary>
        /// Command for downloading and viewing a file.
        /// </summary>
        async void ExecuteDownloadFileCommandAsync()
        {
            StorageFile destinationFile = null;

            if (_selectedFileObject.FileSystemItem is Folder)
            {
                LoggingViewModel.Instance.Information = String.Format("The item '{0}' is a folder and therefore can't be downloaded.", _selectedFileObject.Name);
                return;
            }

            using (var downloadStream = await _fileOperations.DownloadFileAsync(_selectedFileObject))
            {

                // Create the picker object and set options
                FileSavePicker picker = new FileSavePicker();
                picker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.DocumentsLibrary;

                // Dropdown of file types the user can save the file as
                picker.FileTypeChoices.Add("Text", new List<string>() { ".txt" });
                picker.FileTypeChoices.Add("Word document", new List<string>() { ".docx" });
                picker.FileTypeChoices.Add("Excel workbook", new List<string>() { ".xlsx" });
                picker.FileTypeChoices.Add("Powerpoint", new List<string>() { ".pptx" });
                picker.FileTypeChoices.Add("XML", new List<string>() { ".xml" });
                picker.FileTypeChoices.Add("JPEG", new List<string>() { ".jpg" });
                picker.FileTypeChoices.Add("PNG", new List<string>() { ".png" });
                picker.FileTypeChoices.Add("PDF", new List<string>() { ".pdf" });

                // Default file name if the user does not type one in or select a file to replace
                picker.SuggestedFileName = _selectedFileObject.Name;

                destinationFile = await picker.PickSaveFileAsync();

                if (destinationFile != null && downloadStream != null)
                {

                    CachedFileManager.DeferUpdates(destinationFile);

                    using (Stream destinationStream = await destinationFile.OpenStreamForWriteAsync())
                    {
                        int count = 0;
                        do
                        {
                            var buffer = new byte[2048];
                            count = downloadStream.Read(buffer, 0, 2048);
                            await destinationStream.WriteAsync(buffer, 0, count);
                        }
                        while (downloadStream.CanRead && count > 0);

                        await destinationStream.FlushAsync();
                    }

                }
            }

            if (destinationFile != null)
            {
                var viewFile =  await MessageDialogHelper.ShowYesNoDialogAsync(
                               String.Format("Your file was downloaded to {0}\nWould you like to open the file?",destinationFile.Path), "Download Succeeded");

                if (viewFile)
                {
                    // Launch the selected app so the user can see the file contents.

                    // Let the user choose which app to use.
                    var options = new Windows.System.LauncherOptions();
                    options.DisplayApplicationPicker = true;

                    var success = await Windows.System.Launcher.LaunchFileAsync(destinationFile, options);
                    if (!success)
                    {
                        LoggingViewModel.Instance.Information = "We couldn't launch an app to view the file.";
                    }
                }
            }
            else
            {
                LoggingViewModel.Instance.Information = "The file wasn't downloaded.";

            }
        }
Exemple #46
0
 private async void BlogButton_Click(object sender, RoutedEventArgs e)
 {
     string uriToLaunch = @"http://mukosame.github.io/";
     var uri = new Uri(uriToLaunch);
     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 ConfiguraAirplane()
        {
            var uri = new Uri("ms-settings-airplanemode://");
            var options = new Windows.System.LauncherOptions();
            options.TreatAsUntrusted = true;

            bool success = await Windows.System.Launcher.LaunchUriAsync(uri, options);
            if (success)
            {
                Debug.WriteLine("Acesso a Configuracao AirPlane Teve Sucesso");
            }
            else
            {
                Debug.WriteLine("Acesso a Configuracao AirPlane Falhou");
            }
        }
        private async void onFileSelected(object sender, TappedRoutedEventArgs e)
        {
            // TODO
            // check if the download directory exits

            // folder picker
            var folderPicker = new Windows.Storage.Pickers.FolderPicker();
            folderPicker.FileTypeFilter.Add("*");
            folderPicker.ViewMode = PickerViewMode.Thumbnail;
            folderPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
            folderPicker.SettingsIdentifier = "FolderPicker";

            StorageFolder destinationFolde =  await folderPicker.PickSingleFolderAsync();


            StorageFile targetFile;

            DataStructure.File selectedFile = (e.OriginalSource as FrameworkElement).DataContext as DataStructure.File;

            StorageFolder moduleBaseFolder = await getModuleBaseFolderAsync(_currentModule);

            IStorageFolder currentFolder = moduleBaseFolder; 

            foreach (DataStructure.Folder folder in _folderTree)
            {
                currentFolder = await currentFolder.CreateFolderAsync(folder.folderName, CreationCollisionOption.OpenIfExists);
            }

            if (_currentFolder != null)
            {
                currentFolder = await currentFolder.CreateFolderAsync(_currentFolder.folderName, CreationCollisionOption.OpenIfExists);
            }

            try
            {
                targetFile = await currentFolder.GetFileAsync(selectedFile.fileName);
            }
            catch
            {
                targetFile = null;
            }

            // if file has not been downloaded before
            // download it
            if (targetFile == null || (targetFile.DateCreated.CompareTo(selectedFile.fileUploadTime) < 0))
            {
                HttpClient client = new HttpClient();

                // http get request to validate token
                HttpResponseMessage response = await client.GetAsync(Utils.LAPI.GenerateDownloadURL(selectedFile.fileId));

                // make sure the http reponse is successful
                response.EnsureSuccessStatusCode();

                if (targetFile == null)
                {
                    // create the file
                    targetFile = await currentFolder.CreateFileAsync(selectedFile.fileName, CreationCollisionOption.OpenIfExists);
                }
                // if file does exist
                // check the creation date and the file upload time
                else if (targetFile.DateCreated.CompareTo(selectedFile.fileUploadTime) < 0)
                {
                    Windows.Storage.FileProperties.BasicProperties fileProperties = await targetFile.GetBasicPropertiesAsync();

                    // if file is modified after downloading
                    // create a new file with UNIQUE name
                    if (fileProperties.DateModified > targetFile.DateCreated)
                    {
                        string fileExtension = selectedFile.fileName.Substring(selectedFile.fileName.IndexOf('.'));
                        string fileName = selectedFile.fileName.Remove(selectedFile.fileName.IndexOf('.'));
                        await targetFile.RenameAsync(fileName + "_modified_as_of_" + DateTime.Today.ToString("dd_MM_yyyy") + fileExtension);
                        targetFile = await currentFolder.CreateFileAsync(selectedFile.fileName, CreationCollisionOption.ReplaceExisting);
                    }
                }

                // store data in the file
                using (Stream outputStream = await targetFile.OpenStreamForWriteAsync())
                using (Stream inputStream = await response.Content.ReadAsStreamAsync())
                {
                    inputStream.CopyTo(outputStream);
                }
            }

            // if file is sucessfully created and stored
            if (targetFile != null)
            {
                // Set the option to show the picker
                var options = new Windows.System.LauncherOptions();
                options.DisplayApplicationPicker = false;

                // Launch the retrieved file
                await Windows.System.Launcher.LaunchFileAsync(targetFile, options);
            }
            else
            {
                // Could not find file
            }
        }
        private async void Button_Import_Click(object sender, RoutedEventArgs e)
        {

            StringBuilder contents = new StringBuilder();
            StorageFile selectedFile2 = null;
            FileOpenPicker openPicker = new FileOpenPicker();
            openPicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
            openPicker.FileTypeFilter.Add(".pfx");
            openPicker.FileTypeFilter.Add(".p12");

            if (ApplicationView.Value == ApplicationViewState.Snapped)
            {
                if (ApplicationView.TryUnsnap())
                {
                    selectedFile2 = await openPicker.PickSingleFileAsync();
                }
            }
            else
            {                
                selectedFile2 = await openPicker.PickSingleFileAsync();
            }

            if (selectedFile2 != null)
            {
                CredentialPanel cp = new CredentialPanel();
                bool foco = cp.Focus(Windows.UI.Xaml.FocusState.Programmatic);
                CustomDialog customDialog = new CustomDialog(cp, labels.GetString("Etiqueta_peticion_pass"));
                customDialog.Commands.Add(new UICommand(labels.GetString("Boton_aceptar")));
                customDialog.Commands.Add(new UICommand(labels.GetString("Boton_cancelar")));
                customDialog.DefaultCommandIndex = 0;
                customDialog.CancelCommandIndex = 1;
                IUICommand com = await customDialog.ShowAsync();

                if (com.Label.Equals(labels.GetString("Boton_aceptar")))
                    if (cp.getPassword() != null)
                        using (StreamReader reader = new StreamReader(await selectedFile2.OpenStreamForReadAsync()))
                        {
                            char[] password = cp.getPassword().ToCharArray();
                            try
                            {
                                store = new Pkcs12Store(reader.BaseStream, password);
                                if (store != null)
                                {
                                    await selectedFile2.CopyAsync(localFolder, selectedFile2.Name, NameCollisionOption.ReplaceExisting);
                                    storeData = new StoreData();
                                    storeData.LoadData();
                                    _source = storeData.GetGroupsByCategory();
                                    ItemGridView2.ItemsSource = storeData.Collection;
                                    EvaluateDeleteButton(storeData);
                                    // Le quitamos la extensión al nombre del almacén por coherencia con el borrado, que al pillarlo de la lista no tiene extensión.
                                    AfirmaMetroUtils.showMessage(labels.GetString("Info_almacen_importado") + selectedFile2.Name.Replace(selectedFile2.FileType, "") + "\".", "Importación de almacén correcta");

                                    // Lanzamos:
                                    var options = new Windows.System.LauncherOptions();
                                    options.DisplayApplicationPicker = true;
                                    var file2 = await localFolder.GetFileAsync(selectedFile2.Name);
                                    bool success = await Windows.System.Launcher.LaunchFileAsync(file2, options);

                                }
                            }
                            catch
                            {
                                AfirmaMetroUtils.showMessage(labels.GetString("Error_carga_almacen"), "Error en la importación de almacén");
                            }
                        }
            }
        }
        private async void ConfiguraNotificacao()
        {
            var uri = new Uri("ms-settings-screenrotation:");
            var options = new Windows.System.LauncherOptions();
            options.TreatAsUntrusted = true;

            bool success = await Windows.System.Launcher.LaunchUriAsync(uri, options);
            if (success)
            {
                Debug.WriteLine("Acesso a Configuracao Notificacao Teve Sucesso");
            }
            else
            {
                Debug.WriteLine("Acesso a Configuracao Notificacao Falhou");
            }
        }
        /// <summary>
        // Launch a .png file that came with the package. Request to share the screen with the launched app.
        /// </summary>
        private async void LaunchFileSplitScreenButton_Click(object sender, RoutedEventArgs e)
        {
            // First, get a file via the picker.
            var openPicker = new Windows.Storage.Pickers.FileOpenPicker();
            openPicker.FileTypeFilter.Add("*");

            Windows.Storage.StorageFile file = await openPicker.PickSingleFileAsync();
            if (file != null)
            {
                // Configure the request for split screen launch.
                var options = new Windows.System.LauncherOptions();
                if (Default.IsSelected == true)
                {
                    options.DesiredRemainingView = Windows.UI.ViewManagement.ViewSizePreference.Default;
                }
                else if (UseLess.IsSelected == true)
                {
                    options.DesiredRemainingView = Windows.UI.ViewManagement.ViewSizePreference.UseLess;
                }
                else if (UseHalf.IsSelected == true)
                {
                    options.DesiredRemainingView = Windows.UI.ViewManagement.ViewSizePreference.UseHalf;
                }
                else if (UseMore.IsSelected == true)
                {
                    options.DesiredRemainingView = Windows.UI.ViewManagement.ViewSizePreference.UseMore;
                }
                else if (UseMinimum.IsSelected == true)
                {
                    options.DesiredRemainingView = Windows.UI.ViewManagement.ViewSizePreference.UseMinimum;
                }
                else if (UseNone.IsSelected == true)
                {
                    options.DesiredRemainingView = Windows.UI.ViewManagement.ViewSizePreference.UseNone;
                }

                // Next, launch the file.
                bool success = await Windows.System.Launcher.LaunchFileAsync(file, options);
                if (success)
                {
                    rootPage.NotifyUser("File launched: " + file.Name, NotifyType.StatusMessage);
                }
                else
                {
                    rootPage.NotifyUser("File launch failed.", NotifyType.ErrorMessage);
                }
            }
            else
            {
                rootPage.NotifyUser("No file was picked.", NotifyType.ErrorMessage);
            }
        }
        private async void LaunchDefaultBrowser(Uri uri)
        {
           // Set the desired remaining view.
           var options = new Windows.System.LauncherOptions();
           options.DesiredRemainingView = Windows.UI.ViewManagement.ViewSizePreference.UseHalf;

           // Launch the URI 
           var success = await Windows.System.Launcher.LaunchUriAsync(uri, options);

           if (success)
           {
              // URI launched
           }
           else
           {
              // URI launch failed
           }
        }
        /// <summary>
        // Launch a .png file that came with the package. Show an Open With dialog that lets the user chose the handler to use.
        /// </summary>
        private async void LaunchFileOpenWithButton_Click(object sender, RoutedEventArgs e)
        {
            // First, get the image file from the package's image directory.
            var file = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(fileToLaunch);

            // Calculate 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 = GetOpenWithPosition(LaunchFileOpenWithButton);

            // Next, configure the Open With dialog.
            var options = new Windows.System.LauncherOptions();
            options.DisplayApplicationPicker = true;
            options.UI.InvocationPoint = openWithPosition;
            options.UI.PreferredPlacement = Windows.UI.Popups.Placement.Below;

            // Finally, launch the file.
            bool success = await Windows.System.Launcher.LaunchFileAsync(file, options);
            if (success)
            {
                rootPage.NotifyUser("File launched: " + file.Name, NotifyType.StatusMessage);
            }
            else
            {
                rootPage.NotifyUser("File launch failed.", NotifyType.ErrorMessage);
            }
        }
Exemple #54
0
        private async void LaunchIE(Uri uri)
        {
            // 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);

            if (success)
            {
                // URI launched
            }
            else
            {
                // URI launch failed
            }
        }    
        /// <summary>
        // Launch a URI. Request to share the screen with the launched app.
        /// </summary>
        private async void LaunchUriSplitScreenButton_Click(object sender, RoutedEventArgs e)
        {
            // Create the URI to launch from a string.
            var uri = new Uri(UriToLaunch.Text);

            // Configure the request for split screen launch.
            var options = new Windows.System.LauncherOptions();

            if (!(Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons")))
            {
                options.DesiredRemainingView = (Windows.UI.ViewManagement.ViewSizePreference)SizePreference.SelectedValue;
            }

            // Launch the URI.
            bool success = await Windows.System.Launcher.LaunchUriAsync(uri, options);
            if (success)
            {
                rootPage.NotifyUser("URI launched: " + uri.AbsoluteUri, NotifyType.StatusMessage);
            }
            else
            {
                rootPage.NotifyUser("URI launch failed.", NotifyType.ErrorMessage);
            }
        }
Exemple #56
0
        private static async System.Threading.Tasks.Task OnShowAGB()
        {
            try
            {
                var c = CultureHelper.GetCurrentCulture().Substring(0, 2);
                var uri = new Uri("ms-appx:///Assets/AGB_" + c + ".html");
                var options = new Windows.System.LauncherOptions();
                options.DisplayApplicationPicker = false;
                //nav.Navigate(uri);
                var f = await Windows.Storage.StorageFile.GetFileFromApplicationUriAsync(uri);

                Windows.System.Launcher.LaunchFileAsync(f);
            }
            catch (Exception ex)
            {

            }
        }
Exemple #57
0
        /// <summary>
        // Launch a URI. Request to share the screen with the launched app.
        /// </summary>
        private async void LaunchUriSplitScreenButton_Click(object sender, RoutedEventArgs e)
        {
            // Create the URI to launch from a string.
            var uri = new Uri(UriToLaunch.Text);

            // Configure the request for split screen launch.
            var options = new Windows.System.LauncherOptions();
            if (Default.IsSelected == true)
            {
                options.DesiredRemainingView = Windows.UI.ViewManagement.ViewSizePreference.Default;
            }
            else if (UseLess.IsSelected == true)
            {
                options.DesiredRemainingView = Windows.UI.ViewManagement.ViewSizePreference.UseLess;
            }
            else if (UseHalf.IsSelected == true)
            {
                options.DesiredRemainingView = Windows.UI.ViewManagement.ViewSizePreference.UseHalf;
            }
            else if (UseMore.IsSelected == true)
            {
                options.DesiredRemainingView = Windows.UI.ViewManagement.ViewSizePreference.UseMore;
            }
            else if (UseMinimum.IsSelected == true)
            {
                options.DesiredRemainingView = Windows.UI.ViewManagement.ViewSizePreference.UseMinimum;
            }
            else if (UseNone.IsSelected == true)
            {
                options.DesiredRemainingView = Windows.UI.ViewManagement.ViewSizePreference.UseNone;
            }

            // Launch the URI.
            bool success = await Windows.System.Launcher.LaunchUriAsync(uri, options);
            if (success)
            {
                rootPage.NotifyUser("URI launched: " + uri.AbsoluteUri, NotifyType.StatusMessage);
            }
            else
            {
                rootPage.NotifyUser("URI launch failed.", NotifyType.ErrorMessage);
            }
        }
        //string fileToLaunch = null;
        private async void LaunchFileOpenWith(string fileName)
        {

            var file = await KnownFolders.VideosLibrary.GetFileAsync(fileName);
            // First, get the image file from the package's image directory.
            //var file = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(fileToLaunch);

            // Calculate 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 = new Point(600, 500);

            // Next, configure the Open With dialog.
            var options = new Windows.System.LauncherOptions();
            options.DisplayApplicationPicker = true;
            options.UI.InvocationPoint = openWithPosition;
            options.UI.PreferredPlacement = Windows.UI.Popups.Placement.Below;

            // Finally, launch the file.
            bool success = await Windows.System.Launcher.LaunchFileAsync(file, options);
            if (success)
            {
                ShowMessageDialog("File launched: " + file.Name);
            }
            else
            {
                ShowMessageDialog("File launch failed.");
            }
        }
 private async void OpenWithExecute(FileInfo fileToOpen)
 {
     if (fileToOpen.ExtractedStorageFile != null)
     {
         var options = new Windows.System.LauncherOptions();
         options.DisplayApplicationPicker = true;
         await Windows.System.Launcher.LaunchFileAsync(fileToOpen.ExtractedStorageFile, options);
     }
 }
        private async void OnLaunch(object sender, RoutedEventArgs e)
        {
            var file = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///NeonHitch.jpg"));

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

            // Set 3d Builder as the target app
            options.TargetApplicationPackageFamilyName = "Microsoft.3DBuilder_8wekyb3d8bbwe";

            // Launch 3d Builder with any 2D image
            await Windows.System.Launcher.LaunchFileAsync(file, options);
        }