AccessibleStates 列舉

定義

指定數值,代表可存取物件的可能狀態。

此列舉支援其成員值的位元組合。

public enum class AccessibleStates
[System.Flags]
public enum AccessibleStates
[<System.Flags>]
type AccessibleStates = 
Public Enum AccessibleStates
繼承
AccessibleStates
屬性

欄位

AlertHigh 268435456

應立刻傳達給使用者的重要資訊。 例如,剩餘電量指示器 (Indicator) 到達關鍵性的低電位時就會轉換成這個狀態,這種情況下,盲目存取公用程式會立刻向使用者宣告這項資訊,而且螢幕縮放程式會捲動螢幕,讓電量指示器進入檢視當中。 這個狀態也適用於必須先完成,使用者才能夠繼續的任何提示或作業。

AlertLow 67108864

對使用者可能並不重要的低優先權資訊。

AlertMedium 134217728

不必立刻傳達給使用者的重要資訊。 例如,剩餘電量指示器開始達到低電位時,可產生中級的警告。 然後盲目存取公用程式就會產生聲響,讓使用者知道有重要資訊,而不真正中斷使用者的工作。 使用者就可以在所選擇的時間隨時查詢警告資訊。

Animated 16384

快速或經常要變更外觀的物件。 偶爾但並非一定會使用動畫效果的圖形,應該定義成 GraphicORAnimated。 此一狀態不應該用於指示物件變位置。

Busy 2048

無法在目前的條件中接受輸入的控制項。

Checked 16

具有選定核取方塊的物件。

Collapsed 1024

是大綱或樹狀結構中之項目的物件隱藏子系。

Default 256

預設按鈕或功能表項目。

Expanded 512

是大綱或樹狀結構中之項目的物件顯示子系。

ExtSelectable 33554432

變更的選取項目會使選取項目錨點 (也就是具有鍵盤焦點的物件) 之間的所有物件和這個物件取得錨點物件的選取項目狀態。 如果不選取錨點物件,物件會從選取項目移除。 如果選取錨點物件,選取項目會擴充,來包含這個物件和之間所有的物件。 您可以將這個和 AddSelectionRemoveSelection 組合,來設定選取項目的狀態。 這個狀態除非與 TakeFocus 組合,否則不會變更焦點或選取項目的錨點。

Floating 4096

不固定在父物件之界限的物件和不隨著父系自動移動的物件。

Focusable 1048576

使用中視窗上可接收鍵盤焦點的物件。

Focused 4

具有鍵盤焦點的物件。

HasPopup 1073741824

物件被叫用時會顯示快顯功能表或視窗。

HotTracked 128

滑鼠熱點追蹤的物件,表示它的外觀反白顯示,來指示出滑鼠指標位在它的上方。

Indeterminate 32

狀態不定的三態核取方塊或工具列按鈕。 核取方塊不是已選取也不是未核取,是在第三種或混合狀態中。

Invisible 32768

沒有可見的使用者介面的物件。

Linked 4194304

先前尚未選取的已連結物件。

Marqueed 8192

具有捲動或移動文字或圖形的物件。

Mixed 32

狀態不定的三態核取方塊或工具列按鈕。 核取方塊不是已選取也不是未核取,是在第三種或混合狀態中。

Moveable 262144

可移動的物件。

MultiSelectable 16777216

接受多重選取項目的物件。

None 0

沒有狀態。

Offscreen 65536

沒有螢幕上的表示。 聲音或警告物件,或永遠不可見的隱藏視窗可具有這個狀態。

Pressed 8

按下的物件。

Protected 536870912

密碼保護的編輯控制項。

ReadOnly 64

唯讀的物件。

Selectable 2097152

可接受選取項目的物件。

Selected 2

選取的物件。

SelfVoicing 524288

物件或子系可使用文字到語音 (TTS) 的方式來自我描述。 當具有這個狀態的物件擁有焦點時,因為物件會自動宣告有關本身的資訊,所以語音為主的輔助工具不應宣告資訊。

Sizeable 131072

可調大小的物件。

Traversed 8388608

先前已選取的已連結物件。

Unavailable 1

不可用的物件。

Valid 1073741823

有效的物件。 此屬性在 .NET Framework 2.0 中已被取代。

範例

下列程式碼範例示範如何使用 AccessibleObjectControl.ControlAccessibleObject 類別來公開無障礙資訊,建立協助工具感知圖表控制項。 控制項會繪製兩個曲線以及圖例。 ChartControlAccessibleObject衍生自 ControlAccessibleObject 的 類別會用於 方法中 CreateAccessibilityInstance ,以提供圖表控制項的自訂可存取訊號。 因為圖表圖例不是根據 Control 的實際控制項,而是由圖表控制項繪製,所以它不包含任何內建的可存取訊號。 因此,類別 ChartControlAccessibleObjectGetChild 覆寫 方法,以傳回 CurveLegendAccessibleObject ,代表圖例每個部分的可存取訊號。 當可存取感知應用程式使用此控制項時,控制項可以提供必要的可存取訊號。

