public virtual void DragCleanup(bool revertExpanded)
 {
     if (this.m_DropData != null)
     {
         if (this.m_DropData.expandedArrayBeforeDrag != null && revertExpanded)
         {
             this.RestoreExpanded(new List <int>(this.m_DropData.expandedArrayBeforeDrag));
         }
         this.m_DropData = new TreeViewDragging.DropData();
     }
 }
        public virtual bool DragElement(TreeViewItem targetItem, Rect targetItemRect, bool firstItem)
        {
            if (targetItem == null)
            {
                if (this.m_DropData != null)
                {
                    this.m_DropData.dropTargetControlID = 0;
                    this.m_DropData.rowMarkerControlID  = 0;
                }
                bool perform = Event.current.type == EventType.DragPerform;
                DragAndDrop.visualMode = this.DoDrag((TreeViewItem)null, (TreeViewItem)null, perform, TreeViewDragging.DropPosition.Below);
                if (DragAndDrop.visualMode != DragAndDropVisualMode.None && perform)
                {
                    this.FinalizeDragPerformed(true);
                }
                return(false);
            }
            Vector2 mousePosition     = Event.current.mousePosition;
            bool    flag              = this.m_TreeView.data.CanBeParent(targetItem);
            Rect    rect              = targetItemRect;
            float   betweenHalfHeight = !flag ? targetItemRect.height * 0.5f : this.m_TreeView.gui.halfDropBetweenHeight;

            if (firstItem)
            {
                rect.yMin -= betweenHalfHeight;
            }
            rect.yMax += betweenHalfHeight;
            if (!rect.Contains(mousePosition))
            {
                return(false);
            }
            TreeViewDragging.DropPosition dropPosition = (double)mousePosition.y < (double)targetItemRect.yMax - (double)betweenHalfHeight ? (!firstItem || (double)mousePosition.y > (double)targetItemRect.yMin + (double)betweenHalfHeight ? (!flag ? TreeViewDragging.DropPosition.Above : TreeViewDragging.DropPosition.Upon) : TreeViewDragging.DropPosition.Above) : TreeViewDragging.DropPosition.Below;
            TreeViewItem          parentItem           = !this.m_TreeView.data.IsExpanded(targetItem) || !targetItem.hasChildren ? targetItem.parent : targetItem;
            DragAndDropVisualMode andDropVisualMode1   = DragAndDropVisualMode.None;

            if (Event.current.type == EventType.DragPerform)
            {
                if (dropPosition == TreeViewDragging.DropPosition.Upon)
                {
                    andDropVisualMode1 = this.DoDrag(targetItem, targetItem, true, dropPosition);
                }
                if (andDropVisualMode1 == DragAndDropVisualMode.None && parentItem != null)
                {
                    andDropVisualMode1 = this.DoDrag(parentItem, targetItem, true, dropPosition);
                }
                if (andDropVisualMode1 != DragAndDropVisualMode.None)
                {
                    this.FinalizeDragPerformed(false);
                }
                else
                {
                    this.DragCleanup(true);
                    this.m_TreeView.NotifyListenersThatDragEnded((int[])null, false);
                }
            }
            else
            {
                if (this.m_DropData == null)
                {
                    this.m_DropData = new TreeViewDragging.DropData();
                }
                this.m_DropData.dropTargetControlID = 0;
                this.m_DropData.rowMarkerControlID  = 0;
                int itemControlId = TreeView.GetItemControlID(targetItem);
                this.HandleAutoExpansion(itemControlId, targetItem, targetItemRect, betweenHalfHeight, mousePosition);
                if (dropPosition == TreeViewDragging.DropPosition.Upon)
                {
                    andDropVisualMode1 = this.DoDrag(targetItem, targetItem, false, dropPosition);
                }
                if (andDropVisualMode1 != DragAndDropVisualMode.None)
                {
                    this.m_DropData.dropTargetControlID = itemControlId;
                    DragAndDrop.visualMode = andDropVisualMode1;
                }
                else if (targetItem != null && parentItem != null)
                {
                    DragAndDropVisualMode andDropVisualMode2 = this.DoDrag(parentItem, targetItem, false, dropPosition);
                    if (andDropVisualMode2 != DragAndDropVisualMode.None)
                    {
                        this.drawRowMarkerAbove             = dropPosition == TreeViewDragging.DropPosition.Above;
                        this.m_DropData.rowMarkerControlID  = itemControlId;
                        this.m_DropData.dropTargetControlID = !this.drawRowMarkerAbove ? TreeView.GetItemControlID(parentItem) : 0;
                        DragAndDrop.visualMode = andDropVisualMode2;
                    }
                }
            }
            Event.current.Use();
            return(true);
        }
        public virtual bool DragElement(TreeViewItem targetItem, Rect targetItemRect, bool firstItem)
        {
            if (targetItem == null)
            {
                if (this.m_DropData != null)
                {
                    this.m_DropData.dropTargetControlID = 0;
                    this.m_DropData.rowMarkerControlID  = 0;
                }
                bool flag = Event.current.type == EventType.DragPerform;
                DragAndDrop.visualMode = this.DoDrag(null, null, flag, TreeViewDragging.DropPosition.Below);
                if (DragAndDrop.visualMode != DragAndDropVisualMode.None && flag)
                {
                    this.FinalizeDragPerformed(true);
                }
                return(false);
            }
            Vector2 mousePosition = Event.current.mousePosition;
            bool    flag2         = this.m_TreeView.data.CanBeParent(targetItem);
            Rect    rect          = targetItemRect;
            float   num           = (!flag2) ? (targetItemRect.height * 0.5f) : this.m_TreeView.gui.halfDropBetweenHeight;

            if (firstItem)
            {
                rect.yMin -= num;
            }
            rect.yMax += num;
            if (!rect.Contains(mousePosition))
            {
                return(false);
            }
            TreeViewDragging.DropPosition dropPosition;
            if (mousePosition.y >= targetItemRect.yMax - num)
            {
                dropPosition = TreeViewDragging.DropPosition.Below;
            }
            else if (firstItem && mousePosition.y <= targetItemRect.yMin + num)
            {
                dropPosition = TreeViewDragging.DropPosition.Above;
            }
            else
            {
                dropPosition = ((!flag2) ? TreeViewDragging.DropPosition.Above : TreeViewDragging.DropPosition.Upon);
            }
            TreeViewItem treeViewItem;

            if (this.m_TreeView.data.IsExpanded(targetItem) && targetItem.hasChildren)
            {
                treeViewItem = targetItem;
            }
            else
            {
                treeViewItem = targetItem.parent;
            }
            DragAndDropVisualMode dragAndDropVisualMode = DragAndDropVisualMode.None;

            if (Event.current.type == EventType.DragPerform)
            {
                if (dropPosition == TreeViewDragging.DropPosition.Upon)
                {
                    dragAndDropVisualMode = this.DoDrag(targetItem, targetItem, true, dropPosition);
                }
                if (dragAndDropVisualMode == DragAndDropVisualMode.None && treeViewItem != null)
                {
                    dragAndDropVisualMode = this.DoDrag(treeViewItem, targetItem, true, dropPosition);
                }
                if (dragAndDropVisualMode != DragAndDropVisualMode.None)
                {
                    this.FinalizeDragPerformed(false);
                }
                else
                {
                    this.DragCleanup(true);
                    this.m_TreeView.NotifyListenersThatDragEnded(null, false);
                }
            }
            else
            {
                if (this.m_DropData == null)
                {
                    this.m_DropData = new TreeViewDragging.DropData();
                }
                this.m_DropData.dropTargetControlID = 0;
                this.m_DropData.rowMarkerControlID  = 0;
                int itemControlID = TreeView.GetItemControlID(targetItem);
                this.HandleAutoExpansion(itemControlID, targetItem, targetItemRect, num, mousePosition);
                if (dropPosition == TreeViewDragging.DropPosition.Upon)
                {
                    dragAndDropVisualMode = this.DoDrag(targetItem, targetItem, false, dropPosition);
                }
                if (dragAndDropVisualMode != DragAndDropVisualMode.None)
                {
                    this.m_DropData.dropTargetControlID = itemControlID;
                    DragAndDrop.visualMode = dragAndDropVisualMode;
                }
                else if (targetItem != null && treeViewItem != null)
                {
                    dragAndDropVisualMode = this.DoDrag(treeViewItem, targetItem, false, dropPosition);
                    if (dragAndDropVisualMode != DragAndDropVisualMode.None)
                    {
                        this.drawRowMarkerAbove             = (dropPosition == TreeViewDragging.DropPosition.Above);
                        this.m_DropData.rowMarkerControlID  = itemControlID;
                        this.m_DropData.dropTargetControlID = ((!this.drawRowMarkerAbove) ? TreeView.GetItemControlID(treeViewItem) : 0);
                        DragAndDrop.visualMode = dragAndDropVisualMode;
                    }
                }
            }
            Event.current.Use();
            return(true);
        }
		public virtual bool DragElement(TreeViewItem targetItem, Rect targetItemRect, bool firstItem)
		{
			if (targetItem == null)
			{
				if (this.m_DropData != null)
				{
					this.m_DropData.dropTargetControlID = 0;
					this.m_DropData.rowMarkerControlID = 0;
				}
				bool flag = Event.current.type == EventType.DragPerform;
				DragAndDrop.visualMode = this.DoDrag(null, null, flag, TreeViewDragging.DropPosition.Below);
				if (DragAndDrop.visualMode != DragAndDropVisualMode.None && flag)
				{
					this.FinalizeDragPerformed(true);
				}
				return false;
			}
			Vector2 mousePosition = Event.current.mousePosition;
			bool flag2 = this.m_TreeView.data.CanBeParent(targetItem);
			Rect rect = targetItemRect;
			float num = (!flag2) ? (targetItemRect.height * 0.5f) : this.m_TreeView.gui.halfDropBetweenHeight;
			if (firstItem)
			{
				rect.yMin -= num;
			}
			rect.yMax += num;
			if (!rect.Contains(mousePosition))
			{
				return false;
			}
			TreeViewDragging.DropPosition dropPosition;
			if (!flag2 || mousePosition.y >= targetItemRect.yMax - num)
			{
				dropPosition = TreeViewDragging.DropPosition.Below;
			}
			else
			{
				if (!flag2 || (firstItem && mousePosition.y <= targetItemRect.yMin + num))
				{
					dropPosition = TreeViewDragging.DropPosition.Above;
				}
				else
				{
					dropPosition = TreeViewDragging.DropPosition.Upon;
				}
			}
			TreeViewItem treeViewItem;
			if (this.m_TreeView.data.IsExpanded(targetItem) && targetItem.hasChildren)
			{
				treeViewItem = targetItem;
			}
			else
			{
				treeViewItem = targetItem.parent;
			}
			DragAndDropVisualMode dragAndDropVisualMode = DragAndDropVisualMode.None;
			if (Event.current.type == EventType.DragPerform)
			{
				if (dropPosition == TreeViewDragging.DropPosition.Upon)
				{
					dragAndDropVisualMode = this.DoDrag(targetItem, targetItem, true, dropPosition);
				}
				if (dragAndDropVisualMode == DragAndDropVisualMode.None && treeViewItem != null)
				{
					dragAndDropVisualMode = this.DoDrag(treeViewItem, targetItem, true, dropPosition);
				}
				if (dragAndDropVisualMode != DragAndDropVisualMode.None)
				{
					this.FinalizeDragPerformed(false);
				}
				else
				{
					this.DragCleanup(true);
					this.m_TreeView.NotifyListenersThatDragEnded(null, false);
				}
			}
			else
			{
				if (this.m_DropData == null)
				{
					this.m_DropData = new TreeViewDragging.DropData();
				}
				this.m_DropData.dropTargetControlID = 0;
				this.m_DropData.rowMarkerControlID = 0;
				int itemControlID = TreeView.GetItemControlID(targetItem);
				this.HandleAutoExpansion(itemControlID, targetItem, targetItemRect, num, mousePosition);
				if (dropPosition == TreeViewDragging.DropPosition.Upon)
				{
					dragAndDropVisualMode = this.DoDrag(targetItem, targetItem, false, dropPosition);
				}
				if (dragAndDropVisualMode != DragAndDropVisualMode.None)
				{
					this.m_DropData.dropTargetControlID = itemControlID;
					DragAndDrop.visualMode = dragAndDropVisualMode;
				}
				else
				{
					if (targetItem != null && treeViewItem != null)
					{
						dragAndDropVisualMode = this.DoDrag(treeViewItem, targetItem, false, dropPosition);
						if (dragAndDropVisualMode != DragAndDropVisualMode.None)
						{
							this.drawRowMarkerAbove = (dropPosition == TreeViewDragging.DropPosition.Above);
							this.m_DropData.rowMarkerControlID = itemControlID;
							this.m_DropData.dropTargetControlID = ((!this.drawRowMarkerAbove) ? TreeView.GetItemControlID(treeViewItem) : 0);
							DragAndDrop.visualMode = dragAndDropVisualMode;
						}
					}
				}
			}
			Event.current.Use();
			return true;
		}
		public virtual void DragCleanup(bool revertExpanded)
		{
			if (this.m_DropData != null)
			{
				if (this.m_DropData.expandedArrayBeforeDrag != null && revertExpanded)
				{
					this.RestoreExpanded(new List<int>(this.m_DropData.expandedArrayBeforeDrag));
				}
				this.m_DropData = new TreeViewDragging.DropData();
			}
		}
 public virtual bool DragElement(TreeViewItem targetItem, Rect targetItemRect, bool firstItem)
 {
   if (targetItem == null)
   {
     if (this.m_DropData != null)
     {
       this.m_DropData.dropTargetControlID = 0;
       this.m_DropData.rowMarkerControlID = 0;
     }
     bool perform = Event.current.type == EventType.DragPerform;
     DragAndDrop.visualMode = this.DoDrag((TreeViewItem) null, (TreeViewItem) null, perform, TreeViewDragging.DropPosition.Below);
     if (DragAndDrop.visualMode != DragAndDropVisualMode.None && perform)
       this.FinalizeDragPerformed(true);
     return false;
   }
   Vector2 mousePosition = Event.current.mousePosition;
   bool flag = this.m_TreeView.data.CanBeParent(targetItem);
   Rect rect = targetItemRect;
   float betweenHalfHeight = !flag ? targetItemRect.height * 0.5f : this.m_TreeView.gui.halfDropBetweenHeight;
   if (firstItem)
     rect.yMin -= betweenHalfHeight;
   rect.yMax += betweenHalfHeight;
   if (!rect.Contains(mousePosition))
     return false;
   TreeViewDragging.DropPosition dropPosition = (double) mousePosition.y < (double) targetItemRect.yMax - (double) betweenHalfHeight ? (!firstItem || (double) mousePosition.y > (double) targetItemRect.yMin + (double) betweenHalfHeight ? (!flag ? TreeViewDragging.DropPosition.Above : TreeViewDragging.DropPosition.Upon) : TreeViewDragging.DropPosition.Above) : TreeViewDragging.DropPosition.Below;
   TreeViewItem parentItem = !this.m_TreeView.data.IsExpanded(targetItem) || !targetItem.hasChildren ? targetItem.parent : targetItem;
   DragAndDropVisualMode andDropVisualMode1 = DragAndDropVisualMode.None;
   if (Event.current.type == EventType.DragPerform)
   {
     if (dropPosition == TreeViewDragging.DropPosition.Upon)
       andDropVisualMode1 = this.DoDrag(targetItem, targetItem, true, dropPosition);
     if (andDropVisualMode1 == DragAndDropVisualMode.None && parentItem != null)
       andDropVisualMode1 = this.DoDrag(parentItem, targetItem, true, dropPosition);
     if (andDropVisualMode1 != DragAndDropVisualMode.None)
     {
       this.FinalizeDragPerformed(false);
     }
     else
     {
       this.DragCleanup(true);
       this.m_TreeView.NotifyListenersThatDragEnded((int[]) null, false);
     }
   }
   else
   {
     if (this.m_DropData == null)
       this.m_DropData = new TreeViewDragging.DropData();
     this.m_DropData.dropTargetControlID = 0;
     this.m_DropData.rowMarkerControlID = 0;
     int itemControlId = TreeView.GetItemControlID(targetItem);
     this.HandleAutoExpansion(itemControlId, targetItem, targetItemRect, betweenHalfHeight, mousePosition);
     if (dropPosition == TreeViewDragging.DropPosition.Upon)
       andDropVisualMode1 = this.DoDrag(targetItem, targetItem, false, dropPosition);
     if (andDropVisualMode1 != DragAndDropVisualMode.None)
     {
       this.m_DropData.dropTargetControlID = itemControlId;
       DragAndDrop.visualMode = andDropVisualMode1;
     }
     else if (targetItem != null && parentItem != null)
     {
       DragAndDropVisualMode andDropVisualMode2 = this.DoDrag(parentItem, targetItem, false, dropPosition);
       if (andDropVisualMode2 != DragAndDropVisualMode.None)
       {
         this.drawRowMarkerAbove = dropPosition == TreeViewDragging.DropPosition.Above;
         this.m_DropData.rowMarkerControlID = itemControlId;
         this.m_DropData.dropTargetControlID = !this.drawRowMarkerAbove ? TreeView.GetItemControlID(parentItem) : 0;
         DragAndDrop.visualMode = andDropVisualMode2;
       }
     }
   }
   Event.current.Use();
   return true;
 }
 public virtual void DragCleanup(bool revertExpanded)
 {
   if (this.m_DropData == null)
     return;
   if (this.m_DropData.expandedArrayBeforeDrag != null && revertExpanded)
     this.RestoreExpanded(new List<int>((IEnumerable<int>) this.m_DropData.expandedArrayBeforeDrag));
   this.m_DropData = new TreeViewDragging.DropData();
 }