Beispiel #1
0
        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();
                }
            }
        }
Beispiel #2
0
        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();
        }