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 / 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
- ResourceReferenceExpression.cs
- ListMarkerLine.cs
- KernelTypeValidation.cs
- XamlFigureLengthSerializer.cs
- MetaModel.cs
- xml.cs
- ScopedKnownTypes.cs
- OrthographicCamera.cs
- WinCategoryAttribute.cs
- BinaryObjectInfo.cs
- IIS7WorkerRequest.cs
- PageAsyncTaskManager.cs
- CodeStatement.cs
- ControlAdapter.cs
- FontWeight.cs
- SHA512Managed.cs
- PartialCachingControl.cs
- cookieexception.cs
- FixedSOMPageConstructor.cs
- ImageMetadata.cs
- ControlIdConverter.cs
- OutputCacheProfile.cs
- DataBoundControlHelper.cs
- IArgumentProvider.cs
- codemethodreferenceexpression.cs
- VScrollBar.cs
- ExecutionProperties.cs
- SmtpClient.cs
- ConfigViewGenerator.cs
- GroupBox.cs
- WebColorConverter.cs
- Helpers.cs
- VerificationException.cs
- SchemaImporterExtensionElement.cs
- TimeSpanSecondsConverter.cs
- DataGridViewSelectedRowCollection.cs
- TreeViewItem.cs
- QuotedStringWriteStateInfo.cs
- MobileListItemCollection.cs
- PrinterSettings.cs
- SmtpSpecifiedPickupDirectoryElement.cs
- FileLogRecordEnumerator.cs
- SQLResource.cs
- WebPartMenu.cs
- TreeViewImageKeyConverter.cs
- WebResourceAttribute.cs
- SplitterPanel.cs
- SortKey.cs
- TypedTableBase.cs
- QuaternionRotation3D.cs
- SectionVisual.cs
- sqlser.cs
- ConfigUtil.cs
- DbParameterHelper.cs
- ImportContext.cs
- ThousandthOfEmRealPoints.cs
- ExpressionConverter.cs
- PrintDialogDesigner.cs
- HuffmanTree.cs
- SByte.cs
- Scene3D.cs
- WindowsMenu.cs
- GeometryHitTestResult.cs
- EncoderParameters.cs
- TextTreeUndo.cs
- StructuralComparisons.cs
- RelatedImageListAttribute.cs
- CheckBoxAutomationPeer.cs
- TextFormatter.cs
- ConsumerConnectionPointCollection.cs
- CheckBox.cs
- ApplicationActivator.cs
- SystemIPv6InterfaceProperties.cs
- ContentType.cs
- SolidBrush.cs
- SerialErrors.cs
- ReadOnlyCollection.cs
- Types.cs
- PaperSource.cs
- Line.cs
- RelatedPropertyManager.cs
- ScriptComponentDescriptor.cs
- SafeNativeMethods.cs
- xmlsaver.cs
- UnhandledExceptionEventArgs.cs
- UidManager.cs
- DependencyObjectProvider.cs
- HtmlPanelAdapter.cs
- WorkerRequest.cs
- SoapSchemaExporter.cs
- ParseElement.cs
- AttributeProviderAttribute.cs
- ApplicationBuildProvider.cs
- NumericExpr.cs
- LookupTables.cs
- TimeoutHelper.cs
- XmlRootAttribute.cs
- PeerApplicationLaunchInfo.cs
- LexicalChunk.cs
- SwitchAttribute.cs