Piccolo Snippets
From eqqon
Piccolo
The Piccolo Toolkit is a structured 2D graphics framework with striking visual effects like zooming, animation and multiple representations. With Piccolo it is very easy to build Zoomable User Interfaces (ZUIs). A ZUI is a user interface that is able to present highly complex visualizations on a traditional computer display without restrictions by the screen resolution. By letting the user smoothly zoom in, to get more detailed information, and zoom out for an overview it is intuitively interactive and understandable.
Useful Piccolo Extensions
Mouse Wheel Zoom
The class MouseWheelZoomController replaces Piccolo's not very intuitive default zoom event handler with a mouse wheel zoom event handler. Just instantiate it and mouse wheel zooming just works with your Piccolo canvas!
public class MouseWheelZoomController { public static float MIN_SCALE = .0001f; public static float MAX_SCALE = 2500; PCamera camera; public MouseWheelZoomController(PCamera camera) { this.camera = camera; camera.Canvas.ZoomEventHandler = null; camera.MouseWheel += OnMouseWheel; } public void OnMouseWheel(object o, PInputEventArgs ea) { float currentScale = camera.ViewScale; float scaleDelta = (1.0f + (0.001f * ea.WheelDelta)); float newScale = currentScale * scaleDelta; if (newScale < MIN_SCALE) { camera.ViewScale = MIN_SCALE; return; } if ((MAX_SCALE > 0) && (newScale > MAX_SCALE)) { camera.ViewScale = MAX_SCALE; return; } PointF pos = ea.Position; camera.ScaleViewBy(scaleDelta, pos.X, pos.Y); } }