Code to walk through Items for Find and Replace
This commit is contained in:
		
							
								
								
									
										76
									
								
								PROMS/VEPROMS.CSLA.Library/Extension/ItemInfoSearchExt.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										76
									
								
								PROMS/VEPROMS.CSLA.Library/Extension/ItemInfoSearchExt.cs
									
									
									
									
									
										Normal file
									
								
							@@ -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
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user