Exemple #1
0
        protected override void WndProc(ref Message winMessage)
        {
            const int WM_GETOBJECT = 0x003D;

            if (winMessage.Msg == WM_GETOBJECT)
            {
                if (!AutomationIsActive)
                {
                    // If no provider has been created, then create one.
                    myListProvider = new ListProvider(this);

                    // Create providers for each existing item in the list.
                    foreach (CustomListItem listItem in itemsArray)
                    {
                        listItem.Provider = new ListItemProvider(myListProvider, listItem);
                    }
                }

                winMessage.Result =
                    AutomationInteropProvider.ReturnRawElementProvider(
                        Handle, winMessage.WParam, winMessage.LParam, myListProvider);
                return;
            }
            base.WndProc(ref winMessage);
        }
Exemple #2
0
        /// <summary>
        /// Adds an item to the list.
        /// </summary>
        /// <param name="item">Index at which to add the item.</param>
        /// <param name="a">Item to add.</param>
        /// <returns>true if successful.</returns>
        public bool Add(string item, Availability a)
        {
            if (itemsArray.Count < maxNumberOfItems)
            {
                CustomListItem listItem;
                listItem = new CustomListItem(this, item, this.UniqueId, a);
                itemsArray.Add(listItem);

                // Initialize the selection if necessary.
                if (currentSelection < 0)
                {
                    currentSelection    = 0;
                    listItem.IsSelected = true;
                }
                this.Invalidate(); // update to draw new added item

                // Raise a UI Automation event.
                if (myListProvider != null)
                {
                    ListProvider.OnStructureChangeAdd(listItem.Container);
                }
                return(true);
            }
            return(false);
        }
Exemple #3
0
        /// <summary>
        /// Removes an item from the list.
        /// </summary>
        /// <param name="itemIndex">Index of the item.</param>
        /// <returns>true if successful.</returns>
        public bool Remove(int itemIndex)
        {
            if ((this.ItemCount == minNumberOfItems) || (itemIndex <= -1) || (itemIndex >= this.ItemCount))
            {
                // If the number of items in the list is already at minimum,
                // no additional items can be removed.
                return(false);
            }
            CustomListItem itemToBeRemoved = (CustomListItem)itemsArray[itemIndex];

            // Notify the provider that item it going to be destroyed.
            itemToBeRemoved.IsAlive = false;

            // Force refresh.
            this.Invalidate();

            // Raise notification.
            if (myListProvider != null)
            {
                ListProvider.OnStructureChangeRemove(itemToBeRemoved.Container);
            }
            itemsArray.RemoveAt(itemIndex);
            currentSelection = 0;  // Reset selection to first item.

            return(true);
        }
Exemple #4
0
        /// <summary>
        /// Selects an item in the list.
        /// </summary>
        /// <param name="index">Index of the item to select.</param>
        private void InternalSelect(int index)
        {
            if ((index >= itemsArray.Count) || (index < 0))
            {
                throw new ArgumentOutOfRangeException();
            }
            else
            {
                if (currentSelection != index)
                {
                    ((CustomListItem)itemsArray[currentSelection]).IsSelected = false;
                    ((CustomListItem)itemsArray[index]).IsSelected            = true;
                    currentSelection = index;
                    // Force refresh.
                    Invalidate();
                    CustomControls.ListProvider.OnSelectionChange((CustomListItem)itemsArray[index]);
                }

                // Raise an event.
                ListProvider.OnFocusChange((CustomListItem)itemsArray[index]);
            }
        }
Exemple #5
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="rootProvider">UI Automation provider for the
 /// fragment root (the containing list).</param>
 /// <param name="thisItem">The control that owns this provider.</param>
 public ListItemProvider(ListProvider rootProvider, CustomListItem thisItem)
 {
     ContainingListProvider = rootProvider;
     ListItemControl        = thisItem;
 }
Exemple #6
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="rootProvider">
 /// UI Automation provider for the fragment root (the containing list).
 /// </param>
 /// <param name="thisItem">The control that owns this provider.</param>
 public ListItemProvider(ListProvider rootProvider, CustomListItem thisItem)
 {
     containerListProvider = rootProvider;
     listItemControl       = thisItem;
     selectedItems         = new ArrayList();
 }