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); } } }
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); }
public CCBTreeViewItem(CCBBagItem item) { m_itp = CCBItemType.itpBagItem; m_quickEdit = true; this.Header = item.Item; this.m_data = item; m_nodeId = m_kNodeId++; }
private bool IsThisItem(CCBBagItem item) { if (null == item) { return(false); } return(0 == string.Compare(m_name, item.Item)); }
public CCBTreeViewItem Add(CCBBagItem item) { CCBTreeViewItem newNode = new CCBTreeViewItem(item); base.Items.Add(newNode); AddOrMoveAdder(); return(newNode); }
public virtual CCBBagItem Add(CCBBagItem item) { if (null == m_items) { m_items = new List <CCBBagItem>(); } m_items.Add(item); return(item); }
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); }
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)); }
public bool RemovePotentialStoreItem(CCBPotentialStoreItem item) { CCBBagItem foundItem = m_items.Find(item.Item); if (null == foundItem) { return(false); } m_items.RemoveItem(foundItem); return(true); }
public bool RemoveItem(CCBBagItem item) { if (null == m_items) { return(false); } if (!ReferenceEquals(null, item)) { return(m_items.Remove(item)); } return(false); }
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); }
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(); } }
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); }
public StoreItemViewer(CCBBagItem bagItem) { m_item = (CCBStoreItem)bagItem; }
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"; } }
public virtual void SetBagItem(CCBBagItem bagItem) { this.m_data = bagItem; }
public CCBCountedBagItem(CCBBagItem item) : base(item) { m_count = item.Count; }