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
- HttpHeaderCollection.cs
- TogglePattern.cs
- Perspective.cs
- Identity.cs
- ObjectDataSourceMethodEditor.cs
- BinaryObjectInfo.cs
- FontEmbeddingManager.cs
- ErrorFormatterPage.cs
- GPPOINTF.cs
- KeyManager.cs
- FileVersionInfo.cs
- UIElement3D.cs
- HashSetDebugView.cs
- DataGridViewDataErrorEventArgs.cs
- Trace.cs
- LayoutTable.cs
- SqlReferenceCollection.cs
- XsdCachingReader.cs
- HttpCacheParams.cs
- GAC.cs
- TextPatternIdentifiers.cs
- FileEnumerator.cs
- FunctionGenerator.cs
- OuterGlowBitmapEffect.cs
- OletxCommittableTransaction.cs
- Canvas.cs
- VBCodeProvider.cs
- CodeCommentStatement.cs
- SchemaAttDef.cs
- LineServicesRun.cs
- SHA384.cs
- FontFamily.cs
- ResourceReferenceExpressionConverter.cs
- AsymmetricSignatureDeformatter.cs
- SafeNativeMethodsCLR.cs
- RoleManagerSection.cs
- SecurityHelper.cs
- Symbol.cs
- Material.cs
- VisualStyleTypesAndProperties.cs
- ColorMap.cs
- FormatterServices.cs
- XPathNavigatorException.cs
- FontSourceCollection.cs
- ConfigurationPropertyAttribute.cs
- DbFunctionCommandTree.cs
- ExceptionUtil.cs
- x509utils.cs
- Transform3DCollection.cs
- TreeViewImageGenerator.cs
- EventHandlersStore.cs
- SelectionList.cs
- EntityDataSourceDesignerHelper.cs
- StorageEntityTypeMapping.cs
- Imaging.cs
- httpapplicationstate.cs
- FolderNameEditor.cs
- XPathNodeInfoAtom.cs
- BinaryUtilClasses.cs
- DetailsViewActionList.cs
- Column.cs
- GeneralTransformCollection.cs
- BufferBuilder.cs
- AttachmentCollection.cs
- TextServicesContext.cs
- Hash.cs
- SharedPersonalizationStateInfo.cs
- CustomBindingElement.cs
- CompositeCollectionView.cs
- localization.cs
- XmlSchemaAny.cs
- ThousandthOfEmRealDoubles.cs
- XmlDocument.cs
- XPathNavigatorKeyComparer.cs
- Part.cs
- OdbcEnvironmentHandle.cs
- dsa.cs
- SearchForVirtualItemEventArgs.cs
- sqlcontext.cs
- DataGridViewLinkCell.cs
- HtmlGenericControl.cs
- FrameworkElementAutomationPeer.cs
- View.cs
- XmlDeclaration.cs
- GrammarBuilderWildcard.cs
- ApplicationInfo.cs
- RoutedCommand.cs
- StrongNameUtility.cs
- WebPartDisplayModeCollection.cs
- StrongNameIdentityPermission.cs
- TextOnlyOutput.cs
- BrowserCapabilitiesCodeGenerator.cs
- _LocalDataStore.cs
- CanonicalXml.cs
- XmlILConstructAnalyzer.cs
- ConnectionManagementSection.cs
- EntityDataSourceContextCreatingEventArgs.cs
- XmlElementAttributes.cs
- TypeLibConverter.cs
- HostedHttpContext.cs