Ejemplo n.º 1
0
        public static void MoveItem(int itemId, int sourceContainerIndex, int destinationContainerIndex)
        {
            Log($"Request MoveItem item: {itemId}");
            var moveItemCommand = new MoveItemCommand
            {
                PlayerId               = Director.Player.Id,
                ItemId                 = itemId,
                SourceContainerId      = sourceContainerIndex,
                DestinationContainerId = destinationContainerIndex,
                SystemEntityId         = Director.Player.CurrentLocationEntity.Id
            };

            IssueCommand(moveItemCommand);
        }
        private void onItemChanged(object sender, PropertyChangedEventArgs e)
        {
            if (_suppressHistoryChanges)
            {
                return;
            }

            Item item = (Item)sender;

            if (e.PropertyName == nameof(Item.Left) || e.PropertyName == nameof(Item.Top))
            {
                var moveItemCommand = _currentEditPointer >= 0 ? _editHistory[_currentEditPointer] as MoveItemCommand : null;
                if (moveItemCommand != null && moveItemCommand.Item == sender)
                {
                    moveItemCommand.UpdatePosition(moveItemCommand.Item.Left, moveItemCommand.Item.Top);
                    // no need to call raiseChanged(); because non-empty history means that project has already been marked as changed
                }
                else
                {
                    moveItemCommand = new MoveItemCommand(this, item, item.Left, item.Top);
                    PerformCommand(moveItemCommand, false);
                    // no need to call raiseChanged(); because PerformCommand does
                }
            }
            else             // if (e.PropertyName.StartsWith("#"))
            {
                string propertyName            = e.PropertyName.Substring(1);
                var    editItemPropertyCommand = _currentEditPointer >= 0 ? _editHistory[_currentEditPointer] as EditItemPropertyCommand : null;
                if (editItemPropertyCommand != null && editItemPropertyCommand.Item == sender && editItemPropertyCommand.Property.Name == propertyName)
                {
                    editItemPropertyCommand.UpdateValue(editItemPropertyCommand.Property.Value);
                    // no need to call raiseChanged(); because non-empty history means that project has already been marked as changed
                }
                else
                {
                    var property = item.Properties.First(p => p.Name == propertyName);
                    editItemPropertyCommand = new EditItemPropertyCommand(this, item, property, property.Value);
                    PerformCommand(editItemPropertyCommand, false);
                    // no need to call raiseChanged(); because PerformCommand does
                }
            }
        }