This commit is contained in:
Kathy Ruffing 2009-11-20 12:34:14 +00:00
parent 579a1502d6
commit 655ec1ab94
2 changed files with 78 additions and 23 deletions

View File

@ -291,11 +291,7 @@ namespace Volian.Controls.Library
public bool DeleteStepItem(ItemInfo myItemInfo) public bool DeleteStepItem(ItemInfo myItemInfo)
{ {
CleanUpClosedItems(); CleanUpClosedItems();
return DeleteStepTabItem(myItemInfo);
}
private bool DeleteStepTabItem(ItemInfo myItemInfo)
{
//removeitem! //removeitem!
ItemInfo proc = myItemInfo.MyProcedure; // Find procedure Item ItemInfo proc = myItemInfo.MyProcedure; // Find procedure Item
string key = "Item - " + proc.ItemID.ToString(); string key = "Item - " + proc.ItemID.ToString();
@ -303,8 +299,10 @@ namespace Volian.Controls.Library
if (_MyDisplayTabItems.ContainsKey(key)) // If procedure page open use it if (_MyDisplayTabItems.ContainsKey(key)) // If procedure page open use it
{ {
DisplayTabItem pg = _MyDisplayTabItems[key]; DisplayTabItem pg = _MyDisplayTabItems[key];
// if deleting a procedure, close the tab.
if (proc.ItemID == myItemInfo.ItemID) if (proc.ItemID == myItemInfo.ItemID)
{ {
// do we need to close open doc tabs associated with this proc.
CloseTabItem(pg); CloseTabItem(pg);
return false; return false;
} }
@ -317,6 +315,37 @@ namespace Volian.Controls.Library
} }
return false; return false;
} }
public bool InsertStepItem(ItemInfo myItemInfo, string text, E_InsertType insertType, E_FromType fromType, int type)
{
CleanUpClosedItems();
ItemInfo proc = myItemInfo.MyProcedure; // Find procedure Item
string key = "Item - " + proc.ItemID.ToString();
if (_MyDisplayTabItems.ContainsKey(key)) // If procedure page open use it
{
DisplayTabItem pg = _MyDisplayTabItems[key];
if (pg.MyStepTabPanel.MyStepPanel._LookupStepItems.ContainsKey(myItemInfo.ItemID))
{
StepItem stpitm = pg.MyStepTabPanel.MyStepPanel._LookupStepItems[myItemInfo.ItemID];
switch (insertType)
{
case E_InsertType.Before:
stpitm.AddSiblingBefore(text);
break;
case E_InsertType.After:
stpitm.AddSiblingAfter(text);
break;
case E_InsertType.Child:
stpitm.AddChild(text, fromType, type);
break;
default:
return false; ;
}
return true;
}
}
return false;
}
private void CleanUpClosedItems() private void CleanUpClosedItems()
{ {
while (_RemovedDisplayTabItems.Count > 0) // Clean-up any items that have been closed. while (_RemovedDisplayTabItems.Count > 0) // Clean-up any items that have been closed.

View File

@ -132,6 +132,7 @@ namespace Volian.Controls.Library
{ {
// Update the text to reflect the content change // Update the text to reflect the content change
MyStepRTB.MyItemInfo=MyStepRTB.MyItemInfo; // Reset Text MyStepRTB.MyItemInfo=MyStepRTB.MyItemInfo; // Reset Text
SetExpandAndExpander(MyItemInfo);
// TODO: Need code to update tabs ? not sure what this is - maybe for // TODO: Need code to update tabs ? not sure what this is - maybe for
// transitions? // transitions?
} }
@ -804,21 +805,7 @@ namespace Volian.Controls.Library
if (itemInfo != null) if (itemInfo != null)
{ {
Name = string.Format("Item-{0}", itemInfo.ItemID); Name = string.Format("Item-{0}", itemInfo.ItemID);
// Don't allow substeps to expand SetExpandAndExpander(itemInfo);
switch (_Type / 10000)
{
case 1: // Section can expand
CanExpand = true;
// If a word document set the expander to attachment
_MyvlnExpander.Attachment = (itemInfo.MyContent.ContentPartCount == 0);
break;
case 2: // High level steps with children can expand
CanExpand = itemInfo.IsHigh && itemInfo.HasChildren; // TemporaryFormat.IsHigh(item); ;
break;
default://Procedures cannot expand, because they automatically expand
CanExpand = false;
break;
}
if (expand && (itemInfo.MyContent.ContentPartCount != 0)) // If it should expand and it can expand if (expand && (itemInfo.MyContent.ContentPartCount != 0)) // If it should expand and it can expand
Expand(true); Expand(true);
else else
@ -843,6 +830,26 @@ namespace Volian.Controls.Library
//// TIMING: DisplayItem.TimeIt("CSLARTB Controls Add"); //// TIMING: DisplayItem.TimeIt("CSLARTB Controls Add");
} }
private void SetExpandAndExpander(ItemInfo itemInfo)
{
// Don't allow substeps to expand
switch (_Type / 10000)
{
case 1: // Section can expand
CanExpand = true;
// If a word document set the expander to attachment
_MyvlnExpander.Attachment = !(itemInfo.IsStepSection);
//OLD: _MyvlnExpander.Attachment = (itemInfo.MyContent.ContentPartCount == 0);
break;
case 2: // High level steps with children can expand
CanExpand = itemInfo.IsHigh && itemInfo.HasChildren; // TemporaryFormat.IsHigh(item); ;
break;
default://Procedures cannot expand, because they automatically expand
CanExpand = false;
break;
}
}
private void SetupHeader(ItemInfo itemInfo) private void SetupHeader(ItemInfo itemInfo)
{ {
lblTab.Top = 3 + ((itemInfo.HasHeader) ? 23 : 0); lblTab.Top = 3 + ((itemInfo.HasHeader) ? 23 : 0);
@ -1169,7 +1176,11 @@ namespace Volian.Controls.Library
/// </summary> /// </summary>
public void AddSiblingAfter() public void AddSiblingAfter()
{ {
ItemInfo newItemInfo = MyItemInfo.InsertSiblingAfter(""); AddSiblingAfter("");
}
public void AddSiblingAfter(string text)
{
ItemInfo newItemInfo = MyItemInfo.InsertSiblingAfter(text);
DoAddSiblingAfter(newItemInfo); DoAddSiblingAfter(newItemInfo);
} }
public void AddSiblingAfter(int? type) public void AddSiblingAfter(int? type)
@ -1200,7 +1211,18 @@ namespace Volian.Controls.Library
private static int _WatchThis = 1; private static int _WatchThis = 1;
public void AddSiblingBefore() public void AddSiblingBefore()
{ {
ItemInfo newItemInfo = MyItemInfo.InsertSiblingBefore(""); AddSiblingBefore("");
}
public void AddSiblingBefore(string text)
{
// Save RTB text before creating a new item because the process of creating
// a new item will save a change to iteminfo excluding text changes. This
// shouldn't be necessary for adding sibling after because the current step
// doesn't get saved during the insert after because of the MyPrevious field
// is only set on an insert before, which is what saves the item without
// any updates from the richtextbox text.
_MyStepRTB.SaveText();
ItemInfo newItemInfo = MyItemInfo.InsertSiblingBefore(text);
StepItem newStepItem=null; StepItem newStepItem=null;
switch (_MyChildRelation) switch (_MyChildRelation)
{ {
@ -1219,12 +1241,16 @@ namespace Volian.Controls.Library
_MyStepPanel.SelectedStepRTB = newStepItem.MyStepRTB;//Update Screen _MyStepPanel.SelectedStepRTB = newStepItem.MyStepRTB;//Update Screen
} }
public void AddChild(E_FromType fromType, int type) public void AddChild(E_FromType fromType, int type)
{
AddChild("",fromType, type);
}
public void AddChild(string text, E_FromType fromType, int type)
{ {
if (_MyItemInfo.IsHigh || _MyItemInfo.IsSection) if (_MyItemInfo.IsHigh || _MyItemInfo.IsSection)
this.CanExpand = true; this.CanExpand = true;
this.Expanded = true; this.Expanded = true;
_WatchThis = 1; _WatchThis = 1;
ItemInfo newItemInfo = MyItemInfo.InsertChild(fromType,type,""); ItemInfo newItemInfo = MyItemInfo.InsertChild(fromType, type, text);
// TODO: We need to determine where this will go in the stack of children // TODO: We need to determine where this will go in the stack of children
StepItem nextItem = MyStepPanel.FindItem(newItemInfo.NextItem); StepItem nextItem = MyStepPanel.FindItem(newItemInfo.NextItem);
StepItem newStepItem; StepItem newStepItem;