Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.GrammaticalOptimization/DynamicDataDisplay/Viewport2DExtensions.cs @ 13467

Last change on this file since 13467 was 12503, checked in by aballeit, 9 years ago

#2283 added GUI and charts; fixed MCTS

File size: 872 bytes
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.Windows;
6using Microsoft.Research.DynamicDataDisplay.Common.UndoSystem;
7
8namespace 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.