コード例 #1
0
ファイル: Resources.cs プロジェクト: hardikbhalodi/Path-GPL
        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);
        }
コード例 #2
0
ファイル: ActionResources.cs プロジェクト: calumroy/lumpskit
 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);
 }
コード例 #3
0
        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);
        }
コード例 #4
0
    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);
    }
コード例 #5
0
    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;
    }
コード例 #6
0
ファイル: SolveGUI.cs プロジェクト: abdalla4dev/dagamers
    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;
    }
コード例 #7
0
ファイル: Resources.cs プロジェクト: imclab/Path-GPL
		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;
		}
コード例 #8
0
ファイル: Resources.cs プロジェクト: imclab/Path-GPL
		/*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;
		}
コード例 #9
0
ファイル: Resources.cs プロジェクト: hardikbhalodi/Path-GPL
        /*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);
        }