示例#1
0
        public virtual CCBTreeViewBag Add(CCBBag bag)
        {
            CCBTreeViewBag bagNode = new CCBTreeViewBag(bag);

            base.Items.Add(bagNode);
            return(bagNode);
        }
示例#2
0
        private CCBTreeViewBag FindBagNodeFromBag(CCBBag bag)
        {
            foreach (TreeViewItem gameNode in tvGames.Items)
            {
                foreach (TreeViewItem subNode in gameNode.Items)
                {
                    if (subNode.GetType() == typeof(CCBTreeViewBag))
                    {
                        CCBTreeViewBag bagNode = (CCBTreeViewBag)subNode;

                        if (ReferenceEquals(bagNode.Bag, bag))
                        {
                            return(bagNode);
                        }
                    }
                    if (subNode.GetType() == typeof(CCBTreeViewCharacter))
                    {
                        foreach (TreeViewItem characterSubNode in subNode.Items)
                        {
                            if (characterSubNode.GetType() == typeof(CCBTreeViewBag))
                            {
                                CCBTreeViewBag bagNode = (CCBTreeViewBag)characterSubNode;

                                if (ReferenceEquals(bagNode.Bag, bag))
                                {
                                    return(bagNode);
                                }
                            }
                        }
                    }
                }
            }
            return(null);
        }
示例#3
0
 public void RemoveBag(CCBBag bag)
 {
     if (null != m_bags)
     {
         m_bags.Remove(bag);
     }
 }
示例#4
0
        public CCBBag[] GetAllBags(CCBBag bagExcept)
        {
            List <CCBBag> allBags = new List <CCBBag>();

            allBags.Add(m_groupItems);
            if (null != m_groupBags)
            {
                foreach (CCBBag groupBag in m_groupBags)
                {
                    if (!ReferenceEquals(groupBag, bagExcept))
                    {
                        allBags.Add(groupBag);
                    }
                }
            }
            foreach (CCBCharacter character in m_characters)
            {
                if (!ReferenceEquals(character.Items, bagExcept))
                {
                    allBags.Add(new CCBOwnedBag(character, character.Items));
                }
                foreach (CCBBag characterBag in character.BagList)
                {
                    if (!ReferenceEquals(characterBag, bagExcept))
                    {
                        allBags.Add(new CCBOwnedBag(character, characterBag));
                    }
                }
            }
            return(allBags.ToArray());
        }
示例#5
0
 private static void AddPlayersToBag(CCBBag bag, int cPlayers)
 {
     for (int ix = 0; ix < cPlayers; ix++)
     {
         bag.AddItem(string.Format("Player {0}", ix + 1));
     }
 }
示例#6
0
        private static CCBBag AddPlayerBag(string bagName, int cPlayers)
        {
            CCBBag playerBag = new CCBBag(bagName);

            AddPlayersToBag(playerBag, cPlayers);
            return(playerBag);
        }
示例#7
0
        public override CCBTreeViewBag Add(CCBBag bag)
        {
            CCBTreeViewBag newNode = new CCBTreeViewBag(bag);

            base.Items.Add(newNode);
            AddOrMoveAdder();
            return(newNode);
        }
示例#8
0
 public CCBTreeViewItem(CCBBag bag)
 {
     m_itp       = CCBItemType.itpBag;
     m_quickEdit = true;
     this.Header = bag.Name;
     this.m_data = bag;
     m_nodeId    = m_kNodeId++;
 }
示例#9
0
 private bool IsThisBag(CCBBag bag)
 {
     if (null == bag)
     {
         return(false);
     }
     return(0 == string.Compare(m_name, bag.Name));
 }
示例#10
0
 public CCBCharacter()
 {
     m_id           = m_nextId++;
     m_name         = System.String.Format("NewCharacter{0}", m_id);
     m_propertyList = new CharacterPropertyList();
     m_items        = new CCBLockedBag("Items");
     m_bags         = new CCBBags();
 }
示例#11
0
 private void ShowItems(CCBBag bag)
 {
     ResetEntitiesList();
     foreach (CCBBagItem item in bag.Items)
     {
         lbEntities.Items.Add(item.Item);
     }
 }
示例#12
0
 public CCBGame(string name)
 {
     m_name                 = name;
     m_characters           = new CCBCharacterList();
     m_groupItems           = new CCBBag(m_kGroupItemLabel);
     m_groupBags            = new CCBBags();
     m_propertyTemplateList = new CharacterPropertyTemplateList();
 }
示例#13
0
 public CCBCharacter(string name)
 {
     m_id           = m_nextId++;
     m_name         = name;
     m_propertyList = new CharacterPropertyList();
     m_items        = new CCBLockedBag("Items");
     m_bags         = new CCBBags();
     m_image        = null;
 }
示例#14
0
 public CCBBag AddBag(CCBBag bag)
 {
     if (null == m_bags)
     {
         m_bags = new CCBBags();
     }
     m_bags.Add(bag);
     return(bag);
 }
示例#15
0
 public BagSelector(CCBGame game)
 {
     m_game = game;
     m_bag  = null;
     InitializeComponent();
     CeebeetleWindowInit();
     Populate();
     Validate();
 }
