Added tables to movement logic
Improved table layout
This commit is contained in:
parent
3a4ab8c801
commit
df34079386
@ -18,9 +18,7 @@ namespace Volian.Controls.Library
|
|||||||
/// Procedure Item Info - Top ItemInfo
|
/// Procedure Item Info - Top ItemInfo
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private ItemInfo _MyProcedureItemInfo;
|
private ItemInfo _MyProcedureItemInfo;
|
||||||
/// <summary>
|
// TODO: This is not correct. There should be a dictionary of Section Layouts
|
||||||
/// This is not correct. There should be a dictionary of Section Layouts
|
|
||||||
/// </summary>
|
|
||||||
private StepSectionLayoutData _MyStepSectionLayoutData;
|
private StepSectionLayoutData _MyStepSectionLayoutData;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Lookup Table to convert ItemInfo.ItemID to StepItem
|
/// Lookup Table to convert ItemInfo.ItemID to StepItem
|
||||||
@ -642,6 +640,7 @@ namespace Volian.Controls.Library
|
|||||||
if (ii.RNOs != null && ii.RNOLevel >= ii.ColumnMode) return BottomPart(ii.RNOs[0]);
|
if (ii.RNOs != null && ii.RNOLevel >= ii.ColumnMode) return BottomPart(ii.RNOs[0]);
|
||||||
if (ii.Sections != null) return BottomPart(ii.Sections[0].LastSibling);
|
if (ii.Sections != null) return BottomPart(ii.Sections[0].LastSibling);
|
||||||
if (ii.Steps != null) return BottomPart(ii.Steps[0].LastSibling);
|
if (ii.Steps != null) return BottomPart(ii.Steps[0].LastSibling);
|
||||||
|
if (ii.Tables != null) return BottomPart(ii.Tables[0].LastSibling);
|
||||||
return ii;
|
return ii;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -721,6 +720,7 @@ namespace Volian.Controls.Library
|
|||||||
// Subitems - go to top part of subitem
|
// Subitems - go to top part of subitem
|
||||||
// (the lookAtSub prevented looping within a substep group at same level)
|
// (the lookAtSub prevented looping within a substep group at same level)
|
||||||
if (lookAtSub && ii.Steps != null) return TopPart(ii.Steps[0]);
|
if (lookAtSub && ii.Steps != null) return TopPart(ii.Steps[0]);
|
||||||
|
if (lookAtSub && ii.Tables != null) return TopPart(ii.Tables[0]);
|
||||||
// RNOs: Use PMode (column)
|
// RNOs: Use PMode (column)
|
||||||
if (lookAtRNO && ii.RNOs != null && ii.RNOLevel >= ii.ColumnMode) return TopPart(ii.RNOs[0]);
|
if (lookAtRNO && ii.RNOs != null && ii.RNOLevel >= ii.ColumnMode) return TopPart(ii.RNOs[0]);
|
||||||
// Nextsibling - go to top part of sibling
|
// Nextsibling - go to top part of sibling
|
||||||
|
@ -68,6 +68,12 @@ namespace Volian.Controls.Library
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#region Properties and Variables
|
#region Properties and Variables
|
||||||
|
private static FontFamily _MyFontFamily = null;
|
||||||
|
public static FontFamily MyFontFamily
|
||||||
|
{
|
||||||
|
get { return StepRTB._MyFontFamily; }
|
||||||
|
set { StepRTB._MyFontFamily = value; }
|
||||||
|
}
|
||||||
// use newer rich text box....
|
// use newer rich text box....
|
||||||
//[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
|
//[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
|
||||||
//static extern IntPtr LoadLibrary(string lpFileName);
|
//static extern IntPtr LoadLibrary(string lpFileName);
|
||||||
@ -164,6 +170,17 @@ namespace Volian.Controls.Library
|
|||||||
private string _origRTF;
|
private string _origRTF;
|
||||||
public void RTBFillIn(bool edit)
|
public void RTBFillIn(bool edit)
|
||||||
{
|
{
|
||||||
|
if (edit && _MyStepItem != null && (_MyItemInfo.IsTable || _MyItemInfo.IsFigure))
|
||||||
|
{
|
||||||
|
// First get ColR
|
||||||
|
int colR = MyStepItem.MyStepPanel.ToDisplay(MyStepItem.MyStepSectionLayoutData.ColRTable, MyItemInfo.ColumnMode);
|
||||||
|
// Second get WidS
|
||||||
|
int widS = /* _WidthAdjust + borderWidth + */ MyStepItem.MyStepPanel.ToDisplay(MyStepItem.MyStepSectionLayoutData.WidSTableEdit, MyItemInfo.ColumnMode);
|
||||||
|
//int wNew = _MyStepItem.MyStepPanel.ToDisplay(_MyStepItem.MyStepSectionLayoutData.WidT);
|
||||||
|
int wNew = 70 + widS + colR * MyItemInfo.ColumnMode;
|
||||||
|
if(wNew > _MyStepItem.ItemWidth)
|
||||||
|
_MyStepItem.ItemWidth= wNew;
|
||||||
|
}
|
||||||
_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);
|
||||||
@ -177,14 +194,23 @@ namespace Volian.Controls.Library
|
|||||||
#if(DEBUG)
|
#if(DEBUG)
|
||||||
// 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);
|
Font formatFont = _origDisplayText.TextFont.WindowsFont;
|
||||||
|
if (_MyItemInfo.IsTable || _MyItemInfo.IsFigure)
|
||||||
|
Font = formatFont;
|
||||||
|
else
|
||||||
|
Font = new Font(_MyFontFamily == null ? formatFont.FontFamily : _MyFontFamily, formatFont.Size, formatFont.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
|
||||||
// Comment this out for DEMO to customer
|
// Comment this out for DEMO to customer
|
||||||
// UN-Comment this for testing
|
// UN-Comment this for testing
|
||||||
//Font = _origDisplayText.TextFont.WindowsFont; // font defined in plant's format
|
//Font = _origDisplayText.TextFont.WindowsFont; // font defined in plant's format
|
||||||
|
Font formatFont = _origDisplayText.TextFont.WindowsFont;
|
||||||
|
if (_MyItemInfo.IsTable || _MyItemInfo.IsFigure)
|
||||||
|
Font = formatFont;
|
||||||
|
else
|
||||||
|
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
|
||||||
@ -221,18 +247,18 @@ namespace Volian.Controls.Library
|
|||||||
}
|
}
|
||||||
AddEventHandlers();
|
AddEventHandlers();
|
||||||
}
|
}
|
||||||
else
|
//else
|
||||||
{
|
//{
|
||||||
if (_MyStepItem != null && (_MyItemInfo.IsTable || _MyItemInfo.IsFigure))
|
// if (_MyStepItem != null && (_MyItemInfo.IsTable || _MyItemInfo.IsFigure))
|
||||||
{
|
// {
|
||||||
//AdjustWidthForContent();
|
// //_MyStepItem.ItemWidth = (int)_MyStepItem.TableWidth(Font, Text,false);
|
||||||
_MyStepItem.ItemWidth = (int)_MyStepItem.TableWidth(Font, Text);
|
// _MyStepItem.ItemWidth = _MyStepItem.MyStepPanel.ToDisplay(_MyStepItem.MyStepSectionLayoutData.WidT);
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
_origRTF = Rtf;
|
_origRTF = Rtf;
|
||||||
_InitializingRTB = false;
|
_InitializingRTB = false;
|
||||||
_MyItemInfo.MyConfig.PropertyChanged += new PropertyChangedEventHandler(MyConfig_PropertyChanged);
|
_MyItemInfo.MyConfig.PropertyChanged += new PropertyChangedEventHandler(MyConfig_PropertyChanged);
|
||||||
AdjustSizeForContents(); // TODO: this is not quite right yet.
|
AdjustSizeForContents(!edit); // TODO: this is not quite right yet.
|
||||||
}
|
}
|
||||||
private bool _ProcessKeystrokes = true;
|
private bool _ProcessKeystrokes = true;
|
||||||
public bool ProcessKeystrokes
|
public bool ProcessKeystrokes
|
||||||
@ -276,7 +302,7 @@ namespace Volian.Controls.Library
|
|||||||
set
|
set
|
||||||
{
|
{
|
||||||
_ContentsRectangle = value;
|
_ContentsRectangle = value;
|
||||||
AdjustSizeForContents();
|
AdjustSizeForContents(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public Size ContentsSize
|
public Size ContentsSize
|
||||||
@ -290,7 +316,7 @@ namespace Volian.Controls.Library
|
|||||||
set
|
set
|
||||||
{
|
{
|
||||||
_AdjustSize = value;
|
_AdjustSize = value;
|
||||||
AdjustSizeForContents();
|
AdjustSizeForContents(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public System.Windows.Forms.AutoScaleMode AutoScaleMode;
|
public System.Windows.Forms.AutoScaleMode AutoScaleMode;
|
||||||
@ -360,7 +386,6 @@ namespace Volian.Controls.Library
|
|||||||
this.MouseLeave += new EventHandler(StepRTB_MouseLeave);
|
this.MouseLeave += new EventHandler(StepRTB_MouseLeave);
|
||||||
this.SelectionChanged +=new EventHandler(StepRTB_SelectionChanged);
|
this.SelectionChanged +=new EventHandler(StepRTB_SelectionChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetUp()
|
private void SetUp()
|
||||||
{
|
{
|
||||||
this.Height = 10; // initialize the height to 10, the default height was too big for the cells in grid tables
|
this.Height = 10; // initialize the height to 10, the default height was too big for the cells in grid tables
|
||||||
@ -776,18 +801,21 @@ namespace Volian.Controls.Library
|
|||||||
{
|
{
|
||||||
if (HeightChanged != null) HeightChanged(sender, args);
|
if (HeightChanged != null) HeightChanged(sender, args);
|
||||||
}
|
}
|
||||||
private void AdjustSizeForContents()
|
private void AdjustSizeForContents(bool adjustWidth)
|
||||||
|
{
|
||||||
|
if (!_InitializingRTB)
|
||||||
{
|
{
|
||||||
Size offset = Size - ClientSize;
|
Size offset = Size - ClientSize;
|
||||||
int widthNew = ContentsSize.Width + offset.Width + AdjustSize.Width ;
|
int widthNew = ContentsSize.Width + offset.Width + AdjustSize.Width ;
|
||||||
int heightNew = ContentsSize.Height + offset.Height + AdjustSize.Height;
|
int heightNew = ContentsSize.Height + offset.Height + AdjustSize.Height;
|
||||||
Size szNew = new Size(widthNew,heightNew);
|
Size szNew = new Size((adjustWidth ? widthNew : (widthNew > Width ? widthNew : Width)), heightNew);
|
||||||
if (this.Size != szNew && !_InitializingRTB)
|
if (this.Size != szNew)
|
||||||
{
|
{
|
||||||
this.Size = szNew;
|
this.Size = szNew;
|
||||||
OnHeightChanged(this, new EventArgs());
|
OnHeightChanged(this, new EventArgs());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
private float GetStringWidth(string strMeasureString)
|
private float GetStringWidth(string strMeasureString)
|
||||||
{
|
{
|
||||||
using (Graphics g = Graphics.FromHwnd(Handle))
|
using (Graphics g = Graphics.FromHwnd(Handle))
|
||||||
@ -1232,7 +1260,6 @@ namespace Volian.Controls.Library
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#region KeyboardHandling
|
#region KeyboardHandling
|
||||||
|
|
||||||
void StepRTB_KeyUp(object sender, KeyEventArgs e)
|
void StepRTB_KeyUp(object sender, KeyEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.Control)
|
if (e.Control)
|
||||||
@ -1305,7 +1332,6 @@ namespace Volian.Controls.Library
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
private bool IsControlChar = false;
|
private bool IsControlChar = false;
|
||||||
private bool _SendBackSpace = false;
|
private bool _SendBackSpace = false;
|
||||||
@ -2069,35 +2095,42 @@ namespace Volian.Controls.Library
|
|||||||
}
|
}
|
||||||
public void OutlineTable(bool withBorder)
|
public void OutlineTable(bool withBorder)
|
||||||
{
|
{
|
||||||
|
if (_MyStepItem != null) // Set the width based upon the contents
|
||||||
|
_MyStepItem.ItemWidth = (int)_MyStepItem.TableWidth(Font, Text, true);
|
||||||
// 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'");
|
||||||
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;
|
||||||
for (int row = 0; row < Lines.Length; row++)
|
for (int row = 0; row < Lines.Length; row++)
|
||||||
{
|
{
|
||||||
//int spaces = w - line.Length;
|
//int spaces = w - line.Length;
|
||||||
int offset = GetFirstCharIndexFromLine(row);
|
int offset1 = GetFirstCharIndexFromLine(row);
|
||||||
Select(offset, 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;
|
||||||
offset = SelectionStart + w2 + (w - w3) + 1;
|
int offset2 = SelectionStart + w2 + (w - w3) + 1;
|
||||||
|
int selStart = SelectionStart;
|
||||||
SelectedRtf = RtfPrefix + (withBorder ? @"\u9474?" : " ") + "}";
|
SelectedRtf = RtfPrefix + (withBorder ? @"\u9474?" : " ") + "}";
|
||||||
Select(SelectionStart + w2, 0);
|
Select(SelectionStart + w2, 0);
|
||||||
if (w3 < w)
|
if (w3 < w)
|
||||||
{
|
{
|
||||||
SelectedText = "".PadRight(w - w3);
|
SelectedText = "".PadRight(w - w3);
|
||||||
Select(offset, 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);
|
||||||
}
|
}
|
||||||
// Add the top line
|
// Add the top line
|
||||||
if (_MyStepItem != null)
|
//if (_MyStepItem != null)
|
||||||
{
|
//{
|
||||||
//AdjustWidthForContent();
|
// Console.WriteLine("Char[0]={0:X}", (int)(Text[0]));
|
||||||
_MyStepItem.ItemWidth = (int)_MyStepItem.TableWidth(Font, Text);
|
// _MyStepItem.ItemWidth = (int)_MyStepItem.TableWidth(Font, Text.Replace('\u2502','-'), false);
|
||||||
}
|
//}
|
||||||
|
//Console.WriteLine("After Edges\n{0}\n{1}", Rtf, Text);
|
||||||
Select(0, 0);
|
Select(0, 0);
|
||||||
SelectedRtf = RtfPrefix + (withBorder ? @"\u9484?" : " ") + horzLine + (withBorder ? @"\u9488?\par " : @" \par ") + "}";
|
SelectedRtf = RtfPrefix + (withBorder ? @"\u9484?" : " ") + horzLine + (withBorder ? @"\u9488?\par " : @" \par ") + "}";
|
||||||
// Add the bottom line
|
// Add the bottom line
|
||||||
@ -2105,6 +2138,7 @@ namespace Volian.Controls.Library
|
|||||||
ContentsResized += new ContentsResizedEventHandler(StepRTB_ContentsResized);
|
ContentsResized += new ContentsResizedEventHandler(StepRTB_ContentsResized);
|
||||||
SelectedRtf = RtfPrefix + (withBorder ? @"\par\u9492?" : @"\par ") + horzLine + (withBorder ? @"\u9496?" : @" ") + "}";
|
SelectedRtf = RtfPrefix + (withBorder ? @"\par\u9492?" : @"\par ") + horzLine + (withBorder ? @"\u9496?" : @" ") + "}";
|
||||||
ContentsResized -= new ContentsResizedEventHandler(StepRTB_ContentsResized);
|
ContentsResized -= new ContentsResizedEventHandler(StepRTB_ContentsResized);
|
||||||
|
//Console.WriteLine("After Top and Bottom\n{0}\n{1}", Rtf, Text);
|
||||||
ReplaceLinesInTable(withBorder);
|
ReplaceLinesInTable(withBorder);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user