This commit is contained in:
Kathy Ruffing 2012-02-15 15:04:19 +00:00
parent 09b1cce695
commit 7f4896e4c1
3 changed files with 195 additions and 15 deletions

View File

@ -212,6 +212,34 @@ namespace Volian.Controls.Library
else
UserCheckOff = false;
RefreshContent();
// see if change in subsections to be displayed, i.e. if the user made a change to editable data
// on the section properties form, we may have to display steps or remove steps. By design,
// steps are the first children from a section.
if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.UseMetaSections)
{
// find out what the editable flag is to determine if change.
bool showSteps = MyItemInfo.MyConfig is SectionConfig && (MyItemInfo.MyConfig as SectionConfig).SubSection_Edit == "Y";
if (showSteps && _MyAfterEditItems != null && _MyAfterEditItems.Count > 0 && _MyAfterEditItems[0].MyItemInfo.IsSection)
{
// need to add steps in, i.e. they do not exist in step editor yet.
_MyAfterEditItems[0].AddSiblingBeforeNoDataSave(MyItemInfo.Steps, false);
}
else if (!showSteps && _MyAfterEditItems != null && _MyAfterEditItems.Count > 0 && _MyAfterEditItems[0].MyItemInfo.IsStep)
{
// Remove steps - only want sections. Put in a list for removal.
List<EditItem> remEIs = new List<EditItem>();
foreach (EditItem ei in _MyAfterEditItems)
{
if (!ei.MyItemInfo.IsSection) remEIs.Add(ei);
}
foreach (EditItem ei1 in remEIs)
{
ei1.RemoveItemWithoutDelete();
}
remEIs.Clear();
}
}
}
void value_OrdinalChanged(object sender)
{
@ -491,7 +519,7 @@ namespace Volian.Controls.Library
/// </summary>
/// <param name="parentEditItem">Parent Container</param>
/// <param name="siblingEditItems">EditItem List</param>
public void AddItem(EditItem parentEditItem, ref List<EditItem> siblingEditItems, EditItem nextEditItem)
public void AddItem(EditItem parentEditItem, ref List<EditItem> siblingEditItems, EditItem nextEditItem, bool addFirstChld)
{
if (siblingEditItems == null) // Create a list of siblings
{
@ -501,7 +529,22 @@ namespace Volian.Controls.Library
}
else // Add to the existing list
{
if (nextEditItem == null) // Add to the end of the list
// add first child, when there are other children already there. This is used
// for metasection editable data changed from off to on so that the first step is located
// in the editor correctly, i.e. right below the section & above the subsections.
if (addFirstChld)
{
EditItem parent = siblingEditItems[0].MyParentEditItem;
siblingEditItems.Insert(0, this);
MyStepPanel.ItemMoving++;
_MyNextEditItem = siblingEditItems[1];
_MyNextEditItem._MyPreviousEditItem = this;
MyPreviousEditItem = null;
_MyNextEditItem.MyParentEditItem = null;
MyParentEditItem = parent;
MyStepPanel.ItemMoving--;
}
else if (nextEditItem == null) // Add to the end of the list
{
EditItem lastChild = LastChild(siblingEditItems);
siblingEditItems.Add(this);
@ -569,6 +612,71 @@ namespace Volian.Controls.Library
get { return _BeingRemoved; }
set { _BeingRemoved = value; }
}
public void RemoveItemWithoutDelete()
{
BeingRemoved = true;
//MyStepPanel.SelectedEditItem = null; // Unselect the item to be deleted
int TopMostYBefore = TopMostEditItem.Top;
MyStepPanel._LookupEditItems.Remove(MyID);
EditItem newFocus = null;
int? TopMostParentY = (MyParentEditItem == null ? null : (int?)(MyParentEditItem.TopMostEditItem.Top));
int? ParentY = (MyParentEditItem == null ? null : (int?)(MyParentEditItem.Top));
RemoveFromParentsChildList();
if (MyNextEditItem != null)
{
if (MyPreviousEditItem != null)
{
MyNextEditItem.MyPreviousEditItem = MyPreviousEditItem;
MyPreviousEditItem = null;
newFocus = MyNextEditItem;
}
else
{
MyNextEditItem.MyParentEditItem = MyParentEditItem;
MyParentEditItem = null;
MyNextEditItem.MyPreviousEditItem = null;
newFocus = MyNextEditItem;
}
// Adjust the vertical locations of all of the items below the item deleted
MyNextEditItem.TopMostEditItem.AdjustLocation();
MyNextEditItem = null;
}
else if (MyPreviousEditItem != null)
{
MyPreviousEditItem.MyNextEditItem = null;
newFocus = MyPreviousEditItem.BottomMostEditItem;
MyPreviousEditItem = null;
//Console.Write(",\"Previous\",");
}
else
{
newFocus = MyParentEditItem;
MyParentEditItem = null;
//Console.Write(",\"Parent\",");
}
//_MyTimer.ShowElapsedTimes("DeleteItem");
//KBR??return newFocus;
//EditItem newFocus = DeleteItem();
//if (newFocus == null) return;
////_MyTimer.ActiveProcess = "SetFocus";
//newFocus.SetFocus();
////_MyTimer.ActiveProcess = "Dispose";
//Dispose();
////_MyTimer.ActiveProcess = "SetAllTabs";
//newFocus.SetAllTabs();
////_MyTimer.ActiveProcess = "TopMostYAfter";
//int TopMostYAfter = newFocus.TopMostEditItem.Top;
//if (TopMostYAfter > TopMostYBefore)
// newFocus.TopMostEditItem.Top = TopMostYBefore;
////_MyTimer.ActiveProcess = "AdjustLocation";
//newFocus.AdjustLocation();
////newFocus.ShowTops("");
////_MyTimer.ShowElapsedTimes("RemoveItem");
}
public void RemoveItem()
{
//Volian.Base.Library.VlnTimer _MyTimer = new VlnTimer();
@ -750,6 +858,14 @@ namespace Volian.Controls.Library
foreach (ItemInfo item in myItemInfoList)
AddChildBefore(item, expand);
}
public EditItem AddChildBefore(ItemInfoList myItemInfoList, EditItem nextEditItem)
{
EditItem child = null;
if (myItemInfoList != null)
foreach (ItemInfo item in myItemInfoList)
child = AddChildBefore(item, nextEditItem);
return child;
}
/// <summary>
/// Add an RNO (Contingency) child
/// </summary>
@ -775,14 +891,14 @@ namespace Volian.Controls.Library
/// </summary>
/// <param name="MyItemInfo"></param>
/// <param name="expand"></param>
public EditItem AddChildAfter(ItemInfo MyItemInfo, bool expand)
public EditItem AddChildAfter(ItemInfo MyItemInfo, bool expand, bool addFirstChld)
{
EditItem child = null;
//if (MyItemInfo.MyContent.ContentGridCount != 0)
if (MyItemInfo.MyContent.MyGrid != null)
child = new GridItem(MyItemInfo, MyStepPanel, this, ChildRelation.After, expand);
else
child = new RTBItem(MyItemInfo, MyStepPanel, this, ChildRelation.After, expand);
child = new RTBItem(MyItemInfo, MyStepPanel, this, ChildRelation.After, expand, addFirstChld);
return child;
}
public EditItem AddChildAfter(ItemInfo MyItemInfo, EditItem nextEditItem)
@ -889,6 +1005,37 @@ namespace Volian.Controls.Library
if (updateSelection)
MyStepPanel.SelectedEditItem = newEditItem;//Update Screen
}
public void AddSiblingBeforeNoDataSave(ItemInfo newItemInfo, bool updateSelection, EditItem tt)
{
EditItem newEditItem = null;
newEditItem = ActiveParent.AddChildBefore(newItemInfo, this);
//switch (_MyChildRelation)
//{
// case ChildRelation.After:
// newEditItem = ActiveParent.AddChildAfter(newItemInfo, this);
// break;
// case ChildRelation.Before:
// newEditItem = ActiveParent.AddChildBefore(newItemInfo, this);
// break;
// case ChildRelation.RNO:
// newEditItem = ActiveParent.AddChildRNO(newItemInfo, this);
// break;
// default: // Need debug
// break;
//}
if (updateSelection)
MyStepPanel.SelectedEditItem = newEditItem;//Update Screen
}
private bool specialAdd = false;
public void AddSiblingBeforeNoDataSave(ItemInfoList newItemInfos, bool updateSelection)
{
specialAdd = true;
EditItem newEditItem = null;
newEditItem = ActiveParent.AddChildAfter(newItemInfos, false, true);
if (updateSelection)
MyStepPanel.SelectedEditItem = newEditItem;//Update Screen
specialAdd = false;
}
public void AddChild(E_FromType fromType, int type)
{
AddChild("", fromType, type, null);
@ -968,12 +1115,39 @@ namespace Volian.Controls.Library
/// </summary>
/// <param name="myItemInfoList"></param>
/// <param name="expand"></param>
public EditItem AddChildAfter(ItemInfoList myItemInfoList, bool expand, bool addFirstChld)
{
EditItem child = null;
int indx = 0;
if (myItemInfoList != null)
foreach (ItemInfo item in myItemInfoList)
{
if (addFirstChld)
{
// the first time add it as first child, the rest should be done in between.
child = AddChildAfter(item, expand, addFirstChld);
addFirstChld = false;
}
else
child = AddChildAfter(item, this._MyAfterEditItems[indx]);
indx++;
}
return child;
}
public EditItem AddChildAfter(ItemInfoList myItemInfoList, bool expand)
{
EditItem child = null;
if (myItemInfoList != null)
foreach (ItemInfo item in myItemInfoList)
child = AddChildAfter(item, expand);
child = AddChildAfter(item, expand, false);
return child;
}
public EditItem AddChildAfter(ItemInfoList myItemInfoList, EditItem nextEditItem)
{
EditItem child = null;
if (myItemInfoList != null)
foreach (ItemInfo item in myItemInfoList)
child = AddChildAfter(item, nextEditItem);
return child;
}
#endregion
@ -1587,7 +1761,7 @@ namespace Volian.Controls.Library
bool hasMetaSubs = MyItemInfo.IsSection && MyItemInfo.Sections != null && MyItemInfo.Sections.Count>0;
bool EditSteps = !hasMetaSubs || (MyItemInfo.MyConfig is SectionConfig && (MyItemInfo.MyConfig as SectionConfig).SubSection_Edit == "Y");
if (EditSteps) AddChildAfter(MyItemInfo.Steps, expand);
if (MyItemInfo.RNOs != null && MyItemInfo.RNOLevel >= MyItemInfo.ColumnMode)
AddChildRNO(MyItemInfo.RNOs, expand);
AddChildAfter(MyItemInfo.Sections, expand);
@ -1991,7 +2165,7 @@ namespace Volian.Controls.Library
LastMethodsPop();
}
}
protected void SetupEditItem(ItemInfo itemInfo, StepPanel myStepPanel, EditItem myParentEditItem, ChildRelation myChildRelation, bool expand, EditItem nextEditItem)
protected void SetupEditItem(ItemInfo itemInfo, StepPanel myStepPanel, EditItem myParentEditItem, ChildRelation myChildRelation, bool expand, EditItem nextEditItem, bool addFirstChld)
{
//if (itemInfo.ItemID == 10366) Console.WriteLine("Here");
//if (itemInfo.ItemID == 225) _MyStepRTB.Resize += new EventHandler(_MyStepRTB_Resize);
@ -2054,14 +2228,14 @@ namespace Volian.Controls.Library
switch (myChildRelation)
{
case ChildRelation.After:
AddItem(myParentEditItem, ref myParentEditItem._MyAfterEditItems, nextEditItem);
AddItem(myParentEditItem, ref myParentEditItem._MyAfterEditItems, nextEditItem, addFirstChld);
break;
case ChildRelation.Before:
AddItem(myParentEditItem, ref myParentEditItem._MyBeforeEditItems, nextEditItem);
AddItem(myParentEditItem, ref myParentEditItem._MyBeforeEditItems, nextEditItem, addFirstChld);
break;
case ChildRelation.RNO:
RNOLevel = myParentEditItem.RNOLevel + 1;
AddItem(myParentEditItem, ref myParentEditItem._MyRNOEditItems, nextEditItem);
AddItem(myParentEditItem, ref myParentEditItem._MyRNOEditItems, nextEditItem, addFirstChld);
break;
case ChildRelation.None:
break;

View File

@ -238,13 +238,13 @@ namespace Volian.Controls.Library
{
InitializeComponent();
SetupEventHandlers();
SetupEditItem(itemInfo, myStepPanel, myParentEditItem, myChildRelation, expand, null);
SetupEditItem(itemInfo, myStepPanel, myParentEditItem, myChildRelation, expand, null, false);
}
public GridItem(ItemInfo itemInfo, StepPanel myStepPanel, EditItem myParentEditItem, ChildRelation myChildRelation, bool expand, EditItem nextEditItem)
{
InitializeComponent();
SetupEventHandlers();
SetupEditItem(itemInfo, myStepPanel, myParentEditItem, myChildRelation, expand, nextEditItem);
SetupEditItem(itemInfo, myStepPanel, myParentEditItem, myChildRelation, expand, nextEditItem, false);
}
private void SetupEventHandlers()
{

View File

@ -20,7 +20,7 @@ namespace Volian.Controls.Library
Showing = 8,
Done = 16
}
#endregion
#endregion
public partial class RTBItem : EditItem
{
#region Private Fields
@ -213,13 +213,19 @@ namespace Volian.Controls.Library
{
//// TIMING: DisplayItem.TimeIt("CSLARTB Top");
InitializeComponent();// TODO: Performance 25%
SetupEditItem(itemInfo, myStepPanel, myParentEditItem, myChildRelation, expand, null);
SetupEditItem(itemInfo, myStepPanel, myParentEditItem, myChildRelation, expand, null, false);
}
public RTBItem(ItemInfo itemInfo, StepPanel myStepPanel, EditItem myParentEditItem, ChildRelation myChildRelation, bool expand, EditItem nextEditItem)
{
//// TIMING: DisplayItem.TimeIt("CSLARTB Top");
InitializeComponent();// TODO: Performance 25%
SetupEditItem(itemInfo, myStepPanel, myParentEditItem, myChildRelation, expand, nextEditItem);
SetupEditItem(itemInfo, myStepPanel, myParentEditItem, myChildRelation, expand, nextEditItem, false);
}
public RTBItem(ItemInfo itemInfo, StepPanel myStepPanel, EditItem myParentEditItem, ChildRelation myChildRelation, bool expand, bool addFirstChld)
{
//// TIMING: DisplayItem.TimeIt("CSLARTB Top");
InitializeComponent();// TODO: Performance 25%
SetupEditItem(itemInfo, myStepPanel, myParentEditItem, myChildRelation, expand, null, addFirstChld);
}
//private void SetupRTBItem(ItemInfo itemInfo, StepPanel myStepPanel, EditItem myParentEditItem, ChildRelation myChildRelation, bool expand, EditItem nextEditItem)
//{