Version 1.3.1: Added Map.ManipulationMode property.

This commit is contained in:
ClemensF 2013-05-08 17:05:17 +02:00
parent ba9edb14cc
commit 0f4e7d643e
20 changed files with 73 additions and 36 deletions

View file

@ -12,11 +12,13 @@ namespace MapControl
/// </summary>
public class Map : MapBase
{
public static readonly DependencyProperty MouseWheelZoomChangeProperty = DependencyProperty.Register(
"MouseWheelZoomChange", typeof(double), typeof(Map), new PropertyMetadata(1d));
private Point? mousePosition;
public Map()
{
MouseWheelZoomChange = 1d;
MouseWheel += OnMouseWheel;
MouseLeftButtonDown += OnMouseLeftButtonDown;
MouseLeftButtonUp += OnMouseLeftButtonUp;
@ -26,7 +28,11 @@ namespace MapControl
/// <summary>
/// Gets or sets the amount by which the ZoomLevel property changes during a MouseWheel event.
/// </summary>
public double MouseWheelZoomChange { get; set; }
public double MouseWheelZoomChange
{
get { return (double)GetValue(MouseWheelZoomChangeProperty); }
set { SetValue(MouseWheelZoomChangeProperty, value); }
}
private void OnMouseWheel(object sender, MouseWheelEventArgs e)
{

View file

@ -12,17 +12,36 @@ namespace MapControl
/// </summary>
public class Map : MapBase
{
public static readonly DependencyProperty ManipulationModeProperty = DependencyProperty.Register(
"ManipulationMode", typeof(ManipulationModes), typeof(Map), new PropertyMetadata(ManipulationModes.All));
public static readonly DependencyProperty MouseWheelZoomChangeProperty = DependencyProperty.Register(
"MouseWheelZoomChange", typeof(double), typeof(Map), new PropertyMetadata(1d));
private Point? mousePosition;
public Map()
static Map()
{
MouseWheelZoomChange = 1d;
IsManipulationEnabledProperty.OverrideMetadata(typeof(Map), new FrameworkPropertyMetadata(true));
}
/// <summary>
/// Gets or sets a value that specifies how the map control handles manipulations.
/// </summary>
public ManipulationModes ManipulationMode
{
get { return (ManipulationModes)GetValue(ManipulationModeProperty); }
set { SetValue(ManipulationModeProperty, value); }
}
/// <summary>
/// Gets or sets the amount by which the ZoomLevel property changes during a MouseWheel event.
/// </summary>
public double MouseWheelZoomChange { get; set; }
public double MouseWheelZoomChange
{
get { return (double)GetValue(MouseWheelZoomChangeProperty); }
set { SetValue(MouseWheelZoomChangeProperty, value); }
}
protected override void OnMouseWheel(MouseWheelEventArgs e)
{
@ -65,6 +84,13 @@ namespace MapControl
}
}
protected override void OnManipulationStarted(ManipulationStartedEventArgs e)
{
base.OnManipulationStarted(e);
Manipulation.SetManipulationMode(this, ManipulationMode);
}
protected override void OnManipulationDelta(ManipulationDeltaEventArgs e)
{
base.OnManipulationDelta(e);

View file

@ -4,6 +4,7 @@
using Windows.Devices.Input;
using Windows.Foundation;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Input;
namespace MapControl
@ -13,11 +14,13 @@ namespace MapControl
/// </summary>
public class Map : MapBase
{
public static readonly DependencyProperty MouseWheelZoomChangeProperty = DependencyProperty.Register(
"MouseWheelZoomChange", typeof(double), typeof(Map), new PropertyMetadata(1d));
private Point? mousePosition;
public Map()
{
MouseWheelZoomChange = 1d;
ManipulationMode = ManipulationModes.All;
ManipulationDelta += OnManipulationDelta;
PointerWheelChanged += OnPointerWheelChanged;
@ -31,7 +34,11 @@ namespace MapControl
/// <summary>
/// Gets or sets the amount by which the ZoomLevel property changes during a MouseWheel event.
/// </summary>
public double MouseWheelZoomChange { get; set; }
public double MouseWheelZoomChange
{
get { return (double)GetValue(MouseWheelZoomChangeProperty); }
set { SetValue(MouseWheelZoomChangeProperty, value); }
}
private void OnPointerWheelChanged(object sender, PointerRoutedEventArgs e)
{

View file

@ -806,8 +806,8 @@ namespace MapControl
private void UpdateTransform()
{
var center = Center;
var origin = transformOrigin != null ? transformOrigin : center;
var scale = tileContainer.SetViewportTransform(ZoomLevel, Heading, mapTransform.Transform(origin), viewportOrigin, RenderSize);
var origin = mapTransform.Transform(transformOrigin ?? center);
var scale = tileContainer.SetViewportTransform(ZoomLevel, Heading, origin, viewportOrigin, RenderSize);
if (transformOrigin != null)
{

View file

@ -204,7 +204,7 @@ namespace MapControl
{
pen = new Pen
{
Brush = Stroke != null ? Stroke : Foreground,
Brush = Stroke ?? Foreground,
Thickness = StrokeThickness,
DashStyle = new DashStyle(StrokeDashArray, StrokeDashOffset),
DashCap = StrokeDashCap,

View file

@ -15,8 +15,8 @@ using System.Windows;
[assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyVersion("1.3.0")]
[assembly: AssemblyFileVersion("1.3.0")]
[assembly: AssemblyVersion("1.3.1")]
[assembly: AssemblyFileVersion("1.3.1")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]

View file

@ -15,6 +15,8 @@ namespace MapControl
VisualEdgeMode = EdgeMode.Aliased;
}
public Brush Background { get; set; }
protected ContainerVisual TileContainer
{
get { return Parent as ContainerVisual; }

View file

@ -64,7 +64,6 @@ namespace MapControl
public int MaxZoomLevel { get; set; }
public int MaxParallelDownloads { get; set; }
public bool LoadLowerZoomLevels { get; set; }
public Brush Background { get; set; }
public Brush Foreground { get; set; }
public string Description

View file

@ -8,8 +8,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyVersion("1.3.0")]
[assembly: AssemblyFileVersion("1.3.0")]
[assembly: AssemblyVersion("1.3.1")]
[assembly: AssemblyFileVersion("1.3.1")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]