private void Drop(ItemContainer container)
        {
            if (!CanHandleEvent(container))
            {
                return;
            }

            if (!m_isDragging)
            {
                return;
            }

            m_isDragging = false;

            if (m_toPlaceholder == null)
            {
                m_toPlaceholder = m_fromPlaceholder;
            }

            ItemContainer displacedContainer = m_toPlaceholder.GetComponentInChildren <ItemContainer>();

            container.transform.SetParent(m_toPlaceholder.transform);
            container.MoveTo(m_toPlaceholder.transform.position);

            if (displacedContainer != null && displacedContainer != container)
            {
                displacedContainer.transform.SetParent(m_fromPlaceholder.transform);
                displacedContainer.MoveTo(m_fromPlaceholder.transform.position);

                if (ItemDropSound != null)
                {
                    ItemDropSound.Play();
                }
            }


            m_toPlaceholder.StopHover();

            if (m_items == null)
            {
                return;
            }

            if (displacedContainer == null)
            {
                return;
            }


            int fromIndex = IndexOf(displacedContainer);
            int toIndex   = IndexOf(container);

            object tmp = Items[fromIndex];

            Items[fromIndex] = Items[toIndex];
            Items[toIndex]   = tmp;

            if (ItemsArranged != null)
            {
                ItemsArranged(this, EventArgs.Empty);
            }

            m_fromPlaceholder = null;
        }
 private bool CanHandleEvent(ItemContainer container)
 {
     return(container.transform.IsChildOf(transform));
 }
        private void DataBind()
        {
            if (m_placeholders == null)
            {
                return;
            }

            if (m_items != null)
            {
                for (int i = m_items.Count; i < Math.Min(m_placeholders.Length, MaxItemsCount); ++i)
                {
                    m_items.Add(null);
                }

                int count = Math.Min(MaxItemsCount, Math.Min(m_placeholders.Length, m_items.Count));
                for (int i = 0; i < count; ++i)
                {
                    ItemPlaceholder placeholder = m_placeholders[i];
                    GameObject      container   = (GameObject)Instantiate(ItemContainerPrefab);
                    container.transform.SetParent(placeholder.gameObject.transform, false);
                    ItemContainer itemContainer = container.GetComponent <ItemContainer>();

                    //not sure if we should do this way
                    // GameContoller.Instance.ItemContainers.Add(itemContainer);
                    Debug.Log("ArrangeItemsControl::Databind::Burasý çalýþýyor");

                    if (itemContainer == null)
                    {
                        itemContainer = container.AddComponent <ItemContainer>();
                    }

                    itemContainer.Interactable = m_interactable;

                    object item = m_items[i];
                    if (item == null)
                    {
                        GameObject presenter = (GameObject)Instantiate(EmptyPresenterPrefab);
                        presenter.transform.SetParent(container.transform, false);
                        presenter.transform.SetAsFirstSibling();

                        if (EmptyDataBinding != null)
                        {
                            ItemDataBindingEventArgs args = new ItemDataBindingEventArgs(null, presenter);
                            EmptyDataBinding(this, args);
                            itemContainer.CanDrag = args.CanDrag;
                        }
                        else
                        {
                            itemContainer.CanDrag = false;
                        }
                    }
                    else
                    {
                        GameObject presenter = (GameObject)Instantiate(ItemPresenterPrefab);
                        presenter.transform.SetParent(container.transform, false);
                        presenter.transform.SetAsFirstSibling();

                        if (container != null)
                        {
                            if (ItemDataBinding != null)
                            {
                                ItemDataBindingEventArgs args = new ItemDataBindingEventArgs(item, presenter);
                                ItemDataBinding(this, args);

                                itemContainer.CanDrag = args.CanDrag;
                            }
                            else
                            {
                                itemContainer.CanDrag = true;
                            }
                        }
                    }
                }
            }
        }