예제 #1
0
        /// <summary>
        /// Constructor for the application window.
        /// </summary>
        public SampleApplicationForm()
        {
            InitializeComponent();

            // Create a label.
            Label listLabel = new Label();

            listLabel.Location = new Point(20, 10);
            listLabel.AutoSize = true;
            listLabel.TabIndex = 0;
            listLabel.Text     = "&Contacts:";
            this.Controls.Add(listLabel);

            // Create an instance of the custom control.
            customList      = new CustomListControl();
            customList.Name = "customList";

            // Add it to the form's controls. Among other things, this makes it possible for
            // UIAutomation to discover it, as it will become a child of the application window.
            this.Controls.Add(customList);

            // Set some properties.
            customList.Location = new Point(20, 30);
            // Text becomes the Name property for the custom control.
            customList.Text     = listLabel.Text;
            customList.TabIndex = 0;

            // Add list items.
            customList.Add("Prakash", CustomControls.Availability.Online);
            customList.Add("James", CustomControls.Availability.Online);
            customList.Add("Lisa", CustomControls.Availability.Offline);
            customList.Add("Kim", CustomControls.Availability.Online);
            customList.Add("Bailey", CustomControls.Availability.Offline);
        }
예제 #2
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="parent">The owning list.</param>
 /// <param name="text">The text of the item.</param>
 /// <param name="id">The unique identifier of the item within the list.</param>
 /// <param name="availability">The status (online or offline) of the item.</param>
 public CustomListItem(CustomListControl parent, string text, int id, Availability availability)
 {
     ItemIsAlive   = true;
     ItemOwnerList = parent;
     ItemText      = text;
     ItemId        = id;
     ItemStatus    = availability;
 }
예제 #3
0
 /// <summary>
 /// Responds to a removal from the UI Automation tree structure
 /// by raising an event.
 /// </summary>
 /// <param name="list">
 /// The list from which the item was removed.
 /// </param>
 /// <remarks>
 /// For the runtime Id of the list, pass 0 because the provider cannot know
 /// what its actual runtime ID is.
 /// </remarks>
 public static void OnStructureChangeRemove(CustomListControl list)
 {
     if (AutomationInteropProvider.ClientsAreListening)
     {
         int[] fakeRuntimeId            = { 0 };
         StructureChangedEventArgs args =
             new StructureChangedEventArgs(StructureChangeType.ChildrenBulkRemoved,
                                           fakeRuntimeId);
         AutomationInteropProvider.RaiseStructureChangedEvent(
             (IRawElementProviderSimple)list.Provider, args);
     }
 }
예제 #4
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="control">
 /// The control for which this object is providing UI Automation functionality.
 /// </param>
 public ListProvider(CustomListControl control)
 {
     OwnerListControl = control;
     WindowHandle     = control.Handle;
 }