예제 #1
0
        void OnDragStarted(DragStartedMessage obj)
        {
            DraggingGatos = obj.Gatos;

            // Hide the button, show the drop target
            DropTarget.TranslateTo(0, 30);
        }
예제 #2
0
    private void EndDrag()
    {
        if (drag)
        {
            drag = false;
            // Check for a drop target
            bool playOnDroppedOusideSound = true;
            if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out RaycastHit hit))
            {
                DropTarget target = hit.collider.GetComponent <DropTarget>();
                if (target)
                {
                    playOnDroppedOusideSound = false;
                    target.OnDragSourceDropped(this);
                }
            }

            if (playOnDroppedOusideSound && onDragDroppedOutsideTargetSound)
            {
                audioSource.PlayOneShot(onDragDroppedOutsideTargetSound, 2f);
            }

            currentDragPopup = null;

            if (!mousedOver)
            {
                StartCoroutine(ReturnPopupCoroutine(0.25f));
            }
        }
    }
예제 #3
0
        public void OnEndDrag(PointerEventData eventData)
        {
            if (!dragging)
            {
                return;
            }
            UIParent.draggedItem = null;

            ItemUI target = null;
            List <RaycastResult> hitObjects = new List <RaycastResult>();

            EventSystem.current.RaycastAll(eventData, hitObjects);
            if (hitObjects.Count > 0)
            {
                // If we hit an object while ending the drag of an item
                // Check if the object is a valid drop target
                DropTarget dt = hitObjects[0].gameObject.GetComponent <DropTarget>();
                if (dt)
                {
                    target = dt.GetComponentInChildren <ItemUI>(true);
                }
            }
            else
            {
                // If we dropped the item over nothing
                if (item.modelPrefab)
                {
                    // Spawn the item in the scene if it has a model
                    UIParent.inventory.GetComponent <Animator>().SetTrigger("Throw Dice");
                    UIParent.inventory.gameObject.GetComponent <UserKeyBindings>().StartDropItemCoroutine(item, UIParent.inventory.transform, 1.8f);
                    //GameObject droppedItem = Instantiate(item.modelPrefab);
                    //droppedItem.GetComponent<ItemInstance>().SetItem(item, UIParent.inventory.transform);
                }

                // Remove item from player inventory
                UIParent.inventory.SetItem((int)positionInInventory.x, (int)positionInInventory.y, null);
            }

            // If the drop target is not null and not the current ItemUI object
            if (target && target != this)
            {
                if (target.UIParent.CanDrop(this, (int)target.positionInInventory.x, (int)target.positionInInventory.y))
                {
                    // Drop the item in the target if it will take the item
                    target.UIParent.Drop(this, target);
                }
            }

            // Reset the ItemUI's transform
            // and make it a raycast target
            transform.position = originalPosition;
            GetComponent <Image>().raycastTarget = true;
            dragging = false;
        }
예제 #4
0
    public void OnEndDrag(PointerEventData eventData)
    {
        if (!dropSuccess)
        {
            StartCoroutine(ReturnToSender());
        }

        dropSuccess = false;
        canvasGroup.blocksRaycasts = true;

        DropTarget.HideDropHints(type);
    }
예제 #5
0
    public void OnBeginDrag(PointerEventData eventData)
    {
        originalParent   = transform.parent;
        originalPosition = transform.position;
        transform.SetParent(dragLayer);
        startPointerPosition = mainCamera.ScreenToWorldPoint(eventData.position);

        canvasGroup.blocksRaycasts = false;

        DropTarget.ShowDropHints(type);

        onBeginDrag.Invoke();
    }
