Example #1
0
        public void MoveFromNode(DesignerNode source, DropLinePosition position)
        {
            switch (position)
            {
            case DropLinePosition.OnNode:
                int newIndex = Node.Children.Count;
                if (Node.Children.Contains(source.Node))
                {
                    newIndex--;
                }
                InternalMoveNode(source.Node, Node, newIndex);
                // Remove and recreate the designer node -- the tree draws the lines improperly if we just move the node, and ASource.Reposition raises a null reference exception
                source.Remove();
                DesignerNode newNode = source.Copy();
                AddBaseNode(newNode);
                TreeView.SelectedNode = newNode;
                if (Parent != null)
                {
                    Parent.ExpandAll();
                }
                break;

            case DropLinePosition.AboveNode:
                MoveIntoSibling(source, Node.Parent.Children.IndexOf(Node));
                break;

            case DropLinePosition.BelowNode:
                MoveIntoSibling(source, Node.Parent.Children.IndexOf(Node) + 1);
                break;
            }
            DesignerTree.Modified();
        }
Example #2
0
        // Labels

        protected override void OnAfterLabelEdit(NodeLabelEditEventArgs args)
        {
            DesignerNode node = (DesignerNode)args.Node;

            try
            {
                if (node.Node.Name != args.Label)
                {
                    IHost host = node.Node.HostNode;
                    if (host.GetNode(args.Label) != null)
                    {
                        FormDesigner.Dataphoria.Warnings.AppendError(FormDesigner, new DataphoriaException(DataphoriaException.Codes.InvalidRename, args.Label), false);
                    }
                    else
                    {
                        if (args.Label != null)
                        {
                            Modified();
                            node.Node.Name = args.Label;
                        }
                    }
                }
            }
            finally
            {
                LabelEdit       = false;
                args.CancelEdit = true;                 // always cancel so that the edit doesn't overwrite our update
                node.UpdateText(false);
            }
        }
Example #3
0
        public void PasteFromClipboard()
        {
            INode node;

            using (MemoryStream stream = new MemoryStream())
            {
                StreamWriter writer = new StreamWriter(stream);
                writer.Write((string)Clipboard.GetDataObject().GetData(DataFormats.UnicodeText, true));
                writer.Flush();
                stream.Position = 0;
                BOP.Deserializer deserializer = DesignerTree.FormDesigner.FrontendSession.CreateDeserializer();
                deserializer.FindReference += new BOP.FindReferenceHandler(DeserializeFindReference);
                node = (INode)deserializer.Deserialize(stream, null);
                DesignerTree.FormDesigner.Dataphoria.Warnings.AppendErrors(DesignerTree.FormDesigner, deserializer.Errors, true);
            }

            Node.Children.Add(node);

            RecursiveGetUniqueName(node);       // make names unique after adding the node in order to properly account for all nodes

            DesignerNode designerNode = AddNode(node);

            TreeView.SelectedNode = designerNode;
            designerNode.ExpandAll();
            DesignerTree.Modified();
        }
Example #4
0
        public DesignerNode InsertNode(int index, INode node)
        {
            DesignerNode newNode = new DesignerNode(node, this);

            InsertBaseNode(index, newNode);
            ExpandAll();
            return(newNode);
        }
Example #5
0
        public DesignerNode AddNode(INode node)
        {
            DesignerNode newNode = new DesignerNode(node, this);

            AddBaseNode(newNode);
            ExpandAll();
            return(newNode);
        }
Example #6
0
        // Node Operations

        private DesignerNode Copy()
        {
            DesignerNode copy = new DesignerNode(Node, _designerTree, ReadOnly);

            foreach (DesignerNode node in Nodes)
            {
                copy.AddBaseNode(node.Copy());
            }
            return(copy);
        }
Example #7
0
        /// <remarks> This method does not change the modified state of the editor. </remarks>
        public DesignerNode InsertNode(int index, INode node)
        {
            DesignerNode newNode = new DesignerNode(node, _designerTree);

            InsertBaseNode(index, newNode);
            if (TreeView != null)       // throws if node is not inserted
            {
                ExpandAll();
            }
            return(newNode);
        }
