]> granicus.if.org Git - graphviz/commitdiff
attributes, actual size, zoom in, zoom out, zoom to fit toolbar icons and menu commands
authorglenlow <devnull@localhost>
Thu, 26 Jun 2008 04:30:46 +0000 (04:30 +0000)
committerglenlow <devnull@localhost>
Thu, 26 Jun 2008 04:30:46 +0000 (04:30 +0000)
windows/ScrollableImageControl.cs

index 484322e4519926ee31cb8c5e4dc14989f8bdacdf..77d68dc7d0357fff57a77eb29dd88930abbd341a 100755 (executable)
@@ -65,6 +65,28 @@ namespace Graphviz
                        _zoom = 1.0f;\r
                        _lastScroll = new Point(0, 0);\r
                }\r
+               \r
+               public void ActualSize()\r
+               {\r
+                       Zoom = 1.0f;\r
+               }\r
+               \r
+               public void ZoomToFit()\r
+               {\r
+                       Size imageSize = Image.Size;\r
+                       Size controlSize = Size;\r
+                       Zoom = Math.Min((float)controlSize.Width / (float)imageSize.Width, (float)controlSize.Height / (float)imageSize.Height);\r
+               }\r
+               \r
+               public void ZoomIn()\r
+               {\r
+                       Zoom *= _squareRootOfTwo;\r
+               }\r
+               \r
+               public void ZoomOut()\r
+               {\r
+                       Zoom /= _squareRootOfTwo;\r
+               }\r
 \r
                protected override void OnMouseDown(MouseEventArgs e)\r
                {\r
@@ -126,6 +148,7 @@ namespace Graphviz
                        Invalidate();\r
                }\r
                \r
+               private readonly float _squareRootOfTwo = (float)Math.Sqrt(2.0);\r
                private Image _image;\r
                private float _zoom;\r
                private Point _lastScroll;\r