[mapguide-commits] r6827 - in trunk/Tools/Maestro/Maestro.MapViewer: . Properties
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Wed Jun 27 09:41:21 PDT 2012
Author: jng
Date: 2012-06-27 09:41:20 -0700 (Wed, 27 Jun 2012)
New Revision: 6827
Modified:
trunk/Tools/Maestro/Maestro.MapViewer/Interfaces.cs
trunk/Tools/Maestro/Maestro.MapViewer/MapViewer.cs
trunk/Tools/Maestro/Maestro.MapViewer/Properties/Resources.Designer.cs
trunk/Tools/Maestro/Maestro.MapViewer/Properties/Resources.resx
Log:
#2018: Port over mg-desktop viewer enhancements (mouse wheel zoom, custom digitization prompts) to the Maestro RuntimeMap viewer.
Modified: trunk/Tools/Maestro/Maestro.MapViewer/Interfaces.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.MapViewer/Interfaces.cs 2012-06-27 13:15:42 UTC (rev 6826)
+++ trunk/Tools/Maestro/Maestro.MapViewer/Interfaces.cs 2012-06-27 16:41:20 UTC (rev 6827)
@@ -83,6 +83,56 @@
void DigitizeRectangle(RectangleDigitizationCallback callback);
/// <summary>
+ /// Starts the digitization process for a circle
+ /// </summary>
+ /// <param name="callback">The callback to be invoked when the digitization process completes</param>
+ /// <param name="customPrompt">The custom prompt to use for the tracking tooltip</param>
+ void DigitizeCircle(CircleDigitizationCallback callback, string customPrompt);
+
+ /// <summary>
+ /// Starts the digitization process for a line
+ /// </summary>
+ /// <param name="callback">The callback to be invoked when the digitization process completes</param>
+ /// <param name="customPrompt">The custom prompt to use for the tracking tooltip</param>
+ void DigitizeLine(LineDigitizationCallback callback, string customPrompt);
+
+ /// <summary>
+ /// Starts the digitization process for a point
+ /// </summary>
+ /// <param name="callback">The callback to be invoked when the digitization process completes</param>
+ /// <param name="customPrompt">The custom prompt to use for the tracking tooltip</param>
+ void DigitizePoint(PointDigitizationCallback callback, string customPrompt);
+
+ /// <summary>
+ /// Starts the digitization process for a polygon
+ /// </summary>
+ /// <param name="callback">The callback to be invoked when the digitization process completes</param>
+ /// <param name="customPrompt">The custom prompt to use for the tracking tooltip</param>
+ void DigitizePolygon(PolygonDigitizationCallback callback, string customPrompt);
+
+ /// <summary>
+ /// Starts the digitization process for a line string (polyline)
+ /// </summary>
+ /// <param name="callback">The callback to be invoked when the digitization process completes</param>
+ /// <param name="customPrompt">The custom prompt to use for the tracking tooltip</param>
+ void DigitizeLineString(LineStringDigitizationCallback callback, string customPrompt);
+
+ /// <summary>
+ /// Starts the digitization process for a line string (polyline)
+ /// </summary>
+ /// <param name="callback">The callback to be invoked when the digitization process completes</param>
+ /// <param name="segmentDigitized">The callback to be invoked when a new segment of the current line string is digitized</param>
+ /// <param name="customPrompt">The custom prompt to use for the tracking tooltip</param>
+ void DigitizeLineString(LineStringDigitizationCallback callback, LineDigitizationCallback segmentDigitized, string customPrompt);
+
+ /// <summary>
+ /// Starts the digitization process for a rectangle
+ /// </summary>
+ /// <param name="callback">The callback to be invoked when the digitization process completes</param>
+ /// <param name="customPrompt">The custom prompt to use for the tracking tooltip</param>
+ void DigitizeRectangle(RectangleDigitizationCallback callback, string customPrompt);
+
+ /// <summary>
/// Gets the current runtime map
/// </summary>
/// <returns></returns>
@@ -99,6 +149,21 @@
MapActiveTool ActiveTool { get; set; }
/// <summary>
+ /// Gets or sets the minimum allowed zoom scale for this viewer
+ /// </summary>
+ int MinScale { get; set; }
+
+ /// <summary>
+ /// Gets or sets the maximum allowed zoom scale for this viewer
+ /// </summary>
+ int MaxScale { get; set; }
+
+ /// <summary>
+ /// The amount of time (in ms) to wait to re-render after a mouse wheel scroll
+ /// </summary>
+ int MouseWheelDelayRenderInterval { get; set; }
+
+ /// <summary>
/// Gets or sets the factor by which to multiply the scale to zoom in
/// </summary>
double ZoomInFactor { get; set; }
Modified: trunk/Tools/Maestro/Maestro.MapViewer/MapViewer.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.MapViewer/MapViewer.cs 2012-06-27 13:15:42 UTC (rev 6826)
+++ trunk/Tools/Maestro/Maestro.MapViewer/MapViewer.cs 2012-06-27 16:41:20 UTC (rev 6827)
@@ -186,11 +186,15 @@
this.SelectionColor = Color.Blue;
this.PointPixelBuffer = 2;
+ this.MinScale = 10;
+ this.MaxScale = 1000000000;
+
this.DigitizingFillTransparency = 100;
this.DigitizingOutline = Brushes.Red;
this.DigitzingFillColor = Color.White;
this.TooltipFillColor = Color.LightYellow;
this.TooltipFillTransparency = 200;
+ this.MouseWheelDelayRenderInterval = 800;
this.ActiveTool = MapActiveTool.None;
this.DoubleBuffered = true;
@@ -202,6 +206,15 @@
SetStyle(ControlStyles.DoubleBuffer, true);
_mapBgColor = Color.Transparent;
+
+ _defaultDigitizationInstructions = Properties.Resources.GeneralDigitizationInstructions;
+ _defaultMultiSegmentDigitizationInstructions = Properties.Resources.MultiSegmentDigitzationInstructions;
+ _defaultPointDigitizationPrompt = Properties.Resources.PointDigitizationPrompt;
+ _defaultLineDigitizationPrompt = Properties.Resources.LineDigitizationPrompt;
+ _defaultCircleDigitizationPrompt = Properties.Resources.CircleDigitizationPrompt;
+ _defaultLineStringDigitizationPrompt = Properties.Resources.LineStringDigitizationPrompt;
+ _defaultPolygonDigitizationPrompt = Properties.Resources.PolygonDigitizationPrompt;
+ _defaultRectangleDigitizationPrompt = Properties.Resources.RectangleDigitizationPrompt;
renderWorker = new BackgroundWorker();
@@ -215,6 +228,7 @@
base.MouseDoubleClick += OnMapMouseDoubleClick;
base.MouseHover += OnMapMouseHover;
base.MouseEnter += OnMouseEnter;
+ base.MouseWheel += OnMapMouseWheel;
}
/// <summary>
@@ -227,6 +241,18 @@
{
CancelDigitization();
}
+ else if (e.KeyCode == Keys.Z && e.Modifiers == Keys.Control)
+ {
+ if (this.DigitizingType == MapDigitizationType.LineString ||
+ this.DigitizingType == MapDigitizationType.Polygon)
+ {
+ if (dPath.Count > 1) //Slice off the last recorded point
+ {
+ dPath.RemoveAt(dPath.Count - 1);
+ Invalidate();
+ }
+ }
+ }
}
private void CancelDigitization()
@@ -282,6 +308,27 @@
base.Dispose(disposing);
}
+ /// <summary>
+ /// Gets or sets the minimum allowed zoom scale for this viewer
+ /// </summary>
+ [Category("MapGuide Viewer")]
+ [Description("The minimum allowed zoom scale for this viewer")]
+ public int MinScale { get; set; }
+
+ /// <summary>
+ /// Gets or sets the maximum allowed zoom scale for this viewer
+ /// </summary>
+ [Category("MapGuide Viewer")]
+ [Description("The maximum allowed zoom scale for this viewer")]
+ public int MaxScale { get; set; }
+
+ /// <summary>
+ /// The amount of time (in ms) to wait to re-render after a mouse wheel scroll
+ /// </summary>
+ [Category("MapGuide Viewer")]
+ [Description("The amount of time (in ms) to wait to re-render after a mouse wheel scroll")]
+ public int MouseWheelDelayRenderInterval { get; set; }
+
private Color _selColor;
/// <summary>
@@ -381,6 +428,23 @@
}
}
+ private string _defaultDigitizationInstructions;
+ private string _defaultMultiSegmentDigitizationInstructions;
+
+ private string _defaultPointDigitizationPrompt;
+ private string _defaultLineDigitizationPrompt;
+ private string _defaultCircleDigitizationPrompt;
+ private string _defaultLineStringDigitizationPrompt;
+ private string _defaultPolygonDigitizationPrompt;
+ private string _defaultRectangleDigitizationPrompt;
+
+ private string _pointCustomDigitizationPrompt;
+ private string _lineCustomDigitizationPrompt;
+ private string _circleCustomDigitizationPrompt;
+ private string _lineStringCustomDigitizationPrompt;
+ private string _polygonCustomDigitizationPrompt;
+ private string _rectangleCustomDigitizationPrompt;
+
/// <summary>
/// Raises the <see cref="E:System.Windows.Forms.Control.Paint"/> event.
/// </summary>
@@ -390,9 +454,13 @@
base.OnPaint(e);
Trace.TraceInformation("OnPaint(e)");
- if (!translate.IsEmpty)
- e.Graphics.TranslateTransform(translate.X, translate.Y);
+ ApplyPaintTranslateTransform(e);
+ if (mouseWheelSx.HasValue && mouseWheelSy.HasValue && mouseWheelSx.Value != 0.0 && mouseWheelSy.Value != 0.0)
+ {
+ e.Graphics.ScaleTransform(mouseWheelSx.Value, mouseWheelSy.Value);
+ }
+
if (_mapImage != null)
{
Trace.TraceInformation("Render Map");
@@ -406,6 +474,8 @@
e.Graphics.DrawImage(_selectionImage, new PointF(0, 0));
}
+ //TODO: We could add support here for map-space persistent digitizations
+
if (isDragging && (this.ActiveTool == MapActiveTool.Select || this.ActiveTool == MapActiveTool.ZoomIn))
{
DrawDragRectangle(e);
@@ -416,7 +486,8 @@
{
if (this.DigitizingType == MapDigitizationType.Point)
{
- DrawTrackingTooltip(e, "Click to finish. Press ESC to cancel");
+ string str = (_pointCustomDigitizationPrompt ?? _defaultPointDigitizationPrompt) + Environment.NewLine + _defaultDigitizationInstructions;
+ DrawTrackingTooltip(e, str);
}
else
{
@@ -460,6 +531,22 @@
}
}
+ private void ApplyPaintTranslateTransform(PaintEventArgs e)
+ {
+ if (!translate.IsEmpty)
+ {
+ if (mouseWheelTx.HasValue && mouseWheelTy.HasValue)
+ e.Graphics.TranslateTransform(translate.X + mouseWheelTx.Value, translate.Y + mouseWheelTy.Value);
+ else
+ e.Graphics.TranslateTransform(translate.X, translate.Y);
+ }
+ else
+ {
+ if (mouseWheelTx.HasValue && mouseWheelTy.HasValue)
+ e.Graphics.TranslateTransform(mouseWheelTx.Value, mouseWheelTy.Value);
+ }
+ }
+
private Brush _digitizingOutline;
[Category("MapGuide Viewer")]
@@ -594,7 +681,8 @@
e.Graphics.DrawEllipse(CreateOutlinePen(), pt2.X, pt2.Y, diameter, diameter);
e.Graphics.FillEllipse(CreateFillBrush(), pt2.X, pt2.Y, diameter, diameter);
- DrawTrackingTooltip(e, "Click to finish. Press ESC to cancel");
+ string str = (_circleCustomDigitizationPrompt ?? _defaultCircleDigitizationPrompt) + Environment.NewLine + _defaultDigitizationInstructions;
+ DrawTrackingTooltip(e, str);
}
private void DrawTracingLine(PaintEventArgs e)
@@ -602,7 +690,8 @@
e.Graphics.DrawLine(CreateOutlinePen(), dPtStart, new Point(_mouseX, _mouseY));
DrawVertexCoordinates(e, dPtStart.X, dPtStart.Y, true);
DrawVertexCoordinates(e, _mouseX, _mouseY, true);
- DrawTrackingTooltip(e, "Click to finish. Press ESC to cancel");
+ string str = (_lineCustomDigitizationPrompt ?? _defaultLineDigitizationPrompt) + Environment.NewLine + _defaultDigitizationInstructions;
+ DrawTrackingTooltip(e, str);
}
private void DrawTracingLineString(PaintEventArgs e)
@@ -617,7 +706,8 @@
DrawVertexCoordinates(e, pt.X, pt.Y, true);
}
- DrawTrackingTooltip(e, "Click again to add a new vertex.\nDouble-click to finish. Press ESC to cancel");
+ string str = (_lineStringCustomDigitizationPrompt ?? _defaultLineStringDigitizationPrompt) + Environment.NewLine + _defaultMultiSegmentDigitizationInstructions;
+ DrawTrackingTooltip(e, str);
}
private void DrawTracingPolygon(PaintEventArgs e)
@@ -632,8 +722,8 @@
{
DrawVertexCoordinates(e, pt.X, pt.Y, true);
}
-
- DrawTrackingTooltip(e, "Click again to add a new vertex.\nDouble-click to finish. Press ESC to cancel");
+ string str = (_polygonCustomDigitizationPrompt ?? _defaultPolygonDigitizationPrompt) + Environment.NewLine + _defaultMultiSegmentDigitizationInstructions;
+ DrawTrackingTooltip(e, str);
}
private void DrawTracingRectangle(PaintEventArgs e)
@@ -651,7 +741,8 @@
DrawVertexCoordinates(e, r.Left, r.Bottom, true);
DrawVertexCoordinates(e, r.Right, r.Top, true);
DrawVertexCoordinates(e, r.Right, r.Bottom, true);
- DrawTrackingTooltip(e, "Click to finish. Press ESC to cancel");
+ string str = (_rectangleCustomDigitizationPrompt ?? _defaultRectangleDigitizationPrompt) + Environment.NewLine + _defaultDigitizationInstructions;
+ DrawTrackingTooltip(e, str);
}
}
@@ -756,55 +847,65 @@
/// Starts the digitization process for a circle
/// </summary>
/// <param name="callback">The callback to be invoked when the digitization process completes</param>
- public void DigitizeCircle(CircleDigitizationCallback callback)
+ /// <param name="customPrompt">The custom prompt to use for the tracking tooltip</param>
+ public void DigitizeCircle(CircleDigitizationCallback callback, string customPrompt)
{
this.DigitizingType = MapDigitizationType.Circle;
_digitzationCallback = callback;
_digitizationYetToStart = true;
+ _circleCustomDigitizationPrompt = customPrompt;
}
/// <summary>
/// Starts the digitization process for a line
/// </summary>
/// <param name="callback">The callback to be invoked when the digitization process completes</param>
- public void DigitizeLine(LineDigitizationCallback callback)
+ /// <param name="customPrompt">The custom prompt to use for the tracking tooltip</param>
+ public void DigitizeLine(LineDigitizationCallback callback, string customPrompt)
{
this.DigitizingType = MapDigitizationType.Line;
_digitzationCallback = callback;
_digitizationYetToStart = true;
+ _lineCustomDigitizationPrompt = customPrompt;
}
/// <summary>
/// Starts the digitization process for a point
/// </summary>
/// <param name="callback">The callback to be invoked when the digitization process completes</param>
- public void DigitizePoint(PointDigitizationCallback callback)
+ /// <param name="customPrompt">The custom prompt to use for the tracking tooltip</param>
+ public void DigitizePoint(PointDigitizationCallback callback, string customPrompt)
{
this.DigitizingType = MapDigitizationType.Point;
_digitzationCallback = callback;
_digitizationYetToStart = true;
+ _pointCustomDigitizationPrompt = customPrompt;
}
/// <summary>
/// Starts the digitization process for a polygon
/// </summary>
/// <param name="callback">The callback to be invoked when the digitization process completes</param>
- public void DigitizePolygon(PolygonDigitizationCallback callback)
+ /// <param name="customPrompt">The custom prompt to use for the tracking tooltip</param>
+ public void DigitizePolygon(PolygonDigitizationCallback callback, string customPrompt)
{
this.DigitizingType = MapDigitizationType.Polygon;
_digitzationCallback = callback;
_digitizationYetToStart = true;
+ _polygonCustomDigitizationPrompt = customPrompt;
}
/// <summary>
/// Starts the digitization process for a line string (polyline)
/// </summary>
/// <param name="callback">The callback to be invoked when the digitization process completes</param>
- public void DigitizeLineString(LineStringDigitizationCallback callback)
+ /// <param name="customPrompt">The custom prompt to use for the tracking tooltip</param>
+ public void DigitizeLineString(LineStringDigitizationCallback callback, string customPrompt)
{
this.DigitizingType = MapDigitizationType.LineString;
_digitzationCallback = callback;
_digitizationYetToStart = true;
+ _lineStringCustomDigitizationPrompt = customPrompt;
}
private LineDigitizationCallback _segmentCallback;
@@ -814,25 +915,64 @@
/// </summary>
/// <param name="callback">The callback to be invoked when the digitization process completes</param>
/// <param name="segmentCallback">The callback to be invoked when a new segment of the current line string is digitized</param>
- public void DigitizeLineString(LineStringDigitizationCallback callback, LineDigitizationCallback segmentCallback)
+ /// <param name="customPrompt">The custom prompt to use for the tracking tooltip</param>
+ public void DigitizeLineString(LineStringDigitizationCallback callback, LineDigitizationCallback segmentCallback, string customPrompt)
{
this.DigitizingType = MapDigitizationType.LineString;
_digitzationCallback = callback;
_segmentCallback = segmentCallback;
_digitizationYetToStart = true;
+ _lineStringCustomDigitizationPrompt = customPrompt;
}
/// <summary>
/// Starts the digitization process for a rectangle
/// </summary>
/// <param name="callback">The callback to be invoked when the digitization process completes</param>
- public void DigitizeRectangle(RectangleDigitizationCallback callback)
+ /// <param name="customPrompt">The custom prompt to use for the tracking tooltip</param>
+ public void DigitizeRectangle(RectangleDigitizationCallback callback, string customPrompt)
{
this.DigitizingType = MapDigitizationType.Rectangle;
_digitzationCallback = callback;
_digitizationYetToStart = true;
+ _rectangleCustomDigitizationPrompt = customPrompt;
}
+ public void DigitizeCircle(CircleDigitizationCallback callback)
+ {
+ DigitizeCircle(callback, null);
+ }
+
+ public void DigitizeLine(LineDigitizationCallback callback)
+ {
+ DigitizeLine(callback, null);
+ }
+
+ public void DigitizePoint(PointDigitizationCallback callback)
+ {
+ DigitizePoint(callback, null);
+ }
+
+ public void DigitizePolygon(PolygonDigitizationCallback callback)
+ {
+ DigitizePolygon(callback, null);
+ }
+
+ public void DigitizeLineString(LineStringDigitizationCallback callback)
+ {
+ DigitizeLineString(callback, (string)null);
+ }
+
+ public void DigitizeLineString(LineStringDigitizationCallback callback, LineDigitizationCallback segmentDigitized)
+ {
+ DigitizeLineString(callback, segmentDigitized, null);
+ }
+
+ public void DigitizeRectangle(RectangleDigitizationCallback callback)
+ {
+ DigitizeRectangle(callback, null);
+ }
+
private void ResetDigitzationState()
{
_digitzationCallback = null;
@@ -841,6 +981,12 @@
dPtEnd.X = dPtStart.Y = 0;
dPtStart.X = dPtStart.Y = 0;
this.DigitizingType = MapDigitizationType.None;
+ _circleCustomDigitizationPrompt = null;
+ _lineCustomDigitizationPrompt = null;
+ _lineStringCustomDigitizationPrompt = null;
+ _polygonCustomDigitizationPrompt = null;
+ _pointCustomDigitizationPrompt = null;
+ _rectangleCustomDigitizationPrompt = null;
Invalidate();
}
@@ -1012,7 +1158,7 @@
private double CalculateScale(double mcsW, double mcsH, int devW, int devH)
{
var mpu = this.MetersPerUnit;
- var mpp = 0.0254 / _map.DisplayDpi;
+ var mpp = GetMetersPerPixel(_map.DisplayDpi);
if (devH * mcsW > devW * mcsH)
return mcsW * mpu / (devW * mpp); //width-limited
else
@@ -1426,7 +1572,7 @@
//Update current extents
double mpu = this.MetersPerUnit;
double scale = _map.ViewScale;
- double mpp = 0.0254 / _map.DisplayDpi;
+ double mpp = GetMetersPerPixel(_map.DisplayDpi);
var coord = _map.ViewCenter;
var mcsWidth = _map.DisplayWidth * mpp * scale / mpu;
@@ -1923,6 +2069,12 @@
HandleMouseUp(e);
}
+ private void OnMapMouseWheel(object sender, MouseEventArgs e)
+ {
+ this.Focus();
+ HandleMouseWheel(e);
+ }
+
private void OnMapMouseClick(object sender, MouseEventArgs e)
{
this.Focus();
@@ -1957,6 +2109,153 @@
}
}
+ private double? delayRenderScale;
+ private PointF? delayRenderViewCenter;
+ private float? mouseWheelSx = null;
+ private float? mouseWheelSy = null;
+ private float? mouseWheelTx = null;
+ private float? mouseWheelTy = null;
+ private int? mouseWheelDelta = null;
+ private System.Timers.Timer delayRenderTimer = null;
+
+ private void HandleMouseWheel(MouseEventArgs e)
+ {
+ if (delayRenderTimer == null)
+ {
+ delayRenderTimer = new System.Timers.Timer();
+ delayRenderTimer.Enabled = false;
+ delayRenderTimer.Elapsed += new System.Timers.ElapsedEventHandler(OnDelayRender);
+ delayRenderTimer.Interval = this.MouseWheelDelayRenderInterval;
+ }
+
+ delayRenderTimer.Stop();
+ delayRenderTimer.Start();
+ Trace.TraceInformation("Postponed delay render");
+ Trace.TraceInformation("Mouse delta: " + e.Delta + " (" + (e.Delta > 0 ? "Zoom in" : "Zoom out") + ")");
+ //Negative delta = zoom out, Positive delta = zoom in
+ //deltas are in units of 120, so treat each multiple of 120 as a "zoom unit"
+
+ if (!mouseWheelSx.HasValue && !mouseWheelSy.HasValue)
+ {
+ mouseWheelSx = 1.0f;
+ mouseWheelSy = 1.0f;
+ }
+
+ if (!mouseWheelDelta.HasValue)
+ mouseWheelDelta = 0;
+
+ if (e.Delta > 0) //Zoom In
+ {
+ mouseWheelDelta++;
+ mouseWheelSx -= 0.1f;
+ mouseWheelSy -= 0.1f;
+ Invalidate();
+ }
+ else if (e.Delta < 0) //Zoom Out
+ {
+ mouseWheelDelta--;
+ mouseWheelSx += 0.1f;
+ mouseWheelSy += 0.1f;
+ Invalidate();
+ }
+
+ Trace.TraceInformation("Delta units is: " + mouseWheelDelta);
+
+ //Completely ripped the number crunching here from the AJAX viewer with no sense of shame whatsoever :)
+ delayRenderScale = GetNewScale(_map.ViewScale, mouseWheelDelta.Value);
+ double zoomChange = _map.ViewScale / delayRenderScale.Value;
+
+ //Determine the center of the new, zoomed map, in current screen device coords
+ double screenZoomCenterX = e.X - (e.X - this.Width / 2) / zoomChange;
+ double screenZoomCenterY = e.Y - (e.Y - this.Height / 2) / zoomChange;
+ delayRenderViewCenter = ScreenToMapUnits(screenZoomCenterX, screenZoomCenterY);
+
+ var mpu = this.MetersPerUnit;
+ var mpp = GetMetersPerPixel(_map.DisplayDpi);
+ var w = (_extX2 - _extX1) * this.MetersPerUnit / (delayRenderScale * mpp);
+ if (w > 20000)
+ {
+ w = 20000;
+ }
+ var h = w * ((double)this.Height / (double)this.Width);
+ var xClickOffset = screenZoomCenterX - this.Width / 2;
+ var yClickOffset = screenZoomCenterY - this.Height / 2;
+
+ //Set the paint transforms. Will be reset once the delayed render is fired away
+ mouseWheelTx = (float)((double)this.Width / 2 - w / 2 - xClickOffset * zoomChange);
+ mouseWheelTy = (float)((double)this.Height / 2 - h / 2 - yClickOffset * zoomChange);
+ mouseWheelSx = (float)(w / (double)this.Width);
+ mouseWheelSy = (float)(h / (double)this.Height);
+
+ Trace.TraceInformation("Paint transform (tx: " + mouseWheelTx + ", ty: " + mouseWheelTy + ", sx: " + mouseWheelSx + ", sy: " + mouseWheelSy + ")");
+ }
+
+ static double GetMetersPerPixel(int dpi)
+ {
+ return 0.0254 / dpi;
+ }
+
+ double GetNewScale(double currentScale, int wheelZoomDelta)
+ {
+ var newScale = currentScale;
+ /*
+ //handle finite zoom scales for tiled map
+ if (finscale)
+ {
+ var newScaleIndex = sci - wheelDelta;
+ if (newScaleIndex < 0)
+ {
+ newScaleIndex = 0;
+ }
+ if (newScaleIndex > scales.length - 1)
+ {
+ newScaleIndex = scales.length - 1;
+ }
+ newScale = scales[newScaleIndex];
+ }
+ //no finite zoom scales (untiled map)
+ else */
+ {
+ var zoomChange = Math.Pow(1.5, wheelZoomDelta);
+ newScale = zoomChange > 0 ? currentScale / zoomChange : this.MaxScale;
+ newScale = NormalizeScale(newScale);
+ }
+ return newScale;
+ }
+
+ double NormalizeScale(double scale)
+ {
+ if (scale < this.MinScale)
+ return this.MinScale;
+ if (scale > this.MaxScale)
+ return this.MaxScale;
+ return scale;
+ }
+
+ void OnDelayRender(object sender, System.Timers.ElapsedEventArgs e)
+ {
+ Trace.TraceInformation("Delay rendering");
+ Trace.TraceInformation("Set new map coordinates to (" + delayRenderViewCenter.Value.X + ", " + delayRenderViewCenter.Value.Y + " at " + delayRenderScale.Value + ")");
+ ResetMouseWheelPaintTransforms();
+ MethodInvoker action = () => { ZoomToView(delayRenderViewCenter.Value.X, delayRenderViewCenter.Value.Y, delayRenderScale.Value, true); };
+ if (this.InvokeRequired)
+ this.Invoke(action);
+ else
+ action();
+ }
+
+ private void ResetMouseWheelPaintTransforms()
+ {
+ if (delayRenderTimer != null)
+ delayRenderTimer.Stop();
+ mouseWheelSx = null;
+ mouseWheelSy = null;
+ mouseWheelTx = null;
+ mouseWheelTy = null;
+ mouseWheelDelta = 0;
+ Trace.TraceInformation("Mouse wheel paint transform reset");
+ }
+
private void HandleMouseClick(MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
Modified: trunk/Tools/Maestro/Maestro.MapViewer/Properties/Resources.Designer.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.MapViewer/Properties/Resources.Designer.cs 2012-06-27 13:15:42 UTC (rev 6826)
+++ trunk/Tools/Maestro/Maestro.MapViewer/Properties/Resources.Designer.cs 2012-06-27 16:41:20 UTC (rev 6827)
@@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
-// Runtime Version:4.0.30319.225
+// Runtime Version:4.0.30319.269
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -74,6 +74,15 @@
}
}
+ /// <summary>
+ /// Looks up a localized string similar to Click to finish.
+ /// </summary>
+ internal static string CircleDigitizationPrompt {
+ get {
+ return ResourceManager.GetString("CircleDigitizationPrompt", resourceCulture);
+ }
+ }
+
internal static System.Drawing.Bitmap control {
get {
object obj = ResourceManager.GetObject("control", resourceCulture);
@@ -171,6 +180,15 @@
}
}
+ /// <summary>
+ /// Looks up a localized string similar to Press ESC to cancel.
+ /// </summary>
+ internal static string GeneralDigitizationInstructions {
+ get {
+ return ResourceManager.GetString("GeneralDigitizationInstructions", resourceCulture);
+ }
+ }
+
internal static byte[] grab {
get {
object obj = ResourceManager.GetObject("grab", resourceCulture);
@@ -360,6 +378,24 @@
}
}
+ /// <summary>
+ /// Looks up a localized string similar to Click to finish.
+ /// </summary>
+ internal static string LineDigitizationPrompt {
+ get {
+ return ResourceManager.GetString("LineDigitizationPrompt", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Click again to add a new vertex.\nDouble-click to finish.
+ /// </summary>
+ internal static string LineStringDigitizationPrompt {
+ get {
+ return ResourceManager.GetString("LineStringDigitizationPrompt", resourceCulture);
+ }
+ }
+
internal static System.Drawing.Bitmap load_package {
get {
object obj = ResourceManager.GetObject("load_package", resourceCulture);
@@ -381,6 +417,15 @@
}
}
+ /// <summary>
+ /// Looks up a localized string similar to Press Ctrl-Z to undo last point.\nPress ESC to cancel.
+ /// </summary>
+ internal static string MultiSegmentDigitzationInstructions {
+ get {
+ return ResourceManager.GetString("MultiSegmentDigitzationInstructions", resourceCulture);
+ }
+ }
+
internal static System.Drawing.Bitmap options {
get {
object obj = ResourceManager.GetObject("options", resourceCulture);
@@ -395,6 +440,24 @@
}
}
+ /// <summary>
+ /// Looks up a localized string similar to Click to finish.
+ /// </summary>
+ internal static string PointDigitizationPrompt {
+ get {
+ return ResourceManager.GetString("PointDigitizationPrompt", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Click again to add a new vertex.\nDouble-click to finish.
+ /// </summary>
+ internal static string PolygonDigitizationPrompt {
+ get {
+ return ResourceManager.GetString("PolygonDigitizationPrompt", resourceCulture);
+ }
+ }
+
internal static System.Drawing.Bitmap PoweredBy_en {
get {
object obj = ResourceManager.GetObject("PoweredBy_en", resourceCulture);
@@ -416,6 +479,15 @@
}
}
+ /// <summary>
+ /// Looks up a localized string similar to Click to finish.
+ /// </summary>
+ internal static string RectangleDigitizationPrompt {
+ get {
+ return ResourceManager.GetString("RectangleDigitizationPrompt", resourceCulture);
+ }
+ }
+
internal static System.Drawing.Bitmap search {
get {
object obj = ResourceManager.GetObject("search", resourceCulture);
Modified: trunk/Tools/Maestro/Maestro.MapViewer/Properties/Resources.resx
===================================================================
--- trunk/Tools/Maestro/Maestro.MapViewer/Properties/Resources.resx 2012-06-27 13:15:42 UTC (rev 6826)
+++ trunk/Tools/Maestro/Maestro.MapViewer/Properties/Resources.resx 2012-06-27 16:41:20 UTC (rev 6827)
@@ -451,4 +451,28 @@
<data name="TextCoordinatePosition" xml:space="preserve">
<value>X: {0:0.0000000}, Y: {1:0.0000000}</value>
</data>
+ <data name="CircleDigitizationPrompt" xml:space="preserve">
+ <value>Click to finish</value>
+ </data>
+ <data name="GeneralDigitizationInstructions" xml:space="preserve">
+ <value>Press ESC to cancel</value>
+ </data>
+ <data name="LineDigitizationPrompt" xml:space="preserve">
+ <value>Click to finish</value>
+ </data>
+ <data name="LineStringDigitizationPrompt" xml:space="preserve">
+ <value>Click again to add a new vertex.\nDouble-click to finish</value>
+ </data>
+ <data name="MultiSegmentDigitzationInstructions" xml:space="preserve">
+ <value>Press Ctrl-Z to undo last point.\nPress ESC to cancel</value>
+ </data>
+ <data name="PointDigitizationPrompt" xml:space="preserve">
+ <value>Click to finish</value>
+ </data>
+ <data name="PolygonDigitizationPrompt" xml:space="preserve">
+ <value>Click again to add a new vertex.\nDouble-click to finish</value>
+ </data>
+ <data name="RectangleDigitizationPrompt" xml:space="preserve">
+ <value>Click to finish</value>
+ </data>
</root>
\ No newline at end of file
More information about the mapguide-commits
mailing list