Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Framework / System / Windows / Automation / Peers / GroupItemAutomationPeer.cs / 1477467 / GroupItemAutomationPeer.cs
using System; using System.Collections; using System.Collections.Generic; using System.Runtime.InteropServices; using System.Security; using System.Text; using System.Windows; using System.Windows.Automation.Provider; using System.Windows.Controls; using System.Windows.Controls.Primitives; using System.Windows.Data; using System.Windows.Interop; using System.Windows.Media; using MS.Internal; using MS.Win32; namespace System.Windows.Automation.Peers { /// public class GroupItemAutomationPeer : FrameworkElementAutomationPeer { /// public GroupItemAutomationPeer(GroupItem owner): base(owner) { } /// override protected string GetClassNameCore() { return "GroupItem"; } /// override protected AutomationControlType GetAutomationControlTypeCore() { return AutomationControlType.Group; } /// override protected bool IsOffscreenCore() { if (!Owner.IsVisible) return true; Rect boundingRect = CalculateVisibleBoundingRect(); return (boundingRect == Rect.Empty || boundingRect.Height == 0 || boundingRect.Width == 0); } /// protected override ListGetChildrenCore() { GroupItem owner = (GroupItem)Owner; ItemsControl itemsControl = ItemsControl.ItemsControlFromItemContainer(Owner); if (itemsControl != null) { ItemsControlAutomationPeer itemsControlAP = itemsControl.CreateAutomationPeer() as ItemsControlAutomationPeer; if (itemsControlAP != null) { ItemContainerGenerator generator = owner.Generator; if (generator != null) { IList items = generator.Items; List children = new List (items.Count); ItemPeersStorage oldChildren = _dataChildren; //cache the old ones for possible reuse _dataChildren = new ItemPeersStorage (); if (items.Count > 0) { foreach (object item in items) { CollectionViewGroup cvg = item as CollectionViewGroup; if (cvg != null) { GroupItem groupItem = generator.ContainerFromItem(item) as GroupItem; if (groupItem != null) { GroupItemAutomationPeer peer = groupItem.CreateAutomationPeer() as GroupItemAutomationPeer; if (peer != null) children.Add(peer); } } else { //try to reuse old peer if it exists ItemAutomationPeer peer = oldChildren[item]; //no old peer - create new one if (peer == null) peer = itemsControlAP.CreateItemAutomationPeerInternal(item); //perform hookup so the events sourced from wrapper peer are fired as if from the data item if (peer != null) { AutomationPeer wrapperPeer = peer.GetWrapperPeer(); if (wrapperPeer != null) { wrapperPeer.EventsSource = peer; if (peer.ChildrenValid && peer.Children == null && this.AncestorsInvalid) { peer.AncestorsInvalid = true; wrapperPeer.AncestorsInvalid = true; } } } //protection from indistinguishable items - for example, 2 strings with same value //this scenario does not work in ItemsControl however is not checked for. if (_dataChildren[item] == null) { children.Add(peer); _dataChildren[item] = peer; // Update ItemsControl cache too // ItemPeers needs to be updated because used in Selector and other ItemsControl subclasses to access item peers directly if (itemsControlAP.ItemPeers[item] == null) { itemsControlAP.ItemPeers[item] = peer; } } } } return children; } } } } return null; } private ItemPeersStorage _dataChildren = new ItemPeersStorage (); } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. using System; using System.Collections; using System.Collections.Generic; using System.Runtime.InteropServices; using System.Security; using System.Text; using System.Windows; using System.Windows.Automation.Provider; using System.Windows.Controls; using System.Windows.Controls.Primitives; using System.Windows.Data; using System.Windows.Interop; using System.Windows.Media; using MS.Internal; using MS.Win32; namespace System.Windows.Automation.Peers { /// public class GroupItemAutomationPeer : FrameworkElementAutomationPeer { /// public GroupItemAutomationPeer(GroupItem owner): base(owner) { } /// override protected string GetClassNameCore() { return "GroupItem"; } /// override protected AutomationControlType GetAutomationControlTypeCore() { return AutomationControlType.Group; } /// override protected bool IsOffscreenCore() { if (!Owner.IsVisible) return true; Rect boundingRect = CalculateVisibleBoundingRect(); return (boundingRect == Rect.Empty || boundingRect.Height == 0 || boundingRect.Width == 0); } /// protected override List GetChildrenCore() { GroupItem owner = (GroupItem)Owner; ItemsControl itemsControl = ItemsControl.ItemsControlFromItemContainer(Owner); if (itemsControl != null) { ItemsControlAutomationPeer itemsControlAP = itemsControl.CreateAutomationPeer() as ItemsControlAutomationPeer; if (itemsControlAP != null) { ItemContainerGenerator generator = owner.Generator; if (generator != null) { IList items = generator.Items; List children = new List (items.Count); ItemPeersStorage oldChildren = _dataChildren; //cache the old ones for possible reuse _dataChildren = new ItemPeersStorage (); if (items.Count > 0) { foreach (object item in items) { CollectionViewGroup cvg = item as CollectionViewGroup; if (cvg != null) { GroupItem groupItem = generator.ContainerFromItem(item) as GroupItem; if (groupItem != null) { GroupItemAutomationPeer peer = groupItem.CreateAutomationPeer() as GroupItemAutomationPeer; if (peer != null) children.Add(peer); } } else { //try to reuse old peer if it exists ItemAutomationPeer peer = oldChildren[item]; //no old peer - create new one if (peer == null) peer = itemsControlAP.CreateItemAutomationPeerInternal(item); //perform hookup so the events sourced from wrapper peer are fired as if from the data item if (peer != null) { AutomationPeer wrapperPeer = peer.GetWrapperPeer(); if (wrapperPeer != null) { wrapperPeer.EventsSource = peer; if (peer.ChildrenValid && peer.Children == null && this.AncestorsInvalid) { peer.AncestorsInvalid = true; wrapperPeer.AncestorsInvalid = true; } } } //protection from indistinguishable items - for example, 2 strings with same value //this scenario does not work in ItemsControl however is not checked for. if (_dataChildren[item] == null) { children.Add(peer); _dataChildren[item] = peer; // Update ItemsControl cache too // ItemPeers needs to be updated because used in Selector and other ItemsControl subclasses to access item peers directly if (itemsControlAP.ItemPeers[item] == null) { itemsControlAP.ItemPeers[item] = peer; } } } } return children; } } } } return null; } private ItemPeersStorage _dataChildren = new ItemPeersStorage (); } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- AuthorizationSection.cs
- WindowsScroll.cs
- SkipStoryboardToFill.cs
- ExpressionConverter.cs
- EditorBrowsableAttribute.cs
- TemplateKeyConverter.cs
- OleDbRowUpdatingEvent.cs
- DropDownButton.cs
- webproxy.cs
- BaseDataBoundControl.cs
- Nullable.cs
- PermissionToken.cs
- ReadOnlyHierarchicalDataSource.cs
- RectAnimationBase.cs
- EventLogPermissionAttribute.cs
- Int16Converter.cs
- MulticastIPAddressInformationCollection.cs
- GlobalizationSection.cs
- AgileSafeNativeMemoryHandle.cs
- UInt16Converter.cs
- ChildrenQuery.cs
- WsdlInspector.cs
- DoWorkEventArgs.cs
- ButtonFlatAdapter.cs
- SupportsEventValidationAttribute.cs
- _Rfc2616CacheValidators.cs
- EncoderParameters.cs
- Point4D.cs
- PixelShader.cs
- FrugalMap.cs
- ResourceCategoryAttribute.cs
- thaishape.cs
- BooleanFunctions.cs
- Point4DConverter.cs
- ByteStreamMessage.cs
- ValueUnavailableException.cs
- XmlSchemaDocumentation.cs
- OleDbError.cs
- Point3DIndependentAnimationStorage.cs
- MD5.cs
- WindowsButton.cs
- SignatureToken.cs
- OutputCacheModule.cs
- SmtpSpecifiedPickupDirectoryElement.cs
- ExpressionBuilderCollection.cs
- ProbeMatchesMessageCD1.cs
- ScrollViewer.cs
- AudioSignalProblemOccurredEventArgs.cs
- Unit.cs
- CommonGetThemePartSize.cs
- InstancePersistenceCommand.cs
- QueryLifecycle.cs
- LicenseManager.cs
- DataTableTypeConverter.cs
- XmlSchemaObjectCollection.cs
- Vector3DValueSerializer.cs
- mansign.cs
- ValueType.cs
- HwndAppCommandInputProvider.cs
- MouseCaptureWithinProperty.cs
- SafeNativeMethods.cs
- HtmlTableCellCollection.cs
- SoapTypeAttribute.cs
- FormViewDeletedEventArgs.cs
- WsatConfiguration.cs
- RootDesignerSerializerAttribute.cs
- SHA256Cng.cs
- ClientData.cs
- ApplicationServiceManager.cs
- ValidationSummary.cs
- Monitor.cs
- FormViewRow.cs
- ObjectNavigationPropertyMapping.cs
- WindowsTokenRoleProvider.cs
- LocalFileSettingsProvider.cs
- SmtpDigestAuthenticationModule.cs
- RewritingValidator.cs
- FunctionQuery.cs
- BuilderPropertyEntry.cs
- TdsParameterSetter.cs
- ContextMenuStripGroupCollection.cs
- QilBinary.cs
- DoubleLinkListEnumerator.cs
- RSAPKCS1KeyExchangeDeformatter.cs
- Certificate.cs
- ReflectTypeDescriptionProvider.cs
- ASCIIEncoding.cs
- ContentPropertyAttribute.cs
- DataSourceView.cs
- FilterEventArgs.cs
- BatchWriter.cs
- EncryptedData.cs
- CollaborationHelperFunctions.cs
- CacheAxisQuery.cs
- OperatingSystem.cs
- SmtpNtlmAuthenticationModule.cs
- ConfigurationValidatorAttribute.cs
- Point4D.cs
- StringToken.cs
- XhtmlTextWriter.cs