RadialController 類別

定義

表示轉盤輸入裝置或配件,例如 Surface Dial。

具有 Surface Studio 和手寫筆的 Surface Dial。

Surface Dial 使用根據「旋轉」動作 (或手勢) 的形狀規格,做為次要、多重強制回應的輸入裝置,補充主要裝置的輸入。 在大部分情況下,使用者是以慣用手執行工作 (例如以手寫筆寫字),同時以非慣用手操作這類裝置。 其設計的目的並不是為了精確的指標輸入 (例如觸控、手寫筆或滑鼠)。

Surface Dial 也支援「長按」以及「按一下」兩個動作。 長按有單一的功能︰顯示命令的功能表。 如果功能表使用中,旋轉並按一下輸入是由功能表處理。 否則,輸入就會傳遞到您的應用程式進行處理。

RadialController 和相關 API (請參閱主題結尾) 可讓您自訂整合式命令功能表和應用程式支援的互動體驗。

public ref class RadialController sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 196608)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class RadialController final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 196608)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class RadialController
Public NotInheritable Class RadialController
繼承
Object Platform::Object IInspectable RadialController
屬性

Windows 需求

裝置系列
Windows 10 Anniversary Edition (已於 10.0.14393.0 引進)
API contract
Windows.Foundation.UniversalApiContract (已於 v3.0 引進)

範例

在此範例中,我們會將自訂工具新增至 Surface Dial 功能表,並宣告 RadialController 輸入處理常式。

  1. 首先,我們會呼叫CreateForCurrentView,為 Surface Dial (myController 建立 RadialController 物件的參考) 。
  2. 接著,我們會呼叫RadialControllerMenuItem.CreateFromIcon,以建立 myItemRadialControllerMenuItem () 實例。
  3. 接下來,我們將該項目附加到功能表項目的集合。
  4. 我們宣告 RadialController 物件的輸入事件處理常式 (ButtonClicked 和 RotationChanged)。
  5. 最後,我們定義事件處理常式。
public sealed partial class MainPage : Page
 {
     RadialController myController;

     public MainPage()
     {
         this.InitializeComponent();
         // Create a reference to the RadialController.
         myController = RadialController.CreateForCurrentView();

         // Create an icon for the custom tool.
         RandomAccessStreamReference icon =
           RandomAccessStreamReference.CreateFromUri(
             new Uri("ms-appx:///Assets/StoreLogo.png"));

         // Create a menu item for the custom tool.
         RadialControllerMenuItem myItem =
           RadialControllerMenuItem.CreateFromIcon("Sample", icon);

         // Add the custom tool to the RadialController menu.
         myController.Menu.Items.Add(myItem);

         // Declare input handlers for the RadialController.
         myController.ButtonClicked += MyController_ButtonClicked;
         myController.RotationChanged += MyController_RotationChanged;
     }

     // Handler for rotation input from the RadialController.
     private void MyController_RotationChanged(RadialController sender,
       RadialControllerRotationChangedEventArgs args)
     {
         if (RotationSlider.Value + args.RotationDeltaInDegrees > 100)
         {
             RotationSlider.Value = 100;
             return;
         }
         else if (RotationSlider.Value + args.RotationDeltaInDegrees < 0)
         {
             RotationSlider.Value = 0;
             return;
         }
         RotationSlider.Value += args.RotationDeltaInDegrees;
     }

     // Handler for click input from the RadialController.
     private void MyController_ButtonClicked(RadialController sender,
       RadialControllerButtonClickedEventArgs args)
     {
         ButtonToggle.IsOn = !ButtonToggle.IsOn;
     }
 }

在此所示的初始化函式中,我們會宣告 RadialController 物件的各種輸入事件處理常式。

// Create and configure our radial controller.
private void InitializeController() 
{
    // Create a reference to the RadialController.
    radialController = RadialController.CreateForCurrentView();
    // Set rotation resolution to 1 degree of sensitivity.
    radialController.RotationResolutionInDegrees = 1;

    // Declare input handlers for the RadialController.
    radialController.ButtonClicked += (sender, args) =>
    { RadialController_ButtonClicked(sender, args); };
    radialController.RotationChanged += (sender, args) =>
    { RadialController_RotationChanged(sender, args); };

    radialController.ControlAcquired += (sender, args) =>
    { RadialController_ControlAcquired(sender, args); };
    radialController.ControlLost += (sender, args) =>
    { RadialController_ControlLost(sender, args); };
    radialController.ScreenContactStarted += (sender, args) =>
    { RadialController_ScreenContactStarted(sender, args); };
    radialController.ScreenContactContinued += (sender, args) =>
    { RadialController_ScreenContactContinued(sender, args); };
    radialController.ScreenContactEnded += (sender, args) =>
    { RadialController_ScreenContactEnded(sender, args); };
    AddToLog("Input handlers created");

    // Create the custom menu items.
    CreateMenuItems();
    // Specify the menu items.
    ConfigureMenu();
}

ButtonClicked 處理常式中,互動會將切換按鈕的狀態設定為已核取或取消核取。

// Occurs when the wheel device is pressed and then released 
// while a customRadialController tool is active.
// NOTE: Your app does not receive this event when the RadialController 
// menu is active or a built-in tool is active
// Send click input to toggle button of active region.
private void RadialController_ButtonClicked(RadialController sender,
  RadialControllerButtonClickedEventArgs args)
{
    toggles[activeMenuItemIndex].IsOn = !toggles[activeMenuItemIndex].IsOn;
}

