This commit is contained in:
parent
8fe5e8c60c
commit
0b0c769ab0
@ -480,7 +480,12 @@ namespace Volian.Controls.Library
|
|||||||
if (_MyPreviousStepItem != null)
|
if (_MyPreviousStepItem != null)
|
||||||
{
|
{
|
||||||
_IgnoreResize=true;
|
_IgnoreResize=true;
|
||||||
Width = MyPreviousStepItem.Width;
|
if (_MyStepData != null && (_MyStepData.Type == "Table" || _MyStepData.ParentType == "Table"))
|
||||||
|
{
|
||||||
|
ItemWidth = (int)TableWidth(_MyStepRTB.Font, _MyItemInfo.MyContent.Text, true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
Width = MyPreviousStepItem.Width;
|
||||||
_IgnoreResize=false;
|
_IgnoreResize=false;
|
||||||
//ShowMe("");
|
//ShowMe("");
|
||||||
//if (MyID > _StartingID)
|
//if (MyID > _StartingID)
|
||||||
@ -746,7 +751,7 @@ namespace Volian.Controls.Library
|
|||||||
}
|
}
|
||||||
private void SetupStepItem(ItemInfo itemInfo, StepPanel myStepPanel, StepItem myParentStepItem, ChildRelation myChildRelation, bool expand, StepItem nextStepItem)
|
private void SetupStepItem(ItemInfo itemInfo, StepPanel myStepPanel, StepItem myParentStepItem, ChildRelation myChildRelation, bool expand, StepItem nextStepItem)
|
||||||
{
|
{
|
||||||
if (itemInfo.ItemID==225)_MyStepRTB.Resize += new EventHandler(_MyStepRTB_Resize);
|
if (itemInfo.ItemID == 225) _MyStepRTB.Resize += new EventHandler(_MyStepRTB_Resize);
|
||||||
_MyStepRTB.MyStepItem = this;
|
_MyStepRTB.MyStepItem = this;
|
||||||
//// TIMING: DisplayItem.TimeIt("CSLARTB InitComp");
|
//// TIMING: DisplayItem.TimeIt("CSLARTB InitComp");
|
||||||
BackColor = myStepPanel.PanelColor;
|
BackColor = myStepPanel.PanelColor;
|
||||||
@ -1592,6 +1597,11 @@ namespace Volian.Controls.Library
|
|||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void StepItem_Resize(object sender, EventArgs e)
|
private void StepItem_Resize(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
//if (_MyItemInfo != null && _MyItemInfo.MyContent.Type == 20008)
|
||||||
|
//{
|
||||||
|
// vlnStackTrace.ShowStackLocal(string.Format("{0},{1}", _MyItemInfo.ItemID, _MyStepRTB.Width), 3);
|
||||||
|
// Console.WriteLine("asd");
|
||||||
|
//}
|
||||||
//ShowMe("Resize");
|
//ShowMe("Resize");
|
||||||
if (MyStepRTB.Text.EndsWith("\n"))
|
if (MyStepRTB.Text.EndsWith("\n"))
|
||||||
if (!_LookForID.Contains(MyID))
|
if (!_LookForID.Contains(MyID))
|
||||||
@ -1824,28 +1834,62 @@ namespace Volian.Controls.Library
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="myFont"></param>
|
/// <param name="myFont"></param>
|
||||||
/// <param name="txt"></param>
|
/// <param name="txt"></param>
|
||||||
|
/// <param name="addBorder"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public float TableWidth(Font myFont, string txt, bool addBorder)
|
public float TableWidth(Font myFont, string txt, bool addBorder)
|
||||||
{
|
{
|
||||||
string[] lines = txt.Split("\n".ToCharArray());
|
string[] lines = txt.Split("\n".ToCharArray());
|
||||||
float max = 0;
|
float max = 0;
|
||||||
string lineMax = "";
|
//string lineMax = "";
|
||||||
Graphics g = this.CreateGraphics();
|
SizeF siz10 = new SizeF();
|
||||||
PointF pnt = new PointF(0, 0);
|
using (Graphics g = this.CreateGraphics())
|
||||||
|
{
|
||||||
|
PointF pnt = new PointF(0, 0);
|
||||||
|
siz10 = g.MeasureString("MMMMMMMMMM", myFont, pnt, StringFormat.GenericTypographic);
|
||||||
|
}
|
||||||
foreach (string line in lines)
|
foreach (string line in lines)
|
||||||
{
|
{
|
||||||
string line2 = (addBorder ? "--" : "") + Regex.Replace(line, @"\\.*? ", ""); // Remove RTF Commands
|
string line2 = (addBorder ? "--" : "") + Regex.Replace(line, @"\\.*? ", ""); // Remove RTF Commands - Really should not be any
|
||||||
SizeF siz = g.MeasureString(line2, myFont, pnt, StringFormat.GenericTypographic);
|
//line2 = line2.Replace(@"\u8209?", "-");
|
||||||
if (siz.Width + _MyStepPanel.MyStepPanelSettings.TableWidthAdjust > max)
|
//line2 = line2.Replace("<START]", "");
|
||||||
|
//line2 = Regex.Replace(line2, @"#Link:.*?\[END>","");
|
||||||
|
line2 = StepRTB.RemoveLinkComments(line2);
|
||||||
|
// MeasureString doesn't work properly if the line include graphics characters.
|
||||||
|
//SizeF siz = g.MeasureString(line2, myFont, pnt, StringFormat.GenericTypographic);
|
||||||
|
float wid = line2.Length * siz10.Width / 10;
|
||||||
|
//Console.WriteLine("'LineWidth'\t'{0}'\t{1}\t{2:0.}\t{3:0.}\t{4:0.}",
|
||||||
|
// line2.Length, wid, max, _MyStepPanel.MyStepPanelSettings.TableWidthAdjust, line2);
|
||||||
|
if (wid + _MyStepPanel.MyStepPanelSettings.TableWidthAdjust > max)
|
||||||
{
|
{
|
||||||
max = siz.Width + _MyStepPanel.MyStepPanelSettings.TableWidthAdjust;
|
max = wid + _MyStepPanel.MyStepPanelSettings.TableWidthAdjust;
|
||||||
lineMax = line2;
|
//lineMax = line2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//vlnStackTrace.ShowStackLocal("TableWidth", 1, 10);
|
//vlnStackTrace.ShowStackLocal("TableWidth", 1, 10);
|
||||||
Console.WriteLine("TableWidth = {0}, lineMax = '{1}', myFont = {2}", max, lineMax, myFont);
|
//Console.WriteLine("TableWidth = {0}, lineMax = '{1}', myFont = {2}", max, lineMax, myFont);
|
||||||
return max;
|
return max;
|
||||||
}
|
}
|
||||||
|
// OLD - RHM 3-24-2010 public float TableWidth(Font myFont, string txt, bool addBorder)
|
||||||
|
//{
|
||||||
|
// string[] lines = txt.Split("\n".ToCharArray());
|
||||||
|
// float max = 0;
|
||||||
|
// string lineMax = "";
|
||||||
|
// Graphics g = this.CreateGraphics();
|
||||||
|
// PointF pnt = new PointF(0, 0);
|
||||||
|
// foreach (string line in lines)
|
||||||
|
// {
|
||||||
|
// string line2 = (addBorder ? "--" : "") + Regex.Replace(line, @"\\.*? ", ""); // Remove RTF Commands
|
||||||
|
// SizeF siz = g.MeasureString(line2, myFont, pnt, StringFormat.GenericTypographic);
|
||||||
|
// if (siz.Width + _MyStepPanel.MyStepPanelSettings.TableWidthAdjust > max)
|
||||||
|
// {
|
||||||
|
// max = siz.Width + _MyStepPanel.MyStepPanelSettings.TableWidthAdjust;
|
||||||
|
// lineMax = line2;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// //vlnStackTrace.ShowStackLocal("TableWidth", 1, 10);
|
||||||
|
// Console.WriteLine("TableWidth = {0}, lineMax = '{1}', myFont = {2}", max, lineMax, myFont);
|
||||||
|
// return max;
|
||||||
|
//}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Calculates the table location
|
/// Calculates the table location
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -224,7 +224,7 @@ namespace Volian.Controls.Library
|
|||||||
else
|
else
|
||||||
Font = new Font("Bookman Old Style", formatFont.Size, formatFont.Style);
|
Font = new Font("Bookman Old Style", formatFont.Size, formatFont.Style);
|
||||||
#endif
|
#endif
|
||||||
Text = ""; // Initialize text before add text
|
Text = ""; // Initialize text before add text
|
||||||
// IMPORTANT: SetLineSpacing must be set before Links, otherwise it
|
// IMPORTANT: SetLineSpacing must be set before Links, otherwise it
|
||||||
// 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);
|
||||||
@ -609,6 +609,19 @@ namespace Volian.Controls.Library
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#region SaveData
|
#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()
|
public void SaveText()
|
||||||
{
|
{
|
||||||
if (ReadOnly) return;
|
if (ReadOnly) return;
|
||||||
@ -759,7 +772,7 @@ namespace Volian.Controls.Library
|
|||||||
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 + @"[END>\v0 }";
|
||||||
//Console.WriteLine(this.Rtf);
|
//Console.WriteLine(this.Rtf);
|
||||||
this.SelectionLength = 0;
|
this.SelectionLength = 0;
|
||||||
this.SelectionStart = position;
|
this.SelectionStart = position;
|
||||||
@ -2279,24 +2292,42 @@ namespace Volian.Controls.Library
|
|||||||
}
|
}
|
||||||
public void OutlineTable(bool withBorder)
|
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
|
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
|
// Determine the number of characters per line
|
||||||
int w = MaxCharacterWidth();
|
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);
|
string horzLine = Repeat(withBorder ? @"\u9472?" : " ", w);
|
||||||
// Determine the number of lines
|
// Determine the number of lines
|
||||||
int l = Lines.Length;
|
int l = Lines.Length;
|
||||||
|
int lastoffset = 0;
|
||||||
for (int row = 0; row < Lines.Length; row++)
|
for (int row = 0; row < Lines.Length; row++)
|
||||||
{
|
{
|
||||||
|
//string strb4 = Lines[row];
|
||||||
//int spaces = w - line.Length;
|
//int spaces = w - line.Length;
|
||||||
int offset1 = GetFirstCharIndexFromLine(row);
|
int offset1 = GetFirstCharIndexFromLine(row);
|
||||||
|
if (lastoffset != offset1)
|
||||||
|
{
|
||||||
|
//Console.WriteLine("OFFSET MISMATCH {0},{1}", lastoffset, offset1);
|
||||||
|
offset1 = lastoffset;
|
||||||
|
}
|
||||||
Select(offset1, 0);
|
Select(offset1, 0);
|
||||||
string cleanLine = RemoveLinkComments(Lines[row]);
|
string cleanLine = RemoveLinkComments(Lines[row]);
|
||||||
int w2 = Lines[row].Length;
|
int w2 = Lines[row].Length;
|
||||||
int w3 = cleanLine.Length;
|
int w3 = cleanLine.Length;
|
||||||
int offset2 = SelectionStart + w2 + (w - w3) + 1;
|
int offset2 = SelectionStart + w2 + (w - w3) + 1;
|
||||||
|
lastoffset = offset2 + 2;
|
||||||
int selStart = SelectionStart;
|
int selStart = SelectionStart;
|
||||||
SelectedRtf = RtfPrefix + (withBorder ? @"\u9474?" : " ") + "}";
|
SelectedRtf = RtfPrefix + (withBorder ? @"\u9474?" : " ") + "}";
|
||||||
Select(SelectionStart + w2, 0);
|
Select(SelectionStart + w2, 0);
|
||||||
@ -2306,7 +2337,9 @@ namespace Volian.Controls.Library
|
|||||||
Select(offset2, 0);
|
Select(offset2, 0);
|
||||||
}
|
}
|
||||||
SelectedRtf = RtfPrefix + (withBorder ? @"\u9474?" : " ") + "}";
|
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
|
// Add the top line
|
||||||
//if (_MyStepItem != null)
|
//if (_MyStepItem != null)
|
||||||
@ -2338,7 +2371,8 @@ namespace Volian.Controls.Library
|
|||||||
}
|
}
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
private string RemoveLinkComments(string line)
|
//private string RemoveLinkComments(string line)
|
||||||
|
internal static string RemoveLinkComments(string line)
|
||||||
{
|
{
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
int lastIndex = 0;
|
int lastIndex = 0;
|
||||||
@ -2355,7 +2389,7 @@ namespace Volian.Controls.Library
|
|||||||
MatchCollection mcEnd = Regex.Matches(result, @"#Link.*?\[END>");
|
MatchCollection mcEnd = Regex.Matches(result, @"#Link.*?\[END>");
|
||||||
if (mcEnd.Count > 0)
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
@ -2422,7 +2456,21 @@ namespace Volian.Controls.Library
|
|||||||
{
|
{
|
||||||
int rowOffset = GetFirstCharIndexFromLine(row);
|
int rowOffset = GetFirstCharIndexFromLine(row);
|
||||||
Select(rowOffset + col, 1);
|
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
|
#endregion
|
||||||
#region Debug
|
#region Debug
|
||||||
|
Loading…
x
Reference in New Issue
Block a user