Example #8
0
        /// <remarks> This method does not change the modified state of the editor. </remarks>
        public DesignerNode AddNode(INode node)
        {
            DesignerNode newNode = new DesignerNode(node, _designerTree);

            AddBaseNode(newNode);
            if (TreeView != null)       // throws if node is not inserted
            {
                ExpandAll();
            }
            return(newNode);
        }
Example #9
0
        private void MoveIntoSibling(DesignerNode source, int index)
        {
            int siblingIndex = Parent.Nodes.IndexOf(source);

            if ((siblingIndex >= 0) && (siblingIndex < index))
            {
                index--;
            }
            InternalMoveNode(source.Node, Node.Parent, index);
            // Remove and recreate the node -- the tree draws the lines improperly if we just move the node, and ASource.Reposition raises a null reference exception
            source.Remove();
            DesignerNode newNode = source.Copy();

            Parent.InsertBaseNode(index, newNode);
            TreeView.SelectedNode = newNode;
            Parent.ExpandAll();
        }
        public DesignerTreeDropMenu(DesignerNode source, DesignerNode target, DropLinePosition position, DropOperation supportedOperations)
        {
            _source   = source;
            _target   = target;
            _position = position;

            if ((supportedOperations & DropOperation.Copy) != 0)
            {
                MenuItems.Add(new MenuItem(Strings.DropMenu_Copy, new EventHandler(CopyClick)));
            }
            if ((supportedOperations & DropOperation.Move) != 0)
            {
                MenuItems.Add(new MenuItem(Strings.DropMenu_Move, new EventHandler(MoveClick)));
            }
            MenuItems.Add(new MenuItem("-"));
            MenuItems.Add(new MenuItem(Strings.DropMenu_Cancel));
        }
Example #11
0
        public void CopyFromNode(DesignerNode source, DropLinePosition position)
        {
            INode node;

            using (MemoryStream stream = new MemoryStream())
            {
                BOP.Serializer serializer = DesignerTree.FormDesigner.FrontendSession.CreateSerializer();
                serializer.Serialize(stream, source);
                DesignerTree.FormDesigner.Dataphoria.Warnings.AppendErrors(DesignerTree.FormDesigner, serializer.Errors, true);
                stream.Position = 0;
                BOP.Deserializer deserializer = DesignerTree.FormDesigner.FrontendSession.CreateDeserializer();
                deserializer.FindReference += new BOP.FindReferenceHandler(DeserializeFindReference);
                node = (INode)deserializer.Deserialize(stream, null);
                DesignerTree.FormDesigner.Dataphoria.Warnings.AppendErrors(DesignerTree.FormDesigner, deserializer.Errors, true);
            }
            RecursiveGetUniqueName(node);

            PlaceNewNode(node, position);
            DesignerTree.Modified();
        }
Example #12
0
        public void ActivateNode(DesignerTree.DesignerNode node)
        {
            if ((FPropertyGrid.SelectedObject != null) && (FPropertyGrid.SelectedObject is IDisposableNotify))
            {
                ((IDisposableNotify)FPropertyGrid.SelectedObject).Disposed -= SelectedNodeDisposed;
            }

            bool editsAllowed;

            if (node == null)
            {
                FPropertyGrid.SelectedObject = null;
                editsAllowed = false;
            }
            else
            {
                FPropertyGrid.SelectedObject = node.Node;
                node.Node.Disposed          += SelectedNodeDisposed;
                editsAllowed = !node.ReadOnly;
            }
            FDeleteToolStripMenuItem.Enabled = editsAllowed;
            FRenameToolStripMenuItem.Enabled = editsAllowed;
            FCutToolStripMenuItem.Enabled    = editsAllowed;
        }
Example #13
0
 public DesignerNodeData(DesignerNode treeNode)
 {
     _treeNode    = treeNode;
     _rightButton = Control.MouseButtons == MouseButtons.Right;
 }