diff --git a/PROMS/Volian.Controls.Library/StepTabRibbon.cs b/PROMS/Volian.Controls.Library/StepTabRibbon.cs index 47781a51..5dec24d4 100644 --- a/PROMS/Volian.Controls.Library/StepTabRibbon.cs +++ b/PROMS/Volian.Controls.Library/StepTabRibbon.cs @@ -681,6 +681,7 @@ namespace Volian.Controls.Library void btnInsStep_Click(object sender, EventArgs e) { + string cautNoteOrder = _MyEditItem.MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.CautionNoteOrder; DevComponents.DotNetBar.ButtonItem b = (DevComponents.DotNetBar.ButtonItem)sender; if (b.Tag == null) return; char[] sep = { ' ' }; @@ -689,10 +690,24 @@ namespace Volian.Controls.Library int fromtype = Convert.ToInt32(insdata[0]); int contenttype = Convert.ToInt32(insdata[1]) + 20000; string tabletype = (insdata.Length == 3)? insdata[2]:null; + // if CautionNoteOrder format variable is set then use it to determine the placement of the + // Caution, Note, Warning, or Message (calvert format) + if (cautNoteOrder != null && (","+cautNoteOrder+",").Contains(","+(contenttype % 10000).ToString() + ",") && (_MyEditItem.MyItemInfo.Cautions != null || _MyEditItem.MyItemInfo.Notes != null)) + { + EditItem stepBefore = FindStepBefore(cautNoteOrder, contenttype); + if (stepBefore != null) + stepBefore.AddSiblingAfter((int?)contenttype, true); + else + { + EditItem stepAfter = FindStepAfter(cautNoteOrder, contenttype); + if (stepAfter != null) + stepAfter.AddSiblingBefore((int?)contenttype, true); + } + } // if from type == 0, we've inserted a hls. // if inserting from section, insert first child // else do a after from current HLS - if not at HLS, go up parents until find it. - if (fromtype == 0 && !_MyEditItem.MyItemInfo.IsStepSection) + else if (fromtype == 0 && !_MyEditItem.MyItemInfo.IsStepSection) { EditItem hlsEditItem = _MyEditItem; while (!hlsEditItem.MyItemInfo.IsHigh) @@ -722,6 +737,67 @@ namespace Volian.Controls.Library _MyEditItem.AddChild((E_FromType)fromtype, contenttype); } } + + private EditItem FindStepAfter(string types, int contenttype) + { + string[] order = types.Split(",".ToCharArray()); //"29,7,6,22" + bool found = false; + List lOrder = new List(); + foreach (string type in order) + { + if (found) + lOrder.Add(int.Parse(type)); + if (int.Parse(type) == contenttype % 10000) found = true; + } + //_MyEditItem.MyItemInfo.RefreshItemParts(); + _MyEditItem.MyItemInfo.ResetParts(); + if (_MyEditItem.MyItemInfo.Cautions != null) + foreach (ItemInfo ii in _MyEditItem.MyItemInfo.Cautions) + { + if (lOrder.Contains((int)ii.MyContent.Type % 10000)) + return _MyEditItem.MyStepPanel.FindItem(ii); + } + if (_MyEditItem.MyItemInfo.Notes != null) + foreach (ItemInfo ii in _MyEditItem.MyItemInfo.Notes) + { + if (lOrder.Contains((int)ii.MyContent.Type % 10000)) + return _MyEditItem.MyStepPanel.FindItem(ii); + } + return null; + } + + private EditItem FindStepBefore(string types, int contenttype) + { + string[] order = types.Split(",".ToCharArray()); //"29,7,6,22" + List lOrder = new List(); + foreach (string type in order) + { + lOrder.Add(int.Parse(type)); + if (lOrder.Contains(contenttype % 10000)) + break; + } + ItemInfo itemBefore = null; + //_MyEditItem.MyItemInfo.RefreshItemParts(); + _MyEditItem.MyItemInfo.ResetParts(); + if (_MyEditItem.MyItemInfo.Cautions != null) + foreach (ItemInfo ii in _MyEditItem.MyItemInfo.Cautions) + { + if (lOrder.Contains((int)ii.MyContent.Type % 10000)) + itemBefore = ii; + } + if (_MyEditItem.MyItemInfo.Notes != null) + foreach (ItemInfo ii in _MyEditItem.MyItemInfo.Notes) + { + if (lOrder.Contains((int)ii.MyContent.Type % 10000)) + itemBefore = ii; + } + if (itemBefore != null) + { + Console.WriteLine("findStepBefore {0}", itemBefore.DisplayText); + return _MyEditItem.MyStepPanel.FindItem(itemBefore); + } + return null; + } // Table Grid private bool InsertingTable(int contenttype) {