internal static DataGridPrinterLayer GetDataGridPrinterLayer(double width, double height, double centerX, double centerY) { DataTable dataTable = new DataTable(); dataTable.Columns.Add("Header1"); dataTable.Columns.Add("Header2"); dataTable.Columns.Add("Header3"); string text = "content"; for (int i = 0; i < 3; i++) { var row = dataTable.NewRow(); row[0] = text; row[1] = text; row[2] = text; dataTable.Rows.Add(row); } DataGridPrinterLayer dataGridPrinterLayer = new DataGridPrinterLayer { DrawingExceptionMode = DrawingExceptionMode.DrawException }; dataGridPrinterLayer.LoadFromViewModel(new DataGridViewModel { CurrentDataTable = dataTable, FontSize = 22 }); dataGridPrinterLayer.Open(); dataGridPrinterLayer.SetPosition(width, height, centerX, centerY, PrintingUnit.Inch); return(dataGridPrinterLayer); }
private void toolBoxItem_Click(object sender, RoutedEventArgs e) { PrinterInteractiveOverlay printerInteractiveOverlay = (PrinterInteractiveOverlay)Map1.InteractiveOverlays["PrintPreviewOverlay"]; PrinterLayer printerLayer = null; if (sender == btnAddLabel) { printerLayer = new LabelPrinterLayer(); printerLayer.SetPosition(2, 1, 0, 0, PrintingUnit.Inch); } else if (sender == btnAddImage) { printerLayer = new ImagePrinterLayer(); } else if (sender == btnAddScaleLine) { MessageBox.Show("NotImplemented"); } else if (sender == btnAddScaleBar) { MessageBox.Show("NotImplemented"); } else if (sender == btnAddDataGrid) { printerLayer = new DataGridPrinterLayer(); printerLayer.SetPosition(1, 1, 0, 0, PrintingUnit.Inch); } //if (ShowPrinterLayerProperties(printerLayer) == DialogResult.OK) if (ShowPrinterLayerProperties(printerLayer) == true) { printerInteractiveOverlay.PrinterLayers.Add(printerLayer); Map1.Refresh(); } }
private void AddDataGridLayer() { // Create the DataGridPrinterLayer DataGridPrinterLayer dataGridPrinterLayer = new DataGridPrinterLayer(); dataGridPrinterLayer.TextFont = new GeoFont("Arial", 8); //dataGridPrinterLayer.CellTextJustification = LabelTextJustification.Left; dataGridPrinterLayer.TextHorizontalAlignment = PrinterTextHorizontalAlignment.Left; // Set the data grid position 4 inches below the page center and 8 inches wide and 2.5 inches tall RectangleShape pageBoundingbox = GetPageBoundingBox(PrintingUnit.Inch); dataGridPrinterLayer.SetPosition(8, 2.5, pageBoundingbox.GetCenterPoint().X, pageBoundingbox.GetCenterPoint().Y - 4, PrintingUnit.Inch); //Create the data table and columns dataGridPrinterLayer.DataTable = new DataTable(); dataGridPrinterLayer.DataTable.Columns.Add("Country"); dataGridPrinterLayer.DataTable.Columns.Add("Population"); dataGridPrinterLayer.DataTable.Columns.Add("CurrencyCode"); dataGridPrinterLayer.DataTable.Columns.Add("Area"); // Find all of the countries with a population greater than 70 million // and add those items to the data table ShapeFileFeatureLayer shapefileFeatureLayer = new ShapeFileFeatureLayer(@"data/Countries02_3857.shp", FileAccess.Read); shapefileFeatureLayer.Open(); Collection <Feature> features = shapefileFeatureLayer.QueryTools.GetAllFeatures(ReturningColumnsType.AllColumns); shapefileFeatureLayer.Close(); foreach (Feature feature in features) { double pop = Convert.ToDouble(feature.ColumnValues["Pop_cntry"].ToString()); if (pop > 70000000) { dataGridPrinterLayer.DataTable.Rows.Add(new object[4] { feature.ColumnValues["Cntry_Name"], feature.ColumnValues["Pop_cntry"], feature.ColumnValues["curr_code"], feature.ColumnValues["sqkm"] }); } } // Add the DataGridPrinterLayer to the PrinterInteractiveOverlay PrinterInteractiveOverlay printerInteractiveOverlay = (PrinterInteractiveOverlay)Map1.InteractiveOverlays["PrintPreviewOverlay"]; printerInteractiveOverlay.PrinterLayers.Add("DataGridLayer", dataGridPrinterLayer); }
private void AddDataGridLayer2() { // Create the DataGridPrinterLayer for parcels in discussion and place it the right. DataGridPrinterLayer dataGridPrinterLayer = new DataGridPrinterLayer(); dataGridPrinterLayer.TextFont = new GeoFont("Arial", 8); dataGridPrinterLayer.TextHorizontalAlignment = PrinterTextHorizontalAlignment.Left; // Set the data grid position 4.2 inches below the page center to the right and 3.5 inches wide and 2 inches tall RectangleShape pageBoundingbox = GetPageBoundingBox(PrintingUnit.Inch); dataGridPrinterLayer.SetPosition(3.5, 2, 2.25, pageBoundingbox.GetCenterPoint().Y - 4.2, PrintingUnit.Inch); //Create the data table and columns dataGridPrinterLayer.DataTable = new DataTable(); dataGridPrinterLayer.DataTable.Columns.Add("TAXPIN"); dataGridPrinterLayer.DataTable.Columns.Add("LAST_REVIS"); dataGridPrinterLayer.DataTable.Columns.Add("ACRES"); dataGridPrinterLayer.DataTable.Columns.Add("CALCULATED"); // Find all of the parcels that are in discussion and add those items to the data table ShapeFileFeatureLayer shapefileFeatureLayer = new ShapeFileFeatureLayer(@"..\..\..\Data\Shapefile\Parcels.shp", FileAccess.Read); shapefileFeatureLayer.Open(); Collection <Feature> features = shapefileFeatureLayer.QueryTools.GetFeaturesByColumnValue("AFFECTED", "D", ReturningColumnsType.AllColumns); shapefileFeatureLayer.Close(); foreach (Feature feature in features) { dataGridPrinterLayer.DataTable.Rows.Add(new object[4] { feature.ColumnValues["TAXPIN"], feature.ColumnValues["LAST_REVIS"], feature.ColumnValues["ACRES"], feature.ColumnValues["CALCULATED"] }); } // Add the DataGridPrinterLayer to the PrinterInteractiveOverlay PrinterInteractiveOverlay printerInteractiveOverlay = (PrinterInteractiveOverlay)mapView.InteractiveOverlays["PrintPreviewOverlay"]; printerInteractiveOverlay.PrinterLayers.Add("DataGridLayer2", dataGridPrinterLayer); }