예제 #6
0
    public void OnDropped(GameObject draggable, DropTarget toTarget)
    {
        //ToDo: check if the draggable is a worker; if not, ignore
        //if it is,
        // check if it is currently assigned to a task; if it is, UNASSIGN (tell both it and the task)
        // check if what it's dropped into is a task; if it is, ASSIGN (tell both it and the task)
        Worker worker = draggable.GetComponent <Worker>();
        Task   task   = toTarget == null ? null : toTarget.GetComponent <Task>();

        if (worker != null)
        {
            worker.Assign(task);
        }
    }
        protected override void OnAttached()
        {
            base.OnAttached();
            dataPresenter = this.AssociatedObject;
            EventManager.RegisterClassHandler(typeof(XamDataGrid), UIElement.MouseLeftButtonDownEvent, new MouseButtonEventHandler(XamDataGrid_MouseLeftButtonDown));
            var dataPresenterStyle = new Style(typeof(DataRecordPresenter));

            dataPresenterStyle.Setters.Add(new EventSetter(FrameworkElement.LoadedEvent, new RoutedEventHandler(OnRecordPresenterLoaded)));
            dataPresenter.Resources.Add(typeof(DataRecordPresenter), dataPresenterStyle);
            DropTarget dropTarget = new DropTarget()
            {
                IsDropTarget = true
            };

            DragDropManager.SetDropTarget(dataPresenter, dropTarget);
        }
예제 #8
0
    // Update is called once per frame
    void Update()
    {
        //Debug.Log(isInteractable);
        if (isInteractable)
        {
            RectTransform trans         = GetComponent <RectTransform>();
            Vector3       mousePosition = Camera.main.ScreenToViewportPoint(Input.mousePosition);
            mousePosition = trans.InverseTransformPoint(Input.mousePosition);
            //Debug.Log(mousePosition);
            Vector2 cellSize = (trans.rect.size - 4.5f * Vector2.one) / 15;
            mousePosition     = new Vector2(Mathf.Round(mousePosition.x / cellSize.x), Mathf.Round(mousePosition.y / cellSize.y)) * cellSize;
            coordinateToIndex = mousePosition;
            dropTargetType    = DropTarget.None;
            dropTarget        = null;

            if (mousePosition.x > -trans.rect.size.x / 2 && mousePosition.x < trans.rect.size.x / 2 && mousePosition.y > -trans.rect.size.y / 2 && mousePosition.y < trans.rect.size.y / 2)
            {
                //Debug.Log(mousePosition);
                tileHighlight.SetActive(true);
                mousePosition.z = 0.5f;
                tileHighlight.GetComponent <RectTransform>().anchoredPosition = mousePosition;
                dropGoPos      = tileHighlight.transform.position;
                dropTargetType = DropTarget.Board;
                dropTarget     = trans;
            }
            else
            {
                tileHighlight.SetActive(false);
                foreach (var slotTrans in rackSlots)
                {
                    mousePosition = slotTrans.InverseTransformPoint(Input.mousePosition);
                    if (mousePosition.x > -slotTrans.rect.size.x / 2 && mousePosition.x < slotTrans.rect.size.x / 2 && mousePosition.y > -slotTrans.rect.size.y / 2 && mousePosition.y < slotTrans.rect.size.y / 2)
                    {
                        dropGoPos      = slotTrans.transform.position;
                        dropTargetType = DropTarget.Rack;
                        dropTarget     = slotTrans;
                        break;
                    }
                }
            }
        }
    }
예제 #9
0
        void TryAddDropTarget(List <DropTarget> targets, SharpTreeViewItem item, DropPlace place, DragEventArgs e)
        {
            SharpTreeNode node;
            int           index;

            GetNodeAndIndex(item, place, out node, out index);

            if (node != null)
            {
                e.Effects = DragDropEffects.None;
                if (node.CanDrop(e, index))
                {
                    DropTarget target = new DropTarget()
                    {
                        Item  = item,
                        Place = place,
                        Node  = node,
                        Index = index
                    };
                    targets.Add(target);
                }
            }
        }
예제 #10
0
 void OnDragEnded(DragEndedMessage obj)
 {
     // Hide the drop target, show the button
     DropTarget.TranslateTo(0, 180);
 }
예제 #11
0
 public DragHandler(DockPanel dockPanel)
 {
     m_dockPanel = dockPanel;
     m_dropTarget = new DropTarget();
 }
