Esempio n. 1
0
        void SelectNodeRepresentingControl(Gwen.Control.Base pControl, Gwen.Control.TreeNode pNode = null)
        {
            if (pNode == null)
            {
                pNode = m_Tree;
            }

            if (pNode.UserData.ContainsKey("TargetControl") && pNode.UserData.Get <Gwen.Control.Base>("TargetControl") == pControl)
            {
                pNode.SetSelected(true, false);
            }
            else
            {
                foreach (var child in pNode.Children)
                {
                    var pChildNode = child as Gwen.Control.TreeNode;
                    if (pChildNode == null)
                    {
                        continue;
                    }

                    SelectNodeRepresentingControl(pControl, pChildNode);
                }
            }
        }
Esempio n. 2
0
        void AddControlNode(Gwen.Control.TreeNode pNode, Gwen.Control.Base pControl)
        {
            if (pControl.GetType() == typeof(SelectionLayer))
            {
                return;
            }

            var strName = pControl.Name;

            if (strName == null || strName == "")
            {
                strName = "[" + pControl.GetType().Name + "]";
            }

            var pChildNode = pNode.AddNode(strName);

            //pChildNode.SetImage("img/controls/" + pControl.GetType().Name + ".png");
            pChildNode.Selected += OnNodeSelected;
            pChildNode.UserData.Add("TargetControl", pControl);
            //pChildNode.ShouldDrawBackground = true;
            pChildNode.DragAndDrop_SetPackage(true, "ControlHierarchy", pChildNode);
            pChildNode.DragAndDropCanAcceptPackage += new Func <Gwen.Control.Base, Gwen.DragDrop.Package, bool>(
                delegate(Gwen.Control.Base c, Gwen.DragDrop.Package p)
            {
                return(p.Name == "ControlHierarchy");
            });
            pChildNode.DragAndDropHandleDrop += new Func <Gwen.Control.Base, Gwen.DragDrop.Package, int, int, bool>(
                delegate(Gwen.Control.Base control, Gwen.DragDrop.Package p, int x, int y)
            {
                var childNode = p.data as Gwen.Control.TreeNode;
                var node      = control as Gwen.Control.TreeNode;
                if (childNode == null || node == null)
                {
                    return(false);
                }
                node.AddNode(childNode);
                return(true);
            });

            foreach (var child in pControl.Children)
            {
                AddControlNode(pChildNode, child);
            }
        }