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

View File

@ -126,8 +126,8 @@ namespace Volian.Controls.Library
// save portion of this code for an explanation. // save portion of this code for an explanation.
text = text.Replace(@"\~", @"\u160?"); text = text.Replace(@"\~", @"\u160?");
text = text.Replace("\r\n", @"\par "); text = text.Replace("\r\n", @"\par ");
if (text.IndexOf(@"\line") > -1) //if (text.IndexOf(@"\line") > -1)
MessageBox.Show("Found rtf line"); // MessageBox.Show("Found rtf line");
text = text.Replace(@"\line", @"\par"); text = text.Replace(@"\line", @"\par");
// add colors around links: // add colors around links:

View File

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

View File

@ -166,7 +166,6 @@ namespace Volian.Controls.Library
{ {
_InitializingRTB = true; _InitializingRTB = true;
_SelectedRtfSB.Remove(0, _SelectedRtfSB.Length); _SelectedRtfSB.Remove(0, _SelectedRtfSB.Length);
DisplayText vlntxt = new DisplayText(_MyItemInfo, EpMode, VwMode, !edit, FieldToEdit); DisplayText vlntxt = new DisplayText(_MyItemInfo, EpMode, VwMode, !edit, FieldToEdit);
//if (_origDisplayText != null && vlntxt.StartText == _origDisplayText.StartText) //if (_origDisplayText != null && vlntxt.StartText == _origDisplayText.StartText)
//{ //{
@ -179,6 +178,7 @@ namespace Volian.Controls.Library
// Use Times New Roman for Debugging // Use Times New Roman for Debugging
//Font = new Font("Times New Roman", 14, FontStyle.Regular); //Font = new Font("Times New Roman", 14, FontStyle.Regular);
Font = _origDisplayText.TextFont.WindowsFont; Font = _origDisplayText.TextFont.WindowsFont;
//Font = new Font("Times New Roman", _origDisplayText.TextFont.WindowsFont.Size, _origDisplayText.TextFont.WindowsFont.Style);
#elif(RELEASE) #elif(RELEASE)
Font = _origDisplayText.TextFont.WindowsFont; // font defined in plant's format Font = _origDisplayText.TextFont.WindowsFont; // font defined in plant's format
#else //DEMO #else //DEMO
@ -191,7 +191,7 @@ namespace Volian.Controls.Library
// was confusing the 'handle' of the rtf box. // was confusing the 'handle' of the rtf box.
RTBAPI.SetLineSpacing(this, RTBAPI.ParaSpacing.PFS_EXACT); RTBAPI.SetLineSpacing(this, RTBAPI.ParaSpacing.PFS_EXACT);
AddRtfText(vlntxt.StartText); AddRtfText(vlntxt.StartText);
AddRtfStyles(); //AddRtfStyles();
// set readonly based on initial modes, however, these may change if // set readonly based on initial modes, however, these may change if
// user selected view mode. // user selected view mode.
ReadOnly = !(EpMode == E_EditPrintMode.Edit && VwMode == E_ViewMode.Edit); ReadOnly = !(EpMode == E_EditPrintMode.Edit && VwMode == E_ViewMode.Edit);
@ -721,10 +721,10 @@ namespace Volian.Controls.Library
if (SelectionLength > 0) DeleteCurrentSelection(null); if (SelectionLength > 0) DeleteCurrentSelection(null);
int position = SelectionStart; int position = SelectionStart;
SelectionLength = 0; SelectionLength = 0;
Console.WriteLine(this.Rtf); //Console.WriteLine(this.Rtf);
linkValue = linkValue.Replace("\\u8209?", "\\f1\\u8209?\\f0 "); linkValue = linkValue.Replace("\\u8209?", "\\f1\\u8209?\\f0 ");
SelectedRtf = @"{\rtf1\ansi"+FontTable+@"{\colortbl ;\red255\green0\blue0;}\v"+FontSize+@" <START]\v0\cf1 " + linkValue + @"\cf0\v " + linkUrl + @"\v0 \v [END>\v0 }"; SelectedRtf = @"{\rtf1\ansi"+FontTable+@"{\colortbl ;\red255\green0\blue0;}\v"+FontSize+@" <START]\v0\cf1 " + linkValue + @"\cf0\v " + linkUrl + @"\v0 \v [END>\v0 }";
Console.WriteLine(this.Rtf); //Console.WriteLine(this.Rtf);
this.SelectionLength = 0; this.SelectionLength = 0;
this.SelectionStart = position; this.SelectionStart = position;
FindAllLinks(); FindAllLinks();