This commit is contained in:
Kathy Ruffing 2011-11-21 16:58:11 +00:00
parent f48c8fd7e0
commit 5c69100338
2 changed files with 40 additions and 6 deletions

View File

@ -60,7 +60,7 @@ namespace Volian.Controls.Library
get { return Width - lblTab.Left; }
set
{
Width = RTBMargin + value + lblTab.Left;
Width = CheckOffMargin + RTBMargin + value + lblTab.Left;
}
}
/// <summary>
@ -152,11 +152,18 @@ namespace Volian.Controls.Library
ItemInfo.ResetTabString(MyID);
string tabString = MyItemInfo.MyTab.CleanText;
lblTab.Text = tabString;
lblTab.Width = tabString.Length * 8 * MyStepPanel.DPI / 96;// Adjust width for DPI
// calculate the width based upon characters per inch considering user's DPI
int cpi = MyItemInfo.IsStep ? (int)MyItemInfo.FormatStepData.TabData.Font.CPI : 12;
// if the tab ends with a single digit & has a '.' before it, add space for the possibility
// that the number can be two digits, for example... 8.1.9 goes to 8.1.10. We want
// the step windows to line up, so the 8.1.9 has one character more space (lastDigitSingle)
bool lastDigitSingle = Regex.IsMatch(tabString, "^.*[^0-9][0-9] *$");
lblTab.Width = ((lastDigitSingle?1:0) + tabString.Length) * MyStepPanel.DPI/cpi;
Invalidate();
_MyStepRTB.Left = lblTab.Left + lblTab.Width;// +2;
_MyStepRTB.Width = Width - _MyStepRTB.Left - RTBMargin;
_TabFormat = value; // tabString;
_MyStepRTB.Left = lblTab.Left + lblTab.Width;
_MyStepRTB.Width = Width - _MyStepRTB.Left - RTBMargin - CheckOffMargin;
_TabFormat = value;
}
}
}
@ -173,6 +180,33 @@ namespace Volian.Controls.Library
get { return _RTBMargin; }
set { _RTBMargin = value; }
}
private int? _CheckOffMargin = null;
/// <summary>
/// Margin between the EditItem and the StepRTB. Appears on the Right.
/// Will allow space to draw a CheckOff on the right side of the EditItem.
/// </summary>
public int CheckOffMargin
{
get
{
if (_CheckOffMargin == null)
{
if (MyItemInfo==null) _CheckOffMargin = 0;
else
{
if (!MyItemInfo.IsStep || !MyItemInfo.SectionHasCheckOffs()) _CheckOffMargin = 0;
else
{
Graphics g = CreateGraphics();
SizeF sz = g.MeasureString("M", MyItemInfo.FormatStepData.Font.WindowsFont);
_CheckOffMargin = (int)sz.Width;
}
}
}
return (int)_CheckOffMargin;
}
set { _CheckOffMargin = value; }
}
#endregion
#region Constructors
public RTBItem(ItemInfo itemInfo, StepPanel myStepPanel, EditItem myParentEditItem, ChildRelation myChildRelation, bool expand)

View File

@ -323,7 +323,7 @@ namespace Volian.Controls.Library
{
if (_MyItemInfo == null && Parent is EditItem)
_MyItemInfo = (Parent as EditItem).MyItemInfo;
else if (_MyItemInfo == null && Parent.Parent is EditItem)
else if (_MyItemInfo == null && Parent != null && Parent.Parent is EditItem)
_MyItemInfo = (Parent.Parent as EditItem).MyItemInfo;
return _MyItemInfo;
}