Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Framework / System / Windows / Automation / Peers / StatusBarAutomationPeer.cs / 1305600 / 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
- ErrorInfoXmlDocument.cs
- UntypedNullExpression.cs
- CodeTypeDelegate.cs
- DataSvcMapFile.cs
- NamedPipeAppDomainProtocolHandler.cs
- Page.cs
- WindowsSolidBrush.cs
- CodeGroup.cs
- PropertyTabAttribute.cs
- CodeArgumentReferenceExpression.cs
- XamlTreeBuilderBamlRecordWriter.cs
- SolidColorBrush.cs
- SearchForVirtualItemEventArgs.cs
- LinqDataView.cs
- _OverlappedAsyncResult.cs
- Opcode.cs
- DataRecordInternal.cs
- BitStack.cs
- PerformanceCountersElement.cs
- ResourcePermissionBaseEntry.cs
- RenderData.cs
- SByteConverter.cs
- SecurityAlgorithmSuiteConverter.cs
- EventDescriptor.cs
- WindowsRichEdit.cs
- StaticFileHandler.cs
- ToolStripRendererSwitcher.cs
- FacetDescriptionElement.cs
- TabRenderer.cs
- TableCellAutomationPeer.cs
- PageThemeBuildProvider.cs
- _UriTypeConverter.cs
- Group.cs
- CalendarDataBindingHandler.cs
- BinarySecretSecurityToken.cs
- ClientFormsIdentity.cs
- WmpBitmapDecoder.cs
- InProcStateClientManager.cs
- SafeEventHandle.cs
- MediaSystem.cs
- SqlGatherConsumedAliases.cs
- DriveInfo.cs
- DeferredSelectedIndexReference.cs
- IdentityValidationException.cs
- handlecollector.cs
- PrinterUnitConvert.cs
- DesignerLoader.cs
- CodeComment.cs
- SqlCommandBuilder.cs
- IDictionary.cs
- HttpCapabilitiesBase.cs
- StandardToolWindows.cs
- UnsafeNativeMethods.cs
- GeneralTransform3D.cs
- BooleanExpr.cs
- HtmlWindow.cs
- OptimalTextSource.cs
- HttpHandlerActionCollection.cs
- SqlUserDefinedTypeAttribute.cs
- HtmlElement.cs
- Encoder.cs
- AppDomainResourcePerfCounters.cs
- KnownColorTable.cs
- NullEntityWrapper.cs
- IndexedString.cs
- CapabilitiesRule.cs
- DecimalFormatter.cs
- TraceContextRecord.cs
- XmlSchemaGroup.cs
- DataContractAttribute.cs
- JournalEntryStack.cs
- _AutoWebProxyScriptHelper.cs
- FixedSOMGroup.cs
- ProxyFragment.cs
- SafeNativeMethods.cs
- HtmlTableRow.cs
- VectorConverter.cs
- ApplicationContext.cs
- CompilationRelaxations.cs
- parserscommon.cs
- TextTreeNode.cs
- BinaryExpressionHelper.cs
- ExceptionValidationRule.cs
- DrawingAttributesDefaultValueFactory.cs
- CurrentTimeZone.cs
- CodeGenerator.cs
- CodePrimitiveExpression.cs
- TextSelectionHighlightLayer.cs
- PropertyTabChangedEvent.cs
- CharAnimationUsingKeyFrames.cs
- TraceEventCache.cs
- HMACSHA384.cs
- PreProcessor.cs
- ContentPosition.cs
- _FtpControlStream.cs
- RowUpdatedEventArgs.cs
- SemaphoreSecurity.cs
- ActivityScheduledQuery.cs
- TextParagraphCache.cs
- ObjectDataSourceDisposingEventArgs.cs