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;
// TODO: This is not correct. There should be a dictionary of Section Layouts
/// <summary>
/// Lookup Table to convert ItemInfo.ItemID to StepItem
/// Lookup Table to convert ItemInfo.ItemID to RTBItem
/// </summary>
internal Dictionary<int, StepItem> _LookupStepItems;
public StepItem FindItem(ItemInfo itemInfo)
internal Dictionary<int, RTBItem> _LookupRTBItems;
public RTBItem FindItem(ItemInfo itemInfo)
{
if (itemInfo == null) return null;
if (!_LookupStepItems.ContainsKey(itemInfo.ItemID)) return null;
return _LookupStepItems[itemInfo.ItemID];
if (!_LookupRTBItems.ContainsKey(itemInfo.ItemID)) return null;
return _LookupRTBItems[itemInfo.ItemID];
}
/// <summary>
/// Currently selected RichTextBox
@ -61,7 +61,7 @@ namespace Volian.Controls.Library
#endregion
#region Item Events
/// <summary>
/// Occurs when the user clicks tab of a StepItem
/// Occurs when the user clicks tab of a RTBItem
/// </summary>
public event StepPanelEvent ItemClick;
/// <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.
/// <summary>
/// Occurs when the selected StepItem changes
/// Occurs when the selected RTBItem changes
/// </summary>
public event ItemSelectedChangedEvent ItemSelectedChanged;
/// <summary>
@ -101,7 +101,7 @@ namespace Volian.Controls.Library
internal void OnAttachmentClicked(object sender, StepPanelAttachmentEventArgs 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
@ -262,9 +262,9 @@ namespace Volian.Controls.Library
InactiveColor = PanelColor = BackColor;
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;
}
}
@ -278,11 +278,11 @@ namespace Volian.Controls.Library
private void ExpandAsNeeded(ItemInfo myItemInfo)
{
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
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;
if (itm.Visible == false && ii != null)
ExpandAsNeeded((ItemInfo)myItemInfo.ActiveParent);
@ -309,10 +309,10 @@ namespace Volian.Controls.Library
//this.Scroll += new ScrollEventHandler(DisplayPanel_Scroll);
//// TIMING: DisplayItem.TimeIt("pMyItem Scroll");
Controls.Clear();
_LookupStepItems = new Dictionary<int, StepItem>();
_LookupRTBItems = new Dictionary<int, RTBItem>();
//// TIMING: DisplayItem.TimeIt("pMyItem Clear");
//SuspendLayout();
StepItem tmpStepItem = new StepItem(_MyProcedureItemInfo, this, null, ChildRelation.None, false);
RTBItem tmpRTBItem = new RTBItem(_MyProcedureItemInfo, this, null, ChildRelation.None, false);
//ResumeLayout();
//// TIMING: DisplayItem.TimeIt("pMyItem End");
}
@ -345,10 +345,10 @@ namespace Volian.Controls.Library
{
//_SelectedStepRTB.BackColor = InactiveColor;
//lastRTB.SetBackColor();
bool shouldDelete = !lastRTB.MyStepItem.BeingRemoved && lastRTB.Text.Length == 0;
bool shouldDelete = !lastRTB.MyRTBItem.BeingRemoved && lastRTB.Text.Length == 0;
if (shouldDelete)
{
if (lastRTB.MyStepItem.HasChildren)
if (lastRTB.MyRTBItem.HasChildren)
{
if (value != null && value.MyItemInfo.HasAncestor(lastRTB.MyItemInfo))
{
@ -363,30 +363,30 @@ namespace Volian.Controls.Library
}
if (shouldDelete)
{
float oldTop = lastRTB.MyStepItem.Top;
StepItem newFocus = lastRTB.MyStepItem.DeleteItem();
float oldTop = lastRTB.MyRTBItem.Top;
RTBItem newFocus = lastRTB.MyRTBItem.DeleteItem();
float newTop = newFocus.Top;
lastRTB.MyStepItem.Dispose();
lastRTB.MyRTBItem.Dispose();
newFocus.SetAllTabs();
// 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)
if (oldTop < newTop)
{
if (newFocus.MyParentStepItem != null)
if (newFocus.MyParentRTBItem != null)
{
if (newFocus.Top > newFocus.MyParentStepItem.Top)
newFocus.MyParentStepItem.AdjustLocation();
else if (newFocus.MyParentStepItem.MyPreviousStepItem != null &&
newFocus.Top > newFocus.MyParentStepItem.MyPreviousStepItem.Top)
newFocus.MyParentStepItem.MyPreviousStepItem.AdjustLocation();
else if (newFocus.MyParentStepItem.MyParentStepItem != null &&
newFocus.Top > newFocus.MyParentStepItem.MyParentStepItem.Top)
newFocus.MyParentStepItem.MyParentStepItem.AdjustLocation();
if (newFocus.Top > newFocus.MyParentRTBItem.Top)
newFocus.MyParentRTBItem.AdjustLocation();
else if (newFocus.MyParentRTBItem.MyPreviousRTBItem != null &&
newFocus.Top > newFocus.MyParentRTBItem.MyPreviousRTBItem.Top)
newFocus.MyParentRTBItem.MyPreviousRTBItem.AdjustLocation();
else if (newFocus.MyParentRTBItem.MyParentRTBItem != null &&
newFocus.Top > newFocus.MyParentRTBItem.MyParentRTBItem.Top)
newFocus.MyParentRTBItem.MyParentRTBItem.AdjustLocation();
else
newFocus.AdjustLocation();
}
else if (newFocus.MyPreviousStepItem != null)
newFocus.MyPreviousStepItem.AdjustLocation();
else if (newFocus.MyPreviousRTBItem != null)
newFocus.MyPreviousRTBItem.AdjustLocation();
else
newFocus.AdjustLocation();
}
@ -431,8 +431,8 @@ namespace Volian.Controls.Library
int id = value.ItemID;
ExpandAsNeeded(value);
// reset the entire step panel if the item isn't found.
if (!_LookupStepItems.ContainsKey(id)) Reset();
StepItem itm = _LookupStepItems[id];
if (!_LookupRTBItems.ContainsKey(id)) Reset();
RTBItem itm = _LookupRTBItems[id];
ItemSelectionChangeShown = false;//OnItemSelectedChanged has not run yet.
itm.ItemSelect();
if (!ItemSelectionChangeShown) OnItemSelectedChanged(this, new ItemSelectedChangedEventArgs(itm));
@ -446,21 +446,21 @@ namespace Volian.Controls.Library
set { _DisplayItemChanging = value; }
}
/// <summary>
/// Returns the SelectedStepItem
/// Returns the SelectedRTBItem
/// </summary>
public StepItem SelectedStepItem
public RTBItem SelectedRTBItem
{
get { return (_SelectedItemInfo != null) ? _LookupStepItems[_SelectedItemInfo.ItemID] : null; }
get { return (_SelectedItemInfo != null) ? _LookupRTBItems[_SelectedItemInfo.ItemID] : null; }
}
/// <summary>
/// Displays the selected StepItem
/// Displays the selected RTBItem
/// </summary>
public void ItemShow()
{
if (_SelectedItemInfo != null && SelectedStepItem.MyStepRTB.BeingDisposed == false)
if (_SelectedItemInfo != null && SelectedRTBItem.MyStepRTB.BeingDisposed == false)
{
SelectedStepItem.ItemShow();
OnItemSelectedChanged(this, new ItemSelectedChangedEventArgs(SelectedStepItem));
SelectedRTBItem.ItemShow();
OnItemSelectedChanged(this, new ItemSelectedChangedEventArgs(SelectedRTBItem));
}
}
public new void MouseWheel(MouseEventArgs e)
@ -675,17 +675,17 @@ namespace Volian.Controls.Library
}
}
/// <summary>
/// Output all of the StepItem controls to the log
/// Output all of the RTBItem controls to the log
/// </summary>
private void ListControls()
{
// Walk through the controls and find the next control for each
if(_MyLog.IsInfoEnabled)_MyLog.InfoFormat("'Item','Next'");
foreach (Control control in Controls)
if (control.GetType() == typeof(StepItem))
if (control.GetType() == typeof(RTBItem))
{
StepItem rtb = (StepItem)control;
StepItem nxt = rtb.NextDownStepItem;
RTBItem rtb = (RTBItem)control;
RTBItem nxt = rtb.NextDownRTBItem;
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
//ix = ArrowDown(ii);
//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;
case E_ArrowKeys.Down:
case E_ArrowKeys.CtrlDown:
@ -746,14 +746,14 @@ namespace Volian.Controls.Library
case E_ArrowKeys.Right:
case E_ArrowKeys.CtrlRight:
if (rtb.MyItemInfo.RNOs != null)
SelectedStepRTB = _LookupStepItems[rtb.MyItemInfo.RNOs[0].ItemID].MyStepRTB;
SelectedStepRTB = _LookupRTBItems[rtb.MyItemInfo.RNOs[0].ItemID].MyStepRTB;
else
ii = MoveDown(rtb, ii);
break;
case E_ArrowKeys.Left:
case E_ArrowKeys.CtrlLeft:
if (!rtb.MyItemInfo.IsProcedure)
SelectedStepRTB = _LookupStepItems[rtb.MyItemInfo.MyParent.ItemID].MyStepRTB;
SelectedStepRTB = _LookupRTBItems[rtb.MyItemInfo.MyParent.ItemID].MyStepRTB;
break;
default:
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
//ix = ArrowUp(ii);
//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;
}
private ItemInfo ArrowUp(ItemInfo ii)
@ -857,7 +857,7 @@ namespace Volian.Controls.Library
break;
}
if (ii == null) return;
SelectedStepRTB = _LookupStepItems[ii.ItemID].MyStepRTB;
SelectedStepRTB = _LookupRTBItems[ii.ItemID].MyStepRTB;
}
#endregion
}
@ -1019,11 +1019,11 @@ namespace Volian.Controls.Library
}
public partial class StepPanelEventArgs
{
private StepItem _MyStepItem;
public StepItem MyStepItem
private RTBItem _MyRTBItem;
public RTBItem MyRTBItem
{
get { return _MyStepItem; }
set { _MyStepItem = value; }
get { return _MyRTBItem; }
set { _MyRTBItem = value; }
}
private MouseEventArgs _MyMouseEventArgs;
public MouseEventArgs MyMouseEventArgs
@ -1032,9 +1032,9 @@ namespace Volian.Controls.Library
set { _MyMouseEventArgs = value; }
}
public StepPanelEventArgs(StepItem myStepItem, MouseEventArgs myMouseEventArgs)
public StepPanelEventArgs(RTBItem myRTBItem, MouseEventArgs myMouseEventArgs)
{
_MyStepItem = myStepItem;
_MyRTBItem = myRTBItem;
_MyMouseEventArgs = myMouseEventArgs;
}
}
@ -1046,44 +1046,44 @@ namespace Volian.Controls.Library
get { return _MyItemInfo; }
set { _MyItemInfo = value; }
}
private StepItem _MyStepItem = null;
public StepItem MyStepItem
private RTBItem _MyRTBItem = null;
public RTBItem MyRTBItem
{
get { return _MyStepItem; }
set { _MyStepItem = value; }
get { return _MyRTBItem; }
set { _MyRTBItem = value; }
}
public ItemSelectedChangedEventArgs(ItemInfo myItemInfo)
{
_MyItemInfo = myItemInfo;
}
public ItemSelectedChangedEventArgs(StepItem myStepItem)
public ItemSelectedChangedEventArgs(RTBItem myRTBItem)
{
_MyItemInfo = myStepItem.MyItemInfo;
_MyStepItem = myStepItem;
_MyItemInfo = myRTBItem.MyItemInfo;
_MyRTBItem = myRTBItem;
}
}
public partial class StepPanelAttachmentEventArgs
{
private StepItem _MyStepItem;
public StepItem MyStepItem
private RTBItem _MyRTBItem;
public RTBItem MyRTBItem
{
get { return _MyStepItem; }
set { _MyStepItem = value; }
get { return _MyRTBItem; }
set { _MyRTBItem = value; }
}
public StepPanelAttachmentEventArgs(StepItem myStepItem)
public StepPanelAttachmentEventArgs(RTBItem myRTBItem)
{
_MyStepItem = myStepItem;
_MyRTBItem = myRTBItem;
}
}
public partial class StepPanelLinkEventArgs : EventArgs
{
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private StepItem _LinkedStepItem;
public StepItem LinkedStepItem
private RTBItem _LinkedRTBItem;
public RTBItem LinkedRTBItem
{
get { return _LinkedStepItem; }
//set { _LinkedStepItem = value; }
get { return _LinkedRTBItem; }
//set { _LinkedRTBItem = value; }
}
private string _LinkInfoText;
public string LinkInfoText
@ -1095,9 +1095,9 @@ namespace Volian.Controls.Library
{
get { return _MyLinkText;}
}
public StepPanelLinkEventArgs(StepItem linkedStepItem, string linkInfoText)
public StepPanelLinkEventArgs(RTBItem linkedRTBItem, string linkInfoText)
{
_LinkedStepItem = linkedStepItem;
_LinkedRTBItem = linkedRTBItem;
_LinkInfoText = linkInfoText;
_MyLinkText = new LinkText(_LinkInfoText);
//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))
{
SelectedStepRTB = null; // Save Changes
foreach (StepItem stepItem in _LookupStepItems.Values)
foreach (RTBItem RTBItem in _LookupRTBItems.Values)
{
stepItem.MyItemInfo.ResetParts();
stepItem.MyItemInfo.MyContent.RefreshContentParts();
RTBItem.MyItemInfo.ResetParts();
RTBItem.MyItemInfo.MyContent.RefreshContentParts();
}
components.Dispose();
}