Beispiel #1
0
            public void InitDocument(NDrawingDocument document, NDataGrouping dataGrouping)
            {
                // Configure the drawing document
                document.Layers.RemoveAllChildren();
                document.Style.StrokeStyle      = new NStrokeStyle(1, Color.FromArgb(68, 90, 108));
                document.RoutingManager.Enabled = false;
                document.BridgeManager.Enabled  = false;
                document.Bounds = new NRectangleF(0, 0, 5000, 5000);
                document.BackgroundStyle.FillStyle = new NColorFillStyle(Color.LightBlue);

                // Add a style sheet
                NStyleSheet styleSheet = new NStyleSheet(WhiteTextStyleSheetName);
                NTextStyle  textStyle  = (NTextStyle)document.ComposeTextStyle().Clone();

                textStyle.FillStyle = new NColorFillStyle(KnownArgbColorValue.White);
                NStyle.SetTextStyle(styleSheet, textStyle);
                document.StyleSheets.AddChild(styleSheet);

                // Create a map importer
                NEsriMapImporter mapImporter = new NEsriMapImporter();

                mapImporter.MapBounds = NMapBounds.World;

                // Add a shapefile
                NEsriShapefile countries = new NEsriShapefile(HttpContext.Current.Server.MapPath(CountriesShapefileName));

                countries.NameColumn = "NAME";
                countries.TextColumn = "NAME";
                mapImporter.AddLayer(countries);

                // Read the map data
                mapImporter.Read();

                // Create a fill rule
                NMapFillRuleRange fillRule = new NMapFillRuleRange("POP_1994", Color.White, Color.Black, 12);

                fillRule.DataGrouping = dataGrouping;
                countries.FillRule    = fillRule;

                // Associate a shape created listener and import the map data
                mapImporter.ShapeCreatedListener = new NCustomShapeCreatedListener();
                mapImporter.Import(document, document.Bounds);

                // Generate a legend
                NMapLegendRange mapLegend = (NMapLegendRange)mapImporter.GetLegend(fillRule);

                mapLegend.Title                = "Population (thousands people)";
                mapLegend.RangeFormatString    = "{0:#,###,##0,} - {1:#,###,##0,}";
                mapLegend.LastFormatString     = "more than {0:#,###,##0,}";
                NMapLegendRenderPage.MapLegend = mapLegend;

                document.SizeToContent();
            }
Beispiel #2
0
        private void CreateStyleSheets(NDrawingDocument document)
        {
            // Create the zoomed city style sheet
            NStyleSheet zoomedCity = new NStyleSheet();

            zoomedCity.Name = "ZoomedCity";
            NTextStyle textStyle = (NTextStyle)document.ComposeTextStyle().Clone();

            textStyle.FontStyle = new NFontStyle(textStyle.FontStyle.Name, textStyle.FontStyle.EmSize, FontStyle.Bold);
            NStyle.SetTextStyle(zoomedCity, textStyle);
            NStyle.SetFillStyle(zoomedCity, new NColorFillStyle(Color.Red));
            document.StyleSheets.AddChild(zoomedCity);
        }
Beispiel #3
0
            public void InitDocument(NDrawingDocument document)
            {
                // Set up visual formatting
                document.BackgroundStyle.FrameStyle.Visible  = false;
                document.BackgroundStyle.FillStyle           = new NColorFillStyle(Color.LightBlue);
                document.GraphicsSettings.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;

                // Create style sheets
                NStyleSheet clickedCounty = new NStyleSheet("ClickedCounty");

                NStyle.SetFillStyle(clickedCounty, new NColorFillStyle(KnownArgbColorValue.Red));
                NStyle.SetTextStyle(clickedCounty, new NTextStyle(document.ComposeTextStyle().FontStyle, Color.White));
                document.StyleSheets.AddChild(clickedCounty);

                // Load the map of the USA
                LoadUsaMap(document);
            }
        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();
        }