Beispiel #1
0
        /// <summary>
        /// Shows the picker UI and returns the selected device; does not require you to register for an event.
        /// </summary>
        /// <param name="selection">The rectangle from which you want the picker to fly out.
        /// Ignored on Windows Phone.</param>
        /// <param name="placement">The edge of the rectangle from which you want the picker to fly out.
        /// Ignored on Windows Phone.</param>
        /// <returns></returns>
        public async Task <DeviceInformation> PickSingleDeviceAsync(Rect selection, Placement placement)
        {
#if WINDOWS_PHONE_APP
            _dialog = new DevicePickerDialog(this);
            ContentDialogResult result = await _dialog.ShowAsync();

            return(_dialog.SelectedDevice);
#else
            _popup = new Popup();
            DevicePickerControl dpc = new DevicePickerControl(this, _popup);
            _popup.Child                 = dpc;
            _popup.HorizontalOffset      = selection.Right;
            _popup.VerticalOffset        = selection.Top;
            _popup.IsLightDismissEnabled = true;
            _popup.IsOpen                = true;
            return(await Task.Run <DeviceInformation>(() => { return dpc.WaitForSelection(); }));
#endif
        }
Beispiel #2
0
        /// <summary>
        /// Shows the picker UI and returns the selected device; does not require you to register for an event.
        /// </summary>
        /// <param name="selection">The rectangle from which you want the picker to fly out.
        /// <para>Ignored on Phone platforms as dialog is presented full-screen and Windows Desktop where it is centered.</para></param>
        /// <param name="placement">The edge of the rectangle from which you want the picker to fly out.
        /// <para>Ignored on Phone platforms as dialog is presented full-screen and Windows Desktop where it is centered.</para></param>
        /// <returns></returns>
        public async Task <DeviceInformation> PickSingleDeviceAsync(Rect selection, Placement placement)
        {
#if __ANDROID__ || __IOS__ || WIN32 || WINDOWS_UWP
            return(await DoPickSingleDeviceAsync(selection, placement));
#elif WINDOWS_PHONE_APP
            _dialog = new DevicePickerDialog(this);
            Windows.UI.Xaml.Controls.ContentDialogResult result = await _dialog.ShowAsync();

            return(_dialog.SelectedDevice);
#elif WINDOWS_APP
            _popup = new Popup();
            DevicePickerControl dpc = new DevicePickerControl(this, _popup);
            _popup.Child                 = dpc;
            _popup.HorizontalOffset      = selection.X + selection.Width;
            _popup.VerticalOffset        = selection.Y;
            _popup.IsLightDismissEnabled = true;
            _popup.IsOpen                = true;
            return(await Task.Run <DeviceInformation>(() => { return dpc.WaitForSelection(); }));
#else
            return(null);
#endif
        }