From: glenlow Date: Thu, 26 Jun 2008 04:30:46 +0000 (+0000) Subject: attributes, actual size, zoom in, zoom out, zoom to fit toolbar icons and menu commands X-Git-Tag: LAST_LIBGRAPH~32^2~3923 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3d3894b38da97789108e51f5e40d6b78019c275f;p=graphviz attributes, actual size, zoom in, zoom out, zoom to fit toolbar icons and menu commands --- diff --git a/windows/ScrollableImageControl.cs b/windows/ScrollableImageControl.cs index 484322e45..77d68dc7d 100755 --- a/windows/ScrollableImageControl.cs +++ b/windows/ScrollableImageControl.cs @@ -65,6 +65,28 @@ namespace Graphviz _zoom = 1.0f; _lastScroll = new Point(0, 0); } + + public void ActualSize() + { + Zoom = 1.0f; + } + + public void ZoomToFit() + { + Size imageSize = Image.Size; + Size controlSize = Size; + Zoom = Math.Min((float)controlSize.Width / (float)imageSize.Width, (float)controlSize.Height / (float)imageSize.Height); + } + + public void ZoomIn() + { + Zoom *= _squareRootOfTwo; + } + + public void ZoomOut() + { + Zoom /= _squareRootOfTwo; + } protected override void OnMouseDown(MouseEventArgs e) { @@ -126,6 +148,7 @@ namespace Graphviz Invalidate(); } + private readonly float _squareRootOfTwo = (float)Math.Sqrt(2.0); private Image _image; private float _zoom; private Point _lastScroll;