internal void RaiseSelectionEvents(SelectionChangedEventArgs e) { if (base.ItemPeers.Count == 0) { base.RaiseAutomationEvent(AutomationEvents.SelectionPatternOnInvalidated); return; } Selector selector = (Selector)base.Owner; int count = selector._selectedItems.Count; int count2 = e.AddedItems.Count; int count3 = e.RemovedItems.Count; if (count == 1 && count2 == 1) { SelectorItemAutomationPeer selectorItemAutomationPeer = this.FindOrCreateItemAutomationPeer(selector._selectedItems[0].Item) as SelectorItemAutomationPeer; if (selectorItemAutomationPeer != null) { selectorItemAutomationPeer.RaiseAutomationEvent(AutomationEvents.SelectionItemPatternOnElementSelected); return; } } else { if (count2 + count3 > 20) { base.RaiseAutomationEvent(AutomationEvents.SelectionPatternOnInvalidated); return; } for (int i = 0; i < count2; i++) { SelectorItemAutomationPeer selectorItemAutomationPeer2 = this.FindOrCreateItemAutomationPeer(e.AddedItems[i]) as SelectorItemAutomationPeer; if (selectorItemAutomationPeer2 != null) { selectorItemAutomationPeer2.RaiseAutomationEvent(AutomationEvents.SelectionItemPatternOnElementAddedToSelection); } } for (int i = 0; i < count3; i++) { SelectorItemAutomationPeer selectorItemAutomationPeer3 = this.FindOrCreateItemAutomationPeer(e.RemovedItems[i]) as SelectorItemAutomationPeer; if (selectorItemAutomationPeer3 != null) { selectorItemAutomationPeer3.RaiseAutomationEvent(AutomationEvents.SelectionItemPatternOnElementRemovedFromSelection); } } } }
/// <summary>This type or member supports the Windows Presentation Foundation (WPF) infrastructure and is not intended to be used directly from your code.</summary> /// <returns>A collection of UI Automation providers. true if multiple selection is allowed; otherwise false.</returns> // Token: 0x060027EE RID: 10222 RVA: 0x000BB1F4 File Offset: 0x000B93F4 IRawElementProviderSimple[] ISelectionProvider.GetSelection() { Selector selector = (Selector)base.Owner; int count = selector._selectedItems.Count; int count2 = selector.Items.Count; if (count > 0 && count2 > 0) { List <IRawElementProviderSimple> list = new List <IRawElementProviderSimple>(count); for (int i = 0; i < count; i++) { SelectorItemAutomationPeer selectorItemAutomationPeer = this.FindOrCreateItemAutomationPeer(selector._selectedItems[i].Item) as SelectorItemAutomationPeer; if (selectorItemAutomationPeer != null) { list.Add(base.ProviderFromPeer(selectorItemAutomationPeer)); } } return(list.ToArray()); } return(null); }
//------------------------------------------------------------------- // // ISelectionProvider // //------------------------------------------------------------------- #region ISelectionProvider IRawElementProviderSimple [] ISelectionProvider.GetSelection() { Selector owner = (Selector)Owner; int count = owner._selectedItems.Count; int itemsCount = (owner as ItemsControl).Items.Count; if (count > 0 && itemsCount > 0) { List <IRawElementProviderSimple> selectedProviders = new List <IRawElementProviderSimple>(count); for (int i = 0; i < count; i++) { SelectorItemAutomationPeer peer = FindOrCreateItemAutomationPeer(owner._selectedItems[i].Item) as SelectorItemAutomationPeer; if (peer != null) { selectedProviders.Add(ProviderFromPeer(peer)); } } return(selectedProviders.ToArray()); } return(null); }
internal void RaiseSelectionEvents(SelectionChangedEventArgs e) { if (ItemPeers.Count == 0) { // ItemPeers.Count == 0 if children were never fetched. // in the case, when client probably is not interested in the details // of selection changes. but we still want to notify client about it. this.RaiseAutomationEvent(AutomationEvents.SelectionPatternOnInvalidated); return; } Selector owner = (Selector)Owner; // These counters are bound to selection only numAdded = number of items just added and included in the current selection, // numRemoved = number of items just removed from the selection, numSelected = total number of items currently selected after addition and removal. int numSelected = owner._selectedItems.Count; int numAdded = e.AddedItems.Count; int numRemoved = e.RemovedItems.Count; if (numSelected == 1 && numAdded == 1) { SelectorItemAutomationPeer peer = FindOrCreateItemAutomationPeer(owner._selectedItems[0].Item) as SelectorItemAutomationPeer; if (peer != null) { peer.RaiseAutomationEvent(AutomationEvents.SelectionItemPatternOnElementSelected); } } else { // If more than InvalidateLimit element change their state then we invalidate the selection container // Otherwise we fire Add/Remove from selection events if (numAdded + numRemoved > AutomationInteropProvider.InvalidateLimit) { this.RaiseAutomationEvent(AutomationEvents.SelectionPatternOnInvalidated); } else { int i; for (i = 0; i < numAdded; i++) { SelectorItemAutomationPeer peer = FindOrCreateItemAutomationPeer(e.AddedItems[i]) as SelectorItemAutomationPeer; if (peer != null) { peer.RaiseAutomationEvent(AutomationEvents.SelectionItemPatternOnElementAddedToSelection); } } for (i = 0; i < numRemoved; i++) { SelectorItemAutomationPeer peer = FindOrCreateItemAutomationPeer(e.RemovedItems[i]) as SelectorItemAutomationPeer; if (peer != null) { peer.RaiseAutomationEvent(AutomationEvents.SelectionItemPatternOnElementRemovedFromSelection); } } } } }