RotationChanged 處理常式中,互動會修改滑杆的值。

// Occurs when the wheel device is rotated while a custom 
// RadialController tool is active.
// NOTE: Your app does not receive this event when the RadialController 
// menu is active or a built-in tool is active
// Send rotation input to slider of active region.
private void RadialController_RotationChanged(RadialController sender,
  RadialControllerRotationChangedEventArgs args)
{
    Slider slider = sliders[activeMenuItemIndex];
    if (slider.Value + args.RotationDeltaInDegrees > 100)
    {
        slider.Value = 100;
        return;
    }
    else if (slider.Value + args.RotationDeltaInDegrees < 0)
    {
        slider.Value = 0;
        return;
    }
    slider.Value += args.RotationDeltaInDegrees;
    AddToLog("\nRotation: " + sliders[activeMenuItemIndex].Name + " value changed to " + slider.Value);
}

備註

版本歷程記錄

Windows 版本 SDK 版本 已新增值
1703 15063 ButtonHolding
1703 15063 ButtonPressed
1703 15063 ButtonReleased

屬性

Menu

取得與 RadialController 物件相關聯之功能表的參考。

RotationResolutionInDegrees

取得或設定 RadialController 物件引發 RotationChanged 事件所需的最小旋轉值。

UseAutomaticHapticFeedback

取得或設定RadialController所引發的每個RotationChanged事件是否在滾輪裝置上啟用觸覺回饋。

方法

CreateForCurrentView()

具現化滾輪裝置的 RadialController 物件,並將它系結至使用中的應用程式。

IsSupported()

擷取值,指出系統是否支援滾輪裝置。

事件

ButtonClicked

發生于按下滾輪裝置,然後在自訂 RadialController 工具作用中時放開時。

您的應用程式在下列情況下不會收到此事件:

注意

當時間臨界值超過時,按一下會變成按下並按住動作。 在此情況下,會顯示與 RadialController 物件相關聯的內容應用程式命令整合式功能表,然後功能表會處理後續的旋轉和按一下事件。

ButtonHolding

發生于使用者按下並按住滾輪裝置時。

ButtonPressed

發生于按下滾輪裝置時。

ButtonReleased

發生于按下滾輪裝置,然後放開時。

ControlAcquired

發生于從功能表中選取應用程式) 所定義的自訂 RadialController 工具 (,或在自訂 RadialController 工具作用中時將與 RadialController 物件相關聯的應用程式帶入前景時發生。

ControlLost

發生于應用程式) 定義 (自訂 RadialController 工具時發生,而且與 RadialController 物件相關聯的應用程式會傳送至背景,或使用者啟動 RadialController 功能表。

RotationChanged

在自訂 RadialController 工具作用中時旋轉滾輪裝置時發生。

您的應用程式在下列情況下不會收到此事件:

ScreenContactContinued

只有在與數位板表面接觸時移動滾輪裝置,而且自訂 RadialController 工具作用中時才會發生。

您的應用程式在下列情況下不會收到此事件:

提示

除了預設的按下和按住功能表體驗之外,Surface Dial 也可以直接放在Surface Studio的畫面上。 這會產生特殊的「螢幕上」功能表。

藉由偵測 Surface Dial 的連絡位置和界限,系統就可以處理裝置的遮蔽,並顯示較大型版本的功能表,以包裝在 Dial 外部。 您的應用程式也可以使用這個相同的資訊,針對裝置是否存在及其預期的使用方式 (例如使用者的手與手臂的放置位置) 打造 UI。

此事件會在 ScreenContactStarted 之後發生 ,並在 ScreenContactEnded上停止。

ScreenContactEnded

當與數位板表面接觸的滾輪裝置已移除 (或不再偵測到) ,且自訂 RadialController 工具為使用中時發生。

您的應用程式在下列情況下不會收到此事件:

提示

除了預設的按下和按住功能表體驗之外,Surface Dial 也可以直接放在Surface Studio的畫面上。 這會產生特殊的「螢幕上」功能表。

藉由偵測 Surface Dial 的連絡位置和界限,系統就可以處理裝置的遮蔽,並顯示較大型版本的功能表,以包裝在 Dial 外部。 您的應用程式也可以使用這個相同的資訊,針對裝置是否存在及其預期的使用方式 (例如使用者的手與手臂的放置位置) 打造 UI。

此事件會在 ScreenContactStarted之後發生。

ScreenContactStarted

在滾輪裝置與數位板表面之間偵測到初始接觸,而自訂 RadialController 工具處於作用中狀態時發生。

您的應用程式在下列情況下不會收到此事件:

提示

除了預設的按下和按住功能表體驗之外,Surface Dial 也可以直接放在Surface Studio的畫面上。 這會產生特殊的「螢幕上」功能表。

藉由偵測 Surface Dial 的連絡位置和界限,系統就可以處理裝置的遮蔽,並顯示較大型版本的功能表,以包裝在 Dial 外部。 您的應用程式也可以使用這個相同的資訊,針對裝置是否存在及其預期的使用方式 (例如使用者的手與手臂的放置位置) 打造 UI。

適用於

另請參閱