if (textBlockSuperscript || textBlockSubscript)
{
//Sample
////////string firstFragmentText = "abc";
////////string secondFragmentText = "123";
////////string format1 = ApplyFormattingSubScriptSuperScript(firstFragmentText, "Arial", 3, true, true, true, true, true, true, "left", 10);
////////string format2 = ApplyFormattingSubScriptSuperScript(secondFragmentText, "Arial", 3, true, true, true, true, true, true, "left", 10);
//////////firstFragmentText = "{\\A1;" + firstFragmentText + "\\H0.7x;\\S" + secondFragmentText + "^";
////////firstFragmentText = "{\\A1;" + format1 + "\\H0.7x;\\S" + secondFragmentText + "^";
////////mtContents = firstFragmentText;
if (fragment.Count() >= 2)
{
var firstFragment = fragment[0];
var secondFragment = fragment[1];
bool firstfragmentBold, firstfragmentItalic, firstfragmentUnderline, firstfragmentStrikethrough, firstfragmentSuperscript, firstfragmentSubscript, firstfragmentUpperCase, firstfragmentLowerCase;
string firstfragmentFont, firstfragmentText;
int firstcolor;
Global.GetFragmentDetails(xdoc, firstFragment, out firstfragmentBold, out firstfragmentItalic, out firstfragmentFont, out firstfragmentUnderline, out firstcolor, out firstfragmentText, out firstfragmentStrikethrough, out firstfragmentSuperscript, out firstfragmentSubscript, out firstfragmentUpperCase, out firstfragmentLowerCase);
bool secondfragmentBold, secondfragmentItalic, secondfragmentUnderline, secondfragmentStrikethrough, secondfragmentSuperscript, secondfragmentSubscript, secondfragmentUpperCase, secondfragmentLowerCase;
string secondfragmentFont, secondfragmentText;
int secondcolor;
Global.GetFragmentDetails(xdoc, secondFragment, out secondfragmentBold, out secondfragmentItalic, out secondfragmentFont, out secondfragmentUnderline, out secondcolor, out secondfragmentText, out secondfragmentStrikethrough, out secondfragmentSuperscript, out secondfragmentSubscript, out secondfragmentUpperCase, out secondfragmentLowerCase);
string firstfragmentFormattedText = Global.ApplyFormattingSubScriptSuperScript(firstfragmentText, firstfragmentFont, textBlockAlignment, firstfragmentSubscript, firstfragmentSuperscript, firstcolor, firstfragmentBold, firstfragmentItalic, firstfragmentStrikethrough, firstfragmentUnderline, textBlockHeight);
string secondfragmentFormattedText = Global.ApplyFormattingSubScriptSuperScript(secondfragmentText, secondfragmentFont, textBlockAlignment, secondfragmentSubscript, secondfragmentSuperscript, secondcolor, secondfragmentBold, secondfragmentItalic, secondfragmentStrikethrough, secondfragmentUnderline, textBlockHeight);
if (textBlockSuperscript)
{
firstfragmentText = "{\\A1;" + firstfragmentFormattedText + "\\H0.7x;\\S" + secondfragmentFormattedText + "^";
mtContents = firstfragmentText;
}
else if (textBlockSubscript)
{
firstfragmentText = "{\\A1;" + firstfragmentFormattedText + "\\H0.7x;\\S^" + secondfragmentFormattedText;
mtContents = firstfragmentText;
}
}
}
public static string ApplyFormattingSubScriptSuperScript(string content, string font, string alignment, bool isSubscript, bool isSuperscript, int color, bool isBold, bool isItalic, bool isStrikethrough, bool isUnderline, double textHeight)
{
string formattedContent = AddFormatting(content, font, color, isBold, isItalic, isStrikethrough, isUnderline, alignment);
return formattedContent;
}
public static string AddFormatting(string content, string font, int color, bool isBold, bool isItalic, bool isStrikethrough, bool isUnderline, string alignment)
{
string formattedContent = content;
if (!string.IsNullOrEmpty(font))
formattedContent = "{\\f" + font + ";" + formattedContent + "}";
//formattedContent = GetAlignment(alignment, formattedContent);
formattedContent = "{\\C" + color + ";" + formattedContent;
if (isBold)
formattedContent = "{\\B" + formattedContent + "}";
if (isItalic)
formattedContent = "{\\I" + formattedContent + "}";
if (isStrikethrough)
formattedContent = "{\\K" + formattedContent + "}";
if (isUnderline)
formattedContent = "{\\L" + formattedContent + "}";
return formattedContent;
}