F2021-009 PROMS Express - Added methods to determine the levels of sub-steps when doing a Paste CopyStep and to display a message when the pasted step will have an excessive number of sub-steps. Added a method the return the number of sub-step levels defined in the format file (used when inserting new sub-steps)
This commit is contained in:
parent
afb6269082
commit
47c64e0ad4
@ -539,6 +539,55 @@ namespace VEPROMS.CSLA.Library
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// F2021-009 Get the number of children levels the passed in parent has
|
||||||
|
private static int GetMaxSubStepLevel(ItemInfo parent)
|
||||||
|
{
|
||||||
|
int maxStepLevel = parent.StepLevel-1; // subtract one to account for HLS - we want the sub-step level
|
||||||
|
foreach (ItemInfo kid in parent.Steps)
|
||||||
|
{
|
||||||
|
if (kid.Steps != null)
|
||||||
|
maxStepLevel = Math.Max(maxStepLevel, GetMaxSubStepLevel(kid));
|
||||||
|
else
|
||||||
|
maxStepLevel = Math.Max(maxStepLevel,kid.StepLevel-1); // subtract one to account for HLS because we are counting only sub-step levels
|
||||||
|
}
|
||||||
|
return maxStepLevel;
|
||||||
|
}
|
||||||
|
// F2021-009 Find the number of sub-step levels that the Copied Step has.
|
||||||
|
// This is used to determin if the Paste will result in exesssive sub-step levels
|
||||||
|
private static int GetCopyStepMaxLevels(int copyStartID)
|
||||||
|
{
|
||||||
|
ItemInfo cpyItem = ItemInfo.Get(copyStartID);
|
||||||
|
return GetMaxSubStepLevel(cpyItem);
|
||||||
|
}
|
||||||
|
// F2021-009 Find the number of defined sequential tabs. We use this to determin the number of defined sub-step levels
|
||||||
|
public int GetDefinedSubStepCount()
|
||||||
|
{
|
||||||
|
return GetDefinedSubStepCount(this);
|
||||||
|
}
|
||||||
|
// F2021-009 Find the number of defined sequential tabs. We use this to determin the number of defined sub-step levels
|
||||||
|
public static int GetDefinedSubStepCount(ItemInfo curStep)
|
||||||
|
{
|
||||||
|
int cnt = 0;
|
||||||
|
cnt = curStep.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.SeqTabFmtList.Count;
|
||||||
|
return cnt-1; // -1 to account for the high level step level
|
||||||
|
}
|
||||||
|
// F2021-009 for PROMS Express, display a message if the Paste of a CopyStep will results in sub-step levels
|
||||||
|
// greater than what is defined in the format
|
||||||
|
public static bool PasteStepIsWithinDefinedSubStepLevels(int copyStartID, ItemInfo pasteTarget, bool doingReplace)
|
||||||
|
{
|
||||||
|
int largestSubStepLevel = GetCopyStepMaxLevels(copyStartID);
|
||||||
|
int numDefinedSubstepLevels = GetDefinedSubStepCount(pasteTarget);
|
||||||
|
largestSubStepLevel += (pasteTarget.StepLevel-((doingReplace)?1:0));// subtract one because HLS is level one, results in actual sub-step level
|
||||||
|
if (largestSubStepLevel > numDefinedSubstepLevels && pasteTarget.ActiveFormat.PlantFormat.FormatData.Express)
|
||||||
|
{
|
||||||
|
string mbMsg = "This will result with more sub-step levels than are defined in" +
|
||||||
|
"\nthe format and could result in a step that is difficult to follow." +
|
||||||
|
"\n\nConsider rewriting the step using less sub-steps levels.";
|
||||||
|
MessageBox.Show(mbMsg, "Paste Step Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
// B2016-009 - added a message box explaining to the user that the copyed step will take on the destination type. 16-bit PROMS had also done this way.
|
// B2016-009 - added a message box explaining to the user that the copyed step will take on the destination type. 16-bit PROMS had also done this way.
|
||||||
// - this one is used for Paste Replace with copyed step
|
// - this one is used for Paste Replace with copyed step
|
||||||
public static void CheckSourceDestinationType(int copyStartID, ItemInfo itemInfo)
|
public static void CheckSourceDestinationType(int copyStartID, ItemInfo itemInfo)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user