Exemplo n.º 1
0
        private void InitFormControls()
        {
            PauseEventsHandling();

            // Create the layouts
            NLayeredGraphLayout layered = new NLayeredGraphLayout();

            layered.LayerSpacing = 100;

            NSingleCycleLayout singleCycle = new NSingleCycleLayout();

            singleCycle.RingRadius = 1000;

            NSymmetricalLayout symmetrical = new NSymmetricalLayout();

            cbLayout.Items.AddRange(new NLayout[]
            {
                layered,
                singleCycle,
                symmetrical
            });

            cbLayout.SelectedIndex = 0;

            ResumeEventsHandling();
        }
        protected override void LoadExample()
        {
            // create a stylesheet for the CustomConnectors
            NStyleSheet styleSheet = new NStyleSheet("CustomConnectors");

            styleSheet.Style.StartArrowheadStyle = new NArrowheadStyle(ArrowheadShape.Circle, "CustomConnectorStart", new NSizeL(6, 6), new NColorFillStyle(Color.FromArgb(247, 150, 56)), new NStrokeStyle(1, Color.FromArgb(68, 90, 108)));
            styleSheet.Style.EndArrowheadStyle   = new NArrowheadStyle(ArrowheadShape.Arrow, "CustomConnectorStart", new NSizeL(6, 6), new NColorFillStyle(Color.FromArgb(247, 150, 56)), new NStrokeStyle(1, Color.FromArgb(68, 90, 108)));
            styleSheet.Style.StrokeStyle         = new NStrokeStyle(1, Color.FromArgb(68, 90, 108));
            document.StyleSheets.AddChild(styleSheet);

            // init form fields
            m_Layout = new NLayeredGraphLayout();
            propertyGrid1.SelectedObject = m_Layout;

            view.BeginInit();
            view.Grid.Visible = false;
            view.GlobalVisibility.ShowPorts = false;
            view.ViewLayout = ViewLayout.Fit;

            // init document
            document.BeginInit();
            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.EndArrowheadStyle.FillStyle   = new NColorFillStyle(Color.FromArgb(247, 150, 56));
            document.Style.StartArrowheadStyle.FillStyle = new NColorFillStyle(Color.FromArgb(247, 150, 56));
            InitDocument();
            document.EndInit();

            // init form controls
            InitFormControls();

            // end view init
            view.EndInit();
        }
Exemplo n.º 3
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();
        }
Exemplo n.º 4
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));
        }
        /// <summary>
        /// Arranges the shapes in the active page.
        /// </summary>
        private void ArrangeDiagram()
        {
            // Create and configure a layout
            NLayeredGraphLayout layout = new NLayeredGraphLayout();

            // Get all top-level shapes that reside in the active page
            NPage          activePage = m_DrawingDocument.Content.ActivePage;
            NList <NShape> shapes     = activePage.GetShapes(false);

            // Create a layout context and use it to arrange the shapes using the current layout
            NDrawingLayoutContext layoutContext = new NDrawingLayoutContext(m_DrawingDocument, activePage);

            layout.Arrange(shapes.CastAll <object>(), layoutContext);

            // Size the page to the content size
            activePage.SizeToContent();
        }
Exemplo n.º 8
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();
        }
Exemplo n.º 9
0
        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);
        }