예제 #12
0
        private void InitControl()
        {
            // add droptargets to wrappanel

            // droptarget 1 has no visible ghost
            // if that is the case, we must add a width & height.  Default = auto,
            // so if we leave it at that it will have 0 width/height
            DropTarget dropTarget1 = new DropTarget()
            {
                Ghost           = new DropTargetGhost(),
                GhostVisibility = Visibility.Collapsed,
                Width           = 100,
                Height          = 100
            };
            DropTarget dropTarget2 = new DropTarget()
            {
                Ghost = new DropTargetGhost()
            };
            DropTarget dropTarget3 = new DropTarget()
            {
                Ghost = new DropTargetGhost()
            };

            PanelDropTargets.Children.Add(dropTarget1);
            PanelDropTargets.Children.Add(dropTarget2);
            PanelDropTargets.Children.Add(dropTarget3);

            // create list of droptargets to pass to the dragsources

            List <DropTarget> dropTargets = new List <DropTarget>()
            {
                dropTarget1, dropTarget2, dropTarget3
            };


            // add dragsources to wrappanel

            DragSource dragSource1 = new DragSource()
            {
                Content = new DragSourceContent()
                {
                    DataContext = new Dummy()
                    {
                        DummyText = "1"
                    }
                },
                Ghost       = new DragSourceGhost(),
                DropTargets = dropTargets
            };

            DragSource dragSource2 = new DragSource()
            {
                Content = new DragSourceContent()
                {
                    DataContext = new Dummy()
                    {
                        DummyText = "2"
                    }
                },
                //Ghost = new DragSourceGhost(),
                DropTargets = dropTargets
            };


            List <DropTarget> dropTargetsThird = new List <DropTarget>()
            {
                dropTarget1, dropTarget2
            };

            // dragsource 3 cannot be dropped in droptarget 3
            // dragsource 3 has no visible ghost.  We can set width/height if needed, but in this case,
            // it will take the widht/height of the Content (= DragSource)
            DragSource dragSource3 = new DragSource()
            {
                Content = new DragSourceContent()
                {
                    DataContext = new Dummy()
                    {
                        DummyText = "3"
                    }
                },
                Ghost           = new DragSourceGhost(),
                GhostVisibility = Visibility.Collapsed,
                DropTargets     = dropTargetsThird
            };


            // add dragsources to wrappanel
            PanelDragSources.Children.Add(dragSource1);
            PanelDragSources.Children.Add(dragSource2);
            PanelDragSources.Children.Add(dragSource3);
        }
예제 #13
0
 /// <summary>
 /// Associate a <code>DropTarget</code> with this component.
 /// </summary>
 public void setDropTarget(DropTarget @dt)
 {
 }
예제 #14
0
        void TryAddDropTarget(List<DropTarget> targets, SharpTreeViewItem item, DropPlace place, DragEventArgs e)
        {
            SharpTreeNode node;
            int index;

            GetNodeAndIndex(item, place, out node, out index);

            if (node != null) {
                e.Effects = DragDropEffects.None;
                if (node.CanDrop(e, index)) {
                    DropTarget target = new DropTarget() {
                        Item = item,
                        Place = place,
                        Node = node,
                        Index = index
                    };
                    targets.Add(target);
                }
            }
        }
예제 #15
0
        private void InitControl()
        {
            // add droptargets to wrappanel

            DropTarget dropTarget1 = new DropTarget()
            {
                Ghost = new DropTargetGhost(), RemoveElementDropBehaviour = RemoveElementDropBehaviour.Replace
            };
            DropTarget dropTarget2 = new DropTarget()
            {
                Ghost = new DropTargetGhost(), RemoveElementDropBehaviour = RemoveElementDropBehaviour.Replace
            };
            DropTarget dropTarget3 = new DropTarget()
            {
                Ghost = new DropTargetGhost(), RemoveElementDropBehaviour = RemoveElementDropBehaviour.Replace
            };

            PanelDropTargets.Children.Add(dropTarget1);
            PanelDropTargets.Children.Add(dropTarget2);
            PanelDropTargets.Children.Add(dropTarget3);

            // create list of droptargets to pass to the dragsources

            List <DropTarget> dropTargets = new List <DropTarget>()
            {
                dropTarget1, dropTarget2, dropTarget3
            };


            // add dragsources to wrappanel

            DragSource dragSource1 = new DragSource()
            {
                Content = new DragSourceContent()
                {
                    DataContext = new Dummy()
                    {
                        DummyText = "1"
                    }
                },
                Ghost       = new DragSourceGhost(),
                DropTargets = dropTargets
            };

            DragSource dragSource2 = new DragSource()
            {
                Content = new DragSourceContent()
                {
                    DataContext = new Dummy()
                    {
                        DummyText = "2"
                    }
                },
                Ghost       = new DragSourceGhost(),
                DropTargets = dropTargets
            };

            DragSource dragSource3 = new DragSource()
            {
                Content = new DragSourceContent()
                {
                    DataContext = new Dummy()
                    {
                        DummyText = "3"
                    }
                },
                Ghost       = new DragSourceGhost(),
                DropTargets = dropTargets
            };

            // add dragsources to wrappanel
            PanelDragSources.Children.Add(dragSource1);
            PanelDragSources.Children.Add(dragSource2);
            PanelDragSources.Children.Add(dragSource3);
        }
