Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / wpf / src / Framework / System / Windows / Automation / Peers / GridViewItemAutomationPeer.cs / 1 / GridViewItemAutomationPeer.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; using System.Windows.Automation.Provider; using System.Windows.Controls; using System.Windows.Controls.Primitives; using System.Windows.Interop; using System.Windows.Media; using MS.Internal; using MS.Win32; namespace System.Windows.Automation.Peers { /// public class GridViewItemAutomationPeer : ListBoxItemAutomationPeer { /// public GridViewItemAutomationPeer(object owner, ListViewAutomationPeer listviewAP) : base(owner, listviewAP) { Invariant.Assert(owner != null); Invariant.Assert(listviewAP != null); _item = owner; _listviewAP = listviewAP; } /// override protected string GetClassNameCore() { return "ListViewItem"; } /// override protected AutomationControlType GetAutomationControlTypeCore() { return AutomationControlType.DataItem; } /// protected override ListGetChildrenCore() { ListView listview = _listviewAP.Owner as ListView; Invariant.Assert(listview != null); ListViewItem lvi = listview.ItemContainerGenerator.ContainerFromItem(_item) as ListViewItem; if (lvi != null) { GridViewRowPresenter rowPresenter = GridViewAutomationPeer.FindVisualByType(lvi, typeof(GridViewRowPresenter)) as GridViewRowPresenter; if (rowPresenter != null) { Hashtable oldChildren = _dataChildren; //cache the old ones for possible reuse _dataChildren = new Hashtable(rowPresenter.ActualCells.Count); List list = new List (); int row = listview.Items.IndexOf(_item); int column = 0; foreach (UIElement ele in rowPresenter.ActualCells) { GridViewCellAutomationPeer peer = (oldChildren == null ? null : (GridViewCellAutomationPeer)oldChildren[ele]); if (peer == null) { if (ele is ContentPresenter) { peer = new GridViewCellAutomationPeer((ContentPresenter)ele, _listviewAP); } else if (ele is TextBlock) { peer = new GridViewCellAutomationPeer((TextBlock)ele, _listviewAP); } else { Invariant.Assert(false, "Children of GridViewRowPresenter should be ContentPresenter or TextBlock"); } } //protection from indistinguishable UIElement - for example, 2 UIElement wiht same value if (_dataChildren[ele] == null) { //Set Cell's row and column peer.Column = column; peer.Row = row; list.Add(peer); _dataChildren.Add(ele, peer); column++; } } return list; } } return null; } #region Private Fields private object _item; private ListViewAutomationPeer _listviewAP; private Hashtable _dataChildren = null; #endregion } } // 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; using System.Windows.Automation.Provider; using System.Windows.Controls; using System.Windows.Controls.Primitives; using System.Windows.Interop; using System.Windows.Media; using MS.Internal; using MS.Win32; namespace System.Windows.Automation.Peers { /// public class GridViewItemAutomationPeer : ListBoxItemAutomationPeer { /// public GridViewItemAutomationPeer(object owner, ListViewAutomationPeer listviewAP) : base(owner, listviewAP) { Invariant.Assert(owner != null); Invariant.Assert(listviewAP != null); _item = owner; _listviewAP = listviewAP; } /// override protected string GetClassNameCore() { return "ListViewItem"; } /// override protected AutomationControlType GetAutomationControlTypeCore() { return AutomationControlType.DataItem; } /// protected override List GetChildrenCore() { ListView listview = _listviewAP.Owner as ListView; Invariant.Assert(listview != null); ListViewItem lvi = listview.ItemContainerGenerator.ContainerFromItem(_item) as ListViewItem; if (lvi != null) { GridViewRowPresenter rowPresenter = GridViewAutomationPeer.FindVisualByType(lvi, typeof(GridViewRowPresenter)) as GridViewRowPresenter; if (rowPresenter != null) { Hashtable oldChildren = _dataChildren; //cache the old ones for possible reuse _dataChildren = new Hashtable(rowPresenter.ActualCells.Count); List list = new List (); int row = listview.Items.IndexOf(_item); int column = 0; foreach (UIElement ele in rowPresenter.ActualCells) { GridViewCellAutomationPeer peer = (oldChildren == null ? null : (GridViewCellAutomationPeer)oldChildren[ele]); if (peer == null) { if (ele is ContentPresenter) { peer = new GridViewCellAutomationPeer((ContentPresenter)ele, _listviewAP); } else if (ele is TextBlock) { peer = new GridViewCellAutomationPeer((TextBlock)ele, _listviewAP); } else { Invariant.Assert(false, "Children of GridViewRowPresenter should be ContentPresenter or TextBlock"); } } //protection from indistinguishable UIElement - for example, 2 UIElement wiht same value if (_dataChildren[ele] == null) { //Set Cell's row and column peer.Column = column; peer.Row = row; list.Add(peer); _dataChildren.Add(ele, peer); column++; } } return list; } } return null; } #region Private Fields private object _item; private ListViewAutomationPeer _listviewAP; private Hashtable _dataChildren = null; #endregion } } // 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
- XmlSerializerFaultFormatter.cs
- SafeSecurityHelper.cs
- ConstantCheck.cs
- PropertyGeneratedEventArgs.cs
- TextBounds.cs
- Inline.cs
- FixUpCollection.cs
- Rfc2898DeriveBytes.cs
- Thread.cs
- QuotedStringWriteStateInfo.cs
- CompareValidator.cs
- UIInitializationException.cs
- EntityKeyElement.cs
- TickBar.cs
- ListView.cs
- SystemWebExtensionsSectionGroup.cs
- StringConcat.cs
- UInt32Storage.cs
- DoubleCollectionConverter.cs
- ValuePatternIdentifiers.cs
- AudioDeviceOut.cs
- Relationship.cs
- ClientRoleProvider.cs
- PixelShader.cs
- ErrorFormatterPage.cs
- linebase.cs
- TextTrailingWordEllipsis.cs
- InstanceHandleConflictException.cs
- ChildDocumentBlock.cs
- NGCSerializer.cs
- JavaScriptSerializer.cs
- SoapException.cs
- Directory.cs
- DefaultObjectMappingItemCollection.cs
- DocumentXPathNavigator.cs
- ProfileSettingsCollection.cs
- HijriCalendar.cs
- formatter.cs
- DataKeyArray.cs
- SafeCryptContextHandle.cs
- HyperLinkField.cs
- ListGeneralPage.cs
- BitmapEffectDrawingContent.cs
- IISMapPath.cs
- tooltip.cs
- DescendantOverDescendantQuery.cs
- SingleConverter.cs
- PolicyConversionContext.cs
- SynchronousReceiveBehavior.cs
- Size3D.cs
- FontStretch.cs
- TextTreeRootTextBlock.cs
- SQLUtility.cs
- PropertyConverter.cs
- IdentityReference.cs
- DataPagerFieldItem.cs
- AssemblyFilter.cs
- SystemInformation.cs
- CodeDelegateCreateExpression.cs
- DelayedRegex.cs
- ExclusiveNamedPipeTransportManager.cs
- TargetFrameworkAttribute.cs
- ZoneIdentityPermission.cs
- x509utils.cs
- StandardCommands.cs
- ExpressionSelection.cs
- VisualBrush.cs
- DesignerActionUIStateChangeEventArgs.cs
- CommentEmitter.cs
- IsolatedStoragePermission.cs
- MemberRelationshipService.cs
- SchemaImporterExtensionElementCollection.cs
- GridPattern.cs
- LogRestartAreaEnumerator.cs
- ApplicationInfo.cs
- DynamicQueryableWrapper.cs
- ListViewItem.cs
- OletxTransactionFormatter.cs
- AdapterDictionary.cs
- ImageDrawing.cs
- SmtpNetworkElement.cs
- WebPartZone.cs
- ComIntegrationManifestGenerator.cs
- TextBoxAutomationPeer.cs
- HostingEnvironmentException.cs
- TreeNodeStyle.cs
- SQLCharsStorage.cs
- Html32TextWriter.cs
- HtmlInputImage.cs
- WebSysDefaultValueAttribute.cs
- UserInitiatedNavigationPermission.cs
- PathStreamGeometryContext.cs
- WasEndpointConfigContainer.cs
- XmlnsCompatibleWithAttribute.cs
- BinaryFormatter.cs
- ConfigXmlAttribute.cs
- ContentDefinition.cs
- UriParserTemplates.cs
- ValidationError.cs
- Descriptor.cs