public void InitDocument(NDrawingDocument document, NDataGrouping dataGrouping)
            {
                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);

                NEsriMapImporter mapImporter = new NEsriMapImporter();

                mapImporter.MapBounds = NMapBounds.World;

                NEsriShapefile countries = new NEsriShapefile(HttpContext.Current.Server.MapPath(CountriesShapefileName));

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

                mapImporter.Read();

                // Load the data
                DataSet dataSet = new DataSet();

                dataSet.ReadXml(HttpContext.Current.Server.MapPath(SalesXmlFileName), XmlReadMode.ReadSchema);

                // Create a data binding source
                NMapDataTableBindingSource source = new NMapDataTableBindingSource(dataSet.Tables["Sales"]);

                // Create a data binding context
                NMapDataBindingContext context = new NMapDataBindingContext();

                context.AddColumnMatching("NAME", "Country");
                context.ColumnsToImport.Add("Sales");

                // Perform the data binding
                countries.DataBind(source, context);

                // Add a fill rule
                NMapFillRuleRange fillRule = new NMapFillRuleRange("Sales", Color.White, Color.DarkGreen, 8);

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

                mapImporter.Import(document, document.Bounds);

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

                mapLegend.Title                = "Sales";
                mapLegend.RangeFormatString    = "{0:N0} - {1:N0} million dollars";
                mapLegend.LastFormatString     = "{0:N0} million dollars and more";
                NMapLegendRenderPage.MapLegend = mapLegend;

                document.SizeToContent();
            }
Example #2
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();
            }
        private void OnDataGroupingSelectedIndexChanged(NValueChangeEventArgs arg)
        {
            NMapFillRuleRange fillRule = (NMapFillRuleRange)m_MapImporter.GetShapefileAt(0).FillRule;

            switch ((int)arg.NewValue)
            {
            case 0:
                fillRule.DataGrouping = new NDataGroupingOptimal();
                break;

            case 1:
                fillRule.DataGrouping = new NDataGroupingEqualInterval();
                break;

            case 2:
                fillRule.DataGrouping = new NDataGroupingEqualDistribution();
                break;
            }

            ImportMap();
        }
        private void InitDocument()
        {
            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, 10000, 10000);
            document.BackgroundStyle.FillStyle = new NColorFillStyle(Color.LightBlue);

            m_MapImporter           = new NEsriMapImporter();
            m_MapImporter.MapBounds = NMapBounds.World;

            // Configure and add a shapefile
            NEsriShapefile countries = new NEsriShapefile(Path.Combine(Application.StartupPath, COUNTRIES));

            countries.NameColumn = "CNTRY_NAME";
            countries.TextColumn = "CNTRY_NAME";
            m_MapImporter.AddLayer(countries);

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

            // Create a data binding source
            NMapOleDbDataBindingSource source = new NMapOleDbDataBindingSource(string.Format(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0}\..\..\Resources\Maps\Sales.mdb", Application.StartupPath));

            source.SelectQuery = "SELECT * FROM Sales";

            // Create a data binding context
            NMapDataBindingContext context = new NMapDataBindingContext();

            context.AddColumnMatching("CNTRY_NAME", "Country");
            context.ColumnsToImport.Add("Sales");

            // Perform the data binding
            countries.DataBind(source, context);

            // Create and apply a fill rule
            NMapFillRuleRange fillRule = new NMapFillRuleRange("Sales", Color.White, Color.DarkGreen, 8);

            fillRule.DataGrouping = m_DataGrouping;
            countries.FillRule    = fillRule;

            m_MapImporter.ShapeCreatedListener = new NCustomShapeCreatedListener();
            m_MapImporter.ShapeImporter.ImportInMultipleLayers = true;
            m_MapImporter.Import(document, document.Bounds);

            // Generate the legend
            NMapLegendRange mapLegend = (NMapLegendRange)m_MapImporter.GetLegend(fillRule);

            mapLegend.Title             = "Sales";
            mapLegend.RangeFormatString = "{0:N0} - {1:N0} million dollars";
            mapLegend.LastFormatString  = "{0:N0} million dollars and more";

            if (pMapLegend == null)
            {
                pMapLegend          = new Panel();
                pMapLegend.Location = new Point(btnRecreateMap.Left, btnRecreateMap.Bottom + 10);
                pMapLegend.Width    = btnRecreateMap.Width;
                pMapLegend.Anchor   = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top;
                this.Controls.Add(pMapLegend);
            }

            mapLegend.Create(pMapLegend);

            // Size document to content
            document.SizeToContent(new NSizeF(0, 0), new Nevron.Diagram.NMargins(0));
        }
Example #5
0
        private void InitDocument()
        {
            document.Layers.RemoveAllChildren();

            // Configure the drawing document
            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, 10000, 10000);
            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
            m_MapImporter           = new NEsriMapImporter();
            m_MapImporter.MapBounds = NMapBounds.World;

            // Add a shapefile
            NEsriShapefile countries = new NEsriShapefile(Path.Combine(Application.StartupPath, Countries));

            countries.NameColumn = "CNTRY_NAME";
            countries.TextColumn = "CNTRY_NAME";
            m_MapImporter.AddLayer(countries);

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

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

            fillRule.DataGrouping = m_DataGrouping;
            countries.FillRule    = fillRule;

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

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

            mapLegend.Title             = "Population";
            mapLegend.RangeFormatString = "{0:N0} - {1:N0} people";
            mapLegend.LastFormatString  = "{0:N0} people and more";

            if (pMapLegend == null)
            {
                pMapLegend          = new Panel();
                pMapLegend.Location = new Point(btnRecreateMap.Left, btnRecreateMap.Bottom + 10);
                pMapLegend.Width    = btnRecreateMap.Width;
                pMapLegend.Anchor   = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top;
                this.Controls.Add(pMapLegend);
            }

            mapLegend.Create(pMapLegend);
        }