예제 #1
0
        private async void Launch_Clicked(object sender, RoutedEventArgs e)
        {
            RemoteSystem selectedSystem = SystemListComboBox.SelectedItem as RemoteSystem;

            if (selectedSystem != null)
            {
                Uri uri;
                if (Uri.TryCreate(UriTextBox.Text, UriKind.Absolute, out uri))
                {
                    UpdateStatus("LaunchUriAsync called. Waiting for response...", NotifyType.StatusMessage);

                    // Launch URI on the remote system.
                    // Note: LaunchUriAsync needs to called from the UI thread.
                    RemoteLaunchUriStatus launchUriStatus = await RemoteLauncher.LaunchUriAsync(new RemoteSystemConnectionRequest(selectedSystem), uri);

                    UpdateStatus("LaunchUriStatus = " + launchUriStatus.ToString(), launchUriStatus == RemoteLaunchUriStatus.Success ? NotifyType.StatusMessage : NotifyType.ErrorMessage);
                }
                else
                {
                    UpdateStatus("Please enter a valid URI.", NotifyType.ErrorMessage);
                }
            }
            else
            {
                UpdateStatus("Please select a system.", NotifyType.ErrorMessage);
            }
        }
예제 #2
0
        private async void RemoteActivated(object sender, RoutedEventArgs e)
        {
            var fw = sender as FrameworkElement;

            if (fw == null)
            {
                return;
            }
            var remote = fw.DataContext as RemoteSystem;

            if (remote == null)
            {
                return;
            }


            var res = await RemoteSystem.RequestAccessAsync();

            if (res != RemoteSystemAccessStatus.Allowed)
            {
                return;
            }

            bool isRemoteSystemLaunchUriCapable = await remote.GetCapabilitySupportedAsync(KnownRemoteSystemCapabilities.LaunchUri);

            bool isRemoteSystemAppServiceCapable = await remote.GetCapabilitySupportedAsync(KnownRemoteSystemCapabilities.AppService);

            bool isRemoteSystemRemoteSessionCapable = await remote.GetCapabilitySupportedAsync(KnownRemoteSystemCapabilities.RemoteSession);

            bool isRemoteSystemSpatialEntityCapable = await remote.GetCapabilitySupportedAsync(KnownRemoteSystemCapabilities.SpatialEntity);

            var rscr   = new RemoteSystemConnectionRequest(remote);
            var uri    = new Uri("http://www.google.co.uk");
            var status = await RemoteLauncher.LaunchUriAsync(rscr, uri);
        }
예제 #3
0
        public async Task <RomeRemoteLaunchUriStatus> LaunchUri(Uri uri, object remoteSystemOverride)
        {
            RemoteSystem rs = null;

            if (remoteSystemOverride != null)
            {
                rs = remoteSystemOverride as RemoteSystem;
                if (rs == null)
                {
                    throw new InvalidCastException();
                }
            }

            var request         = new RemoteSystemConnectionRequest(rs);
            var launchUriStatus = await RemoteLauncher.LaunchUriAsync(request, uri);

            var result = launchUriStatus.ConvertToRomeRemoteLaunchUriStatus();

            if (result == RomeRemoteLaunchUriStatus.ProtocolUnavailable)
            {
                await LaunchStoreForApp(rs);
            }

            return(result);
        }
 public async void OnContinueWatching()
 {
     if (SelectedSystem != null)
     {
         await RemoteLauncher.LaunchUriAsync(
             new RemoteSystemConnectionRequest(SelectedSystem),
             new Uri($"myvideoapp://?video={SelectedVideo.Name}&position={CurrentPosition.TotalSeconds}"));
     }
 }
예제 #5
0
        private async void RemoteLaunchUriAsync(RemoteSystem remoteSystem, Uri uri)
        {
            var launchUriStatus = await RemoteLauncher.LaunchUriAsync(new RemoteSystemConnectionRequest(remoteSystem), uri);

            if (launchUriStatus != RemoteLaunchUriStatus.Success)
            {
                Console.WriteLine("Failed to Launch!");
            }
        }
예제 #6
0
 public static async Task <RemoteLaunchUriStatus> ExecuteCommand(RemoteSystem remoteSystem, Command comm)
 {
     if (remoteSystem != null)
     {
         return(await RemoteLauncher.LaunchUriAsync(new RemoteSystemConnectionRequest(remoteSystem), new Uri(comm.ToString())));
     }
     else
     {
         return(RemoteLaunchUriStatus.RemoteSystemUnavailable);
     }
 }
        private async Task <RemoteLaunchUriStatus> LaunchAppOnDeviceAsync(RemoteSystem device, string args)
        {
            if (!IsSupported)
            {
                return(RemoteLaunchUriStatus.Unknown);
            }

            RemoteSystemConnectionRequest request = new RemoteSystemConnectionRequest(device);

            return(await RemoteLauncher.LaunchUriAsync(request, new Uri("nep:" + args)));
        }
예제 #8
0
        internal static async void SelectOption(string text)
        {
            switch (currentState)
            {
            case AppState.selectingURL:
                currentURL = text;
                RemoteSystemAccessStatus accessStatus = await RemoteSystem.RequestAccessAsync();

                if (accessStatus == RemoteSystemAccessStatus.Allowed)
                {
                    var remoteSystemWatcher = RemoteSystem.CreateWatcher();
                    remoteSystemWatcher.RemoteSystemAdded   += RemoteSystemWatcher_RemoteSystemAdded;
                    remoteSystemWatcher.RemoteSystemRemoved += RemoteSystemWatcher_RemoteSystemRemoved;
                    remoteSystemWatcher.RemoteSystemUpdated += RemoteSystemWatcher_RemoteSystemUpdated;
                    remoteSystemWatcher.Start();
                    (currentPage as SelectList).setMessage("Finding devices");
                    (currentPage as SelectList).setList(startingDevices);
                    currentState = AppState.selectingDevice;
                }
                else
                {
                    (currentPage as SelectList).setMessage("Select a device");
                    (currentPage as SelectList).setList(startingDevices);
                    currentState = AppState.selectingDevice;
                }
                break;

            case AppState.selectingDevice:
                var downloadUrl = new Uri("https://arcadiogarcia.github.io/HTML5VideoDownloadUWP/?" + Uri.EscapeDataString(currentURL));
                if (startingDevices.Contains(text))
                {
                    //Asuming it never fails
                    await Windows.System.Launcher.LaunchUriAsync(downloadUrl);

                    Application.Current.Exit();
                }
                else
                {
                    var launchUriStatus = await RemoteLauncher.LaunchUriAsync(new RemoteSystemConnectionRequest(remoteSystems.Find(x => x.DisplayName == text)), downloadUrl);

                    if (launchUriStatus == RemoteLaunchUriStatus.Success)
                    {
                        Application.Current.Exit();
                    }
                    else
                    {
                        (currentPage as SelectList).setMessage(launchUriStatus.ToString());
                    }
                }
                break;
            }
        }
예제 #9
0
 private async void button_Click(object sender, RoutedEventArgs e)
 {
     // <SnippetRemoteUriLaunch>
     if (m_deviceList.Count > 0)
     {
         RemoteSystem          SelectedDevice  = m_deviceList[0];
         RemoteLaunchUriStatus launchUriStatus =
             await RemoteLauncher.LaunchUriAsync(
                 new RemoteSystemConnectionRequest(SelectedDevice),
                 new Uri("bingmaps:?cp=47.6204~-122.3491&sty=3d&rad=200&pit=75&hdg=165"));
     }
     // </SnippetRemoteUriLaunch>
 }
        public async void OnInvokeRemoteSystemByUriAsync(object sender, RoutedEventArgs e)
        {
            if (currentRemoteSystem == null)
            {
                return;
            }

            // 檢查設備是否支援需要的特性
            //await currentRemoteSystem.GetCapabilitySupportedAsync(KnownRemoteSystemCapabilities.LaunchUri)
            var launchRequest = new RemoteSystemConnectionRequest(currentRemoteSystem);
            var result        = await RemoteLauncher.LaunchUriAsync(launchRequest, new Uri("https://poumason.blogspot.com"));

            Debug.WriteLine(result.ToString());
        }
