void INCustomRequestCallback.OnCustomRequestCallback(NAspNetThinWebControl control, NRequestContext context, string argument)
            {
                NThinDiagramControl diagramControl = (NThinDiagramControl)control;

                string[]      args         = argument.Split(',');
                NDataGrouping dataGrouping = null;

                switch (args[0])
                {
                case "EqualDistribution":
                    dataGrouping = new NDataGroupingEqualDistribution();
                    break;

                case "EqualInterval":
                    dataGrouping = new NDataGroupingEqualInterval();
                    break;

                case "Optimal":
                    dataGrouping = new NDataGroupingOptimal();
                    break;

                default:
                    throw new Exception("New data grouping type?");
                }

                dataGrouping.RoundedRanges = Boolean.Parse(args[1]);

                MapRenderer mapRenderer = new MapRenderer();

                mapRenderer.InitDocument(diagramControl.Document, dataGrouping);

                diagramControl.UpdateView();
                diagramControl.AddCustomClientCommand("UpdateLegend");
            }
            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();
            }
Ejemplo n.º 3
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();
            }