protected internal override void ConfigureMapItem(SCMap map, MapItem item) { base.ConfigureMapItem(map, item); var mapItem = item as MapPolygon ?? throw new Exception("Map item must be MapPolygon."); if (Image != null || !string.IsNullOrWhiteSpace(ImageFile)) { if (Image != null) { mapItem.Image.Source = Image; } else if (!string.IsNullOrWhiteSpace(ImageFile)) { var imageFile = Project.Current.MapPath(ImageFile); if (string.IsNullOrWhiteSpace(imageFile) || !File.Exists(ImageFile)) { throw new Exception($"Cannot find file: {ImageFile}"); } mapItem.Image.Source = Image.FromFile(ImageFile); } if (ImageTransparency.HasValue) { mapItem.Image.Transparency = ImageTransparency.Value; } } }
protected internal virtual void UpdateMiniMap(SCMap map) { var miniMap = new MiniMap() { EnableScrolling = false, EnableZooming = false, SetMapCenterOnClick = false }; if (Alignment > 0) { miniMap.Alignment = (DevExpress.XtraMap.MiniMapAlignment)Alignment; } if (Width.HasValue) { miniMap.Width = Width.Value; } if (Height.HasValue) { miniMap.Height = Height.Value; } if (ZoomLevel != 1.0 || CenterPoint != null) { var behavior = new FixedMiniMapBehavior(); if (CenterPoint != null) { if (CenterPoint.Length != 2) { throw new Exception("CenterPoint shall be a double array with 2 elements."); } behavior.CenterPoint = map.CreateCoordPoint(CenterPoint[0], CenterPoint[1]); } if (ZoomLevel != 1.0) { behavior.ZoomLevel = ZoomLevel; } miniMap.Behavior = behavior; } var backColor = Utils.ColorFromString(BackColor); if (backColor != Color.Empty) { miniMap.ViewportStyle.Fill = backColor; } var strokeColor = Utils.ColorFromString(StrokeColor); if (strokeColor != Color.Empty) { miniMap.ViewportStyle.Stroke = strokeColor; } map.Map.MiniMap = miniMap; map.Map.PrintOptions.PrintMiniMap = true; }
protected internal override void ConfigureMapItem(SCMap map, MapItem item) { base.ConfigureMapItem(map, item); var mapItem = item as MapPolyline ?? throw new Exception("Map item must be MapPolyline."); mapItem.IsGeodesic = Geodesic; }
protected internal override void ConfigureMapItem(SCMap map, MapItem item) { base.ConfigureMapItem(map, item); var mapItem = item as MapCallout ?? throw new Exception("Map item must be MapCallout."); mapItem.AllowHtmlText = HtmlText; }
protected internal virtual void ConfigureMapItem(SCMap map, MapItem item) { var layer = map.GetLayer(Layer) as VectorItemsLayer ?? throw new Exception("Cannot determine layer. Map items can be added only to recent vector items layer created with cmdlet Add-MapLayerVectorItems."); var storage = layer.Data as MapItemStorage ?? throw new Exception("Current vector items layer cannot be used for custom items. Create new layer using cmdlet Add-MapLayerVectorItems."); storage.Items.Add(item); }
protected internal virtual void ConfigurePointerItem(SCMap map, MapPointer pointer, double[] location, string text) { if (location == null || location.Length != 2) { throw new Exception("Location must be double array with 2 elements."); } pointer.Location = map.CreateCoordPoint(location[0], location[1]); pointer.Text = text; ConfigureMapItem(map, pointer); }
protected internal override void ConfigureMapItem(SCMap map, DevExpress.XtraMap.MapItem item) { base.ConfigureMapItem(map, item); var mapItem = item as MapDot ?? throw new Exception("Map item must be MapDot."); if (Size.HasValue) { mapItem.Size = Size.Value; } if (ShapeKind.HasValue) { mapItem.ShapeKind = (DevExpress.XtraMap.MapDotShapeKind)ShapeKind.Value; } }
protected internal virtual void CreateLayer(SCMap map, InformationDataProviderBase provider) { var layer = new InformationLayer() { EnableHighlighting = false, EnableSelection = false }; if (layer.DataProvider == null) { layer.DataProvider = provider; } map.Map.Layers.Add(layer); map.CurrentLayer = layer; }
protected internal override void ConfigureMapItem(SCMap map, MapItem item) { base.ConfigureMapItem(map, item); var mapItem = item as MapShape ?? throw new Exception("Map item must be MapShape."); var fillColor = Utils.ColorFromString(FillColor); if (fillColor != Color.Empty) { mapItem.Fill = fillColor; } var strokeColor = Utils.ColorFromString(StrokeColor); if (strokeColor != Color.Empty) { mapItem.Stroke = strokeColor; } if (StrokeWidth.HasValue) { mapItem.StrokeWidth = StrokeWidth.Value; } if (!string.IsNullOrWhiteSpace(Title)) { mapItem.Attributes.Add(new MapItemAttribute() { Name = "Title", Value = Title }); mapItem.TitleOptions.Pattern = "{Title}"; var titleColor = Utils.ColorFromString(TitleColor); if (titleColor != Color.Empty) { mapItem.TitleOptions.TextColor = titleColor; } var titleGlowColor = Utils.ColorFromString(TitleGlowColor); if (titleGlowColor != Color.Empty) { mapItem.TitleOptions.TextGlowColor = titleGlowColor; } } }
protected internal virtual void UpdateLayerImage(SCMap map, MapImageDataProviderBase provider) { if (!MiniMap) { var layer = new ImageLayer() { DataProvider = provider, EnableAntialiasing = DevExpress.Utils.DefaultBoolean.True, }; if (Transparency.HasValue) { layer.Transparency = Transparency.Value; } if (!string.IsNullOrWhiteSpace(Name)) { layer.Name = Name; } map.Map.Layers.Add(layer); map.CurrentLayer = layer; } else { var dataProvider = provider as MapDataProviderBase ?? throw new Exception("MiniMap does not support selected data provider."); var layerMini = new MiniMapImageTilesLayer() { DataProvider = dataProvider }; if (!string.IsNullOrWhiteSpace(Name)) { layerMini.Name = Name; } if (map.Map.MiniMap == null) { throw new Exception("Mini map is not created."); } map.Map.MiniMap.Layers.Add(layerMini); map.CurrentLayer = layerMini; } }
protected internal virtual void UpdateMap(SCMap map) { var layer = map.GetLayer(Layer) as VectorItemsLayer ?? throw new Exception("Cannot determine layer. Map items can be added only to vector items layer created with command AddMapLayerVectorItems."); var dataAdapter = layer.Data as MapDataAdapterBase ?? throw new Exception("Cannot apply clusterer to current layer."); var clusterer = (Type ?? ClustererType.Distance) switch { ClustererType.Distance => (MapClustererBase) new DistanceBasedClusterer(), ClustererType.Marker => (MapClustererBase) new MarkerClusterer(), _ => throw new Exception("Unrecognized clusterer type.") }; clusterer.DisplayNonClusteredItems = DisplayNonClusteredItems; if (ItemMaxSize.HasValue) { clusterer.ItemMaxSize = ItemMaxSize.Value; } if (ItemMinSize.HasValue) { clusterer.ItemMinSize = ItemMinSize.Value; } if (Size.HasValue) { clusterer.StepInPixels = Size.Value; } if (!string.IsNullOrWhiteSpace(GroupField)) { clusterer.GroupProvider = new AttributeGroupProvider() { AttributeName = GroupField } } ; dataAdapter.Clusterer = clusterer; } }
protected internal override void ConfigureMapItem(SCMap map, DevExpress.XtraMap.MapItem item) { base.ConfigureMapItem(map, item); var mapItem = item as MapBubble ?? throw new Exception("Map item must be MapBubble."); mapItem.Argument = Argument; if (Value.HasValue) { mapItem.Value = Value.Value; } if (Group.HasValue) { mapItem.Group = Group.Value; } if (MarkerType.HasValue) { mapItem.MarkerType = (DevExpress.XtraMap.MarkerType)MarkerType.Value; } }
protected internal override void ConfigurePointerItem(SCMap map, MapPointer pointer, double[] location, string text) { base.ConfigurePointerItem(map, pointer, location, text); var mapItem = pointer as MapCustomElement ?? throw new Exception("Map item must be MapCustomElement."); mapItem.AllowHtmlText = HtmlText; if (Padding != null) { if (Padding.Length == 1) { mapItem.Padding = new Padding(Padding[0]); } else if (Padding.Length == 4) { mapItem.Padding = new Padding(Padding[0], Padding[1], Padding[2], Padding[3]); } else { throw new Exception("Invalid padding. Padding shall be an array with 1 or 4 integer values."); } } if (RenderOrigin != null && RenderOrigin.Length == 2) { mapItem.RenderOrigin = new MapPoint(RenderOrigin[0], RenderOrigin[1]); } else if (RenderOrigin != null) { throw new Exception("Invalid render origin. Render origin shall be an array with 2 double values."); } var textGlowColor = Utils.ColorFromString(TextGlowColor); if (textGlowColor != Color.Empty) { mapItem.TextGlowColor = textGlowColor; } }
protected internal override void ConfigureMapItem(SCMap map, MapItem item) { base.ConfigureMapItem(map, item); var mapItem = item as MapPushpin ?? throw new Exception("Map item must be MapPushpin."); var textGlowColor = Utils.ColorFromString(TextGlowColor); if (textGlowColor != Color.Empty) { mapItem.TextGlowColor = textGlowColor; } if (TextOrigin != null && TextOrigin.Length == 2) { mapItem.TextOrigin = new Point(TextOrigin[0], TextOrigin[1]); } else if (TextOrigin != null) { throw new Exception("Invalid text origin. Text origin shall be an array with 2 integer values."); } }
protected internal virtual void UpdateMap(SCMap map, string valueField, double[] rangeStops, string[] colors) { var layer = map.GetLayer(Layer) as VectorItemsLayer ?? throw new Exception("Cannot determine layer. Map items can be added only to vector items layer created with command AddMapLayerVectorItems."); if (string.IsNullOrWhiteSpace(valueField)) { throw new Exception("ValueField cannot be empty."); } if (rangeStops == null || rangeStops.Length < 1) { throw new Exception("Range stops cannot be empty."); } if (colors == null || colors.Length < 1) { throw new Exception("Colors cannot be empty."); } var colorizer = new ChoroplethColorizer { ValueProvider = new ShapeAttributeValueProvider() { AttributeName = valueField }, ApproximateColors = this.ApproximateColors, PredefinedColorSchema = PredefinedColorSchema.Palette }; foreach (var col in colors) { var color = Utils.ColorFromString(col); if (color == Color.Empty) { throw new Exception($"Color '{col}' is not valid."); } colorizer.ColorItems.Add(new ColorizerColorItem(color)); } colorizer.RangeStops.AddRange(rangeStops); switch (RangeDistribution ?? ColorizerRangeDistribution.Linear) { case ColorizerRangeDistribution.Linear: colorizer.RangeDistribution = new LinearRangeDistribution(); break; case ColorizerRangeDistribution.Logarithmic: var logDistribution = new LogarithmicRangeDistribution(); if (RangeDistributionFactor.HasValue) { logDistribution.Factor = RangeDistributionFactor.Value; } colorizer.RangeDistribution = logDistribution; break; case ColorizerRangeDistribution.Exponential: var expDistribution = new ExponentialRangeDistribution(); if (RangeDistributionFactor.HasValue) { expDistribution.Factor = RangeDistributionFactor.Value; } colorizer.RangeDistribution = expDistribution; break; } layer.Colorizer = colorizer; }
protected internal virtual void UpdateMapLegend(SCMap map, ItemsLayerLegend legend) { var layer = map.GetLayer(LayerName) as VectorItemsLayer ?? throw new Exception("Cannot determine layer. Map items can be added only to recent vector items layer created with cmdlet Add-MapLayerVectorItems."); legend.Layer = layer; if (Alignment.HasValue) { legend.Alignment = (DevExpress.XtraMap.LegendAlignment)Alignment.Value; } var backColor = Utils.ColorFromString(BackColor); if (backColor != Color.Empty) { legend.BackgroundStyle.Fill = backColor; } var backStrokeColor = Utils.ColorFromString(BackStrokeColor); if (backStrokeColor != Color.Empty) { legend.BackgroundStyle.Stroke = backStrokeColor; } if (StrokeWidth.HasValue) { legend.BackgroundStyle.StrokeWidth = StrokeWidth.Value; } legend.Description = Description; var fontDescription = Utils.StringToFont(DescriptionFont, out Color descriptionColor); if (fontDescription != null) { legend.DescriptionStyle.Font = fontDescription; } if (descriptionColor != Color.Empty) { legend.DescriptionStyle.TextColor = descriptionColor; } legend.Header = Header; var fontHeader = Utils.StringToFont(HeaderFont, out Color headerColor); if (fontHeader != null) { legend.HeaderStyle.Font = fontHeader; } if (headerColor != Color.Empty) { legend.HeaderStyle.TextColor = headerColor; } var fontItem = Utils.StringToFont(ItemFont, out Color itemColor); if (fontItem != null) { legend.ItemStyle.Font = fontItem; } if (itemColor != Color.Empty) { legend.ItemStyle.TextColor = itemColor; } if (!string.IsNullOrWhiteSpace(RangeStopsFormat)) { legend.RangeStopsFormat = RangeStopsFormat; } if (legend is ColorListLegend listLegend) { if (SortOrder.HasValue) { listLegend.SortOrder = (DevExpress.XtraMap.LegendItemsSortOrder)SortOrder.Value; } } if (legend is SizeLegend sizeLegend) { sizeLegend.ShowTickMarks = !HideTickMarks; } map.Map.Legends.Add(legend); }
protected internal virtual void UpdateMapOverlay(SCMap map) { if (Position != null && Position.Length != 2) { throw new Exception("Position shall be an integer array with 2 elements."); } if (Margin != null && Margin.Length != 4 && Margin.Length != 1) { throw new Exception("Margin shall be an integer array with 1 or 4 elements."); } if (Padding != null && Padding.Length != 4 && Padding.Length != 1) { throw new Exception("Padding shall be an integer array with 1 or 4 elements."); } if (Size != null && Size.Length != 2) { throw new Exception("Size shall be an integer array with 2 elements."); } if (ImageMargin != null && ImageMargin.Length != 4 && ImageMargin.Length != 1) { throw new Exception("ImageMargin shall be an integer array with 1 or 4 elements."); } if (ImagePadding != null && ImagePadding.Length != 4 && ImagePadding.Length != 1) { throw new Exception("ImagePadding shall be an integer array with 1 or 4 elements."); } if (TextMargin != null && TextMargin.Length != 4 && TextMargin.Length != 1) { throw new Exception("TextMargin shall be an integer array with 1 or 4 elements."); } if (TextPadding != null && TextPadding.Length != 4 && TextMargin.Length != 1) { throw new Exception("TextPadding shall be an integer array with 1 or 4 elements."); } var overlay = new MapOverlay(); if (Alignment.HasValue) { overlay.Alignment = Alignment.Value; } var backColor = Utils.ColorFromString(BackColor); if (backColor != Color.Empty) { overlay.BackgroundStyle.Fill = backColor; } if (Position != null) { overlay.Location = new Point(Position[0], Position[1]); } if (Margin != null) { overlay.Margin = GetPadding(Margin); } if (Padding != null) { overlay.Padding = GetPadding(Padding); } if (Size != null) { overlay.Size = new Size(Size[0], Size[1]); } if (Image != null || !string.IsNullOrWhiteSpace(ImageFile) || ImageIndex.HasValue) { var imageItem = new MapOverlayImageItem(); if (ImageAlignment.HasValue) { imageItem.Alignment = ImageAlignment.Value; } if (ImageMargin != null) { imageItem.Margin = GetPadding(ImageMargin); } if (ImagePadding != null) { imageItem.Padding = GetPadding(ImagePadding); } if (Image != null) { imageItem.Image = Image; } else if (!string.IsNullOrWhiteSpace(ImageFile)) { var imageFile = Project.Current.MapPath(ImageFile); if (string.IsNullOrWhiteSpace(imageFile) || !File.Exists(ImageFile)) { throw new Exception($"Cannot find file: {ImageFile}"); } imageItem.ImageUri = new Uri($"file://{imageFile}"); } else if (ImageIndex.HasValue) { imageItem.ImageIndex = ImageIndex.Value; } if (backColor != Color.Empty) { imageItem.BackgroundStyle.Fill = backColor; } overlay.Items.Add(imageItem); } if (!string.IsNullOrWhiteSpace(Text)) { if (TextAlignment == 0) { TextAlignment = (Image != null || !string.IsNullOrWhiteSpace(ImageFile) || ImageIndex.HasValue) ? ContentAlignment.MiddleRight : ContentAlignment.MiddleCenter; } var textItem = new MapOverlayTextItem(); if (TextAlignment.HasValue) { textItem.Alignment = TextAlignment.Value; } if (TextMargin != null) { textItem.Margin = GetPadding(TextMargin); } if (TextPadding != null) { textItem.Padding = GetPadding(TextPadding); } textItem.Text = Text; var font = Utils.StringToFont(Font, out Color foreColor); if (font != null) { textItem.TextStyle.Font = font; } if (foreColor != Color.Empty) { textItem.TextStyle.TextColor = foreColor; } else if (backColor == Color.Empty) { textItem.TextStyle.TextColor = Color.White; } if (backColor != Color.Empty) { textItem.BackgroundStyle.Fill = backColor; } overlay.Items.Add(textItem); } map.Map.Overlays.Add(overlay); map.Map.PrintOptions.PrintOverlays = true;
protected internal virtual void CreateLayer(SCMap map, InformationDataProviderBase provider) { var layer = new InformationLayer() { EnableHighlighting = false, EnableSelection = false, DataProvider = provider }; if (!string.IsNullOrWhiteSpace(Name)) { layer.Name = Name; } if (!string.IsNullOrWhiteSpace(ShapeTitlesPattern)) { layer.ShapeTitlesPattern = ShapeTitlesPattern; layer.ShapeTitlesVisibility = VisibilityMode.Visible; } if (ItemImageIndex.HasValue) { layer.ItemImageIndex = ItemImageIndex.Value; } var itemStyle = layer.ItemStyle; var fillColor = Utils.ColorFromString(FillColor); if (fillColor != Color.Empty) { itemStyle.Fill = fillColor; } var font = Utils.StringToFont(Font, out Color textColor); if (font != null) { itemStyle.Font = font; } if (textColor != Color.Empty) { itemStyle.TextColor = textColor; } var strokeColor = Utils.ColorFromString(StrokeColor); if (strokeColor != Color.Empty) { itemStyle.Stroke = strokeColor; } if (StrokeWidth.HasValue) { itemStyle.StrokeWidth = StrokeWidth.Value; } var textGlowColor = Utils.ColorFromString(TextGlowColor); if (textGlowColor != Color.Empty) { itemStyle.TextGlowColor = textGlowColor; } if (layer.DataProvider == null) { layer.DataProvider = provider; } map.Map.Layers.Add(layer); map.CurrentLayer = layer; }
protected internal override void ConfigureMapItem(SCMap map, MapItem item) { base.ConfigureMapItem(map, item); var mapItem = item as MapPointer ?? throw new Exception("Map item must be MapPointer."); mapItem.BackgroundDrawingMode = DrawBackground ? ElementState.All : ElementState.None; var fillColor = Utils.ColorFromString(FillColor); if (fillColor != Color.Empty) { mapItem.Fill = fillColor; } var font = Utils.StringToFont(Font, out Color textColor); if (font != null) { mapItem.Font = font; } if (textColor != Color.Empty) { mapItem.TextColor = textColor; } if (Image != null) { mapItem.Image = Image; } if (ImageIndex.HasValue) { mapItem.ImageIndex = ImageIndex.Value; } if (!string.IsNullOrWhiteSpace(ImageFilename)) { var imagePath = Project.Current.MapPath(ImageFilename); if (string.IsNullOrWhiteSpace(imagePath) || !System.IO.File.Exists(imagePath)) { throw new Exception($"Cannot find image: '{imagePath}'."); } var bmp = new Bitmap(imagePath); mapItem.Image = bmp; } if (TextAlignment.HasValue) { mapItem.TextAlignment = (DevExpress.XtraMap.TextAlignment)TextAlignment.Value; } if (TextPadding.HasValue) { mapItem.TextPadding = TextPadding.Value; } if (Transparency.HasValue) { mapItem.Transparency = Transparency.Value; } }