示例#16
0
 private void btnSelect_Click(object sender, RoutedEventArgs e)
 {
     if (-1 != lbBags.SelectedIndex)
     {
         m_bag = (CCBBag)lbBags.Items[lbBags.SelectedIndex];
     }
     DialogResult = true;
     Close();
 }
示例#17
0
        public CCBBag AddBag(string name)
        {
            CCBBag newBag = new CCBBag(name);

            if (null == m_bags)
            {
                m_bags = new CCBBags();
            }
            m_bags.Add(newBag);
            return(newBag);
        }
示例#18
0
        private void btnCopy_Click(object sender, RoutedEventArgs e)
        {
            if (null != m_copyBagItemsCallback)
            {
                CCBBag targetBag = GetTargetBag();

                if (null != targetBag)
                {
                    string[] itemsToCopy = new string[lbPickedItems.Items.Count];

                    lbPickedItems.Items.CopyTo(itemsToCopy, 0);
                    m_copyBagItemsCallback(targetBag, itemsToCopy);
                }
            }
        }
示例#19
0
        private void AddBagToNode(CCBTreeViewItem node, CCBBag bag)
        {
            if (null != bag)
            {
                CCBTreeViewBag bagNode;

                node.StartBulkEdit();
                bagNode = node.Add(bag);
                foreach (CCBBagItem bagItem in bag.Items)
                {
                    bagNode.Add(bagItem);
                }
                node.EndBulkEdit();
            }
        }
示例#20
0
 public CCBGame(string name, CCBGameTemplate templateFrom)
 {
     m_name                 = name;
     m_characters           = new CCBCharacterList();
     m_groupItems           = new CCBBag(m_kGroupItemLabel);
     m_groupBags            = new CCBBags();
     m_propertyTemplateList = new CharacterPropertyTemplateList();
     foreach (CCBCharacterPropertyTemplate templateProperty in templateFrom.PropertyTemplateList)
     {
         m_propertyTemplateList.Add(new CCBCharacterPropertyTemplate(templateProperty));
     }
     foreach (CCBBag bag in templateFrom.Bags)
     {
         m_groupBags.Add(new CCBBag(bag));
     }
 }
示例#21
0
 public CCBBag(CCBBag bagFrom)
 {
     m_name  = bagFrom.m_name;
     m_items = new List <CCBBagItem>();
     foreach (CCBBagItem item in bagFrom.m_items)
     {
         if (item.IsCountable)
         {
             m_items.Add(new CCBCountedBagItem(item));
         }
         else
         {
             m_items.Add(new CCBBagItem(item));
         }
     }
 }
示例#22
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();
            }
        }
示例#23
0
        public bool OnDeleteBagItems(CCBBag targetBag, string[] bagItems)
        {
            CCBTreeViewBag bagNode = FindBagNodeFromBag(targetBag);

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

                bagNode.StartBulkEdit();
                foreach (string item in bagItems)
                {
                    bag.RemoveItem(item);
                    bagNode.Remove(item);
                }
                bagNode.EndBulkEdit();
                ResetEntitiesList();
                return(true);
            }
            return(false);
        }
示例#24
0
 private EEditMode ModifyBagView(CCBBag bag)
 {
     SetDefaultView();
     if (null != bag)
     {
         tbItem.Text = bag.Name;
     }
     if (bag.IsLocked)
     {
         gbItemView.Header = "View Bag";
         btnSave.IsEnabled = false;
         tbItem.IsEnabled  = false;
     }
     else
     {
         gbItemView.Header   = "Modify Bag";
         btnDelete.IsEnabled = true;
     }
     tbValue.IsEnabled = true;
     ShowItems(bag);
     btnBagPicker.IsEnabled = true;
     btnTemplates.IsEnabled = true;
     return(EEditMode.em_ModifyBag);
 }
示例#25
0
 private void btnClose_Click(object sender, RoutedEventArgs e)
 {
     m_bag        = null;
     DialogResult = false;
     Close();
 }
示例#26
0
 public CCBStorePlaceType(string name)
 {
     m_placeName = name;
     m_items     = new CCBBag();
 }
示例#27
0
 public BagInfo(uint bagNodeId, CCBBag bag, CCBBag[] targetBags)
 {
     m_bagNodeId  = bagNodeId;
     m_bag        = bag;
     m_targetBags = targetBags;
 }
