ListMarkerLine.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 / MS / Internal / PtsHost / ListMarkerLine.cs / 1 / ListMarkerLine.cs

                            //---------------------------------------------------------------------------- 
//
// Copyright (C) Microsoft Corporation.  All rights reserved.
//
// File: LineBase.cs 
//
// Description: Text line formatter. 
// 
// History:
//  02/07/2005 : ghermann - Split from Line.cs 
//
//---------------------------------------------------------------------------
using System;
using System.Diagnostics; 
using System.Collections;
using System.Collections.Generic; 
using System.Windows; 
using System.Windows.Controls;
using System.Windows.Documents; 
using System.Windows.Media;
using System.Windows.Media.TextFormatting;
using MS.Internal.Text;
using MS.Internal.Documents; 

using MS.Internal.PtsHost.UnsafeNativeMethods; 
 
namespace MS.Internal.PtsHost
{ 
    internal class ListMarkerLine : LineBase
    {

        ///  
        /// Constructor
        ///  
        ///  
        /// TextFormatter host
        ///  
        /// 
        /// Owner of the ListMarker
        /// 
        internal ListMarkerLine(TextFormatterHost host, ListParaClient paraClient) : base(paraClient) 
        {
            _host = host; 
        } 

        // ----------------------------------------------------------------- 
        //
        //  TextSource Implementation
        //
        // ----------------------------------------------------------------- 

        #region TextSource Implementation 
 
        /// 
        /// Return the text run at specified text source position. 
        /// 
        /// 
        /// Offset of specified position
        ///  
        internal override TextRun GetTextRun(int dcp)
        { 
            return new ParagraphBreakRun(1, PTS.FSFLRES.fsflrEndOfParagraph); 
        }
 
        /// 
        /// Return the text, as CharacterBufferRange, immediately before specified text source position.
        /// 
        ///  
        /// Offset of specified position
        ///  
        internal override TextSpan GetPrecedingText(int dcp) 
        {
 
            return new TextSpan(
                0,
                new CultureSpecificCharacterBufferRange(null, CharacterBufferRange.Empty)
                ); 
        }
 
        ///  
        /// Get Text effect index from specified position
        ///  
        /// 
        /// Offset of specified position
        /// 
        ///  
        internal override int GetTextEffectCharacterIndexFromTextSourceCharacterIndex(int dcp)
        { 
            return dcp; 
        }
 
        #endregion TextSource Implementation

        /// 
        /// Create and format text line. 
        /// 
        ///  
        /// DrawingContext for text line. 
        /// 
        ///  
        /// LineProperties of text line
        /// 
        /// 
        /// Horizontal draw location 
        /// 
        ///  
        /// Vertical baseline draw location 
        /// 
        internal void FormatAndDrawVisual(DrawingContext ctx, LineProperties lineProps, int ur, int vrBaseline) 
        {
            System.Windows.Media.TextFormatting.TextLine line;
            bool mirror = (lineProps.FlowDirection == FlowDirection.RightToLeft);
 
            _host.Context = this;
 
            try 
            {
                // Create line object 
                line = _host.TextFormatter.FormatLine(_host, 0, 0, lineProps.FirstLineProps, null, new TextRunCache());

                Point drawLocation = new Point(TextDpi.FromTextDpi(ur), TextDpi.FromTextDpi(vrBaseline) - line.Baseline);
 
                line.Draw(ctx, drawLocation, (mirror ? InvertAxes.Horizontal : InvertAxes.None));
                line.Dispose(); 
            } 
            finally
            { 
                // clear the context
                _host.Context = null;
            }
        } 

        ///  
        /// Text formatter host 
        /// 
        private readonly TextFormatterHost _host; 
    }
}

// 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: LineBase.cs 
//
// Description: Text line formatter. 
// 
// History:
//  02/07/2005 : ghermann - Split from Line.cs 
//
//---------------------------------------------------------------------------
using System;
using System.Diagnostics; 
using System.Collections;
using System.Collections.Generic; 
using System.Windows; 
using System.Windows.Controls;
using System.Windows.Documents; 
using System.Windows.Media;
using System.Windows.Media.TextFormatting;
using MS.Internal.Text;
using MS.Internal.Documents; 

using MS.Internal.PtsHost.UnsafeNativeMethods; 
 
namespace MS.Internal.PtsHost
{ 
    internal class ListMarkerLine : LineBase
    {

        ///  
        /// Constructor
        ///  
        ///  
        /// TextFormatter host
        ///  
        /// 
        /// Owner of the ListMarker
        /// 
        internal ListMarkerLine(TextFormatterHost host, ListParaClient paraClient) : base(paraClient) 
        {
            _host = host; 
        } 

        // ----------------------------------------------------------------- 
        //
        //  TextSource Implementation
        //
        // ----------------------------------------------------------------- 

        #region TextSource Implementation 
 
        /// 
        /// Return the text run at specified text source position. 
        /// 
        /// 
        /// Offset of specified position
        ///  
        internal override TextRun GetTextRun(int dcp)
        { 
            return new ParagraphBreakRun(1, PTS.FSFLRES.fsflrEndOfParagraph); 
        }
 
        /// 
        /// Return the text, as CharacterBufferRange, immediately before specified text source position.
        /// 
        ///  
        /// Offset of specified position
        ///  
        internal override TextSpan GetPrecedingText(int dcp) 
        {
 
            return new TextSpan(
                0,
                new CultureSpecificCharacterBufferRange(null, CharacterBufferRange.Empty)
                ); 
        }
 
        ///  
        /// Get Text effect index from specified position
        ///  
        /// 
        /// Offset of specified position
        /// 
        ///  
        internal override int GetTextEffectCharacterIndexFromTextSourceCharacterIndex(int dcp)
        { 
            return dcp; 
        }
 
        #endregion TextSource Implementation

        /// 
        /// Create and format text line. 
        /// 
        ///  
        /// DrawingContext for text line. 
        /// 
        ///  
        /// LineProperties of text line
        /// 
        /// 
        /// Horizontal draw location 
        /// 
        ///  
        /// Vertical baseline draw location 
        /// 
        internal void FormatAndDrawVisual(DrawingContext ctx, LineProperties lineProps, int ur, int vrBaseline) 
        {
            System.Windows.Media.TextFormatting.TextLine line;
            bool mirror = (lineProps.FlowDirection == FlowDirection.RightToLeft);
 
            _host.Context = this;
 
            try 
            {
                // Create line object 
                line = _host.TextFormatter.FormatLine(_host, 0, 0, lineProps.FirstLineProps, null, new TextRunCache());

                Point drawLocation = new Point(TextDpi.FromTextDpi(ur), TextDpi.FromTextDpi(vrBaseline) - line.Baseline);
 
                line.Draw(ctx, drawLocation, (mirror ? InvertAxes.Horizontal : InvertAxes.None));
                line.Dispose(); 
            } 
            finally
            { 
                // clear the context
                _host.Context = null;
            }
        } 

        ///  
        /// Text formatter host 
        /// 
        private readonly TextFormatterHost _host; 
    }
}

// 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