예제 #11
0
        private async void RemoteLaunchUriAsync(RemoteSystem remoteSystem, Uri uri)
        {
            this.LogMessage("Launching URI: " + uri + " on " + remoteSystem.DisplayName);
            var launchUriStatus = await RemoteLauncher.LaunchUriAsync(new RemoteSystemConnectionRequest(remoteSystem), uri);

            if (launchUriStatus == RemoteLaunchUriStatus.Success)
            {
                this.LogMessage("Launch succeeded");
            }
            else
            {
                this.LogMessage("Launch failed due to [" + launchUriStatus.ToString() + "]");
            }
        }
        public async Task LaunchUriAsync()
        {
            using (await _launchUriAsyncLock.LockAsync())
            {
                LaunchRemoteUriResult = string.Empty;

                var target = SelectedRemoteSystem;
                if (target == null)
                {
                    LaunchRemoteUriResult = "Il faut sélectionner une cible...";
                    return;
                }

                if (!string.IsNullOrEmpty(TargetLaunchHost))
                {
                    // construct a HostName object
                    Windows.Networking.HostName deviceHost = new Windows.Networking.HostName(TargetLaunchHost);

                    // create a RemoteSystem object with the HostName
                    var remotesys = await RemoteSystem.FindByHostNameAsync(deviceHost);

                    if (remotesys != null)
                    {
                        LaunchRemoteUriResult = "Cible trouvée";

                        target = remotesys;
                    }
                }
                var targetRs = RemoteSystems
                               .FirstOrDefault(r => r.Status == RemoteSystemStatus.Available);
                var request = new RemoteSystemConnectionRequest(targetRs);
                var uri     = new Uri(TargetLaunchUri);

                var launchUriTask = RemoteLauncher.LaunchUriAsync(request, uri);

                LaunchRemoteUriResult = "Appel en cours...";
                var timeout = Task.Delay(13000);
                await Task.WhenAny(timeout, launchUriTask.AsTask());

                if (timeout.IsCompleted)
                {
                    LaunchRemoteUriResult = "Timeout.... ";
                }
                else
                {
                    var result = await launchUriTask;
                    LaunchRemoteUriResult = "Appel effectué : " + result;
                }
            }
        }
예제 #13
0
        public static async Task LaunchAndConnect(RemoteSystem remoteSystem)
        {
            //Launch app on remote device
            var uri             = new Uri("rome-dlc:");
            var launchUriStatus = await RemoteLauncher.LaunchUriAsync(new RemoteSystemConnectionRequest(remoteSystem), uri);

            if (launchUriStatus == RemoteLaunchUriStatus.Success)
            {
                StatusWrite("App launched on: " + remoteSystem.DisplayName);

                await SendMessageToRemoteSystemAsync(remoteSystem, "Hello");
            }
            else
            {
                StatusWrite("Error: " + launchUriStatus);
            }
        }
        public async Task LaunchOnSystem(RemoteSystem system)
        {
            BrowserPageViewModel browserVM = SimpleIoc.Default.GetInstance <BrowserPageViewModel>();
            string collectionJson          = "{}";

            if (browserVM.Images is IJsonizable)
            {
                collectionJson = (browserVM.Images as IJsonizable).toJson();
            }
            ValueSet values = new ValueSet();

            values["images"] = collectionJson;
            values["index"]  = browserVM.FlipViewIndex;
            RemoteLauncherOptions option = new RemoteLauncherOptions();

            option.FallbackUri = new Uri("https://www.microsoft.com/store/p/monocle-giraffe/9nblggh4qcvh");
            RemoteLaunchUriStatus launchUriStatus = await RemoteLauncher.LaunchUriAsync(new RemoteSystemConnectionRequest(system),
                                                                                        new Uri($"imgur:?images={collectionJson}&index={browserVM.FlipViewIndex}&type={browserVM.Images.GetType().Name}"));
        }
