public NodeAddress AddItem(NodeAddress nodeAddress) { switch (nodeAddress.NodeType) { case NodeType.All: break; case NodeType.Category: Category newCat = AddNewCategory(); Map.AddItem(nodeAddress, newCat); nodeAddress.ChangeAddress(newCat.CategoryName); return(nodeAddress); case NodeType.Institution: Institution newInstit = GetCategory(nodeAddress.Address[0]).AddNewInstitution(); Map.AddItem(nodeAddress, newInstit); nodeAddress.ChangeAddress(newInstit.InstitutionName); return(nodeAddress); case NodeType.Account: Account newAccount = GetCategory(nodeAddress.Address[0]).GetInstitution(nodeAddress.Address[1]).AddNewAccount(); Map.AddItem(nodeAddress, newAccount); nodeAddress.ChangeAddress(newAccount.AccountName); return(nodeAddress); default: break; } throw new Exception("Issue"); }
internal async void TreeView_AfterLabelEdit(NodeLabelEditEventArgs e) { string before = e.Node.Text; string after = e.Label; await Task.Run(() => { bool test = false; if (after != null && after != "") { NodeAddress na = (NodeAddress)e.Node.Tag; if (_ad.ChangeName(before, after, na)) { na.ChangeAddress(after); _view.ChangeActive(na); test = true; } } else { e.CancelEdit = true; } _view.SetUpTree(_ad.Map); if (!test) { MessageBox.Show($"Unable to give the element [{before}] the name [{after}]"); } }); }