Fixed NextItems logic

Replaced duplicate logic in GetChildren with MyItems
Fixed logic to check for Sections = null
This commit is contained in:
Rich 2010-11-15 17:01:36 +00:00
parent ba85df568a
commit e20796dfbf
6 changed files with 12 additions and 9 deletions

View File

@ -725,7 +725,7 @@ namespace VEPROMS.CSLA.Library
{
get
{
if (NextItemCount > 0 && NextItems.Count > 0)
if (NextItemCount > 0 && NextItems != null && NextItems.Count > 0)
return NextItems[0];
return null;
}

View File

@ -111,7 +111,8 @@ namespace VEPROMS.CSLA.Library
{ get { return (_MyItems != null ? _MyItems : _MyItems = ItemInfoList.GetList(_ItemID, _FromType)); } }
public System.Collections.IList GetChildren()
{
return (_MyItems != null ? _MyItems : _MyItems = ItemInfoList.GetList(_ItemID, _FromType));
//return (_MyItems != null ? _MyItems : _MyItems = ItemInfoList.GetList(_ItemID, _FromType));
return MyItems;
}
//public bool ChildrenAreLoaded
//{

View File

@ -630,6 +630,8 @@ namespace VEPROMS.CSLA.Library
int cntsect = 0;
ItemInfo sect = TranGetSectionItem(tb._ToItem);
if (tb._ToItem.MyProcedure.Sections == null)
tb._ToItem.MyProcedure.MyContent.RefreshContentParts();
foreach (ItemInfo ii in tb._ToItem.MyProcedure.Sections) if (ii.IsStepSection) cntsect++;
// If Procedure going to has only 1 step section, do not add it.
if (cntsect == 1) return false; // tb.TextAdded;

View File

@ -266,7 +266,7 @@ namespace Volian.Controls.Library
Content cnt = Content.Get(startitm.MyContent.ContentID);
cnt.Type = 20000 + fmtdata.StepDataList[_MyStepTypeInd[listBoxStepTypes.SelectedIndex]].Index;
cnt.Save();
startitm = (startitm.NextItemCount > 0 ? startitm.NextItems[0] : null);
startitm = (startitm.NextItem != null && startitm.NextItems.Count > 0 ? startitm.NextItems[0] : null);
}
msgBox = string.Format("All Step Types at this level were changed to {0}", listBoxStepTypes.Items[listBoxStepTypes.SelectedIndex]);
}

View File

@ -428,7 +428,7 @@ namespace Volian.Controls.Library
tvTran.SelectedNode = tvTran.Nodes[active];
setsel = true;
}
startitm = (startitm.NextItemCount > 0 ? startitm.NextItems[0] : null);
startitm = (startitm.NextItem != null && startitm.NextItems.Count > 0 ? startitm.NextItems[0] : null);
}
if (!setsel) tvTran.SelectedNode = tvTran.Nodes[0];
tvTran.BeforeExpand += new TreeViewCancelEventHandler(tvTran_BeforeExpand);
@ -457,7 +457,7 @@ namespace Volian.Controls.Library
int active = cbTranSects.Items.Add(secitm);
if (secitm.ItemID == secstart) cbTranSects.SelectedIndex = active;
}
secitm = (secitm.NextItemCount > 0 ? secitm.NextItems[0] : null);
secitm = (secitm.NextItem != null && secitm.NextItems.Count > 0 ? secitm.NextItems[0] : null);
}
}
@ -471,7 +471,7 @@ namespace Volian.Controls.Library
int active = cbTranProcs.Items.Add(prcitm);
if (_CurrentProcedure.ContentID == prcitm.MyContent.ContentID) _CurrentProcIndex = active;
if (prcitm.MyContent.ContentID == selitm.MyContent.ContentID) cbTranProcs.SelectedIndex = active;
prcitm = (prcitm.NextItemCount > 0 ? prcitm.NextItems[0] : null);
prcitm = (prcitm.NextItem != null && prcitm.NextItems.Count > 0 ? prcitm.NextItems[0] : null);
}
}
private void SetControlsEnabling()

View File

@ -778,7 +778,7 @@ namespace Volian.Controls.Library
{
if (lookAtSub && ii.Sections != null) return TopPart(ii.Sections[0]);
if (lookAtSub && ii.Steps != null) return TopPart(ii.Steps[0]);
if (ii.IsSection && ii.NextItems != null) return TopPart(ii.NextItems[0]);
if (ii.IsSection && ii.NextItems != null && ii.NextItems.Count > 0) return TopPart(ii.NextItems[0]);
}
else
{
@ -793,7 +793,7 @@ namespace Volian.Controls.Library
if (lookAtRNO && ii.RNOs != null && ii.RNOLevel >= ii.ColumnMode) return TopPart(ii.RNOs[0]);
// Nextsibling - go to top part of sibling
// TODO: RHM - NextItems was not null when it should have been after delete of a note below a caution
if (ii.NextItems != null && ii.NextItemCount > 0) return TopPart(ii.NextItems[0]);
if (ii.NextItems != null && ii.NextItems.Count > 0) return TopPart(ii.NextItems[0]);
// If on caution, if parent has note - go to note
if (ii.IsCautionPart && ii.MyParent.Notes != null) return ii.MyParent.Notes[0];
// If on caution, if parent !has note or if on note go to parent
@ -822,7 +822,7 @@ namespace Volian.Controls.Library
ii = ii.LastSibling;
break;
case Keys.PageDown:
ii = ii.NextItems == null ? null : ii.NextItems[0];
ii = ii.NextItems != null && ii.NextItems.Count > 0 ? ii.NextItems[0] : null;
break;
case Keys.PageUp:
ii = ii.MyPrevious;