private async void RemoveCustomer(object sender, EventArgs e) { INode currentItem = graphControl.Selection.SelectedNodes.FirstOrDefault(); if (currentItem != null) { // Remember the selected node for triggering a layout. rootNodeToBeRemoved = graphControl.CurrentItem as INode; // Remove the customer which is represented by the selected node. Customer customer = TreeSource.GetBusinessObject(currentItem) as Customer; if (customer != null) { CustomerRepository.RemoveCustomer(customer); await DoLayout(); } } }
private async void CreateCustomer(object sender, EventArgs e) { // Remember whether the new customer is a root customer for triggering a layout. INode currentItem = graphControl.Selection.SelectedNodes.FirstOrDefault(); newRootNode = currentItem == null; // Get parent customer. Customer parentCustomer = null; if (!newRootNode) { parentCustomer = TreeSource.GetBusinessObject(currentItem) as Customer; } // Create the new customer. CustomerRepository.CreateCustomer("Customer " + customerCounter++, parentCustomer); await DoLayout(); }