Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / wpf / src / Framework / System / Windows / Automation / Peers / StatusBarAutomationPeer.cs / 1 / StatusBarAutomationPeer.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.Interop; using System.Windows.Media; using MS.Internal; using MS.Win32; namespace System.Windows.Automation.Peers { /// public class StatusBarAutomationPeer : FrameworkElementAutomationPeer { /// public StatusBarAutomationPeer(StatusBar owner): base(owner) {} /// protected override string GetClassNameCore() { return "StatusBar"; } /// protected override AutomationControlType GetAutomationControlTypeCore() { return AutomationControlType.StatusBar; } /// protected override ListGetChildrenCore() { List list = new List (); ItemsControl itemscontrol = Owner as ItemsControl; if (itemscontrol != null) { foreach (object obj in itemscontrol.Items) { if (obj is Separator) { Separator separator = obj as Separator; list.Add(UIElementAutomationPeer.CreatePeerForElement(separator)); } else { StatusBarItem item = itemscontrol.ItemContainerGenerator.ContainerFromItem(obj) as StatusBarItem; if (item != null) { //If the item is a string or TextBlock or StatusBarItem //StatusBarItemAutomationPeer will be created to show the text //Or we'll use the control's automation peer if (obj is string || obj is TextBlock || (obj is StatusBarItem && ((StatusBarItem)obj).Content is string)) { list.Add(UIElementAutomationPeer.CreatePeerForElement(item)); } else { List childList = GetChildrenAutomationPeer(item); if (childList != null) { foreach (AutomationPeer ap in childList) { list.Add(ap); } } } } } } } return list; } /// /// Get the children of the parent which has automation peer /// private ListGetChildrenAutomationPeer(Visual parent) { Invariant.Assert(parent != null); List children = null; iterate(parent, (IteratorCallback)delegate(AutomationPeer peer) { if (children == null) children = new List (); children.Add(peer); return (false); }); return children; } private delegate bool IteratorCallback(AutomationPeer peer); // private static bool iterate(Visual parent, IteratorCallback callback) { bool done = false; AutomationPeer peer = null; int count = parent.InternalVisualChildrenCount; for (int i = 0; i < count && !done; i++) { Visual child = parent.InternalGetVisualChild(i); if (child != null && child.CheckFlagsAnd(VisualFlags.IsUIElement) && (peer = CreatePeerForElement((UIElement)child)) != null) { done = callback(peer); } else { done = iterate(child, callback); } } return (done); } } } // 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.Interop; using System.Windows.Media; using MS.Internal; using MS.Win32; namespace System.Windows.Automation.Peers { /// public class StatusBarAutomationPeer : FrameworkElementAutomationPeer { /// public StatusBarAutomationPeer(StatusBar owner): base(owner) {} /// protected override string GetClassNameCore() { return "StatusBar"; } /// protected override AutomationControlType GetAutomationControlTypeCore() { return AutomationControlType.StatusBar; } /// protected override List GetChildrenCore() { List list = new List (); ItemsControl itemscontrol = Owner as ItemsControl; if (itemscontrol != null) { foreach (object obj in itemscontrol.Items) { if (obj is Separator) { Separator separator = obj as Separator; list.Add(UIElementAutomationPeer.CreatePeerForElement(separator)); } else { StatusBarItem item = itemscontrol.ItemContainerGenerator.ContainerFromItem(obj) as StatusBarItem; if (item != null) { //If the item is a string or TextBlock or StatusBarItem //StatusBarItemAutomationPeer will be created to show the text //Or we'll use the control's automation peer if (obj is string || obj is TextBlock || (obj is StatusBarItem && ((StatusBarItem)obj).Content is string)) { list.Add(UIElementAutomationPeer.CreatePeerForElement(item)); } else { List childList = GetChildrenAutomationPeer(item); if (childList != null) { foreach (AutomationPeer ap in childList) { list.Add(ap); } } } } } } } return list; } /// /// Get the children of the parent which has automation peer /// private ListGetChildrenAutomationPeer(Visual parent) { Invariant.Assert(parent != null); List children = null; iterate(parent, (IteratorCallback)delegate(AutomationPeer peer) { if (children == null) children = new List (); children.Add(peer); return (false); }); return children; } private delegate bool IteratorCallback(AutomationPeer peer); // private static bool iterate(Visual parent, IteratorCallback callback) { bool done = false; AutomationPeer peer = null; int count = parent.InternalVisualChildrenCount; for (int i = 0; i < count && !done; i++) { Visual child = parent.InternalGetVisualChild(i); if (child != null && child.CheckFlagsAnd(VisualFlags.IsUIElement) && (peer = CreatePeerForElement((UIElement)child)) != null) { done = callback(peer); } else { done = iterate(child, callback); } } return (done); } } } // 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
- DataGrid.cs
- RadioButtonFlatAdapter.cs
- RoutedEventArgs.cs
- FormViewDesigner.cs
- CodePropertyReferenceExpression.cs
- HierarchicalDataBoundControlAdapter.cs
- DataTable.cs
- OrderByBuilder.cs
- EventQueueState.cs
- MessageEnumerator.cs
- ResourcePool.cs
- Event.cs
- DocumentViewer.cs
- AutomationInteropProvider.cs
- PreviewKeyDownEventArgs.cs
- Size3D.cs
- HMACSHA384.cs
- MediaEntryAttribute.cs
- CodeCastExpression.cs
- TypedElement.cs
- AmbientProperties.cs
- WindowsListViewItemCheckBox.cs
- PersistencePipeline.cs
- TraceSection.cs
- QuaternionRotation3D.cs
- HebrewCalendar.cs
- Rect3DConverter.cs
- TabControlToolboxItem.cs
- SolidColorBrush.cs
- Compiler.cs
- HtmlWindow.cs
- BackgroundWorker.cs
- connectionpool.cs
- EncodingInfo.cs
- BlockCollection.cs
- ObjectComplexPropertyMapping.cs
- DataGridViewRowConverter.cs
- MapPathBasedVirtualPathProvider.cs
- XPathDocument.cs
- ImageClickEventArgs.cs
- MetadataCollection.cs
- DataFormats.cs
- ImageClickEventArgs.cs
- MethodCallConverter.cs
- IFormattable.cs
- GridViewColumnHeader.cs
- DictionaryBase.cs
- MouseButtonEventArgs.cs
- IdentityReference.cs
- ScopelessEnumAttribute.cs
- XPathParser.cs
- Stylesheet.cs
- DictionarySectionHandler.cs
- FilteredAttributeCollection.cs
- LineVisual.cs
- NonBatchDirectoryCompiler.cs
- SecurityHelper.cs
- ServiceDescriptionData.cs
- WebPartConnectionsDisconnectVerb.cs
- ResourceDescriptionAttribute.cs
- RadioButtonRenderer.cs
- Matrix3DConverter.cs
- XmlException.cs
- ParenthesizePropertyNameAttribute.cs
- InvalidPrinterException.cs
- DataGridViewSortCompareEventArgs.cs
- WsdlImporter.cs
- ContentType.cs
- MenuTracker.cs
- InputMethodStateTypeInfo.cs
- SqlDataSourceView.cs
- Version.cs
- CalendarDesigner.cs
- ConstantCheck.cs
- TemplateComponentConnector.cs
- UserMapPath.cs
- ApplicationServiceHelper.cs
- ControlValuePropertyAttribute.cs
- ModelFunction.cs
- ipaddressinformationcollection.cs
- RecognitionEventArgs.cs
- ConfigurationStrings.cs
- InvalidMessageContractException.cs
- DbProviderFactory.cs
- ReadOnlyDataSource.cs
- X509ChainPolicy.cs
- System.Data_BID.cs
- EdmTypeAttribute.cs
- FromRequest.cs
- GCHandleCookieTable.cs
- StreamInfo.cs
- UnsafeNativeMethods.cs
- SiteMembershipCondition.cs
- DataGridRelationshipRow.cs
- MessageSecurityOverMsmqElement.cs
- RegionInfo.cs
- BlurBitmapEffect.cs
- WebResponse.cs
- SchemaObjectWriter.cs
- WindowsListViewScroll.cs