public static object SelectList(ICollection list, object selected, OnListItemGUI itemHandler) { ArrayList selectionList; selectionList = new ArrayList(); if (selected != null) { selectionList.Add(selected); } selectionList = new ArrayList(SelectList(list, selectionList, 1, itemHandler)); return((selectionList.Count > 0) ? selectionList[0] : null); }
public static object SelectList(ICollection list, object selected, OnListItemGUI itemHandler) { foreach (object current in list) { if (itemHandler(current, selected == current, list)) { selected = current; } else { if (selected == current) { selected = null; } } } return(selected); }
public static ArrayList SelectList(ICollection list, ICollection selected, OnListItemGUI itemHandler) { ArrayList itemList; ArrayList selectedList; ArrayList updatedSelectedList = new ArrayList(); itemList = new ArrayList(list); selectedList = new ArrayList(selected); foreach (object item in itemList) { bool wasSelected = selectedList.Contains(item); if (itemHandler(item, wasSelected, list)) { updatedSelectedList.Add(item); } } return(updatedSelectedList); }
public string SelectList(ICollection list, string selected, OnListItemGUI itemHandler) { ArrayList itemList; itemList = new ArrayList(list); foreach (string item in itemList) { if (itemHandler(item, item == selected, list)) { selected = item; } else if (selected == item) // If we *were* selected, but aren't any more then deselect { selected = null; } } return(selected); }
public static object SelectList(ICollection list, object selected, OnListItemGUI itemHandler) { ArrayList itemList; itemList = new ArrayList(list); foreach (object item in itemList) { if (itemHandler(item, item == selected, list)) { selected = item; } else if (selected == item) // If we *were* selected, but aren't any more then deselect { selected = null; } } return selected; }
public static string SelectList( IEnumerable<string> list, string selected, OnListItemGUI itemHandler ) { List<string> itemList; itemList = new List<string>( list ); foreach( string item in itemList ) { if( itemHandler( item, item == selected, list ) ) { selected = item; } else if( selected == item ) // If we *were* selected, but aren't any more then deselect { selected = null; } } return selected; }
public static object SelectList( ICollection list, object selected, OnListItemGUI itemHandler ) { ArrayList selectionList; selectionList = new ArrayList(); if( selected != null ) { selectionList.Add( selected ); } selectionList = new ArrayList( SelectList( list, selectionList, 1, itemHandler ) ); return ( selectionList.Count > 0 ) ? selectionList[ 0 ] : null; }
/*public static ICollection SelectList( ICollection list, ICollection selected, int maxSelection, OnListItemGUI itemHandler ) { ArrayList newSelection; newSelection = new ArrayList( selected ); foreach( object item in list ) { if( itemHandler( item, newSelection.Contains( item ), list ) ) // If the item is now/still selected { if( !newSelection.Contains( item ) ) { if( MultiSelectKey ) { if( newSelection.Count < maxSelection ) { newSelection.Add( item ); } } else { newSelection.Clear(); newSelection.Add( item ); } } } else if( newSelection.Contains( item ) ) // If the item has just been deselected { if( MultiSelectKey ) { newSelection.Remove( item ); } else { newSelection.Clear(); } } } return newSelection; }*/ public static ICollection SelectList( ICollection list, ICollection selected, int maxSelection, OnListItemGUI itemHandler ) { object[] oldSelection; ArrayList newSelection = new ArrayList( maxSelection ); oldSelection = new object[ selected.Count ]; selected.CopyTo( oldSelection, 0 ); foreach( object item in list ) { if( itemHandler( item, System.Array.IndexOf( oldSelection, item ) > -1, list ) ) // If the item is now/still selected { if( MultiSelectKey ) { if( newSelection.Count < maxSelection ) { newSelection.Add( item ); } } else { //newSelection.Clear(); //not arsure if needed newSelection.Add( item ); } } } return newSelection; }
/*public static ICollection SelectList( ICollection list, ICollection selected, int maxSelection, OnListItemGUI itemHandler ) * { * ArrayList newSelection; * * newSelection = new ArrayList( selected ); * * foreach( object item in list ) * { * if( itemHandler( item, newSelection.Contains( item ), list ) ) * // If the item is now/still selected * { * if( !newSelection.Contains( item ) ) * { * if( MultiSelectKey ) * { * if( newSelection.Count < maxSelection ) * { * newSelection.Add( item ); * } * } * else * { * newSelection.Clear(); * newSelection.Add( item ); * } * } * } * else if( newSelection.Contains( item ) ) * // If the item has just been deselected * { * if( MultiSelectKey ) * { * newSelection.Remove( item ); * } * else * { * newSelection.Clear(); * } * } * } * * return newSelection; * }*/ public static ICollection SelectList(ICollection list, ICollection selected, int maxSelection, OnListItemGUI itemHandler) { object[] oldSelection; ArrayList newSelection = new ArrayList(maxSelection); oldSelection = new object[selected.Count]; selected.CopyTo(oldSelection, 0); foreach (object item in list) { if (itemHandler(item, System.Array.IndexOf(oldSelection, item) > -1, list)) // If the item is now/still selected { if (MultiSelectKey) { if (newSelection.Count < maxSelection) { newSelection.Add(item); } } else { //newSelection.Clear(); //not arsure if needed newSelection.Add(item); } } } return(newSelection); }