public LegendItemViewModel Clone() { LegendItemViewModel newItem = new LegendItemViewModel { NotifiedGeoFont = NotifiedGeoFont.Clone(), BackgroundMask = BackgroundMask == null ? null : (AreaStyle)BackgroundMask.CloneDeep(), BottomPadding = BottomPadding, Height = Height, ImageBottomPadding = ImageBottomPadding, ImageHeight = ImageHeight, ImageJustificationMode = ImageJustificationMode, ImageLeftPadding = ImageLeftPadding, ImageMask = ImageMask == null ? null : (AreaStyle)ImageMask.CloneDeep(), ImageRightPadding = ImageRightPadding, //ImageStyle = ImageStyle.CloneDeep(), ImageTopPadding = ImageTopPadding, ImageWidth = ImageWidth, LeftPadding = LeftPadding, LegendItemType = LegendItemType, TextBottomPadding = TextBottomPadding, TextLeftPadding = TextLeftPadding, TextMask = TextMask == null ? null : (AreaStyle)TextMask.CloneDeep(), TextRightPadding = TextRightPadding, TextSolidBrush = TextSolidBrush, TextTopPadding = TextTopPadding, Text = this.Text, TopPadding = TopPadding, Width = Width, Parent = Parent }; if (ImageStyle != null) { newItem.ImageStyle = ImageStyle.CloneDeep(); } return(newItem); }
private void DrawInternal(GeoCanvas canvas, Collection <SimpleCandidate> labelsInAllLayers) { RectangleShape currentBoundingBox = GetBoundingBox(); AreaStyle brushStyle = BackgroundMask.CloneDeep() as AreaStyle; brushStyle.OutlinePen.Width = 0; brushStyle.Draw(new BaseShape[] { currentBoundingBox }, canvas, new Collection <SimpleCandidate>(), labelsInAllLayers); // Clear Cache images if (LastmapExtent != null) { if (LastmapExtent.UpperLeftPoint.X != MapExtent.UpperLeftPoint.X || LastmapExtent.UpperLeftPoint.Y != MapExtent.UpperLeftPoint.Y || LastmapExtent.LowerRightPoint.X != MapExtent.LowerRightPoint.X || LastmapExtent.LowerRightPoint.Y != MapExtent.LowerRightPoint.Y || IsDrawing) { mapImageCache = null; } } //For adjusting the world extent of the map to the ratio of the drawing area. RectangleShape adjustedWorldExtent = ExtentHelper.GetDrawingExtent(MapExtent, (float)currentBoundingBox.Width, (float)currentBoundingBox.Height); RectangleShape boundingBox = GetBoundingBox(); PointShape ajustedWorldCenter = adjustedWorldExtent.GetCenterPoint(); PageGeoCanvas pageGeoCanvas = new PageGeoCanvas(new RectangleShape(0, boundingBox.Height, boundingBox.Width, 0), currentBoundingBox); //if (EnableClipping) //{ // pageGeoCanvas.EnableCliping = true; // pageGeoCanvas.ClipingArea = adjustedWorldExtent; //} //if (canvas is GdiPlusGeoCanvas && DrawingMode != Core.DrawingMode.Vector) // only display on map. if (DrawingMode != MapPrinterDrawingMode.Vector && !(canvas is PrinterGeoCanvas)) { double width = boundingBox.Width / canvas.CurrentWorldExtent.Width * canvas.Width; double height = boundingBox.Height / canvas.CurrentWorldExtent.Height * canvas.Height; GeoImage image = GetCacheImage(pageGeoCanvas, canvas.MapUnit, adjustedWorldExtent, labelsInAllLayers, width, height); pageGeoCanvas.BeginDrawing(canvas, adjustedWorldExtent, MapUnit); if (image != null) { pageGeoCanvas.DrawWorldImage(image, ajustedWorldCenter.X, ajustedWorldCenter.Y, (float)boundingBox.Width - 0.5f, (float)boundingBox.Height - 0.5f, DrawingLevel.LabelLevel); } if (DrawDescription) { DrawDescriptionText(pageGeoCanvas); } //pageGeoCanvas.EnableCliping = false; pageGeoCanvas.EndDrawing(); } // display on map or printer. else { pageGeoCanvas.BeginDrawing(canvas, adjustedWorldExtent, MapUnit); double increase = 0; if (BackgroundMask.OutlinePen != null) { float haflPenWidth = BackgroundMask.OutlinePen.Width / 2; increase = haflPenWidth * canvas.CurrentWorldExtent.Width / canvas.Width; } canvas.ClippingArea = new RectangleShape( currentBoundingBox.UpperLeftPoint.X - increase, currentBoundingBox.UpperLeftPoint.Y + increase, currentBoundingBox.LowerRightPoint.X + increase, currentBoundingBox.LowerRightPoint.Y - increase); if (canvas is PrinterGeoCanvas) { foreach (Layer layer in Layers) { pageGeoCanvas.Flush(); float savedDrawingMarginPercentage = 0; FeatureLayer featureLayer = layer as FeatureLayer; if (featureLayer != null) { savedDrawingMarginPercentage = featureLayer.DrawingMarginInPixel; featureLayer.DrawingMarginInPixel = 0; } layer.SafeProcess(() => { layer.Draw(pageGeoCanvas, labelsInAllLayers); }); if (featureLayer != null && savedDrawingMarginPercentage != 0) { featureLayer.DrawingMarginInPixel = savedDrawingMarginPercentage; } } } else { using (MemoryStream ms = GetImageStream(canvas, labelsInAllLayers, adjustedWorldExtent, boundingBox)) { pageGeoCanvas.DrawWorldImage(new GeoImage(ms), ajustedWorldCenter.X, ajustedWorldCenter.Y, (float)boundingBox.Width - 0.5f, (float)boundingBox.Height - 0.5f, DrawingLevel.LabelLevel); } //foreach (Layer layer in Layers) //{ // pageGeoCanvas.Flush(); // layer.SafeProcess(() => // { // layer.Draw(pageGeoCanvas, labelsInAllLayers); // }); //} } if (DrawDescription) { DrawDescriptionText(pageGeoCanvas); } //pageGeoCanvas.EnableCliping = false; var areaStyle = new AreaStyle(BackgroundMask.OutlinePen) { DrawingLevel = DrawingLevel.LabelLevel }; areaStyle.Draw(new BaseShape[1] { currentBoundingBox }, canvas, new Collection <SimpleCandidate>(), labelsInAllLayers); canvas.ClippingArea = null; } AreaStyle lineStyle = new AreaStyle(BackgroundMask.OutlinePen.CloneDeep()); lineStyle.DrawingLevel = DrawingLevel.LabelLevel; lineStyle.Draw(new BaseShape[] { currentBoundingBox }, canvas, new Collection <SimpleCandidate>(), labelsInAllLayers); LastmapExtent = new RectangleShape(MapExtent.UpperLeftPoint.X, MapExtent.UpperLeftPoint.Y, MapExtent.LowerRightPoint.X, MapExtent.LowerRightPoint.Y); }