Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / wpf / src / Framework / System / Windows / Automation / Peers / GroupItemAutomationPeer.cs / 1 / 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; } /// 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; } //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; } /// 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; } //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
- Decimal.cs
- EmbeddedMailObject.cs
- SymbolTable.cs
- UnauthorizedAccessException.cs
- NavigationPropertyEmitter.cs
- SqlServices.cs
- DataGridColumn.cs
- ControlUtil.cs
- NetTcpBinding.cs
- Metafile.cs
- ObjectSpanRewriter.cs
- PlanCompiler.cs
- ArraySortHelper.cs
- Visitor.cs
- DataGridViewCellStyle.cs
- ToolStripPanelRow.cs
- GCHandleCookieTable.cs
- RunWorkerCompletedEventArgs.cs
- ObjectStorage.cs
- While.cs
- OracleConnectionFactory.cs
- DataList.cs
- followingquery.cs
- MonitoringDescriptionAttribute.cs
- Operator.cs
- DbBuffer.cs
- SqlPersonalizationProvider.cs
- PictureBox.cs
- Rotation3DAnimation.cs
- RepeaterItemCollection.cs
- SessionStateContainer.cs
- SystemWebCachingSectionGroup.cs
- StyleCollection.cs
- FacetValueContainer.cs
- VisualTarget.cs
- BooleanSwitch.cs
- CachedTypeface.cs
- WebControlAdapter.cs
- PermissionRequestEvidence.cs
- PolyBezierSegment.cs
- AtomServiceDocumentSerializer.cs
- ByteKeyFrameCollection.cs
- CodeChecksumPragma.cs
- X509SubjectKeyIdentifierClause.cs
- ValidationSummary.cs
- SiteMapNodeItem.cs
- HttpException.cs
- ToolStripStatusLabel.cs
- DataGridViewAccessibleObject.cs
- StylusDevice.cs
- SectionInformation.cs
- DataObjectPastingEventArgs.cs
- PrinterSettings.cs
- XmlUrlResolver.cs
- Activity.cs
- PropertyNames.cs
- AnnotationDocumentPaginator.cs
- Interlocked.cs
- HtmlInputFile.cs
- HttpServerUtilityWrapper.cs
- DynamicILGenerator.cs
- TextFormatterImp.cs
- DoubleKeyFrameCollection.cs
- LicenseManager.cs
- TrustLevelCollection.cs
- PreloadedPackages.cs
- DragDrop.cs
- UpDownBase.cs
- Stopwatch.cs
- InvalidateEvent.cs
- CheckBox.cs
- WebServiceParameterData.cs
- StyleXamlTreeBuilder.cs
- MessageBox.cs
- WmlImageAdapter.cs
- MessageQueueInstaller.cs
- IdnMapping.cs
- XmlTextReaderImplHelpers.cs
- ListViewHitTestInfo.cs
- VirtualDirectoryMapping.cs
- VarRefManager.cs
- TemplatedMailWebEventProvider.cs
- Enumerable.cs
- ParameterRetriever.cs
- DefaultAsyncDataDispatcher.cs
- IIS7UserPrincipal.cs
- AlphabetConverter.cs
- CodeIndexerExpression.cs
- TypeDescriptionProvider.cs
- ThreadStateException.cs
- iisPickupDirectory.cs
- COM2TypeInfoProcessor.cs
- NotifyInputEventArgs.cs
- FontClient.cs
- Peer.cs
- UnmanagedMemoryStream.cs
- SymbolEqualComparer.cs
- Line.cs
- FixedElement.cs
- ToolStripArrowRenderEventArgs.cs