This commit is contained in:
2009-12-09 15:43:14 +00:00
parent 130c6e6aca
commit 111ff933be
3 changed files with 71 additions and 67 deletions

View File

@@ -913,7 +913,6 @@ namespace Volian.Controls.Library
return (((cft.dwMask & CharFormatMasks.CFM_SUPERSCRIPT) == CharFormatMasks.CFM_SUPERSCRIPT) &&
((cft.dwEffects & CharFormatEffects.CFE_SUPERSCRIPT) == CharFormatEffects.CFE_SUPERSCRIPT));
}
public static bool IsSubScript(RichTextBox richTextBox)
{
CharFormatTwo cft = GetCharFormat(richTextBox, RTBSelection.SCF_SELECTION);
@@ -925,12 +924,13 @@ namespace Volian.Controls.Library
CharFormatTwo cft = GetCharFormat(richTextBox, selection); // RTBSelection.SCF_SELECTION);
if (bSet)
{
cft.dwEffects |= CharFormatEffects.CFE_SUBSCRIPT;
cft.dwMask |= CharFormatMasks.CFM_SUBSCRIPT;
cft.dwEffects = CharFormatEffects.CFE_SUBSCRIPT;
cft.dwMask = CharFormatMasks.CFM_SUBSCRIPT;
}
else
{
cft.dwEffects &= ~RTBAPI.CharFormatEffects.CFE_SUBSCRIPT;
cft.dwEffects = CharFormatEffects.CFE_NONE;
cft.dwMask = CharFormatMasks.CFM_SUBSCRIPT;
}
SetCharFormat(richTextBox, selection, cft);
}
@@ -939,12 +939,13 @@ namespace Volian.Controls.Library
CharFormatTwo cft = RTBAPI.GetCharFormat(richTextBox, selection); // RTBAPI.RTBSelection.SCF_SELECTION);
if (bSet)
{
cft.dwEffects |= RTBAPI.CharFormatEffects.CFE_SUPERSCRIPT;
cft.dwMask |= RTBAPI.CharFormatMasks.CFM_SUPERSCRIPT;
cft.dwEffects = RTBAPI.CharFormatEffects.CFE_SUPERSCRIPT;
cft.dwMask = RTBAPI.CharFormatMasks.CFM_SUPERSCRIPT;
}
else
{
cft.dwEffects &= ~RTBAPI.CharFormatEffects.CFE_SUPERSCRIPT;
cft.dwEffects = RTBAPI.CharFormatEffects.CFE_NONE;
cft.dwMask = RTBAPI.CharFormatMasks.CFM_SUPERSCRIPT;
}
SetCharFormat(richTextBox, selection, cft);
}
@@ -959,12 +960,13 @@ namespace Volian.Controls.Library
CharFormatTwo cft = GetCharFormat(richTextBox, selection);
if (bSet)
{
cft.dwEffects |= CharFormatEffects.CFE_BOLD;
cft.dwMask |= CharFormatMasks.CFM_BOLD;
cft.dwEffects = CharFormatEffects.CFE_BOLD;
cft.dwMask = CharFormatMasks.CFM_BOLD;
}
else
{
cft.dwEffects &= ~RTBAPI.CharFormatEffects.CFE_BOLD;
cft.dwEffects = CharFormatEffects.CFE_NONE;
cft.dwMask = CharFormatMasks.CFM_BOLD;
}
SetCharFormat(richTextBox, selection, cft);
}
@@ -979,12 +981,13 @@ namespace Volian.Controls.Library
CharFormatTwo cft = GetCharFormat(richTextBox, selection);
if (bSet)
{
cft.dwEffects |= CharFormatEffects.CFE_UNDERLINE;
cft.dwMask |= CharFormatMasks.CFM_UNDERLINE;
cft.dwEffects = CharFormatEffects.CFE_UNDERLINE;
cft.dwMask = CharFormatMasks.CFM_UNDERLINE;
}
else
{
cft.dwEffects &= ~RTBAPI.CharFormatEffects.CFE_UNDERLINE;
cft.dwEffects = CharFormatEffects.CFE_NONE;
cft.dwMask = CharFormatMasks.CFM_UNDERLINE;
}
SetCharFormat(richTextBox, selection, cft);
}
@@ -999,60 +1002,61 @@ namespace Volian.Controls.Library
CharFormatTwo cft = GetCharFormat(richTextBox, selection);
if (bSet)
{
cft.dwEffects |= CharFormatEffects.CFE_ITALIC;
cft.dwMask |= CharFormatMasks.CFM_ITALIC;
cft.dwEffects = CharFormatEffects.CFE_ITALIC;
cft.dwMask = CharFormatMasks.CFM_ITALIC;
}
else
{
cft.dwEffects &= ~RTBAPI.CharFormatEffects.CFE_ITALIC;
cft.dwEffects = CharFormatEffects.CFE_NONE;
cft.dwMask = CharFormatMasks.CFM_ITALIC;
}
SetCharFormat(richTextBox, selection, cft);
}
public static bool IsLink(RichTextBox richTextBox)
{
CharFormatTwo cft = GetCharFormat(richTextBox, RTBSelection.SCF_SELECTION);
return ((cft.dwEffects & CharFormatEffects.CFE_PROTECTED) == CharFormatEffects.CFE_PROTECTED);
}
public static void ToggleLink(bool bSet, RichTextBox richTextBox, RTBSelection selection)
{
CharFormatTwo cft = GetCharFormat(richTextBox, selection);
if (bSet)
{
cft.dwEffects |= CharFormatEffects.CFE_LINK;
cft.dwMask |= CharFormatMasks.CFM_LINK;
}
else
{
cft.dwEffects &= ~RTBAPI.CharFormatEffects.CFE_LINK;
}
SetCharFormat(richTextBox, selection, cft);
}
public static void UnProtect(RichTextBox richTextBox) //, string type, string text, string link)
{
//richTextBox.DetectUrls = false;
CharFormatTwo cft = GetCharFormat(richTextBox, RTBAPI.RTBSelection.SCF_SELECTION); ;
//int position = richTextBox.SelectionStart = richTextBox.TextLength;
//richTextBox.SelectionLength = 0;
//richTextBox.SelectedRtf = @"{\rtf1\ansi " + text + @"\v #" + link + @"\v0}";
//richTextBox.SelectedRtf = "{" + string.Format(@"\rtf1\ansi\protect\v {0}\v0 {1}\v #{2}", type, text, link) + "}";
//richTextBox.Select(position, type.Length + text.Length + link.Length + 1);
cft.dwMask = RTBAPI.CharFormatMasks.CFM_PROTECTED;
cft.dwEffects = 0;
// The lines below can be used to allow link text to be edited
//charFormat.dwMask = RTBAPI.CharFormatMasks.CFM_LINK;
//charFormat.dwEffects = RTBAPI.CharFormatEffects.CFE_LINK;
SetCharFormat(richTextBox, RTBSelection.SCF_SELECTION, cft);
//rtbRTF.SetSelectionLink(true);
//richTextBox.SelectionStart = richTextBox.TextLength;
//richTextBox.SelectionLength = 0;
}
public static void Protect(RichTextBox richTextBox) //, string type, string text, string link)
{
CharFormatTwo cft = GetCharFormat(richTextBox, RTBAPI.RTBSelection.SCF_SELECTION); ;
cft.dwMask = CharFormatMasks.CFM_PROTECTED;
cft.dwEffects = CharFormatEffects.CFE_PROTECTED;
SetCharFormat(richTextBox, RTBSelection.SCF_SELECTION, cft);
}
//public static bool IsLink(RichTextBox richTextBox)
//{
// CharFormatTwo cft = GetCharFormat(richTextBox, RTBSelection.SCF_SELECTION);
// return ((cft.dwEffects & CharFormatEffects.CFE_PROTECTED) == CharFormatEffects.CFE_PROTECTED);
//}
//public static void ToggleLink(bool bSet, RichTextBox richTextBox, RTBSelection selection)
//{
// CharFormatTwo cft = GetCharFormat(richTextBox, selection);
// if (bSet)
// {
// cft.dwEffects |= CharFormatEffects.CFE_LINK;
// cft.dwMask |= CharFormatMasks.CFM_LINK;
// }
// else
// {
// cft.dwEffects &= ~RTBAPI.CharFormatEffects.CFE_LINK;
// }
// SetCharFormat(richTextBox, selection, cft);
//}
//public static void UnProtect(RichTextBox richTextBox) //, string type, string text, string link)
//{
// //richTextBox.DetectUrls = false;
// CharFormatTwo cft = GetCharFormat(richTextBox, RTBAPI.RTBSelection.SCF_SELECTION); ;
// //int position = richTextBox.SelectionStart = richTextBox.TextLength;
// //richTextBox.SelectionLength = 0;
// //richTextBox.SelectedRtf = @"{\rtf1\ansi " + text + @"\v #" + link + @"\v0}";
// //richTextBox.SelectedRtf = "{" + string.Format(@"\rtf1\ansi\protect\v {0}\v0 {1}\v #{2}", type, text, link) + "}";
// //richTextBox.Select(position, type.Length + text.Length + link.Length + 1);
// cft.dwMask = RTBAPI.CharFormatMasks.CFM_PROTECTED;
// cft.dwEffects = 0;
// // The lines below can be used to allow link text to be edited
// //charFormat.dwMask = RTBAPI.CharFormatMasks.CFM_LINK;
// //charFormat.dwEffects = RTBAPI.CharFormatEffects.CFE_LINK;
// SetCharFormat(richTextBox, RTBSelection.SCF_SELECTION, cft);
// //rtbRTF.SetSelectionLink(true);
// //richTextBox.SelectionStart = richTextBox.TextLength;
// //richTextBox.SelectionLength = 0;
//}
//public static void Protect(RichTextBox richTextBox) //, string type, string text, string link)
//{
// CharFormatTwo cft = GetCharFormat(richTextBox, RTBAPI.RTBSelection.SCF_SELECTION); ;
// cft.dwMask = CharFormatMasks.CFM_PROTECTED;
// cft.dwEffects = CharFormatEffects.CFE_PROTECTED;
// SetCharFormat(richTextBox, RTBSelection.SCF_SELECTION, cft);
//}
//public static void SetLink(RichTextBox richTextBox, string type, string text, string link)
//{
// richTextBox.DetectUrls = false;