示例#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);
                }
            }
        }
示例#2
0
        public CCBTreeViewItem Add(CCBCharacterProperty property)
        {
            CCBTreeViewItem newNode = new CCBTreeViewItem(property);

            base.Items.Add(newNode);
            AddOrMoveAdder();
            return(newNode);
        }
示例#3
0
        public CCBTreeViewItem Add(CCBBagItem item)
        {
            CCBTreeViewItem newNode = new CCBTreeViewItem(item);

            base.Items.Add(newNode);
            AddOrMoveAdder();
            return(newNode);
        }
示例#4
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();
            }
        }
示例#5
0
        private void OpenTemplates()
        {
            CCBTreeViewItem selItem   = (CCBTreeViewItem)tvGames.SelectedItem;
            CCBGame         gameModel = null;

            if (null != selItem)
            {
                CCBTreeViewGame gameNode = FindGameFromNode(selItem);

                if (null != gameNode)
                {
                    gameModel = gameNode.Game;
                }
            }
            CCBChildWindow templatePickerWnd = new GameTemplatePicker(gameModel, m_onCreateNewGameD, m_onCreateNewTemplateD, m_games.TemplateList);

            //templatePickerWnd.Owner = this;
            templatePickerWnd.Show(this);
        }
示例#6
0
 public CEditMode(EEditMode mode, CCBTreeViewItem node)
 {
     EditMode = mode;
     Node     = node;
 }
示例#7
0
 public CEditMode(CCBTreeViewItem node)
 {
     EditMode = EEditMode.em_None;
     Node     = node;
 }
示例#8
0
 public CEditMode()
 {
     EditMode = EEditMode.em_None;
     Node     = null;
 }
示例#9
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";
            }
        }
示例#10
0
        private void OnItemSelected(object sender, RoutedPropertyChangedEventArgs <object> e)
        {
            CCBTreeViewItem selItem = GetSelectedNode();

            if (null == selItem)
            {
                btnSave.IsEnabled = false;
            }
            else
            {
                CEditMode em = new CEditMode(selItem);

                btnSave.IsEnabled = true;
                switch (selItem.ItemType)
                {
                case CCBItemType.itpCharacter:
                    em.EditMode = ModifyCharacterView(selItem.Character);
                    break;

                case CCBItemType.itpGame:
                    em.EditMode = ModifyGameView(selItem.Game);
                    break;

                case CCBItemType.itpBag:
                    em.EditMode = ModifyBagView(selItem.Bag);
                    break;

                case CCBItemType.itpBagItem:
                    em.EditMode = ModifyBagItemView(selItem.BagItem);
                    break;

                case CCBItemType.itpGameAdder:
                    em.EditMode = AddGameView();
                    break;

                case CCBItemType.itpCharacterAdder:
                    em.EditMode = AddCharacterView();
                    break;

                case CCBItemType.itpProperty:
                    em.EditMode = ModifyPropertyView(selItem.Property);
                    break;

                case CCBItemType.itpPropertyAdder:
                    em.EditMode = AddPropertyView();
                    break;

                case CCBItemType.itpBagAdder:
                    em.EditMode = AddBagView();
                    break;

                case CCBItemType.itpBagItemAdder:
                    em.EditMode = AddBagItemView();
                    break;
                }
                CEditModeProperty.SetEditNode(tbItem, em);
                tbItem.SelectAll();
                //Cannot set focus here, so post event.
                Dispatcher.Invoke(m_onAddingNewEntityModeD);
            }
        }