Hello,
In printing I let the user to zoom in and zoom out using custom buttons. I use this code:
private
void
ZoomCommandExecute(ZoomType type)
{
var printerOverlay = (PrinterInteractiveOverlay) MapControl.InteractiveOverlays[PrintPreviewOverlayKey];
var mapPrinterLayer = ((MapPrinterLayer) (printerOverlay.PrinterLayers[MapLayerKey]));
double
currentScale = ExtentHelper.GetScale(mapPrinterLayer.MapExtent,
(
float
) mapPrinterLayer.GetBoundingBox().Width, mapPrinterLayer.MapUnit);
double
newScale = type == ZoomType.ZoomIn
? ZoomLevelSet.GetLowerZoomLevelScale(currentScale, _zoomLevelSet)
: ZoomLevelSet.GetHigherZoomLevelScale(currentScale, _zoomLevelSet);
//newScale = type == ZoomType.ZoomIn ? newScale : newScale/2;
if
(IsDebug)
{
Debug.WriteLine(type +
" “
+ newScale+
” "
+currentScale);
}
mapPrinterLayer.MapExtent = ExtentHelper.ZoomToScale(newScale, mapPrinterLayer.MapExtent,
mapPrinterLayer.MapUnit, (
float
) mapPrinterLayer.GetBoundingBox().Width,
(
float
) mapPrinterLayer.GetBoundingBox().Height);
MapControl.Refresh();
}
This works as expected but zoom steps is big. I am trying to reduce the zoom step but wasn’t successful.
The second argument of ZoomLevelSet.GetLowerZoomLevelScale is ZoomLevelSet. What is the role of this? I tried to update scale of zoomlevels for mentioned ZoomLevelSet using below code:
private void UpdateZoomStep(IList<
ScaleSettings.ScaleItem
> scaleItems)
{
if (scaleItems == null || !scaleItems.Any()) return;
var zoomSet = new ZoomLevelSet();
Collection<
ZoomLevel
> zoomLevels = zoomSet.GetZoomLevels();
int index = 0;
foreach (ZoomLevel zoomLevel in zoomLevels)
{
ScaleSettings.ScaleItem scaleItem = scaleItems[index++];
zoomLevel.Scale = scaleItem.Value;
zoomLevel.Name = scaleItem.LevelName;
}
_zoomLevelSet = zoomSet;
MapControl.ZoomLevelSet = _zoomLevelSet;
MapControl.MinimumScale = scaleItems.Min(s => s.Value);
}
It updates zoom levels successfully, however it doesn’t affect GetLowerZoomLevelScale and GetHigherZoomLevelScale functions.
Any Idea how can I get it to work?
Thanks in advance,
Shahin