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 else
UserCheckOff = false; UserCheckOff = false;
RefreshContent(); 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) void value_OrdinalChanged(object sender)
{ {
@ -491,7 +519,7 @@ namespace Volian.Controls.Library
/// </summary> /// </summary>
/// <param name="parentEditItem">Parent Container</param> /// <param name="parentEditItem">Parent Container</param>
/// <param name="siblingEditItems">EditItem List</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 if (siblingEditItems == null) // Create a list of siblings
{ {
@ -501,7 +529,22 @@ namespace Volian.Controls.Library
} }
else // Add to the existing list 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); EditItem lastChild = LastChild(siblingEditItems);
siblingEditItems.Add(this); siblingEditItems.Add(this);
@ -569,6 +612,71 @@ namespace Volian.Controls.Library
get { return _BeingRemoved; } get { return _BeingRemoved; }
set { _BeingRemoved = value; } 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() public void RemoveItem()
{ {
//Volian.Base.Library.VlnTimer _MyTimer = new VlnTimer(); //Volian.Base.Library.VlnTimer _MyTimer = new VlnTimer();
@ -750,6 +858,14 @@ namespace Volian.Controls.Library
foreach (ItemInfo item in myItemInfoList) foreach (ItemInfo item in myItemInfoList)
AddChildBefore(item, expand); 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> /// <summary>
/// Add an RNO (Contingency) child /// Add an RNO (Contingency) child
/// </summary> /// </summary>
@ -775,14 +891,14 @@ namespace Volian.Controls.Library
/// </summary> /// </summary>
/// <param name="MyItemInfo"></param> /// <param name="MyItemInfo"></param>
/// <param name="expand"></param> /// <param name="expand"></param>
public EditItem AddChildAfter(ItemInfo MyItemInfo, bool expand) public EditItem AddChildAfter(ItemInfo MyItemInfo, bool expand, bool addFirstChld)
{ {
EditItem child = null; EditItem child = null;
//if (MyItemInfo.MyContent.ContentGridCount != 0) //if (MyItemInfo.MyContent.ContentGridCount != 0)
if (MyItemInfo.MyContent.MyGrid != null) if (MyItemInfo.MyContent.MyGrid != null)
child = new GridItem(MyItemInfo, MyStepPanel, this, ChildRelation.After, expand); child = new GridItem(MyItemInfo, MyStepPanel, this, ChildRelation.After, expand);
else else
child = new RTBItem(MyItemInfo, MyStepPanel, this, ChildRelation.After, expand); child = new RTBItem(MyItemInfo, MyStepPanel, this, ChildRelation.After, expand, addFirstChld);
return child; return child;
} }
public EditItem AddChildAfter(ItemInfo MyItemInfo, EditItem nextEditItem) public EditItem AddChildAfter(ItemInfo MyItemInfo, EditItem nextEditItem)
@ -889,6 +1005,37 @@ namespace Volian.Controls.Library
if (updateSelection) if (updateSelection)
MyStepPanel.SelectedEditItem = newEditItem;//Update Screen 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) public void AddChild(E_FromType fromType, int type)
{ {
AddChild("", fromType, type, null); AddChild("", fromType, type, null);
@ -968,12 +1115,39 @@ namespace Volian.Controls.Library
/// </summary> /// </summary>
/// <param name="myItemInfoList"></param> /// <param name="myItemInfoList"></param>
/// <param name="expand"></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) public EditItem AddChildAfter(ItemInfoList myItemInfoList, bool expand)
{ {
EditItem child = null; EditItem child = null;
if (myItemInfoList != null) if (myItemInfoList != null)
foreach (ItemInfo item in myItemInfoList) 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; return child;
} }
#endregion #endregion
@ -1587,7 +1761,7 @@ namespace Volian.Controls.Library
bool hasMetaSubs = MyItemInfo.IsSection && MyItemInfo.Sections != null && MyItemInfo.Sections.Count>0; 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"); bool EditSteps = !hasMetaSubs || (MyItemInfo.MyConfig is SectionConfig && (MyItemInfo.MyConfig as SectionConfig).SubSection_Edit == "Y");
if (EditSteps) AddChildAfter(MyItemInfo.Steps, expand); if (EditSteps) AddChildAfter(MyItemInfo.Steps, expand);
if (MyItemInfo.RNOs != null && MyItemInfo.RNOLevel >= MyItemInfo.ColumnMode) if (MyItemInfo.RNOs != null && MyItemInfo.RNOLevel >= MyItemInfo.ColumnMode)
AddChildRNO(MyItemInfo.RNOs, expand); AddChildRNO(MyItemInfo.RNOs, expand);
AddChildAfter(MyItemInfo.Sections, expand); AddChildAfter(MyItemInfo.Sections, expand);
@ -1991,7 +2165,7 @@ namespace Volian.Controls.Library
LastMethodsPop(); 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 == 10366) Console.WriteLine("Here");
//if (itemInfo.ItemID == 225) _MyStepRTB.Resize += new EventHandler(_MyStepRTB_Resize); //if (itemInfo.ItemID == 225) _MyStepRTB.Resize += new EventHandler(_MyStepRTB_Resize);
@ -2054,14 +2228,14 @@ namespace Volian.Controls.Library
switch (myChildRelation) switch (myChildRelation)
{ {
case ChildRelation.After: case ChildRelation.After:
AddItem(myParentEditItem, ref myParentEditItem._MyAfterEditItems, nextEditItem); AddItem(myParentEditItem, ref myParentEditItem._MyAfterEditItems, nextEditItem, addFirstChld);
break; break;
case ChildRelation.Before: case ChildRelation.Before:
AddItem(myParentEditItem, ref myParentEditItem._MyBeforeEditItems, nextEditItem); AddItem(myParentEditItem, ref myParentEditItem._MyBeforeEditItems, nextEditItem, addFirstChld);
break; break;
case ChildRelation.RNO: case ChildRelation.RNO:
RNOLevel = myParentEditItem.RNOLevel + 1; RNOLevel = myParentEditItem.RNOLevel + 1;
AddItem(myParentEditItem, ref myParentEditItem._MyRNOEditItems, nextEditItem); AddItem(myParentEditItem, ref myParentEditItem._MyRNOEditItems, nextEditItem, addFirstChld);
break; break;
case ChildRelation.None: case ChildRelation.None:
break; break;

View File

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

View File

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