Пример #1
0
		/// <summary>
		/// Remove all items from list.
		/// </summary>
		/// <remarks>
		/// <para>The event <see cref="ItemRemoving"/> is raised for each item prior to
		/// clearing array and allows entire operation to be cancelled.</para>
		/// </remarks>
		/// <param name="adaptor">Reorderable list adaptor.</param>
		/// <returns>
		/// Returns a value of <c>false</c> if operation was cancelled.
		/// </returns>
		protected bool ClearAll( IReorderableListAdaptor adaptor )
		{
			if (adaptor.Count == 0)
				return true;

			var args = new ItemRemovingEventArgs( adaptor, 0 );
			int count = adaptor.Count;
			for (int i = 0; i < count; ++i)
			{
				args.itemIndex = i;
				OnItemRemoving( args );
				if (args.Cancel)
					return false;
			}

			adaptor.Clear();

			GUI.changed = true;
			ReorderableListGUI.indexOfChangedItem = -1;

			return true;
		}
Пример #2
0
		/// <summary>
		/// Raises event before list item is removed and provides oppertunity to cancel.
		/// </summary>
		/// <param name="args">Event arguments.</param>
		protected virtual void OnItemRemoving( ItemRemovingEventArgs args )
		{
			if (ItemRemoving != null)
				ItemRemoving( this, args );
		}
Пример #3
0
		/// <summary>
		/// Remove specified item.
		/// </summary>
		/// <remarks>
		/// <para>The event <see cref="ItemRemoving"/> is raised prior to removing item
		/// and allows removal to be cancelled.</para>
		/// </remarks>
		/// <param name="adaptor">Reorderable list adaptor.</param>
		/// <param name="itemIndex">Zero-based index of item.</param>
		/// <returns>
		/// Returns a value of <c>false</c> if operation was cancelled.
		/// </returns>
		protected bool RemoveItem( IReorderableListAdaptor adaptor, int itemIndex )
		{
			var args = new ItemRemovingEventArgs( adaptor, itemIndex );
			OnItemRemoving( args );
			if (args.Cancel)
				return false;

			adaptor.Remove( itemIndex );

			GUI.changed = true;
			ReorderableListGUI.indexOfChangedItem = -1;

			return true;
		}