public void UpdateScale(bool forceUpdate = false)
{
if (Poi.NEffectiveStyle.ScalePoi == null || !Poi.NEffectiveStyle.ScalePoi.Value) return;
double maxScale = Poi.NEffectiveStyle.MaxScale ?? 4;
double scaleUnits = Poi.NEffectiveStyle.ScaleUnits ?? 50;
double scaleStartResolution = Poi.NEffectiveStyle.ScaleStartResolution ?? 50;
var currRes = AppState.ViewDef.MapControl.Resolution;
var scale = Math.Min(Math.Max(1, scaleUnits * currRes / scaleStartResolution), maxScale);
if (!forceUpdate && lastScale == scale) return;
if (Poi == null) return;
double height;
double width;
if (Poi != null)
{
height = Poi.NEffectiveStyle.IconHeight == null ? 32.0 : Poi.NEffectiveStyle.IconHeight.Value;
width = Poi.NEffectiveStyle.IconWidth == null ? 32.0 : Poi.NEffectiveStyle.IconWidth.Value;
}
else
{
height = 32.0;
width = 32.0;
}
if (Poi != null && Poi.Data != null && Poi.Data.ContainsKey("graphic"))
{
var staticGraphic = Poi.Data["graphic"] as StaticGraphic;
if (staticGraphic != null)
{
var symbol = staticGraphic.Symbol as SimpleMarkerSymbol;
if (symbol != null)
{
if (currRes > scaleStartResolution)
{
symbol.Size = height / scale;
}
else
{
symbol.Size = height;
}
}
}
}
if (Symbol is PictureMarkerSymbol)
{
var pms = (PictureMarkerSymbol)Symbol;
if (currRes > scaleStartResolution)
{
pms.Width = width / scale;
pms.Height = height / scale;
//pms.Width *= 0.85f;
//pms.Height *= 0.85f;
}
else
{
pms.Width = width;
pms.Height = height;
}
pms.OffsetX = pms.Width / 2;
pms.OffsetY = pms.Height / 2;
}
if (ImageGraphic != null)
{
var pms = (PictureMarkerSymbol)ImageGraphic.Symbol;
if (currRes > scaleStartResolution)
{
pms.Width = width / scale;
pms.Height = height / scale;
//pms.Width *= 0.85f;
//pms.Height *= 0.85f;
if (ImageGraphic.MapTip == null)
{
ImageGraphic.MapTip = new Label() { Content = Poi.Labels.ContainsKey(Poi.NEffectiveStyle.NameLabel) ? Poi.Labels[Poi.NEffectiveStyle.NameLabel] : string.Empty };
}
}
else
{
//pms.Width = width * 0.85f;
//pms.Height = height * 0.85f;
ImageGraphic.MapTip = null;
}
pms.OffsetX = pms.Width / 2;
pms.OffsetY = pms.Height / 2;
}
if (LabelGraphic != null && LabelGraphic.Geometry != null && currRes > Poi.NEffectiveStyle.MaxTitleResolution)
{
LabelGraphic.Geometry = null;
}
else if (Visible && LabelGraphic != null && LabelGraphic.Geometry == null && currRes < Poi.NEffectiveStyle.MaxTitleResolution)
{
LabelGraphic.Geometry = BaseGeometry;
MapTip = null;
}
lastScale = scale;
}