Example #1
0
        private void OnCombinePickerClick(object sender, RoutedEventArgs e)
        {
            if (devicePicker == null)
            {
                devicePicker = new DevicePicker();

                // add casting
                devicePicker.Filter.SupportedDeviceSelectors.Add(CastingDevice.GetDeviceSelector(CastingPlaybackTypes.Video));

                // add dial
                devicePicker.Filter.SupportedDeviceSelectors.Add(DialDevice.GetDeviceSelector("castingsample"));

                // add projection
                devicePicker.Filter.SupportedDeviceSelectors.Add(ProjectionManager.GetDeviceSelector());

                devicePicker.DevicePickerDismissed   += DevicePicker_DevicePickerDismissed;
                devicePicker.DeviceSelected          += DevicePicker_DeviceSelected;
                devicePicker.DisconnectButtonClicked += DevicePicker_DisconnectButtonClicked;
            }

            player.Pause();

            // 從按下的 button 出現 picker 内容
            Button           btn       = sender as Button;
            GeneralTransform transform = btn.TransformToVisual(Window.Current.Content as UIElement);
            Point            pt        = transform.TransformPoint(new Point(0, 0));

            devicePicker.Show(new Rect(pt.X, pt.Y, btn.ActualWidth, btn.ActualHeight), Windows.UI.Popups.Placement.Above);
        }
Example #2
0
        private async void TransportControls_CastButtonClicked(object sender, EventArgs e)
        {
            //Pause Current Playback
            player.Pause();

            rootPage.NotifyUser("Show Device Picker Button Clicked", NotifyType.StatusMessage);

            //Get the custom transport controls
            MediaTransportControlsWithCustomCastButton mtc = (MediaTransportControlsWithCustomCastButton)this.player.TransportControls;
            //Retrieve the location of the casting button
            GeneralTransform transform = mtc.CastButton.TransformToVisual(Window.Current.Content as UIElement);
            Point            pt        = transform.TransformPoint(new Point(0, 0));

            //Add the DIAL Filter, so that the application only shows DIAL devices that have the application installed or advertise that they can install them.
            picker.Filter.SupportedDeviceSelectors.Add(DialDevice.GetDeviceSelector(this.dial_appname_textbox.Text));
            System.Diagnostics.Debug.WriteLine(DialDevice.GetDeviceSelector(this.dial_appname_textbox.Text));

            //Add the CAST API Filter, so that the application only shows Miracast, Bluetooth, DLNA devices that can render the video
            //picker.Filter.SupportedDeviceSelectors.Add(await CastingDevice.GetDeviceSelectorFromCastingSourceAsync(player.GetAsCastingSource()));
            //picker.Filter.SupportedDeviceSelectors.Add(CastingDevice.GetDeviceSelector(CastingPlaybackTypes.Video));
            //picker.Filter.SupportedDeviceSelectors.Add("System.Devices.InterfaceClassGuid:=\"{D0875FB4-2196-4c7a-A63D-E416ADDD60A1}\"" + " AND System.Devices.InterfaceEnabled:=System.StructuredQueryType.Boolean#True");
            //Add projection manager filter

            //picker.Filter.SupportedDeviceSelectors.Add(ProjectionManager.GetDeviceSelector());

            //if (activeDevice != null)
            //    //Update the display status for the previously selected device.
            //    picker.SetDisplayStatus(activeDevice, "Connected", DevicePickerDisplayStatusOptions.ShowDisconnectButton);

            //Show the picker above our Show Device Picker button
            picker.Show(new Rect(pt.X, pt.Y, mtc.CastButton.ActualWidth, mtc.CastButton.ActualHeight), Windows.UI.Popups.Placement.Above);
        }
Example #3
0
        public void StartScan(Action <BLE_Device_Info> execute)
        {
            DevicePicker picker = new DevicePicker();

            picker.Filter.SupportedDeviceSelectors.Add(BluetoothLEDevice.GetDeviceSelectorFromPairingState(false));
            picker.Filter.SupportedDeviceSelectors.Add(BluetoothLEDevice.GetDeviceSelectorFromPairingState(true));
            picker.Show(new Rect());
        }
Example #4
0
        /// <summary>
        /// ////////////////////////////////////////////
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void startWatcherButton_Click(object sender, RoutedEventArgs e)
        {
            startWatcherButton.IsEnabled = false;

            DevicePicker picker = new DevicePicker();

            picker.Filter.SupportedDeviceSelectors.Add(BluetoothLEDevice.GetDeviceSelectorFromPairingState(false));
            //picker.Filter.SupportedDeviceSelectors.Add(BluetoothLEDevice.GetDeviceSelectorFromPairingState(true));
            picker.Show(new Rect(0, 0, 300, 400));



            stopWatcherButton.IsEnabled = true;
        }
        private void TransportControls_CastButtonClicked(object sender, EventArgs e)
        {
            //Pause Current Playback
            player.Pause();

            rootPage.NotifyUser("Show Device Picker Button Clicked", NotifyType.StatusMessage);

            //Get the custom transport controls
            MediaTransportControlsWithCustomCastButton mtc = (MediaTransportControlsWithCustomCastButton)this.player.TransportControls;
            //Retrieve the location of the casting button
            GeneralTransform transform = mtc.CastButton.TransformToVisual(Window.Current.Content as UIElement);
            Point            pt        = transform.TransformPoint(new Point(0, 0));

            //Show the picker above our Show Device Picker button
            picker.Show(new Rect(pt.X, pt.Y, mtc.CastButton.ActualWidth, mtc.CastButton.ActualHeight), Windows.UI.Popups.Placement.Above);
        }
