Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Framework / System / Windows / Automation / Peers / GridViewItemAutomationPeer.cs / 1305600 / 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
- DisplayInformation.cs
- OleDbConnectionInternal.cs
- PointLightBase.cs
- Configuration.cs
- StylusPoint.cs
- ComponentResourceManager.cs
- ChildrenQuery.cs
- IndentTextWriter.cs
- MatrixTransform3D.cs
- SoapObjectWriter.cs
- Int32CollectionConverter.cs
- CompilerInfo.cs
- SoapIncludeAttribute.cs
- PropertyGeneratedEventArgs.cs
- MetadataCache.cs
- BitmapSource.cs
- PeerNameRecord.cs
- TransformGroup.cs
- SqlOuterApplyReducer.cs
- BitmapEffect.cs
- QuadraticBezierSegment.cs
- XmlValidatingReader.cs
- _DisconnectOverlappedAsyncResult.cs
- StickyNoteHelper.cs
- InfoCardRSAPKCS1SignatureDeformatter.cs
- SQLBytesStorage.cs
- CodeMemberMethod.cs
- ActivationServices.cs
- LookupTables.cs
- ObjectStateFormatter.cs
- BamlLocalizer.cs
- XmlArrayAttribute.cs
- MouseGesture.cs
- SerializableAttribute.cs
- DesignerDataParameter.cs
- MultipleFilterMatchesException.cs
- TaskHelper.cs
- SequentialWorkflowHeaderFooter.cs
- ResourceReferenceExpressionConverter.cs
- CodeIndexerExpression.cs
- XslAstAnalyzer.cs
- TypeConverterAttribute.cs
- ConfigurationProviderException.cs
- ForEachAction.cs
- CheckoutException.cs
- HashLookup.cs
- SuppressIldasmAttribute.cs
- DesignTimeTemplateParser.cs
- IntSumAggregationOperator.cs
- MarkupObject.cs
- IOException.cs
- TemplateEditingFrame.cs
- MergeFailedEvent.cs
- AspProxy.cs
- ListItemParagraph.cs
- ImplicitInputBrush.cs
- TemplatePropertyEntry.cs
- AssociationType.cs
- UniqueEventHelper.cs
- Latin1Encoding.cs
- InternalResources.cs
- BoundingRectTracker.cs
- FrameworkElementAutomationPeer.cs
- ListViewDataItem.cs
- ProgressiveCrcCalculatingStream.cs
- UnsupportedPolicyOptionsException.cs
- CatalogPartDesigner.cs
- ToolBarDesigner.cs
- ClonableStack.cs
- documentsequencetextpointer.cs
- HttpPostedFile.cs
- StrokeFIndices.cs
- DeclaredTypeElementCollection.cs
- x509utils.cs
- SessionIDManager.cs
- SamlConstants.cs
- PropertyChangedEventArgs.cs
- NamespaceQuery.cs
- EventLogPermissionHolder.cs
- SqlInternalConnectionSmi.cs
- WindowsFormsHelpers.cs
- OdbcConnectionStringbuilder.cs
- SchemaImporterExtensionElement.cs
- mda.cs
- DocumentViewerConstants.cs
- ManifestSignatureInformation.cs
- HitTestFilterBehavior.cs
- ResourceDictionaryCollection.cs
- Schema.cs
- StringBuilder.cs
- Parameter.cs
- Quad.cs
- ArithmeticException.cs
- DataGridViewRowDividerDoubleClickEventArgs.cs
- DeflateEmulationStream.cs
- ParallelDesigner.cs
- SqlGatherProducedAliases.cs
- PackageProperties.cs
- Visitor.cs
- Point3DConverter.cs