Zoom mini map?
#1
Question 
There is no sample about Zoom mini map.

Zoom panel does not support Zoom mini map ?
#2
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:

Code:
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;
    MainGrid.Children.Add(zoomPanelMiniMapCanvas);
}

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);
    bmp.Render(content);

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

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

    _zoomPanelMiniMapCanvas.Children.Add(zoomPanelImage);
    _zoomPanelMiniMapCanvas.Children.Add(_zoomPanelMiniMapRectangle);

    UpdateMiniMapRectangle(ZoomPanel1.Viewbox);

    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
    UpdateMiniMapRectangle(e.NewViewboxValue);
}

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 ?
  


Forum Jump:


Users browsing this thread:
1 Guest(s)