Пример #1
0
        public void AddItem()
        {
            // create item model
            var name = string.Format("{0:D02}", itemIndex++);
            var item = new InventoryModel.ItemModel(0, name, defaultAmount);

            inventory.ItemList.Add(item);
        }
Пример #2
0
        private void RemoveItem(InventoryModel.ItemModel model)
        {
            // get vm
            var vm = viewModelDictionary[model];

            // remove it
            viewModelList.Remove(vm);
            viewModelDictionary.Remove(model);
        }
Пример #3
0
        private void AddItem(InventoryModel.ItemModel model)
        {
            // create view model
            var vm = new ItemViewModel(model);

            // set command
            vm.ClickCommand = new DelegateCommand(() => SelectItem(model));

            // add it
            viewModelList.Add(vm);
            viewModelDictionary.Add(model, vm);
        }
Пример #4
0
        public void SelectItem(InventoryModel.ItemModel item)
        {
            Debug.LogFormat("SelectItem, item={0}", (item != null) ? item.Name : "null");

            selectedItem = item;

            // disable all
            foreach (var vm in viewModelList)
            {
                vm.Selected = false;
            }

            if (selectedItem != null)
            {
                var vm = viewModelDictionary[item];
                vm.Selected = true;
            }
        }
Пример #5
0
 public ItemViewModel(InventoryModel.ItemModel model)
 {
     this.model = model;
 }