private void AddExistingPipeProperty(NodeView nodeView)
        {
            AddExistingPipeComponentProperty dialog = new AddExistingPipeComponentProperty(nodeView.Id);
            dialog.Show();

            dialog.Closed += (s1, e1) =>
            {

                if (dialog.DialogResult.HasValue && dialog.DialogResult.Value)
                {
                    EventHandler<AddPipeComponentTypePropertyCompletedEventArgs> addCompleted = null;
                    addCompleted = (s2, eventArgs) =>
                    {
                        PipeComponentTypeProperty pcpt = eventArgs.Result;

                        if (pcpt != null)
                        {
                            NodeView child = new NodeView(nodeView)
                            {
                                Id = pcpt.Id,
                                Name = dialog.ComponentTypeProperty.PipeProperty.Name,
                                Description = dialog.ComponentTypeProperty.PipeProperty.Description,
                                Icon = "/CmsEquipmentDatabase;component/Images/Configuration.png",
                                Type = NodeType.PipeComponentTypeProperty,
                                HasChildren = false,
                                SortField = pcpt.Ordinal.ToString()
                            };
                            if (nodeView.ChildrenLoaded)
                            {
                                nodeView.Children.Add(child);
                                nodeView.Sort(true);
                            }
                        }
                        mCmsWebServiceClient.AddPipeComponentTypePropertyCompleted -= addCompleted;
                    };

                    mCmsWebServiceClient.AddPipeComponentTypePropertyCompleted += addCompleted;

                    mCmsWebServiceClient.AddPipeComponentTypePropertyAsync(dialog.ComponentTypeProperty);
                }
            };
        }
        private void EditPipeComponentTypeProperty(NodeView nodeView)
        {
            EventHandler<GetPipeComponentTypePropertyCompletedEventArgs> loadCompleted = null;
            loadCompleted = (s1, e1) =>
            {
                mCmsWebServiceClient.GetPipeComponentTypePropertyCompleted -= loadCompleted;

                AddExistingPipeComponentProperty dialog = new AddExistingPipeComponentProperty(e1.Result);
                dialog.Show();

                dialog.Closed += (s2, e2) =>
                {
                    if (dialog.DialogResult.HasValue && dialog.DialogResult.Value)
                    {
                        EventHandler<AddPipeComponentTypePropertyCompletedEventArgs> addCompleted = null;
                        addCompleted = (s3, e3) =>
                        {
                            PipeComponentTypeProperty pcpt = e3.Result;

                            NodeView parentNode = nodeView.Parent;
                            parentNode.Children.Clear();

                            //Reload Load Component Property Types
                            EventHandler<GetPipeComponentTypePropertiesCompletedEventArgs> fetchAllPipeComponentTypePropertiesCompleted = null;
                            fetchAllPipeComponentTypePropertiesCompleted = (s, eventArgs) =>
                            {
                                List<PipeComponentTypeProperty> pipeComponentProperties = eventArgs.Result as List<PipeComponentTypeProperty>;
                                foreach (PipeComponentTypeProperty pipeComponentPropertyType in pipeComponentProperties)
                                {
                                    NodeView child = new NodeView(parentNode)
                                    {
                                        Id = pipeComponentPropertyType.Id,
                                        Name = pipeComponentPropertyType.PipeProperty.Name,
                                        Description = pipeComponentPropertyType.PipeProperty.Description,
                                        Icon = "/CmsEquipmentDatabase;component/Images/Configuration.png",
                                        Type = NodeType.PipeComponentTypeProperty,
                                        HasChildren = false,
                                        SortField = pipeComponentPropertyType.Ordinal.ToString()
                                    };
                                    parentNode.Children.Add(child);
                                    mCmsWebServiceClient.GetPipeComponentTypePropertiesCompleted -= fetchAllPipeComponentTypePropertiesCompleted;
                                }
                                parentNode.ChildrenLoaded = true;
                            };
                            mCmsWebServiceClient.GetPipeComponentTypePropertiesCompleted += fetchAllPipeComponentTypePropertiesCompleted;
                            mCmsWebServiceClient.GetPipeComponentTypePropertiesAsync(parentNode.Id);

                            mCmsWebServiceClient.AddPipeComponentTypePropertyCompleted -= addCompleted;
                        };

                        mCmsWebServiceClient.AddPipeComponentTypePropertyCompleted += addCompleted;
                        mCmsWebServiceClient.AddPipeComponentTypePropertyAsync(dialog.ComponentTypeProperty);
                    }

                    nodeView.Parent.Sort();
                };
            };

            mCmsWebServiceClient.GetPipeComponentTypePropertyCompleted += loadCompleted;
            mCmsWebServiceClient.GetPipeComponentTypePropertyAsync(nodeView.Id);
        }