/** Override transaction to give player the item, gold etc */ override public bool Transact(IDragDrop source) { if (source.DDContent is GuiGold) { Trace.Log("transfering gold..."); var gold = (source.DDContent as GuiGold); Character.CreditGold(gold.Amount, true); gold.DebitSource(); return(true); } if (source is GuiItemSlot) { DDContent = source.DDContent; source.DDContent = new GuiItem(); return(true); } if (source is GuiCharacterFrame) { //swap characters CoM.Party.SwapCharacters(this.Character, (source as GuiCharacterFrame).Character); CoM.Party.Selected = (source as GuiCharacterFrame).Character; return(true); } return(false); }
//**************************************************************************************************** // //**************************************************************************************************** public override void CancelDrag(IDragDrop drag) { if (drag is WebMapObjectBase) { DeleteMapObject(drag as WebMapObjectBase); } }
//**************************************************************************************************** // //**************************************************************************************************** public override void UpdateDrag(IDragDrop drag) { if (drag is WebMapObjectBase) { (drag as WebMapObjectBase).transform.position = m_handpick.Point + (Vector3.up * 40.0f); } }
/** Overrides transact to make a copy of the dragged in item, but leave the origional intact */ public override bool Transact(IDragDrop source) { if (!(source is GuiItemSlot)) { return(false); } var item = source.DDContent; if (item == null) { return(false); } if (OrigionalSource != null) { OrigionalSource.Locked = false; if (OrigionalSource.DDContent != null) { OrigionalSource.DDContent.SelfEnabled = true; } } OrigionalSource = (GuiItemSlot)source; DDContent = (GuiComponent)item.Clone(); OrigionalSource.Locked = true; if (OrigionalSource.DDContent != null) { OrigionalSource.DDContent.SelfEnabled = false; } return(true); }
//**************************************************************************************************** // //**************************************************************************************************** public override bool AcceptDrop(IDragDrop drop) { if (drop is WebMapObjectBase) { WebMapObjectBase mapObject = drop as WebMapObjectBase; Localizable localizable = CreateMapObjectLocalizable((drop is WebMapFlag) ? OBJECT_TYPE.FLAG : OBJECT_TYPE.PIN); if (localizable != null) { localizable.m_coord.latitude = GetLatitudeFrom3DCoord(mapObject.transform.position); localizable.m_coord.longitude = GetLongitudeFrom3DCoord(mapObject.transform.position); localizable.m_coord.altitude = 0.0f; localizable.DBPush(); } DeleteMapObject(mapObject); return(true); } return(false); }
internal static void SetDragDrop(this PanelDesktop desktop) { foreach (IDragDrop dd in dragDrop) { IDragDrop d = dd.New; d.Set(null, desktop); } }
/** Override can send to notify player the item is cursed */ public override bool CanSend(IDragDrop destination) { if ((DataLink != null) && (!(destination is GuiInspectionSlot)) && DataLink.IsEquipSlot && containsCursedItem()) { CoM.PostMessage("This item is cursed!"); return(false); } return(true); }
//**************************************************************************************************** // //**************************************************************************************************** static public void Cancel() { if ((m_handler != null) && (m_cur != null)) { m_handler.CancelDrag(m_cur); m_handler = null; m_cur = null; } }
/** Add character to the list, remove it from source. */ public override bool Transact(IDragDrop source) { MDRCharacter character; character = source == null ? null : (source.DDContent as GuiCharacterPortrait).Character; if (character != null && !characterList.Contains(character)) { characterList.Add(character); } source.DDContent = null; Refresh(); return(true); }
/** Checks if we are dragging an object. If so draws it, and tests for when to release it */ private void UpdateDragDrop() { // reset initial source when mousebutton is up so that when we click next time we can detect the fresh click if (Input.GetMouseButton(0) == false) { initialSource = null; } // release our object, objects update first so if we get this this point no one has 'accepted' the payload... just cancel the trade. if (IsDragging && Input.GetMouseButtonUp(0)) { Cancel(); } }
//**************************************************************************************************** // //**************************************************************************************************** static public bool Begin(IDragDrop handler, IDragDrop obj) { if (m_cur == null) { if ((handler != null) && (obj != null) && (handler.BeginDrag(obj))) { m_cur = obj; m_handler = handler; return(true); } } return(false); }
/** * Begins the drag / drop process * @param forceStart Forces drag drop to begin now rather than waiting for the mouse to move a little */ public void BeginDragDrop(IDragDrop source, bool forceStart = false) { if (IsDragging) { return; } if (source.DDContent == null) { return; } if (source.DDContent.IsEmpty) { return; } // make sure we've moved a little if (!forceStart) { if (initialSource == null) { initialSource = source; initialTime = Time.time; initialX = (int)Mouse.Position.x; initialY = (int)Mouse.Position.y; return; } else { if ((new Vector2(Mouse.Position.x - initialX, Mouse.Position.y - initialY).magnitude < Settings.Advanced.DragMovementThreshold) && (Time.time - initialTime < Settings.Advanced.DragDelay)) { return; } } } // begin the drag, and make a copy of this object to show under mouse if (source is GuiComponent) { offset.x = MOUSE_OFFSET_X - MOUSE_RAW_OFFSET * (Mouse.Position.x - (source as GuiComponent).AbsoluteBounds.x); offset.y = MOUSE_OFFSET_Y - MOUSE_RAW_OFFSET * (Mouse.Position.y - (source as GuiComponent).AbsoluteBounds.y); } DDContent = (GuiComponent)source.DDContent.Clone(); origionalSender = source; source.DDContent.BeingDragged = true; }
//**************************************************************************************************** // //**************************************************************************************************** static public bool Drop(IDragDrop container) { if ((m_handler != null) && (m_cur != null) && (container != null) && (m_cur != container)) { if (container.AcceptDrop(m_cur)) { m_handler = null; m_cur = null; return(true); } Cancel(); } return(false); }
void DragArea_PointerPressed(object sender, PointerRoutedEventArgs e) { IsDrag = true;//表示开始拖放 //fe.CaptureMouse(); ActionDragDrop.DropObject = ParentUC.getDragObject(); ActionDragDrop.Source = ParentUC; FrameworkElement fe = sender as FrameworkElement; if (fe == null) { return; } SP = e.GetCurrentPoint(null).Position; ShowIcon(SP); //e.Handled = true; }
/** Ends the drag / drop process */ public void EndDragDrop(IDragDrop destination) { // make sure we have something to drop if (!IsDragging) { return; } if (origionalSender.DDContent != null) { origionalSender.DDContent.BeingDragged = false; } // transfer object destination if (destination.CanReceive(DDContent) && origionalSender.CanSend(destination)) { destination.Transact(origionalSender); DDContent = null; origionalSender = null; } }
public override bool Transact(IDragDrop source) { if ((source == null) || !(source is GuiItemSlot)) { return(false); } var modal = new ModalDecisionState("Are you sure?", "Do you want to destroy " + source.DDContent + "?\nThis item will be permanently destroyed."); modal.OnNo += delegate { // nothing to do. }; modal.OnYes += delegate { (source as GuiItemSlot).DataLink.ItemInstance = null; }; Engine.PushState(modal); return(false); }
public ActionDragDrop(IDragDrop UC, FrameworkElement dragArea, FrameworkElement dropArea, Panel dp, FrameworkElement Icon)//构造函数 { DragArea = dragArea; DropArea = dropArea; ParentUC = UC; if (dp == null) { dp = FindDesktop(); } DeskPanel = dp; dragicon = Icon; //SProc = sp; //TProc = td; DragArea.PointerPressed += new PointerEventHandler(DragArea_PointerPressed); DragArea.PointerReleased += new PointerEventHandler(DragArea_PointerReleased); //DragArea.PointerExited += new PointerEventHandler(DragArea_PointerExited); DropArea.PointerReleased += new PointerEventHandler(DropArea_PointerReleased); DropArea.PointerEntered += new PointerEventHandler(DropArea_PointerEntered); DropArea.PointerExited += new PointerEventHandler(DropArea_PointerExited); DeskPanel.PointerMoved += new PointerEventHandler(DeskPanel_PointerMoved); DeskPanel.PointerReleased += new PointerEventHandler(DeskPanel_PointerReleased); }
/** Disable dragging from this reference slot */ public override bool CanSend(IDragDrop destination) { return(false); }
public virtual void UpdateDrag(IDragDrop obj) { }
public virtual bool BeginDrag(IDragDrop obj) { return(false); }
//**************************************************************************************************** // //**************************************************************************************************** public override bool BeginDrag(IDragDrop drag) { return(drag is WebMapObjectBase); }
public virtual void CancelDrag(IDragDrop obj) { }
/** Override transaction to switch the store to sell mode, and transfer a copy to the inspection slot */ override public bool Transact(IDragDrop source) { Mode = StoreMode.Sell; return(sellItemArea.ItemSlot.Transact(source)); }
public virtual bool AcceptDrop(IDragDrop obj) { return(false); }