Exemplo n.º 10
0
        private void ImportData()
        {
            NDrawingDocument document = NDrawingView1.Document;

            document.BackgroundStyle.FrameStyle.Visible = false;

            // create two stylesheets - one for the vertices and one for the edges
            NStyleSheet vertexStyleSheet = new NStyleSheet();

            vertexStyleSheet.Name = "Vertices";
            NStyle.SetFillStyle(vertexStyleSheet, new NColorFillStyle(Color.FromArgb(236, 97, 49)));
            document.StyleSheets.AddChild(vertexStyleSheet);

            NStyleSheet edgeStyleSheet = new NStyleSheet();

            edgeStyleSheet.Name = "Edges";
            NStyle.SetStrokeStyle(edgeStyleSheet, new NStrokeStyle(Color.Blue));
            NStyle.SetEndArrowheadStyle(edgeStyleSheet, new NArrowheadStyle(ArrowheadShape.OpenedArrow, null, new NSizeL(6, 4), null, new NStrokeStyle(Color.Blue)));
            NTextStyle textStyle = (NTextStyle)document.ComposeTextStyle().Clone();

            textStyle.StringFormatStyle.VertAlign = Nevron.VertAlign.Bottom;
            NStyle.SetTextStyle(edgeStyleSheet, textStyle);
            document.StyleSheets.AddChild(edgeStyleSheet);

            // create the graph data source importer
            NGraphDataSourceImporter graphImporter = new NGraphDataSourceImporter();

            // set the document in the active layer of which the shapes will be imported
            graphImporter.Document = document;

            // SET THE DATA SOURCE
            // the tree data source importer supports the following data sources
            //      DataTable
            //      DataView
            //      OleDbDataAdapter
            //      SqlDataAdapter
            //      OdbcDataAdapter
            //      OleDbCommand
            //      SqlCommand
            //      OdbcCommand
            // in this example we have created an OleDbDataAdapter,
            // which selects all columns and records from the Sources and Links tables of the Data.xlsx file
            string databasePath     = Server.MapPath(@"..\Examples\Import\Data.xlsx");
            string connectionString = @"Data Source=""" + databasePath + @""";Provider=""Microsoft.ACE.OLEDB.12.0""; Extended Properties=""Excel 12.0 Xml;HDR=YES"";";

            graphImporter.VertexDataSource = new OleDbDataAdapter("SELECT * FROM [Sources$]", connectionString);
            graphImporter.EdgeDataSource   = new OleDbDataAdapter("SELECT * FROM [Links$]", connectionString);

            // vertex records are uniquely identified by their Id (in the Sources table)
            // edges link the vertices with the Fro and ToPageId (in the Links table)
            graphImporter.VertexIdColumnName     = "Id";
            graphImporter.FromVertexIdColumnName = "From";
            graphImporter.ToVertexIdColumnName   = "To";

            // create vertices as group shapes, with default size
            NShapesFactory shapesFactory = new GroupShapesFactory();

            shapesFactory.DefaultSize         = VertexSize;
            graphImporter.VertexShapesFactory = shapesFactory;
            graphImporter.VertexShapesName    = GroupShapes.Group.ToString();

            // set stylesheets to be applied to imported vertices and edges
            graphImporter.VertexStyleSheetName = "Vertices";
            graphImporter.EdgeStyleSheetName   = "Edges";

            // use layered graph layout
            NLayeredGraphLayout layout = new NLayeredGraphLayout();

            layout.LayerSpacing   = 70;
            layout.Direction      = LayoutDirection.LeftToRight;
            layout.LayerAlignment = RelativeAlignment.Near;
            graphImporter.Layout  = layout;

            // subscribe for the vertex and edge imported events,
            // which are raised when a shape was created for a data source record
            graphImporter.VertexImported += new ShapeImportedDelegate(OnVertexImported);
            graphImporter.EdgeImported   += new ShapeImportedDelegate(OnEdgeImported);

            // import
            graphImporter.Import();
        }
Exemplo n.º 11
0
        protected override void LoadExample()
        {
            // begin view init
            view.BeginInit();

            // configure the view
            view.Grid.Visible               = false;
            view.Selection.Mode             = DiagramSelectionMode.Single;
            view.GlobalVisibility.ShowPorts = false;
            view.HorizontalRuler.Visible    = false;
            view.VerticalRuler.Visible      = false;

            // create two stylesheets - one for the vertices and one for the edges
            NStyleSheet vertexStyleSheet = new NStyleSheet();

            vertexStyleSheet.Name            = "Vertices";
            vertexStyleSheet.Style.FillStyle = new NColorFillStyle(Color.FromArgb(236, 97, 49));
            document.StyleSheets.AddChild(vertexStyleSheet);

            NStyleSheet edgeStyleSheet = new NStyleSheet();

            edgeStyleSheet.Name = "Edges";
            edgeStyleSheet.Style.StrokeStyle = new NStrokeStyle(Color.FromArgb(68, 90, 108));
            document.StyleSheets.AddChild(edgeStyleSheet);

            // configure the graph data source importer
            m_GraphImporter = new NGraphDataSourceImporter();

            // set the document in the active layer of which the shapes will be imported
            m_GraphImporter.Document = document;

            // set the data sources
            // the graph data source importer supports the following data sources
            //      DataTable
            //      DataView
            //      OleDbDataAdapter
            //      SqlDataAdapter
            //      OdbcDataAdapter
            //      OleDbCommand
            //      SqlCommand
            //      OdbcCommand
            // in this example we have created two OleDbDataAdapters:
            // the PagesDataAdapter selects all records and columns from the Pages table of the SiteMap.mdb
            // the LinksDataAdapter selects all records and columns from the Links table of the SiteMap.mdb
            oleDbConnection1.ConnectionString = @"Data Source=""" + Application.StartupPath +
                                                @"\..\..\Resources\Data\SiteMap.mdb"";Provider=""Microsoft.Jet.OLEDB.4.0"";";
            oleDbConnection2.ConnectionString = @"Data Source=""" + Application.StartupPath +
                                                @"\..\..\Resources\Data\SiteMap.mdb"";Provider=""Microsoft.Jet.OLEDB.4.0"";";

            m_GraphImporter.VertexDataSource = PagesDataAdapter;
            m_GraphImporter.EdgeDataSource   = LinksDataAdapter;

            // vertex records are uniquely identified by their Id (in the Pages table)
            // edges link the vertices with the FromPageId and ToPageId (in the Links table)
            m_GraphImporter.VertexIdColumnName     = "Id";
            m_GraphImporter.FromVertexIdColumnName = "FromPageId";
            m_GraphImporter.ToVertexIdColumnName   = "ToPageId";

            // create vertices as rectangles shapes, with default size (60, 30)
            NBasicShapesFactory shapesFactory = new NBasicShapesFactory();

            shapesFactory.DefaultSize           = new NSizeF(60, 30);
            m_GraphImporter.VertexShapesFactory = shapesFactory;
            m_GraphImporter.VertexShapesName    = BasicShapes.Rectangle.ToString();

            // set stylesheets to be applied to imported vertices and edges
            m_GraphImporter.VertexStyleSheetName = "Vertices";
            m_GraphImporter.EdgeStyleSheetName   = "Edges";

            // use layered graph layout
            NLayeredGraphLayout layout = new NLayeredGraphLayout();

            layout.Direction       = LayoutDirection.LeftToRight;
            layout.LayerAlignment  = RelativeAlignment.Near;
            m_GraphImporter.Layout = layout;

            // subscribe for the vertex imported event,
            // which is raised when a shape was created for a data source record
            m_GraphImporter.VertexImported += new ShapeImportedDelegate(OnVertexImported);

            // import
            m_GraphImporter.Import();

            // end view init
            view.EndInit();
        }
        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();
        }