Example #6
0
        /// <summary>
        /// Obsługuje zdarzenie kliknięcia w przycisk 'Połącz'. Obsługa polega na sprawdzeniu załączenia modułu Bluetooth.
        /// W przypadku, gdy wynik sprawdzenia jest pozytywny wyświetlane jest menu wyboru urządzenia o nazwie "RobotPajak".
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void ButtonConnect_Click(object sender, RoutedEventArgs e)
        {
            if (labelStartInstruction.Visibility == Visibility.Visible)
            {
                labelStartInstruction.Visibility = Visibility.Collapsed;
            }
            var isBtActive = await Bluetooth.IsEnabled();

            if (isBtActive)
            {
                var picker = new DevicePicker();
                picker.Filter.SupportedDeviceSelectors.Add(BluetoothDevice.GetDeviceSelectorFromDeviceName("RobotPajak"));
                picker.Show(new Rect(10, 10, 300, 300));
                picker.DeviceSelected += (pckr, args) => { _selectedDeviceHandler(pckr, args); };
            }
            else
            {
                PopUp.Show(StringConsts.BtNotActiveError, StringConsts.Error);
            }
        }
Example #7
0
        public MainPage()
        {
            this.InitializeComponent();
            thisViewId = Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().Id;
            // Instantiate the Device Picker
            picker = new DevicePicker();

            // Get the device selecter for Miracast devices
            picker.Filter.SupportedDeviceSelectors.Add(ProjectionManager.GetDeviceSelector());

            //Hook up device selected event
            picker.DeviceSelected += Picker_DeviceSelected;

            //Hook up device disconnected event
            picker.DisconnectButtonClicked += Picker_DisconnectButtonClicked;

            //Hook up picker dismissed event
            picker.DevicePickerDismissed += Picker_DevicePickerDismissed;

            picker.Show(new Rect(this.ActualWidth, this.ActualHeight , this.ActualWidth, this.ActualHeight), Windows.UI.Popups.Placement.Above);
        }
        private async void castButton_Click(object sender, RoutedEventArgs e)
        {
            player.Pause();

            //Retrieve the location of the casting button
            GeneralTransform transform = castButton.TransformToVisual(Window.Current.Content as UIElement);
            Point            pt        = transform.TransformPoint(new Point(0, 0));

            //Add the DIAL Filter, so that the application only shows DIAL devices that have the application installed or advertise that they can install them.
            picker.Filter.SupportedDeviceSelectors.Add(DialDevice.GetDeviceSelector(this.dial_appname_textbox.Text));
            //Add the CAST API Filter, so that the application only shows Miracast, Bluetooth, DLNA devices that can render the video
            picker.Filter.SupportedDeviceSelectors.Add(await CastingDevice.GetDeviceSelectorFromCastingSourceAsync(player.GetAsCastingSource()));
            //RequiredDeviceProperties.AddProps(picker.RequestedProperties);

            //if (activeDevice != null)
            //    //Update the display status for the previously selected device.
            //    picker.SetDisplayStatus(activeDevice, "Connected", DevicePickerDisplayStatusOptions.ShowDisconnectButton);

            //Show the picker above our Show Device Picker button
            picker.Show(new Rect(pt.X, pt.Y, castButton.ActualWidth, castButton.ActualHeight), Windows.UI.Popups.Placement.Above);

            rootPage.NotifyUser("Show Device Picker Button Clicked", NotifyType.StatusMessage);
        }
        private async void ShowDevicePicker(bool pickSingle)
        {
            showDevicePickerButton.IsEnabled = false;
            ResultCollection.Clear();

            devicePicker = new DevicePicker();

            // First get the device selector chosen by the UI.
            DeviceSelectorInfo deviceSelectorInfo = (DeviceSelectorInfo)selectorComboBox.SelectedItem;

            if (null == deviceSelectorInfo.Selector)
            {
                // If the a pre-canned device class selector was chosen, call the DeviceClass overload
                devicePicker.Filter.SupportedDeviceClasses.Add(deviceSelectorInfo.DeviceClassSelector);
            }
            else
            {
                // Use AQS string selector from dynamic call to a device api's GetDeviceSelector call
                devicePicker.Filter.SupportedDeviceSelectors.Add(deviceSelectorInfo.Selector);
            }

            rootPage.NotifyUser("Showing Device Picker", NotifyType.StatusMessage);

            // Calculate the position to show the picker (right below the buttons)
            GeneralTransform ge = pickSingleDeviceButton.TransformToVisual(null);
            Point point = ge.TransformPoint(new Point());
            Rect rect = new Rect(point, new Point(point.X + pickSingleDeviceButton.ActualWidth, point.Y + pickSingleDeviceButton.ActualHeight));

            if (pickSingle)
            {
                DeviceInformation di = await devicePicker.PickSingleDeviceAsync(rect);
                if (null != di)
                {
                    ResultCollection.Add(new DeviceInformationDisplay(di));
                }
                showDevicePickerButton.IsEnabled = true;
            }
            else
            {
                devicePicker.DevicePickerDismissed += new TypedEventHandler<DevicePicker, object>(
                async (picker, obj) =>
                {
                    // Since we have the collection databound to a UI element, we need to update the collection on the UI thread.
                    await rootPage.Dispatcher.RunAsync(CoreDispatcherPriority.Low, () =>
                    {
                        showDevicePickerButton.IsEnabled = true;
                        rootPage.NotifyUser("Hiding Device Picker", NotifyType.StatusMessage);
                    });
                });

                devicePicker.DeviceSelected += new TypedEventHandler<DevicePicker, DeviceSelectedEventArgs>(
                async (picker, args) =>
                {
                    // Since we have the collection databound to a UI element, we need to update the collection on the UI thread.
                    await rootPage.Dispatcher.RunAsync(CoreDispatcherPriority.Low, () =>
                    {
                        ResultCollection.Clear();
                        ResultCollection.Add(new DeviceInformationDisplay(args.SelectedDevice));
                    });
                });

                // Show the picker
                devicePicker.Show(rect);
            }
        }
