Example #1
0
        private void TreeViewDragDrop(TreeView treeView, DragEventArgs e)
        {
            Point pt = treeView.PointToClient(new Point(e.X, e.Y));

            int    x    = pt.X;
            int    y    = pt.Y;
            string data = "";

            NodeBase overNode = (NodeBase)treeView.GetNodeAt(new Point(x, y));

            if (e.Data.GetDataPresent(typeof(string)))
            {
                data = (string)e.Data.GetData(typeof(string));
            }

            if (data == null)
            {
                data = "";
            }

            if (data.Length > 0)
            {
                string  header;
                XmlNode payload = ParseDragData(data, out header);
                if (header == "aspect")
                {
                    PresentationAspect dropAspect = GetDropAspect(payload);
                    if (overNode != null)
                    {
                        if (overNode is TypeNode)
                        {
                            if (dropAspect != null)
                            {
                                dropAspect.AddTypeTarget(((TypeNode)overNode).Type);
                                RefreshAll();
                            }
                        }
                    }
                }
                if (header == "pointcut")
                {
                    PresentationPointcut dropPointcut = GetDropPointcut(payload);
                    if (overNode != null)
                    {
                        if (overNode is TypeNode)
                        {
                            if (dropPointcut != null)
                            {
                                dropPointcut.AddTypeTarget(((TypeNode)overNode).Type);
                                RefreshAll();
                            }
                        }
                        if (overNode is MethodNode)
                        {
                            if (dropPointcut != null)
                            {
                                MethodNode methodNode = overNode as MethodNode;
                                if (methodNode.CanBeProxied())
                                {
                                    dropPointcut.AddMethodTarget(methodNode.MethodBase, methodNode.Type);
                                    RefreshAll();
                                }
                            }
                        }
                    }
                }
                if (header == "interceptor")
                {
                    PresentationInterceptor dropInterceptor = GetDropInterceptor(payload);
                    if (overNode != null)
                    {
                        if (overNode is TypeNode)
                        {
                            if (dropInterceptor != null)
                            {
                                dropInterceptor.AddTypeTarget(((TypeNode)overNode).Type);
                                RefreshAll();
                            }
                        }
                        if (overNode is MethodNode)
                        {
                            if (dropInterceptor != null)
                            {
                                MethodNode methodNode = overNode as MethodNode;
                                if (methodNode.CanBeProxied())
                                {
                                    dropInterceptor.AddMethodTarget(methodNode.MethodBase, methodNode.Type);
                                    RefreshAll();
                                }
                            }
                        }
                    }
                }
            }

            TurnOffTreeDragHilite();
        }