Make TableWidth a Public Method

Fix Logic to move selection around links
This commit is contained in:
Rich 2009-12-08 02:32:32 +00:00
parent 9f780c4477
commit 3858729217
2 changed files with 25 additions and 10 deletions

View File

@ -1607,7 +1607,7 @@ namespace Volian.Controls.Library
/// <param name="myFont"></param>
/// <param name="txt"></param>
/// <returns></returns>
private float TableWidth(Font myFont, string txt)
public float TableWidth(Font myFont, string txt)
{
string[] lines = txt.Split("\n".ToCharArray());
float max = 0;

View File

@ -168,12 +168,12 @@ namespace Volian.Controls.Library
_SelectedRtfSB.Remove(0, _SelectedRtfSB.Length);
DisplayText vlntxt = new DisplayText(_MyItemInfo, EpMode, VwMode, !edit, FieldToEdit);
if (_origDisplayText != null && vlntxt.StartText == _origDisplayText.StartText)
{
ReadOnly = !(EpMode == E_EditPrintMode.Edit && VwMode == E_ViewMode.Edit);
if (!ReadOnly && !edit) ReadOnly = true;
return;
}
//if (_origDisplayText != null && vlntxt.StartText == _origDisplayText.StartText)
//{
// ReadOnly = !(EpMode == E_EditPrintMode.Edit && VwMode == E_ViewMode.Edit);
// if (!ReadOnly && !edit) ReadOnly = true;
// return;
//}
_origDisplayText = vlntxt;
#if(DEBUG)
// Use Times New Roman for Debugging
@ -207,7 +207,6 @@ namespace Volian.Controls.Library
int typ = ((int)_MyItemInfo.MyContent.Type) % 10000;
OutlineTable(_MyItemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList[typ].Type.IndexOf(@"Borderless")<0);
FindAllLinks();
AdjustSizeForContents(); // TODO: this is not quite right yet.
}
SelectAll();
SelectionHangingIndent = 0;
@ -222,9 +221,18 @@ namespace Volian.Controls.Library
}
AddEventHandlers();
}
else
{
if (_MyStepItem != null && (_MyItemInfo.IsTable || _MyItemInfo.IsFigure))
{
//AdjustWidthForContent();
_MyStepItem.ItemWidth = (int)_MyStepItem.TableWidth(Font, Text);
}
}
_origRTF = Rtf;
_InitializingRTB = false;
_MyItemInfo.MyConfig.PropertyChanged += new PropertyChangedEventHandler(MyConfig_PropertyChanged);
AdjustSizeForContents(); // TODO: this is not quite right yet.
}
private bool _ProcessKeystrokes = true;
public bool ProcessKeystrokes
@ -776,7 +784,7 @@ namespace Volian.Controls.Library
int widthNew = ContentsSize.Width + offset.Width + AdjustSize.Width;
int heightNew = ContentsSize.Height + offset.Height + AdjustSize.Height;
Size szNew = new Size(widthNew,heightNew);
if (this.Size != szNew)
if (this.Size != szNew && !_InitializingRTB)
{
this.Size = szNew;
OnHeightChanged(this, new EventArgs());
@ -2080,13 +2088,20 @@ namespace Volian.Controls.Library
SelectedRtf = RtfPrefix + (withBorder ? @"\u9474?" : " ") + "}";
}
// Add the top line
if (_MyStepItem != null)
{
//AdjustWidthForContent();
_MyStepItem.ItemWidth = (int)_MyStepItem.TableWidth(Font, Text);
}
Select(0, 0);
SelectedRtf = RtfPrefix + (withBorder ? @"\u9484?" : " ") + horzLine + (withBorder ? @"\u9488?\par " : @" \par ") + "}";
// Add the bottom line
Select(TextLength, 0);
ContentsResized += new ContentsResizedEventHandler(StepRTB_ContentsResized);
SelectedRtf = RtfPrefix + (withBorder ? @"\par\u9492?" : @"\par ") + horzLine + (withBorder ? @"\u9496?" : @" ") + "}";
ContentsResized -= new ContentsResizedEventHandler(StepRTB_ContentsResized);
ReplaceLinesInTable(withBorder);
}
private int MaxCharacterWidth()
{