Exemple #1
0
        private void InitDocument(NDrawingDocument document)
        {
            // Remove the standard frame
            document.BackgroundStyle.FrameStyle.Visible = false;

            // Adjust the graphics quality
            document.GraphicsSettings.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighSpeed;

            // Set up visual formatting
            document.Style.FillStyle   = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant3, Color.FromArgb(192, 194, 194), Color.FromArgb(129, 133, 133));
            document.Style.StrokeStyle = new NStrokeStyle(1, Color.FromArgb(68, 90, 108));

            document.Style.StartArrowheadStyle = new NArrowheadStyle(ArrowheadShape.None, "", NSizeL.Empty,
                                                                     document.Style.FillStyle, document.Style.StrokeStyle);
            document.Style.EndArrowheadStyle = new NArrowheadStyle(ArrowheadShape.None, "", NSizeL.Empty,
                                                                   document.Style.FillStyle, document.Style.StrokeStyle);

            // Create a graph
            CreateGraph(document);

            // Create the layout
            NLayeredGraphLayout layout = new NLayeredGraphLayout();

            // Get the shapes to layout
            NNodeList shapes = document.ActiveLayer.Children(NFilters.Shape2D);

            // Layout the shapes
            layout.Layout(shapes, new NDrawingLayoutContext(document));

            // Resize document to fit all shapes
            document.SizeToContent();
        }
Exemple #2
0
            void INCustomRequestCallback.OnCustomRequestCallback(NAspNetThinWebControl control, NRequestContext context, string argument)
            {
                NThinDiagramControl diagramControl = (NThinDiagramControl)control;
                NDrawingDocument    document       = diagramControl.Document;

                NDrawingDocumentHelper      helper   = new NDrawingDocumentHelper(document);
                Dictionary <string, string> settings = helper.ParseSettings(argument);

                // Create and configure the layout
                NLayeredGraphLayout layout = new NLayeredGraphLayout();

                helper.ConfigureLayout(layout, settings);

                // Get the shapes to layout
                NNodeList shapes = document.ActiveLayer.Children(NFilters.Shape2D);

                // Layout the shapes
                layout.Layout(shapes, new NDrawingLayoutContext(document));

                // Resize document to fit all shapes
                document.SizeToContent();

                // Update the view
                diagramControl.UpdateView();
            }
        private void CreateScene(NDrawingDocument document)
        {
            document.BackgroundStyle.FrameStyle.Visible = false;
            document.Style.TextStyle.FontStyle.InitFromFont(new Font("Arial Narrow", 8));

            NNetworkShapesFactory factory = new NNetworkShapesFactory(document);

            factory.DefaultSize = new NSizeF(240, 180);

            NShape server   = factory.CreateShape(NetworkShapes.Server);
            NShape computer = factory.CreateShape(NetworkShapes.Computer);
            NShape laptop   = factory.CreateShape(NetworkShapes.Laptop);

            document.ActiveLayer.AddChild(server);
            document.ActiveLayer.AddChild(computer);
            document.ActiveLayer.AddChild(laptop);

            NRoutableConnector link1 = new NRoutableConnector();

            document.ActiveLayer.AddChild(link1);
            link1.FromShape = server;
            link1.ToShape   = computer;

            NRoutableConnector link2 = new NRoutableConnector();

            document.ActiveLayer.AddChild(link2);
            link2.FromShape = server;
            link2.ToShape   = laptop;

            // layout the shapes in the active layer using a table layout
            NLayeredGraphLayout layout = new NLayeredGraphLayout();

            // get the shapes to layout
            NNodeList shapes = document.ActiveLayer.Children(NFilters.Shape2D);

            // layout the shapes
            layout.Layout(shapes, new NDrawingLayoutContext(document));

            // resize document to fit all shapes
            document.SizeToContent();

            // add the data shape
            const float   shapeSize = 10;
            NEllipseShape data      = new NEllipseShape(link2.EndPoint.X - shapeSize / 2, link2.EndPoint.Y - shapeSize, shapeSize, shapeSize);

            document.ActiveLayer.AddChild(data);
            NStyle.SetStrokeStyle(data, new NStrokeStyle(0, KnownArgbColorValue.Transparent));
            NStyle.SetFillStyle(data, new NColorFillStyle(KnownArgbColorValue.Red));

            // set the animations style
            SetAnimationsStyle(data, link1, link2);

            // resize document to fit all shapes
            document.SizeToContent();
        }
        private void CreateScene(NDrawingDocument document)
        {
            // Initialize the default document style
            document.BackgroundStyle.FrameStyle.Visible = false;
            document.Style.StartArrowheadStyle.Shape    = ArrowheadShape.None;
            document.Style.EndArrowheadStyle.Shape      = ArrowheadShape.None;
            document.Style.FillStyle = new NGradientFillStyle(GradientStyle.DiagonalUp, GradientVariant.Variant1,
                                                              new NArgbColor(155, 184, 209), new NArgbColor(83, 138, 179));

            NDrawingDocumentHelper helper = new NDrawingDocumentHelper(document);

            // Create the shapes
            NShape vision = helper.CreateBasicShape(BasicShapes.Rectangle, new NRectangleF(0, 0, 100, 50), "Nevron Vision", String.Empty);
            NInteractivityStyle iStyle = new NInteractivityStyle();

            iStyle.UrlLink = new NUrlLinkAttribute("http://www.nevron.com", true);
            NStyle.SetInteractivityStyle(vision, iStyle);

            NShape chart = helper.CreateBasicShape(BasicShapes.Rectangle, new NRectangleF(0, 0, 100, 50), "Nevron Chart", String.Empty);

            iStyle         = new NInteractivityStyle();
            iStyle.UrlLink = new NUrlLinkAttribute("http://nevron.com/Products.ChartFor.NET.Overview.aspx", true);
            NStyle.SetInteractivityStyle(chart, iStyle);

            NShape diagram = helper.CreateBasicShape(BasicShapes.Rectangle, new NRectangleF(0, 0, 100, 50), "Nevron Diagram", String.Empty);

            iStyle         = new NInteractivityStyle();
            iStyle.UrlLink = new NUrlLinkAttribute("http://nevron.com/Products.DiagramFor.NET.Overview.aspx", true);
            NStyle.SetInteractivityStyle(diagram, iStyle);

            NShape ui = helper.CreateBasicShape(BasicShapes.Rectangle, new NRectangleF(0, 0, 100, 50), "Nevron User Interface", String.Empty);

            iStyle         = new NInteractivityStyle();
            iStyle.UrlLink = new NUrlLinkAttribute("http://nevron.com/Products.UserInterfaceFor.NET.Overview.aspx", true);
            NStyle.SetInteractivityStyle(ui, iStyle);

            // Create the connectors
            Connect(vision, chart);
            Connect(vision, diagram);
            Connect(vision, ui);

            // Layout the shapes
            NLayeredGraphLayout layout = new NLayeredGraphLayout();

            layout.Direction = LayoutDirection.LeftToRight;
            NNodeList shapes = document.ActiveLayer.Children(null);

            layout.Layout(shapes, new NDrawingLayoutContext(document));
        }
