private void AddCard(EditorCardModel cardModel, bool select) { var node = new TreeNode(cardModel.Name) { Tag = cardModel, ImageKey = "Card", SelectedImageKey = "Card" }; CreateNodeParent(cardModel.Category).Add(node); cardModel.Behaviors.ForEach(bhv => AddBehavior(bhv, node, select)); if (select) { ShowNode(node, true); } }
private void toolStripButtonNewCard_Click(object sender, EventArgs e) { var dlg = new NewCard(m_document); if (dlg.ShowDialog() == DialogResult.OK) { var n = treeViewCards.SelectedNode; for (; n != null && n.Tag != null; n = n.Parent) { } var category = n != null ? n.FullPath : String.Empty; var model = new EditorCardModel { Category = category, Id = dlg.CardId, Name = dlg.CardId, Description = "", ArtworkUri = "" }; m_document.Cards.Add(model); AddCard(model, true); m_isModified = true; UpdateTitle(); } }
private void RefreshCardViewer(EditorCardModel cardModel) { if (cardModel == null) { lblCardId.Text = string.Empty; lblCardName.Text = string.Empty; txtCardDescription.Text = string.Empty; lblCardAttack.Text = string.Empty; lblCardLife.Text = string.Empty; return; } lblCardId.Text = cardModel.Id; lblCardName.Text = cardModel.Name; txtCardDescription.Text = cardModel.Description; if (cardModel.Behaviors.FirstOrDefault(bhv => bhv is Behaviors.Warrior.ModelType) != null) { Behaviors.Warrior.ModelType warrior = (Behaviors.Warrior.ModelType) cardModel.Behaviors.FirstOrDefault(bhv => bhv is Behaviors.Warrior.ModelType); lblCardAttack.Text = warrior.Attack.ToString(); lblCardLife.Text = warrior.Life.ToString(); } else { lblCardAttack.Text = string.Empty; lblCardLife.Text = string.Empty; } }