/// <summary> /// Marks an item as modified. Used for splitting stacks and removing charms and relics. /// </summary> /// <param name="newItem">New item to be created after the split.</param> public void MarkModified(Item newItem) { if (this.IsModifiedItem) { // The item is already modified. If it has been modified again, then we should tell the sackPanel to redraw it again this.original.sackPanel.CancelDrag(this.original); this.item = newItem; } else { // Tell the sackPanel the drag was cancelled so that it will redraw its now modified item this.sackPanel.CancelDrag(this); // Tell the sack that it has been modified this.sack.IsModified = true; // Now store our info inside original this.original = (ItemDragInfo)this.MemberwiseClone(); // Now set us up to the new item this.item = newItem; this.sack = null; // it does not belong to a sack this.sackPanel = null; // nor a sack panel // reposition the mouse at the center of the new item if it is a different size than the old item if (newItem.Width != this.original.item.Width || newItem.Height != this.original.item.Height ) { var ibmp = this.UIService.GetBitmap(newItem); this.mouseOffset.X = ibmp.Width / 2; this.mouseOffset.Y = ibmp.Height / 2; } } }
/// <summary> /// Marks the item as placed removing it from the original container. /// </summary> /// <param name="slot">slot if an equipment placement.</param> public void MarkPlaced(int slot) { // Remove the item from the old sack if (this.IsModifiedItem) { // modified items do not have a source sack. // so no one needs to be notified of the placement. } else { if (this.sack.SackType == SackType.Equipment && slot != -1) { // Remove the item out of the equipment slot this.sack.RemoveAtItem(slot); // Put a dummy item in it's place Item newItem = this.item.MakeEmptyItem(); newItem.PositionX = SackCollection.GetEquipmentLocationOffset(slot).X; newItem.PositionY = SackCollection.GetEquipmentLocationOffset(slot).Y; this.sack.InsertItem(slot, newItem); } else { this.sack.RemoveItem(this.item); } } // finally clear things out this.item = null; this.sack = null; this.sackPanel = null; this.original = null; this.autoMove = AutoMoveLocation.NotSet; this.isBeingCancelled = false; }
/// <summary> /// Sets a drag. Initializes the ItemDragInfo /// </summary> /// <param name="sackPanel">sack panel which contains the item</param> /// <param name="sack">sack which contains the item</param> /// <param name="item">the item being dragged</param> /// <param name="mouseOffset">offset of the mouse pointer to the top left corner of the item bitmap</param> public void Set(SackPanel sackPanel, SackCollection sack, Item item, Point mouseOffset) { this.item = item; this.sack = sack; this.sackPanel = sackPanel; this.mouseOffset = mouseOffset; this.original = null; this.AutoMove = AutoMoveLocation.NotSet; this.IsBeingCancelled = false; }
/// <summary> /// Marks the item as placed removing it from the original container. /// </summary> /// <param name="slot">slot if an equipment placement.</param> public void MarkPlaced() { int slot = -1; // modified items do not have a source sack. // so no one needs to be notified of the placement. if (!this.IsModifiedItem) { // Check to see if the dragged item is from one of the equipped slots. if (this.sack.SackType == SackType.Equipment) { slot = EquipmentPanel.FindEquipmentSlot(this.sack, this.item); } if (slot != -1) { // Remove the item out of the equipment slot this.sack.RemoveAtItem(slot); // Put a dummy item in it's place Item newItem = this.item.MakeEmptyItem(); newItem.PositionX = SackCollection.GetEquipmentLocationOffset(slot).X; newItem.PositionY = SackCollection.GetEquipmentLocationOffset(slot).Y; this.sack.InsertItem(slot, newItem); } else { // Remove the item from the old sack this.sack.RemoveItem(this.item); } BagButtonTooltip.InvalidateCache(this.Sack, this.Original?.Sack); } // finally clear things out this.item = null; this.sack = null; this.sackPanel = null; this.original = null; this.AutoMove = AutoMoveLocation.NotSet; this.IsBeingCancelled = false; }