Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / 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
- PointAnimationUsingPath.cs
- UIElementParagraph.cs
- GridViewUpdateEventArgs.cs
- LoginCancelEventArgs.cs
- DBDataPermissionAttribute.cs
- DataGridViewColumnCollectionDialog.cs
- TreeViewAutomationPeer.cs
- PartManifestEntry.cs
- FamilyTypeface.cs
- AsnEncodedData.cs
- SyndicationSerializer.cs
- SmtpSection.cs
- InlineCollection.cs
- Propagator.JoinPropagator.cs
- Rect.cs
- InputScopeAttribute.cs
- XPathMessageFilterElementComparer.cs
- MediaCommands.cs
- GeometryDrawing.cs
- OleDbDataReader.cs
- SecUtil.cs
- DesignerTextBoxAdapter.cs
- PrimitiveXmlSerializers.cs
- ContentFilePart.cs
- PointKeyFrameCollection.cs
- _SSPIWrapper.cs
- Timer.cs
- XmlDownloadManager.cs
- ExceptionRoutedEventArgs.cs
- ObjectItemAssemblyLoader.cs
- MessageQueueEnumerator.cs
- Trigger.cs
- Vector3DCollectionConverter.cs
- OdbcUtils.cs
- XmlSchemaAll.cs
- Message.cs
- XPathSelfQuery.cs
- ArraySet.cs
- _RequestCacheProtocol.cs
- DynamicActivityProperty.cs
- Quaternion.cs
- SmtpNtlmAuthenticationModule.cs
- SspiSafeHandles.cs
- WebPageTraceListener.cs
- COM2ExtendedBrowsingHandler.cs
- NetNamedPipeSecurityElement.cs
- RelatedCurrencyManager.cs
- XmlNodeReader.cs
- EmptyEnumerator.cs
- WorkflowDesignerMessageFilter.cs
- ScriptHandlerFactory.cs
- HitTestParameters3D.cs
- HttpContext.cs
- VirtualizingPanel.cs
- ComplusTypeValidator.cs
- JournalEntryStack.cs
- GroupByExpressionRewriter.cs
- NullableFloatAverageAggregationOperator.cs
- SkipQueryOptionExpression.cs
- GenericAuthenticationEventArgs.cs
- FormViewUpdatedEventArgs.cs
- WebControl.cs
- BamlTreeMap.cs
- path.cs
- ByteStream.cs
- basevalidator.cs
- BridgeDataRecord.cs
- PolyQuadraticBezierSegmentFigureLogic.cs
- DataShape.cs
- FixedHighlight.cs
- URLString.cs
- MetadataCollection.cs
- NavigatingCancelEventArgs.cs
- SqlDataSourceFilteringEventArgs.cs
- BitmapEffectState.cs
- TreeWalker.cs
- BatchWriter.cs
- DeviceFiltersSection.cs
- DetailsViewDeleteEventArgs.cs
- AdCreatedEventArgs.cs
- PageAdapter.cs
- WebEventTraceProvider.cs
- UserUseLicenseDictionaryLoader.cs
- SoapAttributeOverrides.cs
- ActivityDefaults.cs
- CellTreeNodeVisitors.cs
- Timeline.cs
- CustomCategoryAttribute.cs
- Point3DCollection.cs
- Operand.cs
- ClonableStack.cs
- TextShapeableCharacters.cs
- DatasetMethodGenerator.cs
- HScrollBar.cs
- ScriptDescriptor.cs
- FixedHighlight.cs
- FragmentNavigationEventArgs.cs
- ArraySortHelper.cs
- OleDbReferenceCollection.cs
- TextTreeTextElementNode.cs