TextAutomationPeer.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / wpf / src / Framework / System / Windows / Automation / Peers / TextAutomationPeer.cs / 1 / 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

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK