Exemplo n.º 1
0
        private void OnIsCountableChecked(object sender, RoutedEventArgs e)
        {
            CCBTreeViewItem selectedNode = GetSelectedNode();
            CCBTreeViewBag  bagNode      = null;

            bagNode = FindBagFromNode(selectedNode);
            if (true == cbCountable.IsChecked)
            {
                tbValue.IsEnabled = true;
                if (null != bagNode)
                {
                    CCBCountedBagItem newBagItem = new CCBCountedBagItem(selectedNode.BagItem);

                    bagNode.Bag.RemoveItem(selectedNode.BagItem);
                    bagNode.Bag.Add(newBagItem);
                    selectedNode.SetBagItem(newBagItem);
                }
            }
            else
            {
                tbValue.IsEnabled = false;
                if (null != bagNode)
                {
                    CCBBagItem newBagItem = new CCBBagItem(selectedNode.BagItem);

                    bagNode.Bag.RemoveItem(selectedNode.BagItem);
                    bagNode.Bag.Add(newBagItem);
                    selectedNode.SetBagItem(newBagItem);
                }
            }
        }
Exemplo n.º 2
0
        private EEditMode ModifyBagItemView(CCBBagItem bagItem)
        {
            SetDefaultView();
            gbItemView.Header = "Modify Bag Item";
            if (null != bagItem)
            {
                tbItem.Text = bagItem.Item;
            }
            btnDelete.IsEnabled = true;
            ResetEntitiesList();
            if (bagItem.IsCountable)
            {
                CCBCountedBagItem countedBagItem = (CCBCountedBagItem)bagItem;

                cbCountable.IsChecked = true;
                tbValue.Text          = countedBagItem.Count.ToString();
                tbValue.IsEnabled     = true;
            }
            else
            {
                cbCountable.IsChecked = false;
            }
            cbCountable.Visibility = System.Windows.Visibility.Visible;
            btnBagPicker.IsEnabled = true;
            btnTemplates.IsEnabled = true;
            return(EEditMode.em_ModifyBagItem);
        }
Exemplo n.º 3
0
 public CCBTreeViewItem(CCBBagItem item)
 {
     m_itp       = CCBItemType.itpBagItem;
     m_quickEdit = true;
     this.Header = item.Item;
     this.m_data = item;
     m_nodeId    = m_kNodeId++;
 }
Exemplo n.º 4
0
 private bool IsThisItem(CCBBagItem item)
 {
     if (null == item)
     {
         return(false);
     }
     return(0 == string.Compare(m_name, item.Item));
 }
Exemplo n.º 5
0
        public CCBTreeViewItem Add(CCBBagItem item)
        {
            CCBTreeViewItem newNode = new CCBTreeViewItem(item);

            base.Items.Add(newNode);
            AddOrMoveAdder();
            return(newNode);
        }
Exemplo n.º 6
0
 public virtual CCBBagItem Add(CCBBagItem item)
 {
     if (null == m_items)
     {
         m_items = new List <CCBBagItem>();
     }
     m_items.Add(item);
     return(item);
 }
Exemplo n.º 7
0
        public virtual CCBBagItem AddItem(string item)
        {
            CCBBagItem bagItem = new CCBBagItem(item);

            if (null == m_items)
            {
                m_items = new List <CCBBagItem>();
            }
            m_items.Add(bagItem);
            return(bagItem);
        }
Exemplo n.º 8
0
        public override CCBBagItem Add(CCBBagItem item)
        {
            //For a store, we don't want duplicate items
            CCBBagItem exists = Find(item.Item);

            if (null != exists)
            {
                RemoveItem(exists);
            }
            return(base.Add(item));
        }
Exemplo n.º 9
0
        public bool RemovePotentialStoreItem(CCBPotentialStoreItem item)
        {
            CCBBagItem foundItem = m_items.Find(item.Item);

            if (null == foundItem)
            {
                return(false);
            }
            m_items.RemoveItem(foundItem);
            return(true);
        }
Exemplo n.º 10
0
 public bool RemoveItem(CCBBagItem item)
 {
     if (null == m_items)
     {
         return(false);
     }
     if (!ReferenceEquals(null, item))
     {
         return(m_items.Remove(item));
     }
     return(false);
 }
Exemplo n.º 11
0
        public CCBPotentialStoreItem FindItem(string name)
        {
            CCBBagItem item = m_items.Find(name);

            if (null != item)
            {
                CCBPotentialStoreItem storeItem = (CCBPotentialStoreItem)item;

                System.Diagnostics.Debug.Assert(null != storeItem);
                return(storeItem);
            }
            return(null);
        }
