This commit is contained in:
2010-03-25 14:51:27 +00:00
parent 8fe5e8c60c
commit 0b0c769ab0
2 changed files with 112 additions and 20 deletions

View File

@@ -224,7 +224,7 @@ namespace Volian.Controls.Library
else
Font = new Font("Bookman Old Style", formatFont.Size, formatFont.Style);
#endif
Text = ""; // Initialize text before add text
Text = ""; // Initialize text before add text
// IMPORTANT: SetLineSpacing must be set before Links, otherwise it
// was confusing the 'handle' of the rtf box.
RTBAPI.SetLineSpacing(this, RTBAPI.ParaSpacing.PFS_EXACT);
@@ -609,6 +609,19 @@ namespace Volian.Controls.Library
}
#endregion
#region SaveData
public void SaveText(bool force)
{
if (ReadOnly) return;
if (ViewRTB) return;
if (!force && !_IsDirty && Text.Contains("(Resolved Transition Text)") == false) return;
bool success = _origDisplayText.Save((RichTextBox)this);
if (success)
{
FindAllLinks();
_origRTF = Rtf;
ClearUndo();
}
}
public void SaveText()
{
if (ReadOnly) return;
@@ -759,7 +772,7 @@ namespace Volian.Controls.Library
SelectionLength = 0;
//Console.WriteLine(this.Rtf);
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 + @"[END>\v0 }";
//Console.WriteLine(this.Rtf);
this.SelectionLength = 0;
this.SelectionStart = position;
@@ -2279,24 +2292,42 @@ namespace Volian.Controls.Library
}
public void OutlineTable(bool withBorder)
{
//if (_MyItemInfo.ItemID == 64671)
//{
// Console.WriteLine("TABLE");
// Console.WriteLine("WIDTH {0}", this.Width);
//}
if (_MyStepItem != null) // Set the width based upon the contents
_MyStepItem.ItemWidth = (int)_MyStepItem.TableWidth(Font, Text, true);
{
int newwidth = (int)_MyStepItem.TableWidth(Font, Text, true);
if (_MyStepItem.ItemWidth != newwidth)
{
_MyStepItem.ItemWidth = newwidth;
}
}
// Determine the number of characters per line
int w = MaxCharacterWidth();
//Console.WriteLine("Before {0},{1}\n{2}\n{3}", Width, w, Rtf, Text);
Console.WriteLine("'Row','last','Start','w2','w','w3','offset1','offset2'");
//Console.WriteLine("'Row','last','Start','w2','w','w3','offset1','offset2'");
string horzLine = Repeat(withBorder ? @"\u9472?" : " ", w);
// Determine the number of lines
int l = Lines.Length;
int lastoffset = 0;
for (int row = 0; row < Lines.Length; row++)
{
//string strb4 = Lines[row];
//int spaces = w - line.Length;
int offset1 = GetFirstCharIndexFromLine(row);
if (lastoffset != offset1)
{
//Console.WriteLine("OFFSET MISMATCH {0},{1}", lastoffset, offset1);
offset1 = lastoffset;
}
Select(offset1, 0);
string cleanLine = RemoveLinkComments(Lines[row]);
int w2 = Lines[row].Length;
int w3 = cleanLine.Length;
int offset2 = SelectionStart + w2 + (w - w3) + 1;
lastoffset = offset2 + 2;
int selStart = SelectionStart;
SelectedRtf = RtfPrefix + (withBorder ? @"\u9474?" : " ") + "}";
Select(SelectionStart + w2, 0);
@@ -2306,7 +2337,9 @@ namespace Volian.Controls.Library
Select(offset2, 0);
}
SelectedRtf = RtfPrefix + (withBorder ? @"\u9474?" : " ") + "}";
Console.WriteLine("{0},{1},{2},{3},{4},{5},{6},{7}", row, selStart, SelectionStart, w2, w, w3, offset1, offset2);
//string strafter = Lines[row];
//Console.WriteLine("'{0}'\r\n'{1}'\r\n'{2}'", strb4, strafter,cleanLine);
//Console.WriteLine("{0},{1},{2},{3},{4},{5},{6},{7}", row, selStart, SelectionStart, w2, w, w3, offset1, offset2);
}
// Add the top line
//if (_MyStepItem != null)
@@ -2338,7 +2371,8 @@ namespace Volian.Controls.Library
}
return w;
}
private string RemoveLinkComments(string line)
//private string RemoveLinkComments(string line)
internal static string RemoveLinkComments(string line)
{
StringBuilder sb = new StringBuilder();
int lastIndex = 0;
@@ -2355,7 +2389,7 @@ namespace Volian.Controls.Library
MatchCollection mcEnd = Regex.Matches(result, @"#Link.*?\[END>");
if (mcEnd.Count > 0)
{
result = result.Substring(0, mcEnd[0].Index - 1) + result.Substring(mcEnd[0].Index + mcEnd[0].Length);
result = result.Substring(0, mcEnd[0].Index) + result.Substring(mcEnd[0].Index + mcEnd[0].Length);
}
return result;
}
@@ -2422,7 +2456,21 @@ namespace Volian.Controls.Library
{
int rowOffset = GetFirstCharIndexFromLine(row);
Select(rowOffset + col, 1);
SelectedRtf = RtfPrefix + TableCharsU[tableCharIndx] + "?}";
string charToBeReplaced = SelectedText;
if (Text.Length > (rowOffset + col + 7) && Text.Substring(rowOffset + col + 1, 6) != "#Link:")
SelectedRtf = RtfPrefix + TableCharsU[tableCharIndx] + "?}";
else
{
SelectionStart++;
int lenComment = 1 + SelectionStart - (rowOffset + col);
//Console.WriteLine("{0},{1},{2}", rowOffset + col, SelectionStart, SelectionLength);
Select(rowOffset + col, 0);
SelectedRtf = RtfPrefix + TableCharsU[tableCharIndx] + "?}";
Select(rowOffset + col, lenComment);
//Console.WriteLine("'{0}',{1},{2},{3}", SelectedText, lenComment, SelectionLength, SelectionStart);
//Console.WriteLine("'{0}'", SelectedRtf);
SelectedRtf = SelectedRtf.Replace(" " + charToBeReplaced, "");
}
}
#endregion
#region Debug