Rev | Line | |
---|
[12503] | 1 | using System;
|
---|
| 2 | using System.Collections.Generic;
|
---|
| 3 | using System.Linq;
|
---|
| 4 | using System.Text;
|
---|
| 5 | using System.Windows;
|
---|
| 6 | using Microsoft.Research.DynamicDataDisplay.Common.UndoSystem;
|
---|
| 7 |
|
---|
| 8 | namespace Microsoft.Research.DynamicDataDisplay
|
---|
| 9 | {
|
---|
| 10 | public static class Viewport2DExtensions
|
---|
| 11 | {
|
---|
| 12 | public static void Zoom(this Viewport2D viewport, double factor)
|
---|
| 13 | {
|
---|
| 14 | DataRect visible = viewport.Visible;
|
---|
| 15 | DataRect oldVisible = visible;
|
---|
| 16 | Point center = visible.GetCenter();
|
---|
| 17 | Vector halfSize = new Vector(visible.Width * factor / 2, visible.Height * factor / 2);
|
---|
| 18 |
|
---|
| 19 | viewport.SetChangeType(ChangeType.Zoom);
|
---|
| 20 | viewport.Visible = new DataRect(center - halfSize, center + halfSize);
|
---|
| 21 | viewport.SetChangeType();
|
---|
| 22 |
|
---|
| 23 | viewport.Plotter.UndoProvider.AddAction(new DependencyPropertyChangedUndoAction(viewport, Viewport2D.VisibleProperty, oldVisible, visible));
|
---|
| 24 | }
|
---|
| 25 | }
|
---|
| 26 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.