This commit is contained in:
Kathy Ruffing 2011-01-19 16:20:57 +00:00
parent 0830dc5323
commit 3214475301
2 changed files with 77 additions and 77 deletions

View File

@ -21,14 +21,14 @@ namespace Volian.Controls.Library
private ItemInfo _MyProcedureItemInfo; private ItemInfo _MyProcedureItemInfo;
// TODO: This is not correct. There should be a dictionary of Section Layouts // TODO: This is not correct. There should be a dictionary of Section Layouts
/// <summary> /// <summary>
/// Lookup Table to convert ItemInfo.ItemID to StepItem /// Lookup Table to convert ItemInfo.ItemID to RTBItem
/// </summary> /// </summary>
internal Dictionary<int, StepItem> _LookupStepItems; internal Dictionary<int, RTBItem> _LookupRTBItems;
public StepItem FindItem(ItemInfo itemInfo) public RTBItem FindItem(ItemInfo itemInfo)
{ {
if (itemInfo == null) return null; if (itemInfo == null) return null;
if (!_LookupStepItems.ContainsKey(itemInfo.ItemID)) return null; if (!_LookupRTBItems.ContainsKey(itemInfo.ItemID)) return null;
return _LookupStepItems[itemInfo.ItemID]; return _LookupRTBItems[itemInfo.ItemID];
} }
/// <summary> /// <summary>
/// Currently selected RichTextBox /// Currently selected RichTextBox
@ -61,7 +61,7 @@ namespace Volian.Controls.Library
#endregion #endregion
#region Item Events #region Item Events
/// <summary> /// <summary>
/// Occurs when the user clicks tab of a StepItem /// Occurs when the user clicks tab of a RTBItem
/// </summary> /// </summary>
public event StepPanelEvent ItemClick; public event StepPanelEvent ItemClick;
/// <summary> /// <summary>
@ -75,7 +75,7 @@ namespace Volian.Controls.Library
} }
private bool ItemSelectionChangeShown = false; // This keeps OnItemSelectedChanged from being called twice when an item is selected. private bool ItemSelectionChangeShown = false; // This keeps OnItemSelectedChanged from being called twice when an item is selected.
/// <summary> /// <summary>
/// Occurs when the selected StepItem changes /// Occurs when the selected RTBItem changes
/// </summary> /// </summary>
public event ItemSelectedChangedEvent ItemSelectedChanged; public event ItemSelectedChangedEvent ItemSelectedChanged;
/// <summary> /// <summary>
@ -101,7 +101,7 @@ namespace Volian.Controls.Library
internal void OnAttachmentClicked(object sender, StepPanelAttachmentEventArgs args) internal void OnAttachmentClicked(object sender, StepPanelAttachmentEventArgs args)
{ {
if (AttachmentClicked != null) AttachmentClicked(sender, args); if (AttachmentClicked != null) AttachmentClicked(sender, args);
else MessageBox.Show(args.MyStepItem.MyItemInfo.MyContent.MyEntry.MyDocument.DocumentTitle, "Unhandled Attachment Click", MessageBoxButtons.OK, MessageBoxIcon.Information); else MessageBox.Show(args.MyRTBItem.MyItemInfo.MyContent.MyEntry.MyDocument.DocumentTitle, "Unhandled Attachment Click", MessageBoxButtons.OK, MessageBoxIcon.Information);
} }
// Edit/View mode change // Edit/View mode change
@ -262,9 +262,9 @@ namespace Volian.Controls.Library
InactiveColor = PanelColor = BackColor; InactiveColor = PanelColor = BackColor;
foreach (Control ctrl in Controls) foreach (Control ctrl in Controls)
{ {
if (ctrl.GetType() == typeof(StepItem)) if (ctrl.GetType() == typeof(RTBItem))
{ {
StepItem rtb = (StepItem)ctrl; RTBItem rtb = (RTBItem)ctrl;
rtb.BackColor = BackColor; rtb.BackColor = BackColor;
} }
} }
@ -278,11 +278,11 @@ namespace Volian.Controls.Library
private void ExpandAsNeeded(ItemInfo myItemInfo) private void ExpandAsNeeded(ItemInfo myItemInfo)
{ {
int id = myItemInfo.ItemID; int id = myItemInfo.ItemID;
if (!_LookupStepItems.ContainsKey(id)) // If the item is not currently displayed if (!_LookupRTBItems.ContainsKey(id)) // If the item is not currently displayed
ExpandAsNeeded((ItemInfo)myItemInfo.ActiveParent); // Expand it's parent ExpandAsNeeded((ItemInfo)myItemInfo.ActiveParent); // Expand it's parent
if (_LookupStepItems.ContainsKey(id)) // Expanding Parent should have added it to _LookupStepItems if (_LookupRTBItems.ContainsKey(id)) // Expanding Parent should have added it to _LookupRTBItems
{ {
StepItem itm = _LookupStepItems[id]; RTBItem itm = _LookupRTBItems[id];
ItemInfo ii = myItemInfo.ActiveParent as ItemInfo; ItemInfo ii = myItemInfo.ActiveParent as ItemInfo;
if (itm.Visible == false && ii != null) if (itm.Visible == false && ii != null)
ExpandAsNeeded((ItemInfo)myItemInfo.ActiveParent); ExpandAsNeeded((ItemInfo)myItemInfo.ActiveParent);
@ -309,10 +309,10 @@ namespace Volian.Controls.Library
//this.Scroll += new ScrollEventHandler(DisplayPanel_Scroll); //this.Scroll += new ScrollEventHandler(DisplayPanel_Scroll);
//// TIMING: DisplayItem.TimeIt("pMyItem Scroll"); //// TIMING: DisplayItem.TimeIt("pMyItem Scroll");
Controls.Clear(); Controls.Clear();
_LookupStepItems = new Dictionary<int, StepItem>(); _LookupRTBItems = new Dictionary<int, RTBItem>();
//// TIMING: DisplayItem.TimeIt("pMyItem Clear"); //// TIMING: DisplayItem.TimeIt("pMyItem Clear");
//SuspendLayout(); //SuspendLayout();
StepItem tmpStepItem = new StepItem(_MyProcedureItemInfo, this, null, ChildRelation.None, false); RTBItem tmpRTBItem = new RTBItem(_MyProcedureItemInfo, this, null, ChildRelation.None, false);
//ResumeLayout(); //ResumeLayout();
//// TIMING: DisplayItem.TimeIt("pMyItem End"); //// TIMING: DisplayItem.TimeIt("pMyItem End");
} }
@ -345,10 +345,10 @@ namespace Volian.Controls.Library
{ {
//_SelectedStepRTB.BackColor = InactiveColor; //_SelectedStepRTB.BackColor = InactiveColor;
//lastRTB.SetBackColor(); //lastRTB.SetBackColor();
bool shouldDelete = !lastRTB.MyStepItem.BeingRemoved && lastRTB.Text.Length == 0; bool shouldDelete = !lastRTB.MyRTBItem.BeingRemoved && lastRTB.Text.Length == 0;
if (shouldDelete) if (shouldDelete)
{ {
if (lastRTB.MyStepItem.HasChildren) if (lastRTB.MyRTBItem.HasChildren)
{ {
if (value != null && value.MyItemInfo.HasAncestor(lastRTB.MyItemInfo)) if (value != null && value.MyItemInfo.HasAncestor(lastRTB.MyItemInfo))
{ {
@ -363,30 +363,30 @@ namespace Volian.Controls.Library
} }
if (shouldDelete) if (shouldDelete)
{ {
float oldTop = lastRTB.MyStepItem.Top; float oldTop = lastRTB.MyRTBItem.Top;
StepItem newFocus = lastRTB.MyStepItem.DeleteItem(); RTBItem newFocus = lastRTB.MyRTBItem.DeleteItem();
float newTop = newFocus.Top; float newTop = newFocus.Top;
lastRTB.MyStepItem.Dispose(); lastRTB.MyRTBItem.Dispose();
newFocus.SetAllTabs(); newFocus.SetAllTabs();
// If the step being deleted appears above the step to recieve focus, find another step // If the step being deleted appears above the step to recieve focus, find another step
// to use so that the steps are positioned properly (vertically) // to use so that the steps are positioned properly (vertically)
if (oldTop < newTop) if (oldTop < newTop)
{ {
if (newFocus.MyParentStepItem != null) if (newFocus.MyParentRTBItem != null)
{ {
if (newFocus.Top > newFocus.MyParentStepItem.Top) if (newFocus.Top > newFocus.MyParentRTBItem.Top)
newFocus.MyParentStepItem.AdjustLocation(); newFocus.MyParentRTBItem.AdjustLocation();
else if (newFocus.MyParentStepItem.MyPreviousStepItem != null && else if (newFocus.MyParentRTBItem.MyPreviousRTBItem != null &&
newFocus.Top > newFocus.MyParentStepItem.MyPreviousStepItem.Top) newFocus.Top > newFocus.MyParentRTBItem.MyPreviousRTBItem.Top)
newFocus.MyParentStepItem.MyPreviousStepItem.AdjustLocation(); newFocus.MyParentRTBItem.MyPreviousRTBItem.AdjustLocation();
else if (newFocus.MyParentStepItem.MyParentStepItem != null && else if (newFocus.MyParentRTBItem.MyParentRTBItem != null &&
newFocus.Top > newFocus.MyParentStepItem.MyParentStepItem.Top) newFocus.Top > newFocus.MyParentRTBItem.MyParentRTBItem.Top)
newFocus.MyParentStepItem.MyParentStepItem.AdjustLocation(); newFocus.MyParentRTBItem.MyParentRTBItem.AdjustLocation();
else else
newFocus.AdjustLocation(); newFocus.AdjustLocation();
} }
else if (newFocus.MyPreviousStepItem != null) else if (newFocus.MyPreviousRTBItem != null)
newFocus.MyPreviousStepItem.AdjustLocation(); newFocus.MyPreviousRTBItem.AdjustLocation();
else else
newFocus.AdjustLocation(); newFocus.AdjustLocation();
} }
@ -431,8 +431,8 @@ namespace Volian.Controls.Library
int id = value.ItemID; int id = value.ItemID;
ExpandAsNeeded(value); ExpandAsNeeded(value);
// reset the entire step panel if the item isn't found. // reset the entire step panel if the item isn't found.
if (!_LookupStepItems.ContainsKey(id)) Reset(); if (!_LookupRTBItems.ContainsKey(id)) Reset();
StepItem itm = _LookupStepItems[id]; RTBItem itm = _LookupRTBItems[id];
ItemSelectionChangeShown = false;//OnItemSelectedChanged has not run yet. ItemSelectionChangeShown = false;//OnItemSelectedChanged has not run yet.
itm.ItemSelect(); itm.ItemSelect();
if (!ItemSelectionChangeShown) OnItemSelectedChanged(this, new ItemSelectedChangedEventArgs(itm)); if (!ItemSelectionChangeShown) OnItemSelectedChanged(this, new ItemSelectedChangedEventArgs(itm));
@ -446,21 +446,21 @@ namespace Volian.Controls.Library
set { _DisplayItemChanging = value; } set { _DisplayItemChanging = value; }
} }
/// <summary> /// <summary>
/// Returns the SelectedStepItem /// Returns the SelectedRTBItem
/// </summary> /// </summary>
public StepItem SelectedStepItem public RTBItem SelectedRTBItem
{ {
get { return (_SelectedItemInfo != null) ? _LookupStepItems[_SelectedItemInfo.ItemID] : null; } get { return (_SelectedItemInfo != null) ? _LookupRTBItems[_SelectedItemInfo.ItemID] : null; }
} }
/// <summary> /// <summary>
/// Displays the selected StepItem /// Displays the selected RTBItem
/// </summary> /// </summary>
public void ItemShow() public void ItemShow()
{ {
if (_SelectedItemInfo != null && SelectedStepItem.MyStepRTB.BeingDisposed == false) if (_SelectedItemInfo != null && SelectedRTBItem.MyStepRTB.BeingDisposed == false)
{ {
SelectedStepItem.ItemShow(); SelectedRTBItem.ItemShow();
OnItemSelectedChanged(this, new ItemSelectedChangedEventArgs(SelectedStepItem)); OnItemSelectedChanged(this, new ItemSelectedChangedEventArgs(SelectedRTBItem));
} }
} }
public new void MouseWheel(MouseEventArgs e) public new void MouseWheel(MouseEventArgs e)
@ -675,17 +675,17 @@ namespace Volian.Controls.Library
} }
} }
/// <summary> /// <summary>
/// Output all of the StepItem controls to the log /// Output all of the RTBItem controls to the log
/// </summary> /// </summary>
private void ListControls() private void ListControls()
{ {
// Walk through the controls and find the next control for each // Walk through the controls and find the next control for each
if(_MyLog.IsInfoEnabled)_MyLog.InfoFormat("'Item','Next'"); if(_MyLog.IsInfoEnabled)_MyLog.InfoFormat("'Item','Next'");
foreach (Control control in Controls) foreach (Control control in Controls)
if (control.GetType() == typeof(StepItem)) if (control.GetType() == typeof(RTBItem))
{ {
StepItem rtb = (StepItem)control; RTBItem rtb = (RTBItem)control;
StepItem nxt = rtb.NextDownStepItem; RTBItem nxt = rtb.NextDownRTBItem;
if(_MyLog.IsInfoEnabled)_MyLog.InfoFormat("{0},{1}", rtb.MyID, nxt == null ? 0 : nxt.MyID); if(_MyLog.IsInfoEnabled)_MyLog.InfoFormat("{0},{1}", rtb.MyID, nxt == null ? 0 : nxt.MyID);
} }
} }
@ -737,7 +737,7 @@ namespace Volian.Controls.Library
// The following lines are debug to check that the results of moving down and moving up are the same // The following lines are debug to check that the results of moving down and moving up are the same
//ix = ArrowDown(ii); //ix = ArrowDown(ii);
//Console.WriteLine("'Up',{0},{1},{2},{3}", rtb.MyItemInfo.ItemID, rtb.MyItemInfo.DBSequence, ii.DBSequence, ix.DBSequence); //Console.WriteLine("'Up',{0},{1},{2},{3}", rtb.MyItemInfo.ItemID, rtb.MyItemInfo.DBSequence, ii.DBSequence, ix.DBSequence);
if (ii != null) SelectedStepRTB = _LookupStepItems[ii.ItemID].MyStepRTB; if (ii != null) SelectedStepRTB = _LookupRTBItems[ii.ItemID].MyStepRTB;
break; break;
case E_ArrowKeys.Down: case E_ArrowKeys.Down:
case E_ArrowKeys.CtrlDown: case E_ArrowKeys.CtrlDown:
@ -746,14 +746,14 @@ namespace Volian.Controls.Library
case E_ArrowKeys.Right: case E_ArrowKeys.Right:
case E_ArrowKeys.CtrlRight: case E_ArrowKeys.CtrlRight:
if (rtb.MyItemInfo.RNOs != null) if (rtb.MyItemInfo.RNOs != null)
SelectedStepRTB = _LookupStepItems[rtb.MyItemInfo.RNOs[0].ItemID].MyStepRTB; SelectedStepRTB = _LookupRTBItems[rtb.MyItemInfo.RNOs[0].ItemID].MyStepRTB;
else else
ii = MoveDown(rtb, ii); ii = MoveDown(rtb, ii);
break; break;
case E_ArrowKeys.Left: case E_ArrowKeys.Left:
case E_ArrowKeys.CtrlLeft: case E_ArrowKeys.CtrlLeft:
if (!rtb.MyItemInfo.IsProcedure) if (!rtb.MyItemInfo.IsProcedure)
SelectedStepRTB = _LookupStepItems[rtb.MyItemInfo.MyParent.ItemID].MyStepRTB; SelectedStepRTB = _LookupRTBItems[rtb.MyItemInfo.MyParent.ItemID].MyStepRTB;
break; break;
default: default:
break; break;
@ -766,7 +766,7 @@ namespace Volian.Controls.Library
// The following lines are debug to check that the results of moving down and moving up are the same // The following lines are debug to check that the results of moving down and moving up are the same
//ix = ArrowUp(ii); //ix = ArrowUp(ii);
//Console.WriteLine("'Down',{0},{1},{2},{3}", rtb.MyItemInfo.ItemID, rtb.MyItemInfo.DBSequence, ii.DBSequence, ix.DBSequence); //Console.WriteLine("'Down',{0},{1},{2},{3}", rtb.MyItemInfo.ItemID, rtb.MyItemInfo.DBSequence, ii.DBSequence, ix.DBSequence);
if (ii != null) SelectedStepRTB = _LookupStepItems[ii.ItemID].MyStepRTB; if (ii != null) SelectedStepRTB = _LookupRTBItems[ii.ItemID].MyStepRTB;
return ii; return ii;
} }
private ItemInfo ArrowUp(ItemInfo ii) private ItemInfo ArrowUp(ItemInfo ii)
@ -857,7 +857,7 @@ namespace Volian.Controls.Library
break; break;
} }
if (ii == null) return; if (ii == null) return;
SelectedStepRTB = _LookupStepItems[ii.ItemID].MyStepRTB; SelectedStepRTB = _LookupRTBItems[ii.ItemID].MyStepRTB;
} }
#endregion #endregion
} }
@ -1019,11 +1019,11 @@ namespace Volian.Controls.Library
} }
public partial class StepPanelEventArgs public partial class StepPanelEventArgs
{ {
private StepItem _MyStepItem; private RTBItem _MyRTBItem;
public StepItem MyStepItem public RTBItem MyRTBItem
{ {
get { return _MyStepItem; } get { return _MyRTBItem; }
set { _MyStepItem = value; } set { _MyRTBItem = value; }
} }
private MouseEventArgs _MyMouseEventArgs; private MouseEventArgs _MyMouseEventArgs;
public MouseEventArgs MyMouseEventArgs public MouseEventArgs MyMouseEventArgs
@ -1032,9 +1032,9 @@ namespace Volian.Controls.Library
set { _MyMouseEventArgs = value; } set { _MyMouseEventArgs = value; }
} }
public StepPanelEventArgs(StepItem myStepItem, MouseEventArgs myMouseEventArgs) public StepPanelEventArgs(RTBItem myRTBItem, MouseEventArgs myMouseEventArgs)
{ {
_MyStepItem = myStepItem; _MyRTBItem = myRTBItem;
_MyMouseEventArgs = myMouseEventArgs; _MyMouseEventArgs = myMouseEventArgs;
} }
} }
@ -1046,44 +1046,44 @@ namespace Volian.Controls.Library
get { return _MyItemInfo; } get { return _MyItemInfo; }
set { _MyItemInfo = value; } set { _MyItemInfo = value; }
} }
private StepItem _MyStepItem = null; private RTBItem _MyRTBItem = null;
public StepItem MyStepItem public RTBItem MyRTBItem
{ {
get { return _MyStepItem; } get { return _MyRTBItem; }
set { _MyStepItem = value; } set { _MyRTBItem = value; }
} }
public ItemSelectedChangedEventArgs(ItemInfo myItemInfo) public ItemSelectedChangedEventArgs(ItemInfo myItemInfo)
{ {
_MyItemInfo = myItemInfo; _MyItemInfo = myItemInfo;
} }
public ItemSelectedChangedEventArgs(StepItem myStepItem) public ItemSelectedChangedEventArgs(RTBItem myRTBItem)
{ {
_MyItemInfo = myStepItem.MyItemInfo; _MyItemInfo = myRTBItem.MyItemInfo;
_MyStepItem = myStepItem; _MyRTBItem = myRTBItem;
} }
} }
public partial class StepPanelAttachmentEventArgs public partial class StepPanelAttachmentEventArgs
{ {
private StepItem _MyStepItem; private RTBItem _MyRTBItem;
public StepItem MyStepItem public RTBItem MyRTBItem
{ {
get { return _MyStepItem; } get { return _MyRTBItem; }
set { _MyStepItem = value; } set { _MyRTBItem = value; }
} }
public StepPanelAttachmentEventArgs(StepItem myStepItem) public StepPanelAttachmentEventArgs(RTBItem myRTBItem)
{ {
_MyStepItem = myStepItem; _MyRTBItem = myRTBItem;
} }
} }
public partial class StepPanelLinkEventArgs : EventArgs public partial class StepPanelLinkEventArgs : EventArgs
{ {
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private StepItem _LinkedStepItem; private RTBItem _LinkedRTBItem;
public StepItem LinkedStepItem public RTBItem LinkedRTBItem
{ {
get { return _LinkedStepItem; } get { return _LinkedRTBItem; }
//set { _LinkedStepItem = value; } //set { _LinkedRTBItem = value; }
} }
private string _LinkInfoText; private string _LinkInfoText;
public string LinkInfoText public string LinkInfoText
@ -1095,9 +1095,9 @@ namespace Volian.Controls.Library
{ {
get { return _MyLinkText;} get { return _MyLinkText;}
} }
public StepPanelLinkEventArgs(StepItem linkedStepItem, string linkInfoText) public StepPanelLinkEventArgs(RTBItem linkedRTBItem, string linkInfoText)
{ {
_LinkedStepItem = linkedStepItem; _LinkedRTBItem = linkedRTBItem;
_LinkInfoText = linkInfoText; _LinkInfoText = linkInfoText;
_MyLinkText = new LinkText(_LinkInfoText); _MyLinkText = new LinkText(_LinkInfoText);
//if(_MyLog.IsInfoEnabled)_MyLog.InfoFormat("\r\n LinkInfo '{0}'\r\n", linkInfo.LinkText); //if(_MyLog.IsInfoEnabled)_MyLog.InfoFormat("\r\n LinkInfo '{0}'\r\n", linkInfo.LinkText);

View File

@ -16,10 +16,10 @@ namespace Volian.Controls.Library
if (disposing && (components != null)) if (disposing && (components != null))
{ {
SelectedStepRTB = null; // Save Changes SelectedStepRTB = null; // Save Changes
foreach (StepItem stepItem in _LookupStepItems.Values) foreach (RTBItem RTBItem in _LookupRTBItems.Values)
{ {
stepItem.MyItemInfo.ResetParts(); RTBItem.MyItemInfo.ResetParts();
stepItem.MyItemInfo.MyContent.RefreshContentParts(); RTBItem.MyItemInfo.MyContent.RefreshContentParts();
} }
components.Dispose(); components.Dispose();
} }