此程式碼摘錄示範如何搭配 State 屬性使用 AccessibleStates 列舉。 AccessibleObject如需完整的程式碼範例,請參閱類別概觀。

// Inner class ChartControlAccessibleObject represents accessible information associated with the ChartControl.
// The ChartControlAccessibleObject is returned in the ChartControl::CreateAccessibilityInstance .
ref class ChartControlAccessibleObject: public ControlAccessibleObject
{
private:
   ChartControl^ chartControl;

public:
   ChartControlAccessibleObject( ChartControl^ ctrl )
      : ControlAccessibleObject( ctrl )
   {
      chartControl = ctrl;
   }


   property System::Windows::Forms::AccessibleRole Role 
   {

      // Gets the role for the Chart. This is used by accessibility programs.
      virtual System::Windows::Forms::AccessibleRole get() override
      {
         return ::AccessibleRole::Chart;
      }

   }

   property AccessibleStates State 
   {

      // Gets the state for the Chart. This is used by accessibility programs.
      virtual AccessibleStates get() override
      {
         return AccessibleStates::ReadOnly;
      }

   }

   // The CurveLegend objects are "child" controls in terms of accessibility so
   // return the number of ChartLengend objects.
   virtual int GetChildCount() override
   {
      return chartControl->Legends->Length;
   }


   // Gets the Accessibility object of the child CurveLegend idetified by index.
   virtual AccessibleObject^ GetChild( int index ) override
   {
      if ( index >= 0 && index < chartControl->Legends->Length )
      {
         return chartControl->Legends[ index ]->AccessibilityObject;
      }

      return nullptr;
   }


internal:

   // Helper function that is used by the CurveLegend's accessibility object
   // to navigate between sibiling controls. Specifically, this function is used in
   // the CurveLegend::CurveLegendAccessibleObject.Navigate function.
   AccessibleObject^ NavigateFromChild( CurveLegend::CurveLegendAccessibleObject^ child, AccessibleNavigation navdir )
   {
      switch ( navdir )
      {
         case AccessibleNavigation::Down:
         case AccessibleNavigation::Next:
            return GetChild( child->ID + 1 );

         case AccessibleNavigation::Up:
         case AccessibleNavigation::Previous:
            return GetChild( child->ID - 1 );
      }
      return nullptr;
   }


   // Helper function that is used by the CurveLegend's accessibility object
   // to select a specific CurveLegend control. Specifically, this function is used
   // in the CurveLegend::CurveLegendAccessibleObject.Select function.
   void SelectChild( CurveLegend::CurveLegendAccessibleObject^ child, AccessibleSelection selection )
   {
      int childID = child->ID;
      
      // Determine which selection action should occur, based on the
      // AccessibleSelection value.
      if ( (selection & AccessibleSelection::TakeSelection) != (AccessibleSelection)0 )
      {
         for ( int i = 0; i < chartControl->Legends->Length; i++ )
         {
            if ( i == childID )
            {
               chartControl->Legends[ i ]->Selected = true;
            }
            else
            {
               chartControl->Legends[ i ]->Selected = false;
            }

         }
         
         // AccessibleSelection->AddSelection means that the CurveLegend will be selected.
         if ( (selection & AccessibleSelection::AddSelection) != (AccessibleSelection)0 )
         {
            chartControl->Legends[ childID ]->Selected = true;
         }
         
         // AccessibleSelection->AddSelection means that the CurveLegend will be unselected.
         if ( (selection & AccessibleSelection::RemoveSelection) != (AccessibleSelection)0 )
         {
            chartControl->Legends[ childID ]->Selected = false;
         }
      }
   }

};

// class ChartControlAccessibleObject
// Inner class ChartControlAccessibleObject represents accessible information associated with the ChartControl.
// The ChartControlAccessibleObject is returned in the ChartControl.CreateAccessibilityInstance override.
public class ChartControlAccessibleObject : ControlAccessibleObject
{
    ChartControl chartControl;

    public ChartControlAccessibleObject(ChartControl ctrl) : base(ctrl) 
    {
        chartControl = ctrl;
    }

    // Gets the role for the Chart. This is used by accessibility programs.
    public override AccessibleRole Role
    {  
        get {
            return AccessibleRole.Chart;
        }
    }

    // Gets the state for the Chart. This is used by accessibility programs.
    public override AccessibleStates State
    {  
        get {                    
            return AccessibleStates.ReadOnly;
        }
    }

    // The CurveLegend objects are "child" controls in terms of accessibility so 
    // return the number of ChartLengend objects.
    public override int GetChildCount()
    {  
        return chartControl.Legends.Length;
    }

    // Gets the Accessibility object of the child CurveLegend idetified by index.
    public override AccessibleObject GetChild(int index)
    {  
        if (index >= 0 && index < chartControl.Legends.Length) {
            return chartControl.Legends[index].AccessibilityObject;
        }                
        return null;
    }

