diff --git a/PROMS/Volian.Controls.Library/DisplayTags.cs b/PROMS/Volian.Controls.Library/DisplayTags.cs index 36671d83..69b79635 100644 --- a/PROMS/Volian.Controls.Library/DisplayTags.cs +++ b/PROMS/Volian.Controls.Library/DisplayTags.cs @@ -13,10 +13,34 @@ namespace Volian.Controls.Library public partial class DisplayTags : UserControl { #region Properties - private ItemInfo _CurItemInfo=null; + private ItemInfo _CurItemInfo = null; + /// + /// Current ItemInfo + /// + public ItemInfo CurItemInfo + { + get { return _CurItemInfo; } + set { _CurItemInfo = value; } + } private bool _Initalizing = false; private IList _MyStepTypeInd = null; // use to keep track of step types put in step type menu private StepRTB _NotVisibleRTB = null; + /// + /// This stores the last selected StepRTB when the Panel was not visible + /// This allows the panel to be filled when the when it is made visible + /// + public StepRTB NotVisibleRTB + { + get { return _NotVisibleRTB; } + set + { + _NotVisibleRTB = null; // Initialize it to null + if (value != null) + if (value.MyItemInfo != null) + if (value.MyItemInfo.IsStep) + _NotVisibleRTB = value; // Only visible for steps + } + } private StepRTB _MyRTB; public StepRTB MyRTB { @@ -25,29 +49,30 @@ namespace Volian.Controls.Library { if (!Visible) { - _NotVisibleRTB = value; + NotVisibleRTB = value; // Remember RTB if the panel becomes visible + CurItemInfo = null; // The Current Item Info should be forgotten return; } - _NotVisibleRTB = null; + NotVisibleRTB = null; // If Visible, no need to remember the RTB when the panel wasn't visible if (value == null) { ClearControls(); return; } - if (_CurItemInfo != null && _CurItemInfo.ItemID == value.MyItemInfo.ItemID) return; + if (CurItemInfo != null && CurItemInfo.ItemID == value.MyItemInfo.ItemID) return; if (!value.MyItemInfo.IsStep) { ClearControls(); return; } _MyRTB = value; - _CurItemInfo = MyRTB.MyItemInfo; + CurItemInfo = value.MyItemInfo; // only change all at level if all substeps are of same type bool allSameType = true; - ItemInfo itmp = _CurItemInfo.FirstSibling; + ItemInfo itmp = CurItemInfo.FirstSibling; while (itmp != null) { - if (_CurItemInfo.MyContent.Type != itmp.MyContent.Type) + if (CurItemInfo.MyContent.Type != itmp.MyContent.Type) { allSameType = false; break; @@ -58,6 +83,11 @@ namespace Volian.Controls.Library TagsFillIn(); } } + public bool IsVisible + { + get { return Visible; } + set { if (Visible != value) Visible = value; } + } #endregion #region Constructor public DisplayTags() @@ -76,11 +106,12 @@ namespace Volian.Controls.Library rbChgBarOn.Enabled = false; listBoxStepTypes.Items.Clear(); _MyStepTypeInd.Clear(); + CurItemInfo = null; } private bool StepOverRide() { - ItemInfo myparent = _CurItemInfo.MyActiveParent as ItemInfo; - if (_CurItemInfo.IsRNOPart && myparent !=null && myparent.IsHigh) + ItemInfo myparent = CurItemInfo.MyActiveParent as ItemInfo; + if (CurItemInfo.IsRNOPart && myparent !=null && myparent.IsHigh) { // does the high level step of an RNO have a checkoff, if so it // can be overridden? @@ -106,19 +137,19 @@ namespace Volian.Controls.Library groupPanelMisc.Style.BackColor = Color.Cornsilk; groupPanelCheckoff.Style.BackColor = Color.Cornsilk; cbPageBreak.Checked = false; // will be set below if HLS & config has it on - cbPageBreak.Enabled = _CurItemInfo.IsHigh; + cbPageBreak.Enabled = CurItemInfo.IsHigh; cbCAS.Enabled = true; rbChgBarOff.Enabled = true; rbChgBarOn.Enabled = true; - FormatData fmtdata = _CurItemInfo.ActiveFormat.PlantFormat.FormatData; - StepConfig sc = _CurItemInfo.MyConfig as StepConfig; + FormatData fmtdata = CurItemInfo.ActiveFormat.PlantFormat.FormatData; + StepConfig sc = CurItemInfo.MyConfig as StepConfig; // in certain cases, the checkbox control should be disabled, check for this stuff now... - int formatSteptype = _CurItemInfo.FormatStepType; + int formatSteptype = CurItemInfo.FormatStepType; cmbCheckoff.Enabled = true; - if ((_CurItemInfo.IsCaution || _CurItemInfo.IsNote) & !fmtdata.SectData.StepSectionData.StepSectionLayoutData.TieTabToLevel) + if ((CurItemInfo.IsCaution || CurItemInfo.IsNote) & !fmtdata.SectData.StepSectionData.StepSectionLayoutData.TieTabToLevel) cmbCheckoff.Enabled = false; - if (_CurItemInfo.IsRNOPart && sc != null && sc.Step_CheckOffIndex != -1 && !fmtdata.StepDataList[formatSteptype].CheckOffSameAsParent) + if (CurItemInfo.IsRNOPart && sc != null && sc.Step_CheckOffIndex != -1 && !fmtdata.StepDataList[formatSteptype].CheckOffSameAsParent) cmbCheckoff.Enabled = false; // Checkoffs already assigned to RNO. if (StepOverRide()) cmbCheckoff.Enabled = false; // Checkoffs already assigned to AER @@ -127,12 +158,12 @@ namespace Volian.Controls.Library if (sc == null) // if there is no config data, Page Break and CAS check boxes are false { - if (_CurItemInfo.IsHigh)cbPageBreak.Checked = false; + if (CurItemInfo.IsHigh)cbPageBreak.Checked = false; cbCAS.Checked = false; } else // otherwise, get data from config { - if (_CurItemInfo.IsHigh) cbPageBreak.Checked = sc.Step_ManualPagebreak; + if (CurItemInfo.IsHigh) cbPageBreak.Checked = sc.Step_ManualPagebreak; cbCAS.Checked = sc.Step_CAS; } @@ -151,7 +182,7 @@ namespace Volian.Controls.Library // if the date show it as having one, or allow a change bar to be 'on' if there the dates are // not different. Note also that a user may edit data after the change bar is set to 'on'. DateTime curDts; - using (Item itm = Item.Get(_CurItemInfo.ItemID)) + using (Item itm = Item.Get(CurItemInfo.ItemID)) { curDts = itm.DTS; } @@ -166,7 +197,7 @@ namespace Volian.Controls.Library // change bar & override sets it to Off. if (sc.Step_CBOverride == null) { - if (curDts > _CurItemInfo.MyProcedure.DTS) + if (curDts > CurItemInfo.MyProcedure.DTS) { rbChgBarOn.Checked = true; rbChgBarOff.Text = "OFF (Override)"; @@ -182,7 +213,7 @@ namespace Volian.Controls.Library // If the date of this is greater than the procedure, a change bar should be displayed - // see what the override says. The override states whether change bar is on/off (not // whether override is on/off) - if (curDts > _CurItemInfo.MyProcedure.DTS) + if (curDts > CurItemInfo.MyProcedure.DTS) { rbChgBarOff.Text = "OFF (Override)"; rbChgBarOn.Text = "ON"; @@ -199,7 +230,7 @@ namespace Volian.Controls.Library //int tmpi = formatSteptype; // RNO is a special case in that it has a parent type of high, for formatting, but does not walk // up tree to define types that it can be changed into.... - if (!_CurItemInfo.IsRNOPart) top = fmtdata.StepTopUnderBase(top, formatSteptype); + if (!CurItemInfo.IsRNOPart) top = fmtdata.StepTopUnderBase(top, formatSteptype); listBoxStepTypes.Items.Clear(); listBoxStepTypes.SelectedIndex = DoListStepTypes(fmtdata, top, fmtdata.StepDataList[formatSteptype].Type); lblNoTypeChgReason.Visible = !(listBoxStepTypes.Items.Count>0); @@ -210,7 +241,7 @@ namespace Volian.Controls.Library private int DoListStepTypes(FormatData fmtdata, StepData topType, string curType) { int cursel=-1; - List sdl = fmtdata.StepGetLevelTypes(false, topType, ref cursel, curType, _CurItemInfo); + List sdl = fmtdata.StepGetLevelTypes(false, topType, ref cursel, curType, CurItemInfo); if (sdl==null || sdl.Count==0) { if (listBoxStepTypes.Items.Count==0)lblNoTypeChgReason.Text = topType.StepEditData.TypeMenu.NoChgReason; @@ -243,14 +274,14 @@ namespace Volian.Controls.Library private void cbPageBreak_CheckedChanged(object sender, EventArgs e) { if (_Initalizing) return; - StepConfig sc = _CurItemInfo.MyConfig as StepConfig; + StepConfig sc = CurItemInfo.MyConfig as StepConfig; if (sc == null) return; sc.Step_ManualPagebreak = cbPageBreak.Checked; } private void cbCAS_CheckedChanged(object sender, EventArgs e) { if (_Initalizing) return; - StepConfig sc = _CurItemInfo.MyConfig as StepConfig; + StepConfig sc = CurItemInfo.MyConfig as StepConfig; if (sc == null) return; sc.Step_CAS = cbCAS.Checked; } @@ -258,11 +289,11 @@ namespace Volian.Controls.Library { if (_Initalizing) return; StepItem topStepItem = _MyRTB.MyStepItem; - FormatData fmtdata = _CurItemInfo.ActiveFormat.PlantFormat.FormatData; + FormatData fmtdata = CurItemInfo.ActiveFormat.PlantFormat.FormatData; string msgBox = null; if (cbChgAll.Checked) { - ItemInfo startitm = _CurItemInfo.FirstSibling; + ItemInfo startitm = CurItemInfo.FirstSibling; topStepItem = _MyRTB.MyStepItem.MyStepPanel._LookupStepItems[startitm.ItemID]; while (startitm != null) { @@ -285,14 +316,14 @@ namespace Volian.Controls.Library } else { - using (Content cnt1 = Content.Get(_CurItemInfo.MyContent.ContentID)) + using (Content cnt1 = Content.Get(CurItemInfo.MyContent.ContentID)) { cnt1.Type = 20000 + fmtdata.StepDataList[_MyStepTypeInd[listBoxStepTypes.SelectedIndex]].Index; cnt1.DTS = DateTime.Now; cnt1.UserID = Volian.Base.Library.VlnSettings.UserID; cnt1.Save(); } - using (Item itm1 = Item.Get(_CurItemInfo.ItemID)) + using (Item itm1 = Item.Get(CurItemInfo.ItemID)) { itm1.DTS = DateTime.Now; itm1.UserID = Volian.Base.Library.VlnSettings.UserID; @@ -306,7 +337,8 @@ namespace Volian.Controls.Library } private void groupPanelCheckoff_VisibleChanged(object sender, EventArgs e) { - if (Visible==true && _NotVisibleRTB != null) MyRTB = _NotVisibleRTB; + if (Visible==true && NotVisibleRTB != null) + MyRTB = NotVisibleRTB; // If it becomes visible, update the panel } private void rbChgBarOvrRideOn_CheckedChanged(object sender, EventArgs e) { @@ -316,9 +348,9 @@ namespace Volian.Controls.Library // handler for the other control sets the data appropriately. if (rbChgBarOn.Checked) { - StepConfig sc = _CurItemInfo.MyConfig as StepConfig; + StepConfig sc = CurItemInfo.MyConfig as StepConfig; sc.Step_CBOverride = "On"; - using (Content cnt = Content.Get(_CurItemInfo.MyContent.ContentID)) + using (Content cnt = Content.Get(CurItemInfo.MyContent.ContentID)) { cnt.DTS = DateTime.Now; cnt.UserID = Volian.Base.Library.VlnSettings.UserID; @@ -334,12 +366,12 @@ namespace Volian.Controls.Library // handler for the other control sets the data appropriately. if (rbChgBarOff.Checked) { - StepConfig sc = _CurItemInfo.MyConfig as StepConfig; + StepConfig sc = CurItemInfo.MyConfig as StepConfig; sc.Step_CBOverride = "Off"; - using (Content cnt = Content.Get(_CurItemInfo.MyContent.ContentID)) + using (Content cnt = Content.Get(CurItemInfo.MyContent.ContentID)) { - cnt.DTS = _CurItemInfo.MyProcedure.DTS; - cnt.UserID = _CurItemInfo.MyProcedure.UserID; + cnt.DTS = CurItemInfo.MyProcedure.DTS; + cnt.UserID = CurItemInfo.MyProcedure.UserID; cnt.Save(); } }