Exemplo n.º 13
0
        private void InitDocument()
        {
            NDrawingDocument document = NDrawingView1.Document;

            document.BackgroundStyle.FrameStyle.Visible = false;

            // create two stylesheets - one for the vertices and one for the edges
            NStyleSheet vertexStyleSheet = new NStyleSheet();

            vertexStyleSheet.Name            = "Vertices";
            vertexStyleSheet.Style.FillStyle = new NColorFillStyle(Color.FromArgb(236, 97, 49));
            document.StyleSheets.AddChild(vertexStyleSheet);

            NStyleSheet edgeStyleSheet = new NStyleSheet();

            edgeStyleSheet.Name = "Edges";
            edgeStyleSheet.Style.StrokeStyle = new NStrokeStyle(Color.FromArgb(68, 90, 108));
            document.StyleSheets.AddChild(edgeStyleSheet);

            // create the tree data source importer
            NGraphDataSourceImporter graphImporter = new NGraphDataSourceImporter();

            // set the document in the active layer of which the shapes will be imported
            graphImporter.Document = document;

            // SET THE DATA SOURCE
            // the tree data source importer supports the following data sources
            //      DataTable
            //      DataView
            //      OleDbDataAdapter
            //      SqlDataAdapter
            //      OdbcDataAdapter
            //      OleDbCommand
            //      SqlCommand
            //      OdbcCommand
            // in this example we have created an OleDbDataAdapter,
            // which selects all columns and records from the Pages table of the SiteMap.mdb
            string  databasePath = HttpContext.Current.Server.MapPath(@"..\App_Data\SiteMap.xml");
            DataSet dataSet      = new DataSet();

            dataSet.ReadXml(databasePath, XmlReadMode.ReadSchema);

            graphImporter.VertexDataSource = dataSet.Tables["Pages"];
            graphImporter.EdgeDataSource   = dataSet.Tables["Links"];

            // vertex records are uniquely identified by their Id (in the Pages table)
            // edges link the vertices with the FromPageId and ToPageId (in the Links table)
            graphImporter.VertexIdColumnName     = "Id";
            graphImporter.FromVertexIdColumnName = "FromPageId";
            graphImporter.ToVertexIdColumnName   = "ToPageId";

            // create vertices as rectangles shapes, with default size (60,30)
            NBasicShapesFactory shapesFactory = new NBasicShapesFactory();

            shapesFactory.DefaultSize         = new NSizeF(60, 30);
            graphImporter.VertexShapesFactory = shapesFactory;
            graphImporter.VertexShapesName    = BasicShapes.Rectangle.ToString();

            // set stylesheets to be applied to imported vertices and edges
            graphImporter.VertexStyleSheetName = "Vertices";
            graphImporter.EdgeStyleSheetName   = "Edges";

            // use layered graph layout
            NLayeredGraphLayout layout = new NLayeredGraphLayout();

            layout.Direction      = LayoutDirection.LeftToRight;
            layout.LayerAlignment = RelativeAlignment.Near;
            graphImporter.Layout  = layout;

            // subscribe for the vertex imported event,
            // which is raised when a shape was created for a data source record
            graphImporter.VertexImported += new ShapeImportedDelegate(OnVertexImported);

            // import
            graphImporter.Import();
        }