Example #10
0
        private async void ShowDevicePicker(bool pickSingle)
        {
            showDevicePickerButton.IsEnabled = false;
            resultCollection.Clear();

            var devicePicker = new DevicePicker();

            // First get the device selector chosen by the UI.
            DeviceSelectorInfo deviceSelectorInfo = (DeviceSelectorInfo)selectorComboBox.SelectedItem;

            if (null == deviceSelectorInfo.Selector)
            {
                // If the a pre-canned device class selector was chosen, call the DeviceClass overload
                devicePicker.Filter.SupportedDeviceClasses.Add(deviceSelectorInfo.DeviceClassSelector);
            }
            else
            {
                // Use AQS string selector from dynamic call to a device api's GetDeviceSelector call
                devicePicker.Filter.SupportedDeviceSelectors.Add(deviceSelectorInfo.Selector);
            }

            rootPage.NotifyUser("Showing Device Picker", NotifyType.StatusMessage);

            // Calculate the position to show the picker (right below the buttons)
            GeneralTransform ge    = pickSingleDeviceButton.TransformToVisual(null);
            Point            point = ge.TransformPoint(new Point());
            Rect             rect  = new Rect(point, new Point(point.X + pickSingleDeviceButton.ActualWidth, point.Y + pickSingleDeviceButton.ActualHeight));

            if (pickSingle)
            {
                DeviceInformation di = await devicePicker.PickSingleDeviceAsync(rect);

                if (null != di)
                {
                    resultCollection.Add(new DeviceInformationDisplay(di));
                }
                showDevicePickerButton.IsEnabled = true;
            }
            else
            {
                devicePicker.DevicePickerDismissed += new TypedEventHandler <DevicePicker, object>(
                    async(picker, obj) =>
                {
                    // Must access UI elements from the UI thread.
                    await rootPage.Dispatcher.RunAsync(CoreDispatcherPriority.Low, () =>
                    {
                        showDevicePickerButton.IsEnabled = true;
                        rootPage.NotifyUser("Hiding Device Picker", NotifyType.StatusMessage);
                    });
                });

                devicePicker.DeviceSelected += new TypedEventHandler <DevicePicker, DeviceSelectedEventArgs>(
                    async(picker, args) =>
                {
                    // Since we have the collection databound to a UI element, we need to update the collection on the UI thread.
                    await rootPage.Dispatcher.RunAsync(CoreDispatcherPriority.Low, () =>
                    {
                        resultCollection.Clear();
                        resultCollection.Add(new DeviceInformationDisplay(args.SelectedDevice));
                    });
                });

                // Show the picker
                devicePicker.Show(rect);
            }
        }
Example #11
0
        public void SelectDevice()
        {
            var rect = new Rect(0, 0, 100, 200);

            _picker.Show(rect);
        }
Example #12
0
 public void ConnectButton_Click(object sender, RoutedEventArgs e)
 {
     devicePicker.Show(new Rect(0, 0, 200, 500), Windows.UI.Popups.Placement.Below);
 }