Exemple #5
0
        private void PerformLayout(Hashtable args)
        {
            // Create the layout
            NLayeredGraphLayout layout = new NLayeredGraphLayout();

            // Configure the layout
            NLayoutsHelper.ConfigureLayout(layout, args);

            // Get the shapes to layout
            NNodeList shapes = NDrawingView1.Document.ActiveLayer.Children(NFilters.Shape2D);

            // Layout the shapes
            layout.Layout(shapes, new NDrawingLayoutContext(NDrawingView1.Document));

            // Resize document to fit all shapes
            NDrawingView1.Document.SizeToContent();
        }
        private void DoLayout()
        {
            NLayoutContext context = new NLayoutContext();

            context.GraphAdapter         = new NShapeGraphAdapter(true);
            context.BodyAdapter          = new NShapeBodyAdapter(document);
            context.BodyContainerAdapter = new NDrawingBodyContainerAdapter(document);

            NLayeredGraphLayout layout = new NLayeredGraphLayout();

            layout.Direction        = LayoutDirection.LeftToRight;
            layout.EdgeRouting      = LayeredLayoutEdgeRouting.Polyline;
            layout.PlugSpacing.Mode = PlugSpacingMode.None;

            NNodeList shapesToLayout = document.ActiveLayer.Children(NFilters.Shape2D);

            layout.Layout(shapesToLayout, context);

            // size to visible shapes
            document.SizeToContent(document.AutoBoundsMinSize, document.AutoBoundsPadding, NFilters.Visible);
        }
        private void CreateScene(NDrawingDocument document)
        {
            document.BackgroundStyle.FrameStyle.Visible = false;

            // change default document styles
            document.Style.TextStyle.TextFormat      = TextFormat.XML;
            document.Style.StartArrowheadStyle.Shape = ArrowheadShape.None;
            document.Style.EndArrowheadStyle.Shape   = ArrowheadShape.None;
            document.Style.FillStyle = new NGradientFillStyle(GradientStyle.DiagonalUp, GradientVariant.Variant1,
                                                              new NArgbColor(155, 184, 209), new NArgbColor(83, 138, 179));

            // the fill style for the cells
            NStyleSheet transparent = new NStyleSheet("transparent");

            NStyle.SetFillStyle(transparent, new NColorFillStyle(KnownArgbColorValue.Transparent));
            document.StyleSheets.AddChild(transparent);

            NNodeList shapes = new NNodeList();
            NShape    shape1, shape2, winner = null;
            int       i, depth = 0;
            int       count = MATCHES.Length;

            for (i = 0; i < count; i++)
            {
                winner = CreateShape(MATCHES[i]);
                shapes.Add(winner);

                if (i >= 8)
                {
                    if (i < 12)
                    {   // The quarter finals
                        depth  = 0;
                        shape1 = (NShape)shapes[(i - 8) * 2];
                        shape2 = (NShape)shapes[(i - 8) * 2 + 1];
                    }
                    else if (i < 14)
                    {   // The semi finals
                        depth  = 2;
                        shape1 = (NShape)shapes[8 + (i - 12) * 2];
                        shape2 = (NShape)shapes[8 + (i - 12) * 2 + 1];
                    }
                    else
                    {   // The final
                        depth  = 4;
                        shape1 = (NShape)shapes[12];
                        shape2 = (NShape)shapes[13];
                    }

                    SetAnimationsStyle(shape1, depth);
                    SetAnimationsStyle(shape2, depth);

                    ConnectShapes(shape1, shape2, winner, depth + 1);
                }
            }

            SetAnimationsStyle(winner, depth + 2);

            NLayeredGraphLayout layout = new NLayeredGraphLayout();

            layout.Direction = LayoutDirection.LeftToRight;
            layout.Layout(shapes, new NDrawingLayoutContext(document));

            // resize document to fit all shapes
            document.SizeToContent();
        }