예제 #15
0
        public async void RemoteSystemItemClick(object sender, ItemClickEventArgs e)
        {
            try
            {
                LoadingPane.Visibility = Windows.UI.Xaml.Visibility.Visible;
                var system = (RemoteSystem)e.ClickedItem;

                if (SimpleIoc.Default.GetInstance <IPlaybackService>().GetCurrentTrack() != null)
                {
                    var track    = new BaseSoundByteItem(SimpleIoc.Default.GetInstance <IPlaybackService>().GetCurrentTrack());
                    var playlist = SimpleIoc.Default.GetInstance <IPlaybackService>().GetMediaPlaybackList().Items.Select(x => new BaseSoundByteItem(x.Source.AsBaseTrack()));
                    var token    = SimpleIoc.Default.GetInstance <IPlaybackService>().GetPlaylistToken();
                    var source   = SimpleIoc.Default.GetInstance <IPlaybackService>().GetPlaylistSource();

                    var status = await RemoteLauncher.LaunchUriAsync(new RemoteSystemConnectionRequest(system),
                                                                     new Uri(ProtocolHelper.EncodeTrackProtocolItem(new ProtocolHelper.TrackProtocolItem(source, track, playlist, token, SimpleIoc.Default.GetInstance <IPlaybackService>().GetTrackDuration()), true)));

                    if (status == RemoteLaunchUriStatus.Success)
                    {
                        Hide();
                        LoadingPane.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                    }
                    else
                    {
                        Hide();
                        LoadingPane.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                        await NavigationService.Current.CallMessageDialogAsync("Failed with status: " + status, "Remote System Error");
                    }
                }
                else
                {
                    Hide();
                    LoadingPane.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                    await NavigationService.Current.CallMessageDialogAsync("A track must be playing", "Remote System Error");
                }
            }
            finally
            {
                LoadingPane.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
            }
        }
        /// <summary>
        /// Start the slideshow on the remote system
        /// </summary>
        /// <param name="system"></param>
        /// <param name="deepLink"></param>
        /// <returns></returns>
        public async Task <bool> ConnectToSystem(AdventureRemoteSystem system, string deepLink = "")
        {
            ValueSet message = new ValueSet();

            message.Add("query", ConnectedServiceQuery.StartHostingSession.ToString());

            var response = await system.SendMessage(message);

            if (response != null && response.ContainsKey("success") && (bool)response["success"])
            {
                var status = (ConnectedServiceStatus)Enum.Parse(typeof(ConnectedServiceStatus), (String)response["status"]);

                if (status != ConnectedServiceStatus.HostingNotConnected && status != ConnectedServiceStatus.HostingConnected)
                {
                    var launchUriStatus =
                        await RemoteLauncher.LaunchUriAsync(
                            new RemoteSystemConnectionRequest(system.RemoteSystem),
                            new Uri("adventure:" + deepLink)).AsTask().ConfigureAwait(false);

                    if (launchUriStatus != RemoteLaunchUriStatus.Success)
                    {
                        return(false);
                    }
                }
                if (_remoteSystem != system)
                {
                    if (_remoteSystem != null)
                    {
                        _remoteSystem.MessageReceived -= _remoteSystem_MessageReceived;
                        _remoteSystem = null;
                    }
                    _remoteSystem = system;
                    _remoteSystem.MessageReceived += _remoteSystem_MessageReceived;
                }

                return(true);
            }

            return(false);
        }
