Zoom in ZoomPanel, using input in ZoomPanelMiniMap
#1
Hi

Is it possible to catch input (mousedown and touch) in ZoomPanelMiniMap, center display in ZoomPanel using this input, and updating ZoomPanelMiniMap to show the new position?

The feature of dragging the ViewBox around is nice, but it is not something we can use for our customers.

I played around with your sample, but it is hard to get things working with the amount of documentation that comes with it
#2
You can set the CenterPosition of the ZoomPanel to the position of the mouse / touch.

For example the following code does the trick and support touch and mouse down/move (ZoomPanel1 is the name of the ZoomPanel control):

XAML (disable standard rectangle moving and mouse wheel zoom and subscribe touch and mouse events):
Code:
<ab2d:ZoomPanelMiniMap Name="MiniMap1"
                       IsMovingViewboxEnabled="False"
                       IsMouseWheelZoomEnabled="False"
                       TouchMove="MiniMap1_OnTouchMove"
                       MouseDown="MiniMap1_OnMouseDown"
                       MouseMove="MiniMap1_OnMouseMove"/>

c#:
Code:
private void MiniMap1_OnTouchMove(object sender, TouchEventArgs e)
{
    var touchPoint = e.GetTouchPoint(MiniMap1);

    ZoomPanel1.CenterPosition = new Point(touchPoint.Position.X / MiniMap1.ActualWidth,
                                          touchPoint.Position.Y / MiniMap1.ActualHeight);
}

private void MiniMap1_OnMouseMove(object sender, MouseEventArgs e)
{
    if (e.LeftButton != MouseButtonState.Pressed)
        return;

    var mousePoint = e.GetPosition(MiniMap1);

    ZoomPanel1.CenterPosition = new Point(mousePoint.X / MiniMap1.ActualWidth,
                                          mousePoint.Y / MiniMap1.ActualHeight);
}

private void MiniMap1_OnMouseDown(object sender, MouseButtonEventArgs e)
{
    var mousePoint = e.GetPosition(MiniMap1);

    ZoomPanel1.CenterPosition = new Point(mousePoint.X / MiniMap1.ActualWidth,
                                          mousePoint.Y / MiniMap1.ActualHeight);          
}
Andrej Benedik
#3
Hi

Very nice implementation, thank you for that. After having tested using this code, I came to realise another challenge that may be simple for you to handle.

The zoomable area is in your sample your extension of a canvas. In our product it would be a Window. When I test your product it behaves as if the area is a canvas, so it is possible to "scroll" outside of the actual window. It is like the minimap and zoomcontrol treats a Window as endless.

What I would like is the minimap to treat the window as it is, a window with "ends"/boundaries. Is it possible? I've tried to play around with the sample project but can't seem to get it to work

//Martin


(02-20-2015, 11:38 PM)abenedik Wrote: You can set the CenterPosition of the ZoomPanel to the position of the mouse / touch.

For example the following code does the trick and support touch and mouse down/move (ZoomPanel1 is the name of the ZoomPanel control):

XAML (disable standard rectangle moving and mouse wheel zoom and subscribe touch and mouse events):
Code:
<ab2d:ZoomPanelMiniMap Name="MiniMap1"
                       IsMovingViewboxEnabled="False"
                       IsMouseWheelZoomEnabled="False"
                       TouchMove="MiniMap1_OnTouchMove"
                       MouseDown="MiniMap1_OnMouseDown"
                       MouseMove="MiniMap1_OnMouseMove"/>

c#:
Code:
private void MiniMap1_OnTouchMove(object sender, TouchEventArgs e)
{
    var touchPoint = e.GetTouchPoint(MiniMap1);

    ZoomPanel1.CenterPosition = new Point(touchPoint.Position.X / MiniMap1.ActualWidth,
                                          touchPoint.Position.Y / MiniMap1.ActualHeight);
}

private void MiniMap1_OnMouseMove(object sender, MouseEventArgs e)
{
    if (e.LeftButton != MouseButtonState.Pressed)
        return;

    var mousePoint = e.GetPosition(MiniMap1);

    ZoomPanel1.CenterPosition = new Point(mousePoint.X / MiniMap1.ActualWidth,
                                          mousePoint.Y / MiniMap1.ActualHeight);
}

private void MiniMap1_OnMouseDown(object sender, MouseButtonEventArgs e)
{
    var mousePoint = e.GetPosition(MiniMap1);

    ZoomPanel1.CenterPosition = new Point(mousePoint.X / MiniMap1.ActualWidth,
                                          mousePoint.Y / MiniMap1.ActualHeight);          
}
  


Forum Jump:


Users browsing this thread:
1 Guest(s)