    // Helper function that is used by the CurveLegend's accessibility object
    // to navigate between sibiling controls. Specifically, this function is used in
    // the CurveLegend.CurveLegendAccessibleObject.Navigate function.
    internal AccessibleObject NavigateFromChild(CurveLegend.CurveLegendAccessibleObject child, 
                                                AccessibleNavigation navdir) 
    {  
        switch(navdir) {
            case AccessibleNavigation.Down:
            case AccessibleNavigation.Next:
                return GetChild(child.ID + 1);
                
            case AccessibleNavigation.Up:
            case AccessibleNavigation.Previous:
                return GetChild(child.ID - 1);                        
        }
        return null;
    }

    // Helper function that is used by the CurveLegend's accessibility object
    // to select a specific CurveLegend control. Specifically, this function is used
    // in the CurveLegend.CurveLegendAccessibleObject.Select function.
    internal void SelectChild(CurveLegend.CurveLegendAccessibleObject child, AccessibleSelection selection) 
    {   
        int childID = child.ID;

        // Determine which selection action should occur, based on the
        // AccessibleSelection value.
        if ((selection & AccessibleSelection.TakeSelection) != 0) {
            for(int i = 0; i < chartControl.Legends.Length; i++) {
                if (i == childID) {
                    chartControl.Legends[i].Selected = true;                        
                } else {
                    chartControl.Legends[i].Selected = false;
                }
            }

            // AccessibleSelection.AddSelection means that the CurveLegend will be selected.
            if ((selection & AccessibleSelection.AddSelection) != 0) {
                chartControl.Legends[childID].Selected = true;                        
            }

            // AccessibleSelection.AddSelection means that the CurveLegend will be unselected.
            if ((selection & AccessibleSelection.RemoveSelection) != 0) {
                chartControl.Legends[childID].Selected = false;                        
            }
        }            
    }
}
' Inner Class ChartControlAccessibleObject represents accessible information 
' associated with the ChartControl.
' The ChartControlAccessibleObject is returned in the         ' ChartControl.CreateAccessibilityInstance override.
Public Class ChartControlAccessibleObject
    Inherits Control.ControlAccessibleObject

    Private chartControl As ChartControl
    
    Public Sub New(ctrl As ChartControl)
        MyBase.New(ctrl)
        chartControl = ctrl
    End Sub
    
    ' Get the role for the Chart. This is used by accessibility programs.            
    Public Overrides ReadOnly Property Role() As AccessibleRole
        Get
            Return System.Windows.Forms.AccessibleRole.Chart
        End Get
    End Property
    
    ' Get the state for the Chart. This is used by accessibility programs.            
    Public Overrides ReadOnly Property State() As AccessibleStates
        Get
            Return AccessibleStates.ReadOnly
        End Get
    End Property                        
    
    ' The CurveLegend objects are "child" controls in terms of accessibility so 
    ' return the number of ChartLengend objects.            
    Public Overrides Function GetChildCount() As Integer
        Return chartControl.Legends.Length
    End Function 
    
    ' Get the Accessibility object of the child CurveLegend idetified by index.
    Public Overrides Function GetChild(index As Integer) As AccessibleObject
        If index >= 0 And index < chartControl.Legends.Length Then
            Return chartControl.Legends(index).AccessibilityObject
        End If
        Return Nothing
    End Function 
    
    ' Helper function that is used by the CurveLegend's accessibility object
    ' to navigate between sibiling controls. Specifically, this function is used in
    ' the CurveLegend.CurveLegendAccessibleObject.Navigate function.
    Friend Function NavigateFromChild(child As CurveLegend.CurveLegendAccessibleObject, _
                                    navdir As AccessibleNavigation) As AccessibleObject
        Select Case navdir
            Case AccessibleNavigation.Down, AccessibleNavigation.Next
                    Return GetChild(child.ID + 1)
            
            Case AccessibleNavigation.Up, AccessibleNavigation.Previous
                    Return GetChild(child.ID - 1)
        End Select
        Return Nothing
    End Function            

    ' Helper function that is used by the CurveLegend's accessibility object
    ' to select a specific CurveLegend control. Specifically, this function is used 
    ' in the CurveLegend.CurveLegendAccessibleObject.Select function.            
    Friend Sub SelectChild(child As CurveLegend.CurveLegendAccessibleObject, selection As AccessibleSelection)
        Dim childID As Integer = child.ID
        
        ' Determine which selection action should occur, based on the
        ' AccessibleSelection value.
        If (selection And AccessibleSelection.TakeSelection) <> 0 Then
            Dim i As Integer
            For i = 0 To chartControl.Legends.Length - 1
                If i = childID Then
                    chartControl.Legends(i).Selected = True
                Else
                    chartControl.Legends(i).Selected = False
                End If
            Next i
            
            ' AccessibleSelection.AddSelection means that the CurveLegend will be selected.
            If (selection And AccessibleSelection.AddSelection) <> 0 Then
                chartControl.Legends(childID).Selected = True
            End If

            ' AccessibleSelection.AddSelection means that the CurveLegend will be unselected.                    
            If (selection And AccessibleSelection.RemoveSelection) <> 0 Then
                chartControl.Legends(childID).Selected = False
            End If
        End If
    End Sub
End Class

備註

可存取的物件可以與其中一或多個狀態相關聯。

適用於

另請參閱