private static void DoNode(TreeNode node, SearchResults results, string text) { foreach (TreeNode subNode in node.Nodes) { DoNode(subNode, results, text); } // Issue 10 - Update the code to Net Framework 3.5 - http://code.google.com/p/pandorasbox3/issues/detail?id=10 - Smjert if (node.Tag != null && node.Tag is List <object> ) { List <object> list = node.Tag as List <object>; // Issue 10 - End for (int i = 0; i < list.Count; i++) { object o = list[i]; if (o is BoxMobile) { BoxMobile mob = o as BoxMobile; if (mob.Name.ToLower().IndexOf(text.ToLower()) > -1) { Result res = new Result(node, i); results.Add(res); } } else if (o is BoxItem) { BoxItem item = o as BoxItem; if (item.Name.ToLower().IndexOf(text.ToLower()) > -1) { Result res = new Result(node, i); results.Add(res); } } } } }
public int CompareTo(object obj) { BoxItem cmp = obj as BoxItem; return(m_Name.CompareTo(cmp.m_Name)); }
/// <summary> /// Creates a BoxItem definition from a type /// </summary> /// <param name="type">The type that will be analyzed</param> /// <returns>The corresponding BoxItem object, null if the object can't be constructed</returns> public static BoxItem FromType( Type type ) { BoxItem item = new BoxItem(); ConstructorInfo[] ctors = type.GetConstructors(); item.m_Name = type.Name; foreach ( ConstructorInfo ctor in ctors ) { if ( BoxUtil.IsConstructable( ctor ) ) { int NumOfParams = ctor.GetParameters().Length; if ( NumOfParams == 0 ) { item.m_EmptyCtor = true; item.m_Item = ItemDef.GetItemDef( type ); } else if ( NumOfParams <= 2 ) { if ( item.m_AdditionalCtors == null ) { item.m_AdditionalCtors = new ArrayList(); } item.m_AdditionalCtors.Add( ConstructorDef.FromConstructorInfo( ctor ) ); } } } if ( item.m_EmptyCtor || item.m_AdditionalCtors != null ) { // If there's no default constructor, try to get the ItemDef from the additional constructors if ( ! item.m_EmptyCtor ) { // Get the first available def foreach ( ConstructorDef cDef in item.m_AdditionalCtors ) { if ( cDef.DefaultArt != null ) { item.m_Item = cDef.DefaultArt.Clone() as ItemDef; break; } } } return item; } else { return null; } }
public object Clone() { BoxItem item = new BoxItem(); item.m_Item = this.m_Item.Clone() as ItemDef; item.m_Name = this.m_Name; return item; }