当前位置: 首页>>代码示例>>C#>>正文


C# TextUnit.ToString方法代码示例

本文整理汇总了C#中TextUnit.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# TextUnit.ToString方法的具体用法?C# TextUnit.ToString怎么用?C# TextUnit.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TextUnit的用法示例。


在下文中一共展示了TextUnit.ToString方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TS_MoveNTimes

        //---------------------------------------------------------------------------
        // Calls move N+1 times and validates results
        // First N times should equal expected result
        // N+1'th time should return 0
        // Unit is the actual unit we're going to call move with.
        //---------------------------------------------------------------------------
        internal void TS_MoveNTimes(TextUnit unit, int[] numberOfTextUnits, TextPatternRange range, int moveCount, int expectedResult, CheckType checkType)
        {
            int count = 0;
            int countOffset = 0;
            int actualResult = 0;
            bool isRichEdit = TextLibrary.IsRichEdit(m_le);
            string msg = "Move(" + unit.ToString() + ", " + moveCount + ")";
            TextPatternRange callingRange = null;

            // Get document range and clone calling range
            Range_Clone(range, ref callingRange, null, checkType);

            // Get count of type
            count = numberOfTextUnits[(int)unit];

            if (isRichEdit == true)    // Bug 1059357 or 1134056 (take your pick)
            {
                if (unit == TextUnit.Character)
                {
                    countOffset = _trailingCRLFCount;
                    count += countOffset;
                    Comment("Depricating expected count of chracters by " + countOffset + " for textunit " + ParseType(TextUnit.Character));
                }
                else if (unit == TextUnit.Word)
                {
                    count--;
                    Comment("Depricating expected count of words by -1 for textunit " + ParseType(TextUnit.Word));
                }
            }

            // First N times, the return value of Move should equal result
            for (int i = 0; i < count; i++)
            {
                Range_Move(callingRange, unit, moveCount, ref actualResult, null, checkType);

                if (actualResult != expectedResult)
                {
                    ThrowMe(checkType, msg + " returned " + actualResult + ", expected = " + expectedResult);
                }
            }
            Comment(msg + " called " + count + " times successfully");


            // Now move N+1'th time, should always return 0
            moveCount = 0;
            Range_Move(callingRange, unit, moveCount, ref actualResult, null, checkType);

            if (actualResult != 0)
                ThrowMe(checkType, msg + " returned " + actualResult + ", expected = 0");
            else
                Comment(msg + " returned 0 as expected");

            m_TestStep++;
        }
开发者ID:sergeyDyadenchuk,项目名称:Testing,代码行数:60,代码来源:TextTestsHelper.cs

示例2: wpf_IdentifySupportedTextUnits

 //-------------------------------------------------------------------
 // Identify supported TextUnits in WPF
 //-------------------------------------------------------------------
 internal static TextUnit wpf_IdentifySupportedTextUnits(AutomationElement element, TextUnit targetUnit)
 {
     switch (targetUnit)
     {
         case TextUnit.Character: return TextUnit.Character;
         case TextUnit.Format: return TextUnit.Format;
         case TextUnit.Word: return TextUnit.Word;
         case TextUnit.Line: return TextUnit.Line;
         case TextUnit.Paragraph: return TextUnit.Paragraph;
         case TextUnit.Page:                                 // Maps to Document for everything but MS Word
         case TextUnit.Document: return TextUnit.Document;
         default:
             throw new NotImplementedException("IdentifySupportedTextUnits() does not support " + targetUnit.ToString());
     }
 }
开发者ID:geeksree,项目名称:cSharpGeeks,代码行数:18,代码来源:TextLibraryCount.cs

示例3: Win32CountTextUnit

        internal static int Win32CountTextUnit(TextUnit textUnit, TextPatternRange rangeToCount)
        {
            AutomationElement element = null;
            string actualText = "";

            ValidateArgumentNonNull(rangeToCount, "rangeToCount argument cannot be null");  // Sanity check

            // Get text
            try
            {
                actualText = rangeToCount.GetText(-1);
                element = rangeToCount.GetEnclosingElement();
                if (element == null)
                    throw new InvalidOperationException("Null automation element incorrectly returned by TextPatternRange.GetEnclosingElement() in Win32CountTextUnit()");
            }
            catch (Exception exception)
            {
                if (IsCriticalException(exception))
                    throw;

                throw new InvalidOperationException("Unable to call TextPatternRange.GetText() in Win32CountTextUnit()", exception);
            }

            // Count text units and assign to array element
            switch (textUnit)
            {
                case TextUnit.Character:
                    return actualText.Length;
                case TextUnit.Format:
                    return CountTextUnit(TextUnit.Format, rangeToCount);
                case TextUnit.Word:
                    return CountTextUnit(TextUnit.Word, rangeToCount);
                case TextUnit.Line:
                    return Win32CountLines(element);
                case TextUnit.Paragraph:
                    return CountParagraphs(actualText);
                case TextUnit.Page:
                    return 1;
                case TextUnit.Document:
                    return 1;
                default:
                    throw new ArgumentException("CountTextUnits() does not support " + textUnit.ToString());
            }
        }
开发者ID:geeksree,项目名称:cSharpGeeks,代码行数:44,代码来源:TextLibraryCount.cs

示例4: win32_IdentifySupportedTextUnits

        //-------------------------------------------------------------------
        // Identify supported TextUnits in Win32
        //-------------------------------------------------------------------
        internal static TextUnit win32_IdentifySupportedTextUnits(AutomationElement element, TextUnit targetUnit)
        {
            string className = GetClassName(element);

            if (className.IndexOf(RichEditClassName) > -1)
            {
                switch (targetUnit)
                {
                    case TextUnit.Character: return TextUnit.Character;
                    case TextUnit.Format: return TextUnit.Format;
                    case TextUnit.Word: return TextUnit.Word;
                    case TextUnit.Line: return TextUnit.Line;
                    case TextUnit.Paragraph: return TextUnit.Paragraph;
                    case TextUnit.Page:                                 // Maps to Document for everything but MS Word
                    case TextUnit.Document: return TextUnit.Document;
                    default:
                        throw new NotImplementedException("IdentifySupportedTextUnits() does not support " + targetUnit.ToString());
                }
            }
            else if (className.IndexOf(EditClassName) > -1)
            {
                switch (targetUnit)
                {
                    case TextUnit.Character: return TextUnit.Character;
                    case TextUnit.Word: return TextUnit.Word;
                    case TextUnit.Line: return TextUnit.Line;
                    case TextUnit.Paragraph: return TextUnit.Paragraph;
                    case TextUnit.Format:                               // No support for Format in Win32 Edit
                    case TextUnit.Page:                                 // Maps to Document for everything but MS Word
                    case TextUnit.Document: return TextUnit.Document;
                    default:
                        throw new NotImplementedException("IdentifySupportedTextUnits() does not support " + targetUnit.ToString());
                }
            }

            throw new NotImplementedException("IdentifySupportedTextUnits() cannot determine supported text units for class " + className);
        }
开发者ID:geeksree,项目名称:cSharpGeeks,代码行数:40,代码来源:TextLibraryCount.cs

示例5: ParseType

 /// ---------------------------------------------------------------------------
 /// <summary>Parses values for enum</summary>
 /// ---------------------------------------------------------------------------
 static public string ParseType(TextUnit value)
 {
     return ParseType(value.GetType().ToString(), value.ToString());
 }
开发者ID:sergeyDyadenchuk,项目名称:Testing,代码行数:7,代码来源:TextTests.cs


注:本文中的TextUnit.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。