From fbd642967021cd7dae01501dcf008f0ccbfe4b06 Mon Sep 17 00:00:00 2001 From: Rich Date: Mon, 1 Feb 2010 19:38:34 +0000 Subject: [PATCH] Code to walk through Items for Find and Replace --- .../Extension/ItemInfoSearchExt.cs | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 PROMS/VEPROMS.CSLA.Library/Extension/ItemInfoSearchExt.cs diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/ItemInfoSearchExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/ItemInfoSearchExt.cs new file mode 100644 index 00000000..9a5bf19e --- /dev/null +++ b/PROMS/VEPROMS.CSLA.Library/Extension/ItemInfoSearchExt.cs @@ -0,0 +1,76 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace VEPROMS.CSLA.Library +{ + public partial class ItemInfo + { + public ItemInfo SearchNext + { + get + { + return SearchNextSkip(SkipPartType.This); + } + } + public string SearchNextPath + { + get + { + ItemInfo itemInfo = SearchNext; + return itemInfo == null ? "" : itemInfo.Path; + } + } + private ItemInfo SearchNextSkip(SkipPartType skip) + { + if (skip < SkipPartType.Caution && Cautions != null) return Cautions[0].SearchTop; + if (skip < SkipPartType.Note && Notes != null) return Notes[0].SearchTop; + if (skip < SkipPartType.This) return this; + if (skip < SkipPartType.RNO && RNOs != null) return RNOs[0].SearchTop; + if (skip < SkipPartType.Table && Tables != null) return Tables[0].SearchTop; + if (skip < SkipPartType.Procedures && Procedures != null) return Procedures[0].SearchTop; + if (skip < SkipPartType.Sections && Sections != null) return Sections[0].SearchTop; + if (skip < SkipPartType.Steps && Steps != null) return Steps[0].SearchTop; + if (NextItem != null) return NextItem.SearchTop; + return UpOneNext; + } + public ItemInfo SearchTop + { + get + { + if (Cautions != null) return Cautions[0].SearchTop; + if (Notes != null) return Notes[0].SearchTop; + return this; + } + } + public ItemInfo UpOneNext + { + get + { + ItemInfo parentItem = ActiveParent as ItemInfo; + if (parentItem == null) return null; + if (IsCautionStructureFirstSib) return parentItem.SearchNextSkip(SkipPartType.Caution); + if (IsNoteStructureFirstSib) return parentItem.SearchNextSkip(SkipPartType.Note); + if (IsRNO) return parentItem.SearchNextSkip(SkipPartType.RNO); + if (IsTable) return parentItem.SearchNextSkip(SkipPartType.Table); + if (IsProcedure) return parentItem.SearchNextSkip(SkipPartType.Procedures); + if (IsSection) return parentItem.SearchNextSkip(SkipPartType.Sections); + if (IsStep) return parentItem.SearchNextSkip(SkipPartType.Steps); + if (parentItem.NextItem != null) return parentItem.NextItem.SearchTop; + return parentItem.UpOneNext; + } + } + enum SkipPartType + { + Nothing=0, + Caution=1, + Note=2, + This=3, + RNO=4, + Table=5, + Procedures=6, + Sections=7, + Steps=8 + } + } +}