private void cbxPaperSize_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (IsLoaded) { // When the page size combobox is changed then we update the PagePrinterLayer to reflect the changes PrinterInteractiveOverlay printerInteractiveOverlay = (PrinterInteractiveOverlay)Map1.InteractiveOverlays["PrintPreviewOverlay"]; PagePrinterLayer pagePrinterLayer = (PagePrinterLayer)printerInteractiveOverlay.PrinterLayers["PageLayer"]; string selectText = ((ComboBoxItem)e.AddedItems[0]).Content.ToString(); if (selectText.StartsWith("ANSI A")) { pagePrinterLayer.PageSize = PrinterPageSize.AnsiA; } else if (selectText.StartsWith("ANSI B")) { pagePrinterLayer.PageSize = PrinterPageSize.AnsiB; } else if (selectText.StartsWith("ANSI C")) { pagePrinterLayer.PageSize = PrinterPageSize.AnsiC; } else if (selectText.StartsWith("ANSI D")) { pagePrinterLayer.PageSize = PrinterPageSize.AnsiD; } else if (selectText.StartsWith("ANSI E")) { pagePrinterLayer.PageSize = PrinterPageSize.AnsiE; } Map1.Refresh(); } }
private void AddLegendLayer2() { //Set the legend for the new proposal on top of the map in the upper right corner. LegendItem titleLegendItem = new LegendItem(); titleLegendItem.TextStyle = new TextStyle("New Proposal", new GeoFont("Arial", 10, DrawingFontStyles.Bold), new GeoSolidBrush(GeoColors.Black)); LegendItem legendItem1 = new LegendItem(); legendItem1.ImageStyle = new AreaStyle(new GeoPen(GeoColors.DarkGreen, 4), new GeoSolidBrush(GeoColors.Transparent)); legendItem1.TextStyle = new TextStyle("Approved", new GeoFont("Arial", 8), new GeoSolidBrush(GeoColors.Black)); LegendItem legendItem2 = new LegendItem(); legendItem2.ImageStyle = new AreaStyle(new GeoPen(GeoColors.DarkRed, 4), new GeoSolidBrush(GeoColors.Transparent)); legendItem2.TextStyle = new TextStyle("In Discussion", new GeoFont("Arial", 8), new GeoSolidBrush(GeoColors.Black)); LegendAdornmentLayer legendAdornmentLayer = new LegendAdornmentLayer(); legendAdornmentLayer.BackgroundMask = new AreaStyle(new GeoPen(GeoColors.Black, 1), GeoBrushes.White); legendAdornmentLayer.Height = 100; legendAdornmentLayer.Width = 140; legendAdornmentLayer.Title = titleLegendItem; legendAdornmentLayer.LegendItems.Add(legendItem1); legendAdornmentLayer.LegendItems.Add(legendItem2); LegendPrinterLayer legendPrinterLayer = new LegendPrinterLayer(legendAdornmentLayer); legendPrinterLayer.SetPosition(2, 1, 2.9, 3.9, PrintingUnit.Inch); PrinterInteractiveOverlay printerInteractiveOverlay = (PrinterInteractiveOverlay)mapView.InteractiveOverlays["PrintPreviewOverlay"]; printerInteractiveOverlay.PrinterLayers.Add("LegendPrinterLayer2", legendPrinterLayer); }
private void btnPan_Click(object sender, EventArgs e) { // Grab the MapPrinterLayer and adjust the extent PrinterInteractiveOverlay printerOverlay = (PrinterInteractiveOverlay)Map1.InteractiveOverlays["PrintPreviewOverlay"]; MapPrinterLayer mapPrinterLayer = ((MapPrinterLayer)(printerOverlay.PrinterLayers["MapLayer"])); if (sender == btnPanNorth) { mapPrinterLayer.MapExtent = MapUtil.Pan(mapPrinterLayer.MapExtent, PanDirection.Up, 30); } else if (sender == btnPanSouth) { mapPrinterLayer.MapExtent = MapUtil.Pan(mapPrinterLayer.MapExtent, PanDirection.Down, 30); } else if (sender == btnPanWest) { mapPrinterLayer.MapExtent = MapUtil.Pan(mapPrinterLayer.MapExtent, PanDirection.Left, 30); } else if (sender == btnPanEast) { mapPrinterLayer.MapExtent = MapUtil.Pan(mapPrinterLayer.MapExtent, PanDirection.Right, 30); } Map1.Refresh(); }
private void Map1_MapClick(object sender, MapClickMapViewEventArgs e) { // Here we loop through all of the PrinterLayers to find the one the user right mouse clicked on. // Then we show the right click menu to give the user some options if (e.MouseButton == MapMouseButton.Right) { ((MenuItem)Map1.ContextMenu.Items[0]).IsEnabled = false; ((MenuItem)Map1.ContextMenu.Items[1]).IsEnabled = false; PrinterInteractiveOverlay printerOverlay = (PrinterInteractiveOverlay)Map1.InteractiveOverlays["PrintPreviewOverlay"]; for (int i = printerOverlay.PrinterLayers.Count - 1; i >= 0; i--) { if (printerOverlay.PrinterLayers[i].GetType() != typeof(PagePrinterLayer)) { RectangleShape boundingBox = printerOverlay.PrinterLayers[i].GetPosition(); if (boundingBox.Contains(e.WorldLocation)) { ((MenuItem)Map1.ContextMenu.Items[0]).Tag = printerOverlay.PrinterLayers[i]; ((MenuItem)Map1.ContextMenu.Items[0]).IsEnabled = true; ((MenuItem)Map1.ContextMenu.Items[1]).Tag = printerOverlay.PrinterLayers[i]; ((MenuItem)Map1.ContextMenu.Items[1]).IsEnabled = true; break; } } } } }
private void SetupMapWithBlankPage() { // Setup the map unit, you want to always use feet or meters for the printer layout map. mapView.MapUnit = GeographyUnit.Meter; // Here we create the default zoom levels for the sample. We have pre-created a PrinterZoomLevelSet // That pre-defines commonly used zoom levels based on percentages of zoom mapView.ZoomLevelSet = new PrinterZoomLevelSet(mapView.MapUnit, PrinterHelper.GetPointsPerGeographyUnit(mapView.MapUnit)); // Here we set the background color to gray so there is contrast with the white page mapView.Background = System.Windows.Media.Brushes.White; // Create the PrinterInteractiveOverlay to contain all of the PrinterLayers. // The interactive overlay allows the layers to be interacted with PrinterInteractiveOverlay printerOverlay = new PrinterInteractiveOverlay(); mapView.InteractiveOverlays.Add("PrintPreviewOverlay", printerOverlay); mapView.InteractiveOverlays.MoveToBottom("PrintPreviewOverlay"); // Create the PagePrinterLayer which shows the page boundary and is the area the user will // arrange all of the other layer on top of. PagePrinterLayer pagePrinterLayer = new PagePrinterLayer(PrinterPageSize.AnsiA, PrinterOrientation.Portrait); pagePrinterLayer.Open(); pagePrinterLayer.BackgroundMask = new AreaStyle(new GeoPen(GeoColors.LightGray, 1), GeoBrushes.White); printerOverlay.PrinterLayers.Add("PageLayer", pagePrinterLayer); // Get the pages extent, slightly scale it up, and then set that as the default current extent mapView.CurrentExtent = pagePrinterLayer.GetPosition().GetBoundingBox(); // Set the minimum sscale of the map to the last zoom level mapView.MinimumScale = mapView.ZoomLevelSet.ZoomLevel20.Scale; }
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 AddLegendLayer() { LegendItem title = new LegendItem(); title.TextStyle = new TextStyle("Map Legend", new GeoFont("Arial", 10, DrawingFontStyles.Bold), new GeoSolidBrush(GeoColors.Black)); LegendItem legendItem1 = new LegendItem(); legendItem1.ImageStyle = new AreaStyle(new GeoSolidBrush(GeoColor.FromArgb(170, GeoColors.Green))); legendItem1.TextStyle = new TextStyle("Population > 70 million", new GeoFont("Arial", 8), new GeoSolidBrush(GeoColors.Black)); LegendItem legendItem2 = new LegendItem(); legendItem2.ImageStyle = AreaStyle.CreateSimpleAreaStyle(GeoColors.Green); legendItem2.TextStyle = new TextStyle("Population < 70 million", new GeoFont("Arial", 8), new GeoSolidBrush(GeoColors.Black)); LegendAdornmentLayer legendAdornmentLayer = new LegendAdornmentLayer(); legendAdornmentLayer.Height = 100; legendAdornmentLayer.Title = title; legendAdornmentLayer.LegendItems.Add(legendItem1); legendAdornmentLayer.LegendItems.Add(legendItem2); LegendPrinterLayer legendPrinterLayer = new LegendPrinterLayer(legendAdornmentLayer); legendPrinterLayer.SetPosition(2, 1, -2.9, 3.9, PrintingUnit.Inch); legendPrinterLayer.BackgroundMask = AreaStyle.CreateSimpleAreaStyle(new GeoColor(255, 230, 230, 230), GeoColors.Black, 1); PrinterInteractiveOverlay printerInteractiveOverlay = (PrinterInteractiveOverlay)Map1.InteractiveOverlays["PrintPreviewOverlay"]; printerInteractiveOverlay.PrinterLayers.Add("LegendPrinterLayer", legendPrinterLayer); }
private void EditLayer_Click(object sender, RoutedEventArgs e) { PrinterInteractiveOverlay printerInteractiveOverlay = (PrinterInteractiveOverlay)Map1.InteractiveOverlays["PrintPreviewOverlay"]; PrinterLayer printerLayer = (PrinterLayer)((MenuItem)sender).Tag; ShowPrinterLayerProperties(printerLayer); Map1.Refresh(); }
private RectangleShape GetPageBoundingBox(PrintingUnit unit) { // This helper method gets the pages bounding box in the unit requested PrinterInteractiveOverlay printerInteractiveOverlay = (PrinterInteractiveOverlay)mapView.InteractiveOverlays["PrintPreviewOverlay"]; PagePrinterLayer pagePrinterLayer = (PagePrinterLayer)printerInteractiveOverlay.PrinterLayers["PageLayer"]; return(pagePrinterLayer.GetPosition(unit));; }
private void RemoveLayer_Click(object sender, RoutedEventArgs e) { PrinterInteractiveOverlay printerInteractiveOverlay = (PrinterInteractiveOverlay)Map1.InteractiveOverlays["PrintPreviewOverlay"]; PrinterLayer printerLayer = (PrinterLayer)((MenuItem)sender).Tag; printerInteractiveOverlay.PrinterLayers.Remove(printerLayer); Map1.Refresh(); }
private void AddMapLayer() { // Create the MapPrinterLayer and set the position MapPrinterLayer mapPrinterLayer = new MapPrinterLayer(); mapPrinterLayer.MapUnit = GeographyUnit.Meter; mapPrinterLayer.MapExtent = new RectangleShape(-20026376.39, 20048966.10, 20026376.39, -20048966.10); mapPrinterLayer.BackgroundMask = new AreaStyle(new GeoPen(GeoColors.Black, 1)); mapPrinterLayer.Open(); // Set the maps position slightly below the pages center and 8 inches wide and 7 inches tall RectangleShape pageBoundingbox = GetPageBoundingBox(PrintingUnit.Inch); mapPrinterLayer.SetPosition(8, 7, pageBoundingbox.GetCenterPoint().X, pageBoundingbox.GetCenterPoint().Y + 1, PrintingUnit.Inch); // Setup the intial extent and ensure they snap to the default ZoomLevel ZoomLevelSet zoomLevelSet = new ZoomLevelSet(); mapPrinterLayer.MapExtent = MapUtil.ZoomToScale(zoomLevelSet.ZoomLevel03.Scale, new RectangleShape(-20026376.39, 20048966.10, 20026376.39, -20048966.10), mapPrinterLayer.MapUnit, (float)mapPrinterLayer.GetBoundingBox().Width, (float)mapPrinterLayer.GetBoundingBox().Height); // This ThinkGeo Cloud test key is exclusively for demonstration purposes and is limited to requesting base map // tiles only. Do not use it in your own applications, as it may be restricted or disabled without prior notice. // Please visit https://cloud.thinkgeo.com to create a free key for your own use. //ThinkGeoCloudRasterMapsLayer worldMapKitLayer = new ThinkGeoCloudRasterMapsLayer("itZGOI8oafZwmtxP-XGiMvfWJPPc-dX35DmESmLlQIU~", "bcaCzPpmOG6le2pUz5EAaEKYI-KSMny_WxEAe7gMNQgGeN9sqL12OA~~"); //worldMapKitLayer.TileCache = null; //mapPrinterLayer.Layers.Add(worldMapKitLayer); ShapeFileFeatureLayer backgroundLayer = new ShapeFileFeatureLayer(@"data/Countries02_3857.shp", FileAccess.Read); backgroundLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; backgroundLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyle.CreateSimpleAreaStyle(GeoColors.White, GeoColors.Black); mapPrinterLayer.Layers.Add(backgroundLayer); // Setup the Countries mapping layer ShapeFileFeatureLayer shapefileFeatureLayer = new ShapeFileFeatureLayer(@"data/Countries02_3857.shp", FileAccess.Read); shapefileFeatureLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; //Create the class break style for countries less than 70 million ClassBreakStyle classBreakStyle = new ClassBreakStyle("POP_CNTRY"); // Create the style and class break for countries with greater and 70 million AreaStyle hatchAreaStyle = new AreaStyle(new GeoSolidBrush(GeoColor.FromArgb(100, GeoColors.Green))); classBreakStyle.ClassBreaks.Add(new ClassBreak(70000000, hatchAreaStyle)); // Add the class break style to the layer shapefileFeatureLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(classBreakStyle); // Add the new country layer to the MapPrinterLayer mapPrinterLayer.Layers.Add(shapefileFeatureLayer); // Add the MapPrinterLayer to the PrinterInteractiveOverlay PrinterInteractiveOverlay printerInteractiveOverlay = (PrinterInteractiveOverlay)Map1.InteractiveOverlays["PrintPreviewOverlay"]; printerInteractiveOverlay.PrinterLayers.Add("MapLayer", mapPrinterLayer); }
private void AddMapLayer() { // Create the MapPrinterLayer and set the position MapPrinterLayer mapPrinterLayer = new MapPrinterLayer(); //Map Printer Layer is in feet (State Plane Texas North Central Feet NAD83) mapPrinterLayer.MapUnit = GeographyUnit.Feet; //Set the extent of the MapPrinterLayer with world coordinates. RectangleShape currentExtent = new RectangleShape(2276456, 6897886, 2280391, 6895437); mapPrinterLayer.MapExtent = currentExtent; mapPrinterLayer.BackgroundMask = new AreaStyle(new GeoPen(GeoColors.Black, 1)); mapPrinterLayer.Open(); // Set the maps position slightly above the page center and 8 inches wide and 7 inches tall RectangleShape pageBoundingbox = GetPageBoundingBox(PrintingUnit.Inch); mapPrinterLayer.SetPosition(8, 7, pageBoundingbox.GetCenterPoint().X, pageBoundingbox.GetCenterPoint().Y + 1, PrintingUnit.Inch); //Setup the styles for the parcels layer. ShapeFileFeatureLayer parcelsLayer = new ShapeFileFeatureLayer(@"..\..\..\Data\Shapefile\parcels.shp", FileAccess.Read); //Creates a value style for the parcel type (residential 1, commercial 2, industrial 3). ValueStyle typeValueStyle = new ValueStyle(); typeValueStyle.ColumnName = "PARCELTYPE"; typeValueStyle.ValueItems.Add(new ValueItem("1", new AreaStyle(new GeoPen(GeoColors.Black), new GeoSolidBrush(GeoColors.PastelGreen)))); typeValueStyle.ValueItems.Add(new ValueItem("2", new AreaStyle(new GeoPen(GeoColors.Black), new GeoSolidBrush(GeoColors.PastelOrange)))); typeValueStyle.ValueItems.Add(new ValueItem("3", new AreaStyle(new GeoPen(GeoColors.Black), new GeoSolidBrush(GeoColors.PastelBlue)))); parcelsLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(typeValueStyle); //Creates a value style for affected parcels by new proposal ValueStyle affectedValueStyle = new ValueStyle(); affectedValueStyle.ColumnName = "AFFECTED"; affectedValueStyle.ValueItems.Add(new ValueItem("YES", new AreaStyle(new GeoPen(GeoColors.DarkGreen, 4), new GeoSolidBrush(GeoColors.Transparent)))); affectedValueStyle.ValueItems.Add(new ValueItem("D", new AreaStyle(new GeoPen(GeoColors.DarkRed, 4), new GeoSolidBrush(GeoColors.Transparent)))); parcelsLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(affectedValueStyle); //Creates a text style to display tax id of parcels TextStyle textStyle = new TextStyle("TAXPIN", new GeoFont("Arial", 12, DrawingFontStyles.Bold), new GeoSolidBrush(GeoColors.Black)); textStyle.HaloPen = new GeoPen(GeoColors.White, 2); parcelsLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(textStyle); parcelsLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; // Add the new parcels layer to the MapPrinterLayer mapPrinterLayer.Layers.Add(parcelsLayer); // Add the MapPrinterLayer to the PrinterInteractiveOverlay PrinterInteractiveOverlay printerInteractiveOverlay = (PrinterInteractiveOverlay)mapView.InteractiveOverlays["PrintPreviewOverlay"]; printerInteractiveOverlay.PrinterLayers.Add("MapLayer", mapPrinterLayer); }
private void btnToBitmap_Click(object sender, RoutedEventArgs e) { PrinterInteractiveOverlay printerInteractiveOverlay = (PrinterInteractiveOverlay)Map1.InteractiveOverlays["PrintPreviewOverlay"]; PagePrinterLayer pagePrinterLayer = printerInteractiveOverlay.PrinterLayers["PageLayer"] as PagePrinterLayer; // Create a bitmap that is the size of the pages bounding box. The page by default is in points unit // system which is very similar to pixels so that ampping is nice. GeoImage bitmap = null; try { bitmap = new GeoImage((int)pagePrinterLayer.GetBoundingBox().Width, (int)pagePrinterLayer.GetBoundingBox().Height); // Create a GeoCanvas and start the drawing GeoCanvas gdiPlusGeoCanvas = GeoCanvas.CreateDefaultGeoCanvas(); gdiPlusGeoCanvas.BeginDrawing(bitmap, pagePrinterLayer.GetBoundingBox(), Map1.MapUnit); // Loop through all of the PrintingLayer in the PrinterInteractiveOverlay and print all of the // except for the PagePrinterLayer Collection <SimpleCandidate> labelsInAllLayers = new Collection <SimpleCandidate>(); foreach (PrinterLayer printerLayer in printerInteractiveOverlay.PrinterLayers) { printerLayer.IsDrawing = true; if (!(printerLayer is PagePrinterLayer)) { printerLayer.Draw(gdiPlusGeoCanvas, labelsInAllLayers); } printerLayer.IsDrawing = false; } // End the drawing gdiPlusGeoCanvas.EndDrawing(); //Save the resulting bitmap to a file and open the file to show the user string filename = "PrintingResults.bmp"; bitmap.Save(filename); Process.Start("explorer.exe", filename); } catch (Exception ex) { MessageBox.Show(ex.Message + " " + ex.StackTrace, "Exception"); } finally { if (bitmap != null) { bitmap.Dispose(); } } }
private void btnZoomOut_Click(object sender, RoutedEventArgs e) { // Grab the MapPrinterLayer and adjust the extent PrinterInteractiveOverlay printerOverlay = (PrinterInteractiveOverlay)Map1.InteractiveOverlays["PrintPreviewOverlay"]; MapPrinterLayer mapPrinterLayer = ((MapPrinterLayer)(printerOverlay.PrinterLayers["MapLayer"])); // Here we snap the current scale to the default zoomLevelSet when we zoom in ZoomLevelSet zoomLevelSet = new ZoomLevelSet(); double newScale = ZoomLevelSet.GetHigherZoomLevelScale(MapUtil.GetScale(mapPrinterLayer.MapExtent, (float)mapPrinterLayer.GetBoundingBox().Width, mapPrinterLayer.MapUnit), zoomLevelSet); mapPrinterLayer.MapExtent = MapUtil.ZoomToScale(newScale, mapPrinterLayer.MapExtent, mapPrinterLayer.MapUnit, (float)mapPrinterLayer.GetBoundingBox().Width, (float)mapPrinterLayer.GetBoundingBox().Height); Map1.Refresh(); }
private void AddLogoImage() { //Load the image to a GeoImage and then create the ImagePrinterLayer using that image GeoImage compassGeoImage = new GeoImage(@"..\..\..\Resources\Compass.png"); ImagePrinterLayer imagePrinterLayer = new ImagePrinterLayer(compassGeoImage); // Set the imagePrinterLayer position offset from the page center and .75 inches wide and .75 inches tall RectangleShape pageBoundingbox = GetPageBoundingBox(PrintingUnit.Inch); imagePrinterLayer.SetPosition(.75, .75, pageBoundingbox.GetCenterPoint().X + 3.5, pageBoundingbox.GetCenterPoint().Y - 2.0, PrintingUnit.Inch); // Add the imagePrinterLayer to the PrinterInteractiveOverlay PrinterInteractiveOverlay printerInteractiveOverlay = (PrinterInteractiveOverlay)mapView.InteractiveOverlays["PrintPreviewOverlay"]; printerInteractiveOverlay.PrinterLayers.Add("ImageLayer", imagePrinterLayer); }
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 AddCenteredMapTitles() { RectangleShape pageBoundingbox = GetPageBoundingBox(PrintingUnit.Inch); //For the main title LabelPrinterLayer titleLabelPrinterLayer = new LabelPrinterLayer(); //Setup the text and the font.. titleLabelPrinterLayer.Text = "Tarrant County Parcels"; titleLabelPrinterLayer.Font = new GeoFont("Verdana", 8); titleLabelPrinterLayer.TextBrush = new GeoSolidBrush(GeoColors.Black); // Set the title position so that is it centered on the page. PointShape titleCenterPointShape = new PointShape(); titleCenterPointShape.X = pageBoundingbox.UpperRightPoint.X - pageBoundingbox.Width / 2; titleCenterPointShape.Y = pageBoundingbox.UpperLeftPoint.Y - 0.3; titleLabelPrinterLayer.PrinterWrapMode = PrinterWrapMode.AutoSizeText; titleLabelPrinterLayer.SetPosition(3, 0.5, titleCenterPointShape, PrintingUnit.Inch); //For the subtitle LabelPrinterLayer subTitleLabelPrinterLayer = new LabelPrinterLayer(); //Setup the text and the font.. subTitleLabelPrinterLayer.Text = "Affected Parcels By New Proposal"; subTitleLabelPrinterLayer.Font = new GeoFont("Arial", 2, DrawingFontStyles.Bold); subTitleLabelPrinterLayer.TextBrush = new GeoSolidBrush(GeoColors.Black); // Set the sub title position so that is it centered on the page below the title. PointShape subtitleCenterPointShape = new PointShape(); subtitleCenterPointShape.X = pageBoundingbox.UpperRightPoint.X - pageBoundingbox.Width / 2; subtitleCenterPointShape.Y = pageBoundingbox.UpperLeftPoint.Y - 0.6; subTitleLabelPrinterLayer.PrinterWrapMode = PrinterWrapMode.AutoSizeText; subTitleLabelPrinterLayer.SetPosition(3, 0.3, subtitleCenterPointShape, PrintingUnit.Inch); // Find the PrinterInteractiveOverlay so we can add the new LabelPrinterLayer PrinterInteractiveOverlay printerInteractiveOverlay = (PrinterInteractiveOverlay)mapView.InteractiveOverlays["PrintPreviewOverlay"]; printerInteractiveOverlay.PrinterLayers.Add("titleLabelPrinterLayer", titleLabelPrinterLayer); printerInteractiveOverlay.PrinterLayers.Add("subtitleLabelPrinterLayer", subTitleLabelPrinterLayer); }
private void btnToPrintPreview_Click(object sender, RoutedEventArgs e) { PrinterInteractiveOverlay printerInteractiveOverlay = (PrinterInteractiveOverlay)Map1.InteractiveOverlays["PrintPreviewOverlay"]; PagePrinterLayer pagePrinterLayer = printerInteractiveOverlay.PrinterLayers["PageLayer"] as PagePrinterLayer; PrintDialog printDialog = new PrintDialog(); PrintDocument printDocument = new PrintDocument(); printDocument.DefaultPageSettings.Landscape = true; if (pagePrinterLayer.Orientation == PrinterOrientation.Portrait) { printDocument.DefaultPageSettings.Landscape = false; } printDocument.DefaultPageSettings.PaperSize = GetPrintPreviewPaperSize(pagePrinterLayer); PrinterGeoCanvas printerGeoCanvas = new PrinterGeoCanvas(); printerGeoCanvas.DrawingArea = printDocument.DefaultPageSettings.Bounds; printerGeoCanvas.BeginDrawing(printDocument, pagePrinterLayer.GetBoundingBox(), Map1.MapUnit); // Loop through all of the PrintingLayer in the PrinterInteractiveOverlay and print all of the // except for the PagePrinterLayer Collection <SimpleCandidate> labelsInAllLayers = new Collection <SimpleCandidate>(); foreach (PrinterLayer printerLayer in printerInteractiveOverlay.PrinterLayers) { printerLayer.IsDrawing = true; if (!(printerLayer is PagePrinterLayer)) { printerLayer.Draw(printerGeoCanvas, labelsInAllLayers); } printerLayer.IsDrawing = false; } printerGeoCanvas.Flush(); System.Windows.Forms.PrintPreviewDialog printPreviewDialog = new System.Windows.Forms.PrintPreviewDialog(); printPreviewDialog.Document = printDocument; System.Windows.Forms.DialogResult dialogResult = printPreviewDialog.ShowDialog(); }
private void AddLegendLayer1() { //Set the legend for the parcel type on top of the map in the upper left corner. LegendItem titleLegendItem = new LegendItem(); titleLegendItem.TextStyle = new TextStyle("Parcel Types", new GeoFont("Arial", 10, DrawingFontStyles.Bold), new GeoSolidBrush(GeoColors.Black)); LegendItem legendItem1 = new LegendItem(); legendItem1.ImageStyle = new AreaStyle(new GeoPen(GeoColors.Black), new GeoSolidBrush(GeoColors.PastelGreen)); legendItem1.TextStyle = new TextStyle("Residential", new GeoFont("Arial", 8), new GeoSolidBrush(GeoColors.Black)); LegendItem legendItem2 = new LegendItem(); legendItem2.ImageStyle = new AreaStyle(new GeoPen(GeoColors.Black), new GeoSolidBrush(GeoColors.PastelRed)); legendItem2.TextStyle = new TextStyle("Industrial", new GeoFont("Arial", 8), new GeoSolidBrush(GeoColors.Black)); LegendItem legendItem3 = new LegendItem(); legendItem3.ImageStyle = new AreaStyle(new GeoPen(GeoColors.Black), new GeoSolidBrush(GeoColors.PastelBlue)); legendItem3.TextStyle = new TextStyle("Commerial", new GeoFont("Arial", 8), new GeoSolidBrush(GeoColors.Black)); LegendAdornmentLayer legendAdornmentLayer = new LegendAdornmentLayer(); legendAdornmentLayer.BackgroundMask = new AreaStyle(new GeoPen(GeoColors.Black, 1), GeoBrushes.White); legendAdornmentLayer.Height = 250; legendAdornmentLayer.Width = 250; legendAdornmentLayer.Title = titleLegendItem; legendAdornmentLayer.LegendItems.Add(legendItem1); legendAdornmentLayer.LegendItems.Add(legendItem2); legendAdornmentLayer.LegendItems.Add(legendItem3); LegendPrinterLayer legendPrinterLayer = new LegendPrinterLayer(legendAdornmentLayer); legendPrinterLayer.SetPosition(2, 1.2, -2.9, 3.8, PrintingUnit.Inch); PrinterInteractiveOverlay printerInteractiveOverlay = (PrinterInteractiveOverlay)mapView.InteractiveOverlays["PrintPreviewOverlay"]; printerInteractiveOverlay.PrinterLayers.Add("LegendPrinterLayer1", legendPrinterLayer); }
private void AddGridTitle2() { //Set the grid tile for approved parcels on top of the right grid. RectangleShape pageBoundingbox = GetPageBoundingBox(PrintingUnit.Inch); //For the grid title LabelPrinterLayer gridTitleLabelPrinterLayer = new LabelPrinterLayer(); //Setup the text and the font.. gridTitleLabelPrinterLayer.Text = "Parcels In Discussion"; gridTitleLabelPrinterLayer.Font = new GeoFont("Arial", 8, DrawingFontStyles.Bold); gridTitleLabelPrinterLayer.TextBrush = new GeoSolidBrush(GeoColors.Black); // Set the title position so that is it centered on the page one inch from the top and to the right gridTitleLabelPrinterLayer.PrinterWrapMode = PrinterWrapMode.AutoSizeText; gridTitleLabelPrinterLayer.SetPosition(3, 0.5, new PointShape(2.25, pageBoundingbox.GetCenterPoint().Y - 2.9), PrintingUnit.Inch); // Find the PrinterInteractiveOverlay so we can add the new LabelPrinterLayer PrinterInteractiveOverlay printerInteractiveOverlay = (PrinterInteractiveOverlay)mapView.InteractiveOverlays["PrintPreviewOverlay"]; printerInteractiveOverlay.PrinterLayers.Add("gridtitle2LabelPrinterLayer", gridTitleLabelPrinterLayer); }
private void cbxOrientation_SelectionChanged(object sender, SelectionChangedEventArgs e) { // When the orientation combobox is changed then we update the PagePrinterLayer to reflect the changes if (this.IsLoaded) { PrinterInteractiveOverlay printerInteractiveOverlay = (PrinterInteractiveOverlay)Map1.InteractiveOverlays["PrintPreviewOverlay"]; PagePrinterLayer pagePrinterLayer = (PagePrinterLayer)printerInteractiveOverlay.PrinterLayers["PageLayer"]; string selectText = ((ComboBoxItem)e.AddedItems[0]).Content.ToString(); if (selectText.ToUpper() == "LANDSCAPE") { pagePrinterLayer.Orientation = PrinterOrientation.Landscape; } else if (selectText.ToUpper() == "PORTRAIT") { pagePrinterLayer.Orientation = PrinterOrientation.Portrait; } Map1.Refresh(); } }
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); }
private void AddScaleLineLayer() { // Get the PrinterInteractiveOverlay PrinterInteractiveOverlay printerInteractiveOverlay = (PrinterInteractiveOverlay)mapView.InteractiveOverlays["PrintPreviewOverlay"]; // Grab the MapPrinterLayer as we need to pass that into the scaleLinePrinterLayer so it // can be synced up to the map itself in real-time MapPrinterLayer mapPrinterLayer = (MapPrinterLayer)printerInteractiveOverlay.PrinterLayers["MapLayer"]; //Create the scaleLinePrinterLayer and pass in the MapPrinterLayer ScaleLinePrinterLayer scaleLinePrinterLayer = new ScaleLinePrinterLayer(mapPrinterLayer); scaleLinePrinterLayer.MapUnit = GeographyUnit.Feet; // Set the scale line position offset from the page center and 1.25 inches wide and .25 inches tall RectangleShape pageBoundingbox = GetPageBoundingBox(PrintingUnit.Inch); scaleLinePrinterLayer.SetPosition(1.25, .25, pageBoundingbox.GetCenterPoint().X - 3.25, pageBoundingbox.GetCenterPoint().Y - 2.25, PrintingUnit.Inch); // Add the ScaleLinePrinterLayer to the PrinterInteractiveOverlay printerInteractiveOverlay.PrinterLayers.Add("ScaleLineLayer", scaleLinePrinterLayer); }
private void btnPrint_Click(object sender, RoutedEventArgs e) { PrinterInteractiveOverlay printerInteractiveOverlay = (PrinterInteractiveOverlay)mapView.InteractiveOverlays["PrintPreviewOverlay"]; PagePrinterLayer pagePrinterLayer = printerInteractiveOverlay.PrinterLayers["PageLayer"] as PagePrinterLayer; PrintDocument printDocument = new PrintDocument(); printDocument.DefaultPageSettings.Landscape = true; if (pagePrinterLayer.Orientation == PrinterOrientation.Portrait) { printDocument.DefaultPageSettings.Landscape = false; } printDocument.DefaultPageSettings.PaperSize = new PaperSize("AnsiA", 850, 1100); PrinterGeoCanvas printerGeoCanvas = new PrinterGeoCanvas(); printerGeoCanvas.DrawingArea = new Rectangle(0, 0, Convert.ToInt32(printDocument.DefaultPageSettings.PrintableArea.Width), Convert.ToInt32(printDocument.DefaultPageSettings.PrintableArea.Height)); printerGeoCanvas.BeginDrawing(printDocument, pagePrinterLayer.GetBoundingBox(), mapView.MapUnit); // Loop through all of the PrintingLayer in the PrinterInteractiveOverlay and print all of the // except for the PagePrinterLayer Collection <SimpleCandidate> labelsInAllLayers = new Collection <SimpleCandidate>(); foreach (PrinterLayer printerLayer in printerInteractiveOverlay.PrinterLayers) { printerLayer.IsDrawing = true; if (!(printerLayer is PagePrinterLayer)) { printerLayer.Draw(printerGeoCanvas, labelsInAllLayers); } printerLayer.IsDrawing = false; } printerGeoCanvas.EndDrawing(); }
private void AddCenteredTitleLabel() { LabelPrinterLayer labelPrinterLayer = new LabelPrinterLayer(); //Setup the text and the font.. labelPrinterLayer.Text = "Population > 70 Million"; labelPrinterLayer.Font = new GeoFont("Arial", 10, DrawingFontStyles.Bold); labelPrinterLayer.TextBrush = new GeoSolidBrush(GeoColors.Black); // Set the labels position so that is it centered on the page one inch from the top RectangleShape pageBoundingbox = GetPageBoundingBox(PrintingUnit.Inch); PointShape labelCenter = new PointShape(); labelCenter.X = pageBoundingbox.UpperRightPoint.X - pageBoundingbox.Width / 2; labelCenter.Y = pageBoundingbox.UpperLeftPoint.Y - .5; labelPrinterLayer.PrinterWrapMode = PrinterWrapMode.AutoSizeText; labelPrinterLayer.SetPosition(5, 1, labelCenter, PrintingUnit.Inch); // Find the PrinterInteractiveOverlay so we can add the new LabelPrinterLayer PrinterInteractiveOverlay printerInteractiveOverlay = (PrinterInteractiveOverlay)Map1.InteractiveOverlays["PrintPreviewOverlay"]; printerInteractiveOverlay.PrinterLayers.Add("LabelLayer", labelPrinterLayer); }
private static void SetLegendIsPrinting(bool isPrinting, PrinterInteractiveOverlay printerOverlay) { printerOverlay.PrinterLayers.OfType <GisEditorLegendPrinterLayer>().ForEach(l => l.IsPrinting = isPrinting); }
private static void SetDescriptionLabelVisible(bool visible, PrinterInteractiveOverlay printerOverlay) { printerOverlay.PrinterLayers.Where(IsSimplifyMapPrinterLayer).OfType <SimplifyMapPrinterLayer>().ForEach(l => l.DrawDescription = visible); }