Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Framework / System / Windows / Automation / Peers / TextAutomationPeer.cs / 1305600 / TextAutomationPeer.cs
//----------------------------------------------------------------------------
//
// Copyright (C) Microsoft Corporation. All rights reserved.
//
// File: ContentTextElementAutomationPeer.cs
//
// Description: Base class for AutomationPeers associated with TextPattern.
//
//---------------------------------------------------------------------------
using System.Collections.Generic; // List
using System.Windows.Automation.Provider; // IRawElementProviderSimple
using System.Windows.Documents; // ITextPointer
namespace System.Windows.Automation.Peers
{
///
/// Base class for AutomationPeers associated with TextPattern.
///
public abstract class TextAutomationPeer : FrameworkElementAutomationPeer
{
///
/// Constructor.
///
protected TextAutomationPeer(FrameworkElement owner)
: base(owner)
{}
///
/// GetNameCore will return a value matching (in priority order)
///
/// 1. Automation.Name
/// 2. GetLabeledBy.Name
/// 3. String.Empty
///
/// This differs from the base implementation in that we must
/// never return GetPlainText() .
///
override protected string GetNameCore()
{
string result = AutomationProperties.GetName(this.Owner);
if (string.IsNullOrEmpty(result))
{
AutomationPeer labelAutomationPeer = GetLabeledByCore();
if (labelAutomationPeer != null)
{
result = labelAutomationPeer.GetName();
}
}
return result ?? string.Empty;
}
///
/// Maps AutomationPeer to provider object.
///
internal new IRawElementProviderSimple ProviderFromPeer(AutomationPeer peer)
{
return base.ProviderFromPeer(peer);
}
///
/// Maps automation provider to DependencyObject.
///
internal DependencyObject ElementFromProvider(IRawElementProviderSimple provider)
{
DependencyObject element = null;
AutomationPeer peer = PeerFromProvider(provider);
if (peer is UIElementAutomationPeer)
{
element = ((UIElementAutomationPeer)peer).Owner;
}
else if (peer is ContentElementAutomationPeer)
{
element = ((ContentElementAutomationPeer)peer).Owner;
}
return element;
}
///
/// Gets collection of AutomationPeers for given text range.
///
internal abstract List GetAutomationPeersFromRange(ITextPointer start, ITextPointer end);
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------------------------
//
// Copyright (C) Microsoft Corporation. All rights reserved.
//
// File: ContentTextElementAutomationPeer.cs
//
// Description: Base class for AutomationPeers associated with TextPattern.
//
//---------------------------------------------------------------------------
using System.Collections.Generic; // List
using System.Windows.Automation.Provider; // IRawElementProviderSimple
using System.Windows.Documents; // ITextPointer
namespace System.Windows.Automation.Peers
{
///
/// Base class for AutomationPeers associated with TextPattern.
///
public abstract class TextAutomationPeer : FrameworkElementAutomationPeer
{
///
/// Constructor.
///
protected TextAutomationPeer(FrameworkElement owner)
: base(owner)
{}
///
/// GetNameCore will return a value matching (in priority order)
///
/// 1. Automation.Name
/// 2. GetLabeledBy.Name
/// 3. String.Empty
///
/// This differs from the base implementation in that we must
/// never return GetPlainText() .
///
override protected string GetNameCore()
{
string result = AutomationProperties.GetName(this.Owner);
if (string.IsNullOrEmpty(result))
{
AutomationPeer labelAutomationPeer = GetLabeledByCore();
if (labelAutomationPeer != null)
{
result = labelAutomationPeer.GetName();
}
}
return result ?? string.Empty;
}
///
/// Maps AutomationPeer to provider object.
///
internal new IRawElementProviderSimple ProviderFromPeer(AutomationPeer peer)
{
return base.ProviderFromPeer(peer);
}
///
/// Maps automation provider to DependencyObject.
///
internal DependencyObject ElementFromProvider(IRawElementProviderSimple provider)
{
DependencyObject element = null;
AutomationPeer peer = PeerFromProvider(provider);
if (peer is UIElementAutomationPeer)
{
element = ((UIElementAutomationPeer)peer).Owner;
}
else if (peer is ContentElementAutomationPeer)
{
element = ((ContentElementAutomationPeer)peer).Owner;
}
return element;
}
///
/// Gets collection of AutomationPeers for given text range.
///
internal abstract List GetAutomationPeersFromRange(ITextPointer start, ITextPointer end);
}
}
// 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
- FlowLayoutSettings.cs
- SmtpFailedRecipientException.cs
- BaseProcessor.cs
- Int32Converter.cs
- ToolStripHighContrastRenderer.cs
- FtpWebRequest.cs
- StylusPointPropertyInfo.cs
- AbstractDataSvcMapFileLoader.cs
- AxisAngleRotation3D.cs
- ColorAnimation.cs
- OleAutBinder.cs
- PeerApplication.cs
- DotExpr.cs
- AccessDataSourceWizardForm.cs
- StorageBasedPackageProperties.cs
- _TransmitFileOverlappedAsyncResult.cs
- IResourceProvider.cs
- CalendarTable.cs
- MembershipPasswordException.cs
- SafeEventLogWriteHandle.cs
- InputElement.cs
- DataGridViewRowStateChangedEventArgs.cs
- ProfilePropertySettings.cs
- Deflater.cs
- PositiveTimeSpanValidator.cs
- WebAdminConfigurationHelper.cs
- Point.cs
- EnumerableCollectionView.cs
- ItemAutomationPeer.cs
- CodeObject.cs
- SecurityException.cs
- DataPagerCommandEventArgs.cs
- KeyValueConfigurationElement.cs
- x509utils.cs
- FontEmbeddingManager.cs
- ClrProviderManifest.cs
- FixedPageProcessor.cs
- ResourceProperty.cs
- GenerateScriptTypeAttribute.cs
- DataGridCellAutomationPeer.cs
- UncommonField.cs
- ScalarType.cs
- UnsafeNativeMethods.cs
- PropertyFilterAttribute.cs
- PanelStyle.cs
- CompletedAsyncResult.cs
- ImageFormat.cs
- HorizontalAlignConverter.cs
- FastEncoder.cs
- EventNotify.cs
- ListParaClient.cs
- HtmlControlDesigner.cs
- CrossSiteScriptingValidation.cs
- Binding.cs
- DbDataRecord.cs
- WebEncodingValidatorAttribute.cs
- CompilationUtil.cs
- unsafeIndexingFilterStream.cs
- CatalogPart.cs
- Button.cs
- CryptoConfig.cs
- AppDomainProtocolHandler.cs
- ItemCheckEvent.cs
- MemberNameValidator.cs
- XMLSchema.cs
- TcpServerChannel.cs
- Relationship.cs
- XhtmlConformanceSection.cs
- ErrorWrapper.cs
- _ProxyRegBlob.cs
- BitmapInitialize.cs
- NavigateEvent.cs
- DeploymentSection.cs
- FreezableDefaultValueFactory.cs
- TableLayoutRowStyleCollection.cs
- BulletChrome.cs
- ListItemCollection.cs
- FactoryGenerator.cs
- DataBindingValueUIHandler.cs
- GeometryModel3D.cs
- Types.cs
- CorrelationManager.cs
- CurrencyWrapper.cs
- HostedBindingBehavior.cs
- ReflectEventDescriptor.cs
- FontWeights.cs
- RoutedEventConverter.cs
- KeyInstance.cs
- SqlCacheDependencyDatabaseCollection.cs
- DrawingContextWalker.cs
- LexicalChunk.cs
- ColorMatrix.cs
- TripleDES.cs
- TargetConverter.cs
- BamlBinaryReader.cs
- ImageSourceConverter.cs
- FrameworkName.cs
- ExpressionVisitorHelpers.cs
- Logging.cs
- ParenExpr.cs