public void MovePrevious_DragDrop() => Create("SampleRotation.pdf", "", 9, vm => { var src = vm.Data.Images.ToList(); var obj = new DragDropObject(6) { DropIndex = 3 }; src[1].IsSelected = true; src[3].IsSelected = true; src[6].IsSelected = true; Assert.That(Invoke(vm, () => vm.InsertOrMove.Execute(obj)), "Invoke"); var dest = vm.Data.Images.ToList(); Assert.That(dest.Count, Is.EqualTo(9)); Assert.That(dest[0].RawObject.Number, Is.EqualTo(2)); Assert.That(dest[1].RawObject.Number, Is.EqualTo(4)); Assert.That(dest[2].RawObject.Number, Is.EqualTo(1)); Assert.That(dest[3].RawObject.Number, Is.EqualTo(3)); Assert.That(dest[4].RawObject.Number, Is.EqualTo(7)); Assert.That(dest[5].RawObject.Number, Is.EqualTo(5)); Assert.That(dest[6].RawObject.Number, Is.EqualTo(6)); Assert.That(dest[7].RawObject.Number, Is.EqualTo(8)); Assert.That(dest[8].RawObject.Number, Is.EqualTo(9)); for (var i = 0; i < dest.Count; ++i) { Assert.That(dest[i].Index, Is.EqualTo(i)); } });
private void Awake() { dragDropObject = GetComponent <DragDropObject>(); cardName = transform.Find("Name").GetComponent <Text>(); cardContext = transform.Find("Context").GetComponent <Text>(); cardFrame = transform.Find("Frame").GetComponent <Image>(); cardIcon = transform.Find("Icon").GetComponent <Image>(); }
public void OnDragDropEvent(DragDropObject ddObject, bool isDrag) { if (isDrag) { OnDragObject(ddObject); } else { OnDropObject(ddObject); } }
public void OnDrop(PointerEventData eventData) { DragDropObject d = eventData.pointerDrag.GetComponent <DragDropObject>(); if (d != null) { d.transform.SetParent(transform); //GetComponent<CanvasGroup>().blocksRaycasts = true; d.transform.localPosition = Vector3.zero; d.defaultPosition = transform.position; d.parent = transform; } }
/* * Displays the final sandwich that the user has made. It also destorys the menu game object. */ public void DisplaySandwich() { if (!displaySandwich) { displaySandwich = true; finalList = DragDropObject.selectedItemsInSandwich(); if (finalList.Count >= 1) { for (int i = 0; i < finalList.Count; i++) { finalList [i].transform.Translate(new Vector3(1.659f, 0f, 0f)); } } } }
public void Insert(DragDropObject dropObject, int index) { //If Holder capacity is overwhelm int childCount = transform.childCount; if (maximumItems >= 0 && childCount >= maximumItems) { dropObject.Reset(); return; } dropObject.transform.SetParent(transform); if (index >= 0) { dropObject.transform.SetSiblingIndex(index); } }
private void OnDragObject(DragDropObject ddObject) { currentDragObject = ddObject; if (tempDragHolder) { currentDragObject.transform.SetParent(tempDragHolder.transform); } TaskDataSlot task = GetTaskData(ddObject); if (task != null) { taskDataSlots.Remove(task); UpdateCalculationResult(); } NotifyUILock(); }
private void OnDropObject(DragDropObject ddObject) { //If current inside a drop holder if (currentDropHolder != null) { currentDropHolder.Insert(ddObject); TaskDataSlot task = GetTaskData(ddObject); if (task != null && currentDropHolder.mount) { taskDataSlots.Add(task); UpdateCalculationResult(); } } else { ddObject.Reset(); } NotifyUIRelease(); currentDragObject = null; }
// Start is called before the first frame update void Start() { if (taskProcessor == null) { taskProcessor = GetComponent <TaskProcessor>(); } currentDropHolder = null; currentDragObject = null; _camera = Camera.main; taskDataSlots = new List <TaskDataSlot>(); dragDropHolders = transform.GetComponentsInChildren <DragDropHolder>(); taskCalculationHelper = new TaskCalculationHelper(); TaskPickScrollRect.OnBeginDragEvent += NotifyUILock; TaskPickScrollRect.OnEndDragEvent += NotifyUIRelease; taskProcessor.OnTaskDone += Init; AssignOnDropEvent(dragDropHolders); Init(); }
private void OnItemDragDrop(object sender, DragEventArgs e) { DragDropObject data = new DragDropObject(e.Data); DragDropOption action = DragDropOption.None; DragDropOption allowedActions = ConvertEnum.GetDragDropAction(e.AllowedEffect); ModifierFlags modifiers = ConvertEnum.GetModifierFlags(e); Point clientPoint = _listView.PointToClient(new Point(e.X, e.Y)); IGalleryItem targetItem; bool skipNearestItem = false; if (_component.AllowsDropOnItem) { targetItem = GetTargetItemAt(clientPoint, false); if (targetItem != null) { action = _component.PerformDrop(data, targetItem, allowedActions, modifiers); skipNearestItem = true; if (action != DragDropOption.None) DrawInsertionMark(_gallery.IndexOf(targetItem), true, clientPoint); } } if (_component.AllowsDropAtIndex && action == DragDropOption.None) { int targetIndex = GetNearestTargetIndexAt(clientPoint); if (targetIndex >= 0) { action = _component.PerformDrop(data, targetIndex, allowedActions, modifiers); if (action != DragDropOption.None) DrawInsertionMark(targetIndex, false, clientPoint); } } if (!skipNearestItem && _component.AllowsDropOnItem && action == DragDropOption.None) { targetItem = GetTargetItemAt(clientPoint, true); if (targetItem != null) { action = _component.PerformDrop(data, targetItem, allowedActions, modifiers); if (action != DragDropOption.None) DrawInsertionMark(_gallery.IndexOf(targetItem), true, clientPoint); } } e.Effect = ConvertEnum.GetDragDropEffects(action); DrawInsertionMark(-1, false, Point.Empty); }
private TaskDataSlot GetTaskData(DragDropObject dragObject) { return(dragObject.GetComponent <TaskDataSlot>()); }
public void Insert(DragDropObject dropObject) { Insert(dropObject, -1); }