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();
            }
        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));
        }