本文整理汇总了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++;
}
示例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());
}
}
示例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());
}
}
示例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);
}
示例5: ParseType
/// ---------------------------------------------------------------------------
/// <summary>Parses values for enum</summary>
/// ---------------------------------------------------------------------------
static public string ParseType(TextUnit value)
{
return ParseType(value.GetType().ToString(), value.ToString());
}