AB4D Forum
Zoom mini map? - Printable Version

+- AB4D Forum (https://forum.ab4d.com)
+-- Forum: Products Forums (https://forum.ab4d.com/forumdisplay.php?fid=4)
+--- Forum: ZoomPanel (https://forum.ab4d.com/forumdisplay.php?fid=8)
+--- Thread: Zoom mini map? (/showthread.php?tid=11)

Zoom mini map? - hoyong - 10-19-2009

There is no sample about Zoom mini map.

Zoom panel does not support Zoom mini map ?

RE: Zoom mini map? - abenedik - 10-20-2009

In the current version of ZoomPanel there is no mini map included.
But it could be a nice feature - I have added it to my todo list and will implement it in the new version (cannot say when it will be available).

I have prepared a code to implement a simple mini map by yourself:

private void Page_Loaded(object sender, RoutedEventArgs e)
    ZoomPanel1.ZoomMode = Ab2d.Controls.ZoomPanel.ZoomModeType.Move;

    Canvas zoomPanelMiniMapCanvas;

    zoomPanelMiniMapCanvas = CreateMinimap(200);

    zoomPanelMiniMapCanvas.VerticalAlignment = VerticalAlignment.Center;
    zoomPanelMiniMapCanvas.HorizontalAlignment = HorizontalAlignment.Left;

private Canvas _zoomPanelMiniMapCanvas;
private Rectangle _zoomPanelMiniMapRectangle;

private Canvas CreateMinimap(int width)
    int height;
    Image zoomPanelImage;
    FrameworkElement content;

    content = ZoomPanel1.Content as FrameworkElement;

    if (content == null)
        return _zoomPanelMiniMapCanvas;

    // Adjust height for aspect ratio
    height = Convert.ToInt32(width * content.ActualHeight / content.ActualWidth);

    _zoomPanelMiniMapCanvas.Width = width;
    _zoomPanelMiniMapCanvas.Height = height;

    RenderTargetBitmap bmp = new RenderTargetBitmap(width, height, 96, 96 /* standard WPF dpi setting 96 */, PixelFormats.Pbgra32);

    zoomPanelImage = new Image();
    zoomPanelImage.Source = bmp;

    _zoomPanelMiniMapRectangle = new Rectangle();
    _zoomPanelMiniMapRectangle.Stroke = Brushes.Red;



    ZoomPanel1.ViewboxChanged += new Ab2d.Controls.ZoomPanel.ViewboxChangedRoutedEventHandler(ZoomPanel1_ViewboxChanged);

    return _zoomPanelMiniMapCanvas;

void ZoomPanel1_ViewboxChanged(object sender, Ab2d.Controls.ViewboxChangedRoutedEventArgs e)
    // NOTE that if ZoomPanel is animated, the ZoomPanel1.Viewbox is not yet changed to the final value because the animation is just started
    // The e.NewViewboxValue is already the final value

private void UpdateMiniMapRectangle(Rect ZoomPanelviewbox)
    Canvas.SetLeft(_zoomPanelMiniMapRectangle, ZoomPanelviewbox.X * _zoomPanelMiniMapCanvas.Width);
    Canvas.SetTop(_zoomPanelMiniMapRectangle, ZoomPanelviewbox.Y * _zoomPanelMiniMapCanvas.Height);

    _zoomPanelMiniMapRectangle.Width = ZoomPanelviewbox.Width * _zoomPanelMiniMapCanvas.Width;
    _zoomPanelMiniMapRectangle.Height = ZoomPanelviewbox.Height * _zoomPanelMiniMapCanvas.Height;

(10-19-2009, 03:53 AM)hoyong Wrote: There is no sample about Zoom mini map.

Zoom panel does not support Zoom mini map ?