예제 #16
0
        private void InitControl()
        {
            // add droptargets to wrappanel

            DropTarget dropTarget1 = new DropTarget()
            {
                Ghost = new DropTargetGhost()
            };
            DropTarget dropTarget2 = new DropTarget()
            {
                Ghost = new DropTargetGhost()
            };
            DropTarget dropTarget3 = new DropTarget()
            {
                Ghost = new DropTargetGhost()
            };
            DropTarget dropTarget4 = new DropTarget()
            {
                Ghost = new DropTargetGhost()
            };
            DropTarget dropTarget5 = new DropTarget()
            {
                Ghost = new DropTargetGhost()
            };
            DropTarget dropTarget6 = new DropTarget()
            {
                Ghost = new DropTargetGhost()
            };

            PanelDropTargets.Children.Add(dropTarget1);
            PanelDropTargets.Children.Add(dropTarget2);
            PanelDropTargets.Children.Add(dropTarget3);
            PanelDragSources.Children.Add(dropTarget4);
            PanelDragSources.Children.Add(dropTarget5);
            PanelDragSources.Children.Add(dropTarget6);

            // create list of droptargets to pass to the dragsources

            List <DropTarget> dropTargets = new List <DropTarget>()
            {
                dropTarget1, dropTarget2, dropTarget3,
                dropTarget4, dropTarget5, dropTarget6
            };

            // add dragsources to wrappanel

            DragSource dragSource1 = new DragSource()
            {
                Content = new DragSourceContent()
                {
                    DataContext = new Dummy()
                    {
                        DummyText = "1"
                    }
                },
                Ghost       = new DragSourceGhost(),
                DropTargets = dropTargets
            };

            DragSource dragSource2 = new DragSource()
            {
                Content = new DragSourceContent()
                {
                    DataContext = new Dummy()
                    {
                        DummyText = "2"
                    }
                },
                Ghost       = new DragSourceGhost(),
                DropTargets = dropTargets
            };

            DragSource dragSource3 = new DragSource()
            {
                Content = new DragSourceContent()
                {
                    DataContext = new Dummy()
                    {
                        DummyText = "3"
                    }
                },
                Ghost       = new DragSourceGhost(),
                DropTargets = dropTargets
            };

            // add dragsources as content to droptargets
            dropTarget4.Content = dragSource1;
            dropTarget5.Content = dragSource2;
            dropTarget6.Content = dragSource3;
        }
예제 #17
0
 private void Awake()
 {
     _dropTarget = GetComponent <DropTarget>();
 }
예제 #18
0
 int NativeMethods.IDocHostUIHandler.GetDropTarget(NativeMethods.IOleDropTarget pDropTarget, out NativeMethods.IOleDropTarget ppDropTarget)
 {
     ppDropTarget = new DropTarget(new DataObjectConverter(), pDropTarget);
     return((ppDropTarget != null) ? NativeMethods.S_OK : NativeMethods.E_NOTIMPL);
 }
예제 #19
0
파일: Main.cs 프로젝트: silverio/rush
 private void menuItem12_Click(object sender, System.EventArgs e)
 {
     if (!ItemDropTarget.Checked)
     {
         Convertor                 = new DropTarget();
         Convertor.Visible         = true;
         ItemDropTarget.Checked  = true;
     }
     else
     {
         Convertor.Visible         = false;
         Convertor.Dispose();
         ItemDropTarget.Checked  = false;
     }
 }