예제 #1
0
        /// <summary>
        /// Draw new shape
        /// </summary>
        /// <param name="centerLocation"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        private Microsoft.Msagl.Drawing.Node Draw(Microsoft.Msagl.Core.Geometry.Point centerLocation)
        {
            graph = gViewer.Graph;
            var id = drawForm.ShapeId;

            Microsoft.Msagl.Drawing.Node node = graph.AddNode(id);
            node.Label.Text     = drawForm.ShapeLabel;
            node.Attr.Shape     = drawForm.ChosenShape;
            node.Attr.Color     = Color.Black;
            node.Attr.FillColor = new Microsoft.Msagl.Drawing.Color(drawForm.ChosenColor.A,
                                                                    drawForm.ChosenColor.R,
                                                                    drawForm.ChosenColor.G,
                                                                    drawForm.ChosenColor.B);
            node.Attr.LineWidth  = MinSize / 5;
            node.Attr.XRadius    = node.Attr.YRadius = MinSize / 2;
            node.Label.FontColor = Color.Black;
            node.Label.FontSize  = drawForm.FontSize;

            NodeWidth  = drawForm.ShapeWidth;
            NodeHeight = drawForm.ShapeHeight;
            NodeCenter = centerLocation;
            node.NodeBoundaryDelegate = new DelegateToSetNodeBoundary(DrawCurve);
            //if (drawForm.BackgroundNode)
            //{
            //    node.NodeBoundaryDelegate = new DelegateToSetNodeBoundary(GetNodeBoundary);
            //    node.DrawNodeDelegate = new DelegateToOverrideNodeRendering(DrawImageNode);
            //    drawForm.BackgroundNode = false;
            //}
            IViewerNode dNode = gViewer.CreateIViewerNode(node, centerLocation, null);

            gViewer.AddNode(dNode, true);
            // gViewer.ResizeNodeToLabel(node);
            return(node);
        }
예제 #2
0
        internal virtual Node InsertNode(MSAGLPoint center, string id)
        {
            var node = new Node(id);

            node.Label.Text      = "default";
            node.Attr.FillColor  = MSAGLColor.Black;
            node.Label.FontColor = MSAGLColor.White;
            node.Label.FontSize  = 10;
            node.Attr.Shape      = Shape.Circle;
            string s = "User Data object";

            node.UserData = s;
            IViewerNode dNode = gViewer.CreateIViewerNode(node, center, null);

            gViewer.AddNode(dNode, true);
            gViewer.Invalidate(dNode);
            //NodeInsertedByUser(this, new NodeInsertedByUserEventArgs(node));
            return(node);
        }
예제 #3
0
파일: MainForm.cs 프로젝트: iakov/REAL.NET
        private void InitPalette()
        {
            foreach (var type in graph.GetNodeTypes())
            {
                var button = new Button {
                    Text = type.Name, Dock = DockStyle.Bottom
                };
                button.Click += (sender, args) =>
                {
                    var node = graph.CreateNewNode(type);
                    node.GeometryNode = GeometryGraphCreator.CreateGeometryNode(viewer.Graph, viewer.Graph.GeometryGraph, node, ConnectionToGraph.Disconnected);
                    var viewNode = viewer.CreateIViewerNode(node, viewer.Graph.Nodes.ToList()[0].Pos - new Point(250, 0), null);
                    viewer.AddNode(viewNode, true);
                    viewer.Graph.AddNode(node);
                    viewer.Invalidate();
                };
                button.Font = new Font(button.Font.FontFamily, fontSize);
                button.Size = new Size(button.Width, button.Height + 10);
                paletteGrid.Controls.Add(button, 0, paletteGrid.RowCount - 1);

                ++paletteGrid.RowCount;
            }
        }
예제 #4
0
        /// <summary>
        /// Inserts a new node at the selected point, with standard attributes, and displays it.
        /// </summary>
        /// <param name="center">The location of the node on the graph</param>
        /// <param name="nte">The NodeTypeEntry structure containing the initial aspect of the node</param>
        /// <param name="id">The id for the node</param>
        /// <returns>The new node</returns>
        internal virtual DrawingNode InsertNode(Point center, NodeTypeEntry nte, string id)
        {
            var node = new DrawingNode(id);

            node.Label.Text      = nte.DefaultLabel;
            node.Attr.FillColor  = nte.FillColor;
            node.Label.FontColor = nte.FontColor;
            node.Label.FontSize  = nte.FontSize;
            node.Attr.Shape      = nte.Shape;
            string s = nte.UserData;

            node.UserData = s;
            IViewerNode dNode = gViewer.CreateIViewerNode(node, center, null);

            gViewer.AddNode(dNode, true);

            return(node);
        }