예제 #17
0
        private async void selectFromList(object sender, SelectionChangedEventArgs e)
        {
            RemoteSystem selection = ((sender as ListBox).SelectedItem as RemoteSystem);

            if (selection != null)
            {
                /**
                 *
                 * Windows.Storage.StorageFolder storageFolder = Windows.Storage.ApplicationData.Current.LocalFolder;
                 * Windows.Storage.StorageFile sampleFile =
                 *  await storageFolder.CreateFileAsync("helloworld.pdf",
                 *      Windows.Storage.CreationCollisionOption.ReplaceExisting);
                 *
                 * sampleFile = await storageFolder.GetFileAsync("helloworld.pdf");
                 * await Windows.Storage.FileIO.WriteTextAsync(sampleFile, "Hello World");
                 * // var success = await Windows.System.Launcher.LaunchFileAsync(sampleFile);
                 * //after the device is selected, create a new session for particpants to join
                 * Debug.WriteLine(sampleFile.Path);
                 * var uri = new System.Uri(sampleFile.Path);
                 * var converted = uri.AbsoluteUri;
                 *
                 * Windows.System.LauncherOptions options = new Windows.System.LauncherOptions();
                 * options.ContentType = "application/pdf";
                 * Windows.System.Launcher.LaunchUriAsync(new Uri(sampleFile.Path), options);
                 **/
                RemoteLaunchUriStatus launchURIstatus = await RemoteLauncher.LaunchUriAsync(
                    new RemoteSystemConnectionRequest(selection),
                    new Uri($"ms-chat:?Body={"Hello World"}"));

                // Debug.WriteLine(uri.AbsoluteUri);
                Debug.WriteLine("3");
                //await CreateSession(selection);
                //StartRecievingMessages();

                //rmeote system connection request
                //RemoteSystemConnectionRequest connRequest = new RemoteSystemConnectionRequest(selection);
            }
        }
예제 #18
0
        public static async Task LaunchRemoteUriAsync(RemoteSystem remoteSystem, Uri uri)
        {
            if (remoteSystem != null)
            {
                var connection = new RemoteSystemConnectionRequest(remoteSystem);

                Events.TrackEvent(Events.LaunchUriAsyncStart);
                var result = await RemoteLauncher.LaunchUriAsync(connection, uri);

                if (result == RemoteLaunchUriStatus.Success)
                {
                    Events.TrackEvent(Events.LaunchUriAsyncSuccess);
                }
                switch (result)
                {
                case RemoteLaunchUriStatus.Success:
                    Events.TrackEvent(Events.LaunchUriAsyncSuccess);
                    break;

                case RemoteLaunchUriStatus.DeniedByRemoteSystem:
                    Events.TrackEvent(Events.LaunchUriAsyncErrorDeniedByRemoteSystem);
                    break;

                case RemoteLaunchUriStatus.ProtocolUnavailable:
                    Events.TrackEvent(Events.LaunchUriAsyncErrorProtocolUnavailable);
                    break;

                case RemoteLaunchUriStatus.RemoteSystemUnavailable:
                    Events.TrackEvent(Events.LaunchUriAsyncErrorRemoteSystemUnavailable);
                    break;

                default:
                    Events.TrackEvent(Events.LaunchUriAsyncErrorOther);
                    break;
                }
            }
        }
        public static async Task <RemoteLaunchUriStatus> TryOpenStoreToApp(RemoteSystem device, String appTarget)
        {
            RemoteSystemConnectionRequest connectionRequest = new RemoteSystemConnectionRequest(device);

            return(await RemoteLauncher.LaunchUriAsync(connectionRequest, new Uri(appTarget)));
        }
        public static async Task <RemoteLaunchUriStatus> TryBeginShareFile(RemoteSystem device, string fileName, string ipAddress)
        {
            RemoteSystemConnectionRequest connectionRequest = new RemoteSystemConnectionRequest(device);

            return(await RemoteLauncher.LaunchUriAsync(connectionRequest, new Uri("share-app:?FileName=" + fileName + "&IpAddress=" + ipAddress)));
        }
        public static async Task <RemoteLaunchUriStatus> TrySharetext(RemoteSystem device, string text)
        {
            RemoteSystemConnectionRequest connectionRequest = new RemoteSystemConnectionRequest(device);

            return(await RemoteLauncher.LaunchUriAsync(connectionRequest, new Uri("share-app:?Text=" + Uri.EscapeDataString(text))));
        }
        public static async Task <RemoteLaunchUriStatus> TryShareURL(RemoteSystem device, string url)
        {
            RemoteSystemConnectionRequest connectionRequest = new RemoteSystemConnectionRequest(device);

            return(await RemoteLauncher.LaunchUriAsync(connectionRequest, new Uri(url)));
        }