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 / FrameworkElementAutomationPeer.cs / 1 / FrameworkElementAutomationPeer.cs
using System;
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.Interop;
using System.Windows.Media;
using System.Windows.Markup;
using MS.Internal;
using MS.Win32;
namespace System.Windows.Automation.Peers
{
///
public class FrameworkElementAutomationPeer: UIElementAutomationPeer
{
///
public FrameworkElementAutomationPeer(FrameworkElement owner): base(owner)
{}
///
protected override string GetAutomationIdCore()
{
// 1. fetch AutomationProperties.AutomationIdProperty
string result = base.GetAutomationIdCore();
if (string.IsNullOrEmpty(result))
{
// 2. fetch x:Uid
FrameworkElement owner = (FrameworkElement)Owner;
result = Owner.Uid;
if (string.IsNullOrEmpty(result))
{
// 3. fetch FrameworkElement.NameProperty
result = owner.Name;
}
}
return result ?? string.Empty;
}
///
override protected string GetNameCore()
{
string result = base.GetNameCore();
if (string.IsNullOrEmpty(result))
{
AutomationPeer labelAutomationPeer = GetLabeledByCore();
if (labelAutomationPeer != null)
result = labelAutomationPeer.GetName();
if (string.IsNullOrEmpty(result))
result = ((FrameworkElement)Owner).GetPlainText();
}
return result ?? string.Empty;
}
///
protected override string GetHelpTextCore()
{
string result = base.GetHelpTextCore();
if (string.IsNullOrEmpty(result))
{
object toolTip = ((FrameworkElement)Owner).ToolTip;
if (toolTip != null)
{
result = toolTip as string;
if (string.IsNullOrEmpty(result))
{
FrameworkElement toolTipElement = toolTip as FrameworkElement;
if (toolTipElement != null)
result = toolTipElement.GetPlainText();
}
}
}
return result ?? String.Empty;
}
///
override protected AutomationPeer GetLabeledByCore()
{
AutomationPeer labelPeer = base.GetLabeledByCore();
if (labelPeer == null)
{
Label label = Label.GetLabeledBy(Owner);
if (label != null)
return label.GetAutomationPeer();
}
return null;
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
using System;
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.Interop;
using System.Windows.Media;
using System.Windows.Markup;
using MS.Internal;
using MS.Win32;
namespace System.Windows.Automation.Peers
{
///
public class FrameworkElementAutomationPeer: UIElementAutomationPeer
{
///
public FrameworkElementAutomationPeer(FrameworkElement owner): base(owner)
{}
///
protected override string GetAutomationIdCore()
{
// 1. fetch AutomationProperties.AutomationIdProperty
string result = base.GetAutomationIdCore();
if (string.IsNullOrEmpty(result))
{
// 2. fetch x:Uid
FrameworkElement owner = (FrameworkElement)Owner;
result = Owner.Uid;
if (string.IsNullOrEmpty(result))
{
// 3. fetch FrameworkElement.NameProperty
result = owner.Name;
}
}
return result ?? string.Empty;
}
///
override protected string GetNameCore()
{
string result = base.GetNameCore();
if (string.IsNullOrEmpty(result))
{
AutomationPeer labelAutomationPeer = GetLabeledByCore();
if (labelAutomationPeer != null)
result = labelAutomationPeer.GetName();
if (string.IsNullOrEmpty(result))
result = ((FrameworkElement)Owner).GetPlainText();
}
return result ?? string.Empty;
}
///
protected override string GetHelpTextCore()
{
string result = base.GetHelpTextCore();
if (string.IsNullOrEmpty(result))
{
object toolTip = ((FrameworkElement)Owner).ToolTip;
if (toolTip != null)
{
result = toolTip as string;
if (string.IsNullOrEmpty(result))
{
FrameworkElement toolTipElement = toolTip as FrameworkElement;
if (toolTipElement != null)
result = toolTipElement.GetPlainText();
}
}
}
return result ?? String.Empty;
}
///
override protected AutomationPeer GetLabeledByCore()
{
AutomationPeer labelPeer = base.GetLabeledByCore();
if (labelPeer == null)
{
Label label = Label.GetLabeledBy(Owner);
if (label != null)
return label.GetAutomationPeer();
}
return null;
}
}
}
// 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
- PrintController.cs
- SocketStream.cs
- XmlElementAttribute.cs
- DataRecordInternal.cs
- LinkLabelLinkClickedEvent.cs
- ExpressionBuilderCollection.cs
- Int64Animation.cs
- XmlSchemaParticle.cs
- CharacterString.cs
- HtmlUtf8RawTextWriter.cs
- EntityKeyElement.cs
- SecurityManager.cs
- TypeSystem.cs
- ObjectDataSourceStatusEventArgs.cs
- TextTreeDeleteContentUndoUnit.cs
- TransformerInfoCollection.cs
- PieceDirectory.cs
- ItemContainerGenerator.cs
- XmlSchemaSimpleContentRestriction.cs
- DefaultParameterValueAttribute.cs
- ObjectIDGenerator.cs
- QueryableFilterUserControl.cs
- FilterQueryOptionExpression.cs
- IdentityNotMappedException.cs
- IEnumerable.cs
- BindingList.cs
- JavaScriptString.cs
- BooleanExpr.cs
- DataGridViewTextBoxColumn.cs
- UDPClient.cs
- MailAddress.cs
- TextBoxRenderer.cs
- ResXDataNode.cs
- LocationReferenceEnvironment.cs
- BasePropertyDescriptor.cs
- RoutingTable.cs
- TreeWalkHelper.cs
- SponsorHelper.cs
- HandlerBase.cs
- VectorValueSerializer.cs
- DictionarySurrogate.cs
- DataGridViewDesigner.cs
- TextDpi.cs
- DSASignatureFormatter.cs
- DurableErrorHandler.cs
- DataIdProcessor.cs
- VBCodeProvider.cs
- messageonlyhwndwrapper.cs
- ConstructorBuilder.cs
- RsaSecurityKey.cs
- MasterPageBuildProvider.cs
- IntSecurity.cs
- InfoCardRSACryptoProvider.cs
- XPathParser.cs
- StructuralType.cs
- HttpHeaderCollection.cs
- FragmentNavigationEventArgs.cs
- OleDbStruct.cs
- WSSecurityTokenSerializer.cs
- ErrorRuntimeConfig.cs
- InputLanguageManager.cs
- WorkflowDesignerColors.cs
- Deserializer.cs
- SystemIPAddressInformation.cs
- SecureConversationServiceElement.cs
- QuaternionIndependentAnimationStorage.cs
- BindingContext.cs
- ResourceReferenceKeyNotFoundException.cs
- SupportsEventValidationAttribute.cs
- PackageRelationshipSelector.cs
- ArithmeticException.cs
- HeaderedContentControl.cs
- ToolboxBitmapAttribute.cs
- WebPartConnectionsCancelEventArgs.cs
- ButtonBase.cs
- WeakRefEnumerator.cs
- SqlRecordBuffer.cs
- ConnectionProviderAttribute.cs
- VersionPair.cs
- KeyValuePair.cs
- CodeObject.cs
- BuildDependencySet.cs
- CopyOnWriteList.cs
- SettingsPropertyIsReadOnlyException.cs
- TagPrefixInfo.cs
- BaseTreeIterator.cs
- AppDomainAttributes.cs
- WinInetCache.cs
- TransformPatternIdentifiers.cs
- CodeIdentifiers.cs
- PointHitTestResult.cs
- FileDialogCustomPlace.cs
- SqlNodeAnnotations.cs
- AuthenticationModuleElement.cs
- Point3DAnimationBase.cs
- Baml2006ReaderFrame.cs
- WebPartsPersonalization.cs
- ContextStack.cs
- ControlCollection.cs
- UrlParameterWriter.cs