示例#28
0
        private void Save()
        {
            CEditMode editMode = CEditModeProperty.GetEditNode(tbItem);

            if (null == editMode)
            {
                return;
            }
            if (EEditMode.em_Frozen == editMode.EditMode)
            {
                return;
            }
            switch (editMode.EditMode)
            {
            case EEditMode.em_None:
                tbLastError.Text = "No mode.";
                break;

            case EEditMode.em_AddCharacter:
            {
                CCBTreeViewGame currentGameNode = FindGameFromNode(editMode.Node);

                if ((null == currentGameNode) || (CCBItemType.itpGame != currentGameNode.ItemType))
                {
                    tbLastError.Text = "No game selected.";
                }
                else
                {
                    CCBCharacter         newCharacter  = new CCBCharacter(tbItem.Text);
                    CCBTreeViewCharacter characterNode = currentGameNode.Add(newCharacter);

                    currentGameNode.Game.AddCharacter(newCharacter);
                    characterNode.StartBulkEdit();
                    AddPropertiesToCharacterNode(characterNode);
                    AddBagsToCharacterNode(characterNode);
                    characterNode.EndBulkEdit();
                    characterNode.IsSelected = true;
                }
                break;
            }

            case EEditMode.em_AddGame:
            {
                CCBGame         newGame  = m_games.AddGame(tbItem.Text);
                CCBTreeViewGame gameNode = new CCBTreeViewGame(newGame);

                tvGames.Items.Add(gameNode);
                AddBagToNode(gameNode, newGame.GroupItems);
                AddOrMoveAdder();
                gameNode.IsSelected = true;
                break;
            }

            case EEditMode.em_AddProperty:
            {
                CCBTreeViewCharacter characterNode = FindCharacterFromNode(editMode.Node);
                CCBTreeViewGame      gameNode      = FindGameFromNode(editMode.Node);

                if (null == characterNode)
                {
                    tbLastError.Text = "Internal error[p]: Cannot find character node.";
                    return;
                }
                CCBCharacterProperty newProperty = characterNode.Character.AddProperty(tbItem.Text, tbValue.Text);

                characterNode.Add(newProperty);
                if (null != gameNode)
                {
                    CCBGame game = gameNode.Game;

                    game.AddPropertyToTemplate(newProperty);
                }
                break;
            }

            case EEditMode.em_AddBag:
            {
                CCBTreeViewCharacter characterNode = FindCharacterFromNode(editMode.Node);

                if (null == characterNode)
                {
                    tbLastError.Text = "Internal error[b]: Cannot find node.";
                    return;
                }
                CCBBag newBag = characterNode.Character.AddBag(tbItem.Text);

                TreeViewItem newNode = characterNode.Add(newBag);
                newNode.IsSelected = true;
                break;
            }

            case EEditMode.em_AddBagItem:
            {
                CCBTreeViewBag bagNode     = FindBagFromNode(editMode.Node);
                bool           isCountable = true == cbCountable.IsChecked;
                CCBBagItem     newItem;

                if (null == bagNode)
                {
                    tbLastError.Text = "Internal error[b]: Cannot find bag node.";
                    return;
                }
                if (true == cbCountable.IsChecked)
                {
                    int count = 1;

                    if (!Int32.TryParse(tbValue.Text, out count))
                    {
                        tbLastError.Text = string.Format("Use number. Could not parse [{0}]", tbValue.Text);
                    }
                    newItem = bagNode.Bag.AddCountableItem(tbItem.Text, count);
                }
                else
                {
                    newItem = bagNode.Bag.AddItem(tbItem.Text);
                }
                TreeViewItem newNode = bagNode.Add(newItem);
                newNode.IsSelected = true;
                break;
            }

            case EEditMode.em_ModifyCharacter:
                if (null == editMode.Node)
                {
                    tbLastError.Text = "Internal error[mc]: No edit node.";
                    return;
                }
                editMode.Node.Header         = tbItem.Text;
                editMode.Node.Character.Name = tbItem.Text;
                break;

            case EEditMode.em_ModifyGame:
            {
                CCBTreeViewGame currentGameNode = FindGameFromNode(editMode.Node);

                currentGameNode.Game.Name = tbItem.Text;
                currentGameNode.Header    = tbItem.Text;
                break;
            }

            case EEditMode.em_ModifyProperty:
                if (null == editMode.Node)
                {
                    tbLastError.Text = "Internal error[mp]: No edit node.";
                    return;
                }
                editMode.Node.Header         = tbItem.Text;
                editMode.Node.Property.Name  = tbItem.Text;
                editMode.Node.Property.Value = tbValue.Text;
                break;

            case EEditMode.em_ModifyBag:
                if (null == editMode.Node)
                {
                    tbLastError.Text = "No bag node.";
                    return;
                }
                editMode.Node.Header   = tbItem.Text;
                editMode.Node.Bag.Name = tbItem.Text;
                break;

            case EEditMode.em_ModifyBagItem:
                if (null == editMode.Node)
                {
                    tbLastError.Text = "No bag item node.";
                    return;
                }
                editMode.Node.Header       = tbItem.Text;
                editMode.Node.BagItem.Item = tbItem.Text;
                if (editMode.Node.BagItem.IsCountable)
                {
                    int count;

                    if (Int32.TryParse(tbValue.Text, out count))
                    {
                        editMode.Node.BagItem.Count = count;
                    }
                    else
                    {
                        tbLastError.Text = string.Format("{0} not a number", tbValue.Text);
                    }
                }
                break;

            default:
                tbLastError.Text = "Unknown mode.";
                break;
            }
        }
示例#29
0
 private void AddBagToCharacterNode(CCBTreeViewCharacter characterNode, CCBBag bag)
 {
     AddBagToNode(characterNode, bag);
 }
示例#30
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";
            }
        }