Exemplo n.º 12
0
        public void OnCopyBagItems(CCBBag targetBag, string[] bagItems)
        {
            CCBTreeViewBag bagNode = FindBagNodeFromBag(targetBag);

            if (null != bagNode)
            {
                CCBBag bag = bagNode.Bag;

                bagNode.StartBulkEdit();
                foreach (string item in bagItems)
                {
                    CCBBagItem bagItem = bag.AddItem(item);
                    bagNode.Items.Add(new CCBTreeViewItem(bagItem));
                }
                bagNode.EndBulkEdit();
            }
        }
Exemplo n.º 13
0
        public bool Remove(string itemToFind)
        {
            if (null != itemToFind)
            {
                foreach (CCBTreeViewItem itemNode in base.Items)
                {
                    CCBBagItem itemToCompare = itemNode.BagItem;

                    if (itemToCompare.Equals(itemToFind))
                    {
                        base.Items.Remove(itemNode);
                        return(true);
                    }
                }
            }
            return(false);
        }
Exemplo n.º 14
0
 public StoreItemViewer(CCBBagItem bagItem)
 {
     m_item = (CCBStoreItem)bagItem;
 }
Exemplo n.º 15
0
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            m_deleteUsed = true;
            if (m_deleteEnabled)
            {
                CCBTreeViewItem selItem = (CCBTreeViewItem)tvGames.SelectedItem;

                if (null == selItem)
                {
                    tbLastError.Text = "Wrong item in treeview:";
                }
                else
                {
                    switch (selItem.ItemType)
                    {
                    case CCBItemType.itpCharacter:
                    {
                        CCBCharacter character = selItem.Character;

                        if (null == character)
                        {
                            tbLastError.Text = String.Format("Mismatch in CBTVI selected ({0})", selItem.ItemType);
                        }
                        else
                        {
                            CCBTreeViewGame gameNode = FindGameFromNode(selItem);

                            if (null == gameNode)
                            {
                                tbLastError.Text = "Internal error: cannot find game node.";
                            }
                            else
                            {
                                CCBGame game = gameNode.Game;

                                gameNode.Items.Remove(selItem);
                                game.DeleteCharacter(character);
                            }
                        }
                        break;
                    }

                    case CCBItemType.itpGame:
                    {
                        CCBGame game = selItem.Game;

                        if (null == game)
                        {
                            tbLastError.Text = String.Format("Mismatch in CBTVI selected ({0})", selItem.ItemType);
                        }
                        else
                        {
                            tvGames.Items.Remove(selItem);
                            m_games.DeleteGameSafe(game);
                        }
                        break;
                    }

                    case CCBItemType.itpProperty:
                    {
                        CCBCharacterProperty property = selItem.Property;

                        if (null == property)
                        {
                            tbLastError.Text = String.Format("Mismatch in CBTVI selected ({0})", selItem.ItemType);
                        }
                        else
                        {
                            CCBTreeViewCharacter characterNode = FindCharacterFromNode(selItem);
                            CCBTreeViewGame      gameNode      = FindGameFromNode(selItem);

                            if (null != characterNode)
                            {
                                characterNode.Items.Remove(selItem);
                                characterNode.Character.RemovePropertySafe(property);
                                if (null != gameNode)
                                {
                                    CCBGame game = gameNode.Game;

                                    game.CheckPropertyForDeletion(property.Name);
                                }
                            }
                        }
                        break;
                    }

                    case CCBItemType.itpBag:
                    {
                        CCBBag bag = selItem.Bag;

                        if (null == bag)
                        {
                            tbLastError.Text = String.Format("Mismatch in CBTVI selected ({0})", selItem.ItemType);
                        }
                        else
                        {
                            CCBTreeViewCharacter characterNode = FindCharacterFromNode(selItem);

                            if (null != characterNode)
                            {
                                characterNode.Character.RemoveBag(bag);
                            }
                            characterNode.Items.Remove(selItem);
                        }
                        break;
                    }

                    case CCBItemType.itpBagItem:
                    {
                        CCBBagItem bagItem = selItem.BagItem;

                        if (null == bagItem)
                        {
                            tbLastError.Text = String.Format("Mismatch in CBTVI selected ({0})", selItem.ItemType);
                        }
                        else
                        {
                            CCBTreeViewBag bagNode = FindBagFromNode(selItem);

                            if (null != bagNode)
                            {
                                bagNode.Bag.RemoveItem(bagItem);
                            }
                            bagNode.Items.Remove(selItem);
                        }
                        break;
                    }

                    default:
                        break;
                    }
                }
            }
            else
            {
                m_deleteEnabled   = true;
                btnDelete.Content = "Delete Selected";
            }
        }
Exemplo n.º 16
0
 public virtual void SetBagItem(CCBBagItem bagItem)
 {
     this.m_data = bagItem;
 }
Exemplo n.º 17
0
 public CCBCountedBagItem(CCBBagItem item) : base(item)
 {
     m_count = item.Count;
 }