Example #1
0
        public GoBasicNode InsertNode(PointF pt, string title, GoShape shape = null, int userFlag = 0, Object userObj = null)
        {
            if (shape == null)
            {
                shape = new GoRectangle();
            }
            GoDocument doc = goView.Document;

            doc.StartTransaction();
            GoBasicNode n = new GoBasicNode();

            n.UserFlags  = userFlag;
            n.UserObject = userObj;
            n.LabelSpot  = GoObject.Middle;
            n.Text       = title;
            n.Shape      = shape;

            // specify the position and colors
            n.Location       = pt;
            n.Brush          = new SolidBrush(Color.White);
            n.Shape.PenColor = Color.Red;
            n.Shape.PenWidth = 2;
            // allow the user to edit the text in-place
            n.Label.Editable = true;
            doc.Add(n);
            doc.FinishTransaction("Insert node finished");
            return(n);
        }
Example #2
0
        public GoNode InsertNode(PointF pt, GoNode node, int userFlag = 0, Object userObj = null)
        {
            GoDocument doc = goView.Document;

            doc.StartTransaction();
            node.UserFlags  = userFlag;
            node.UserObject = userObj;
            node.Location   = pt;
            doc.Add(node);
            doc.FinishTransaction("Insert node finished");
            return(node);
        }
Example #3
0
        public void PerformLayout(IContainerBase containerBase, IList <IHasLayoutInfo> freeNodes)
        {
            GoDocument doc = containerBase as GoDocument;

            if (doc == null && containerBase as GoObject == null)
            {
                _dialogCreator.MessageBoxInfo("Bad ContainerBase Type = " + containerBase.GetType().Name);
                return;
            }

            if (doc == null)
            {
                doc = ((GoObject)containerBase).Document;
            }
            Document = doc;

            doc.StartTransaction();

            string text = "DiagramModel";
            var    containerBaseNode = containerBase as IContainerNode;

            if (containerBaseNode != null)
            {
                text = containerBaseNode.GetLongName();
            }

            LayerSpacing      = 0F;
            ColumnSpacing     = 0F;
            DirectionOption   = GoLayoutDirection.Right;
            CycleRemoveOption = GoLayoutLayeredDigraphCycleRemove.DepthFirst;
            LayeringOption    = GoLayoutLayeredDigraphLayering.OptimalLinkLength;
            InitializeOption  = GoLayoutLayeredDigraphInitIndices.DepthFirstOut;
            Iterations        = 4;
            AggressiveOption  = GoLayoutLayeredDigraphAggressive.Less;
            PackOption        = GoLayoutLayeredDigraphPack.Straighten;
            SetsPortSpots     = false;


            var net = CreateNetwork();

            net.AddNodesAndLinksFromCollection(containerBase as IGoCollection, true);

            setNodeType(net, freeNodes);

            Network = net;

            if (net.NodeCount > 0)
            {
                base.PerformLayout();
            }
            doc.FinishTransaction("DoLayerLayout");
        }
Example #4
0
        /// <summary>
        /// Create a GoBasicNode with random colors and editable middle label,
        /// and add it to the document at the given point.
        /// </summary>
        /// <param name="pt">the location of the new node (the center of the shape)</param>
        /// <param name="rectangular">whether the node has a rectangle shape instead of elliptical</param>
        /// <returns>a GoBasicNode</returns>
        private GoBasicNode InsertNode(PointF pt, bool rectangular, string title)
        {
            GoDocument doc = goView1.Document;

            doc.StartTransaction();
            GoBasicNode n = new GoBasicNode();

            n.LabelSpot = GoObject.Middle;
            n.Text      = title; //(++myNodeCounter).ToString();
                                 //if (rectangular)
                                 //n.Shape = new GoRectangle(); ;
                                 // specify the position and colors
            n.Location       = pt;
            n.Brush          = new SolidBrush(GetRandomColor(100));
            n.Shape.PenColor = GetRandomColor(130);
            n.Shape.PenWidth = 3;
            // allow the user to edit the text in-place
            //n.Label.Editable = true;
            doc.Add(n);
            doc.FinishTransaction("inserted node");
            return(n);
        }