diff --git a/PROMS/Volian.Controls.Library/StepItem.cs b/PROMS/Volian.Controls.Library/StepItem.cs
index 81571155..fe69931c 100644
--- a/PROMS/Volian.Controls.Library/StepItem.cs
+++ b/PROMS/Volian.Controls.Library/StepItem.cs
@@ -480,7 +480,12 @@ namespace Volian.Controls.Library
if (_MyPreviousStepItem != null)
{
_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;
//ShowMe("");
//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)
{
- if (itemInfo.ItemID==225)_MyStepRTB.Resize += new EventHandler(_MyStepRTB_Resize);
+ if (itemInfo.ItemID == 225) _MyStepRTB.Resize += new EventHandler(_MyStepRTB_Resize);
_MyStepRTB.MyStepItem = this;
//// TIMING: DisplayItem.TimeIt("CSLARTB InitComp");
BackColor = myStepPanel.PanelColor;
@@ -1592,6 +1597,11 @@ namespace Volian.Controls.Library
///
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");
if (MyStepRTB.Text.EndsWith("\n"))
if (!_LookForID.Contains(MyID))
@@ -1824,28 +1834,62 @@ namespace Volian.Controls.Library
///
///
///
+ ///
///
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);
+ //string lineMax = "";
+ SizeF siz10 = new SizeF();
+ using (Graphics g = this.CreateGraphics())
+ {
+ PointF pnt = new PointF(0, 0);
+ siz10 = g.MeasureString("MMMMMMMMMM", myFont, pnt, StringFormat.GenericTypographic);
+ }
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)
+ string line2 = (addBorder ? "--" : "") + Regex.Replace(line, @"\\.*? ", ""); // Remove RTF Commands - Really should not be any
+ //line2 = line2.Replace(@"\u8209?", "-");
+ //line2 = line2.Replace("","");
+ 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;
- lineMax = line2;
+ max = wid + _MyStepPanel.MyStepPanelSettings.TableWidthAdjust;
+ //lineMax = line2;
}
}
//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;
}
+ // 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;
+ //}
///
/// Calculates the table location
///
diff --git a/PROMS/Volian.Controls.Library/StepRTB.cs b/PROMS/Volian.Controls.Library/StepRTB.cs
index 153637ef..ddc692f4 100644
--- a/PROMS/Volian.Controls.Library/StepRTB.cs
+++ b/PROMS/Volian.Controls.Library/StepRTB.cs
@@ -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+@" \v0 }";
+ SelectedRtf = @"{\rtf1\ansi"+FontTable+@"{\colortbl ;\red255\green0\blue0;}\v"+FontSize+@" \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