private void glControl_OpenGLInitialized(object sender, SharpGL.SceneGraph.OpenGLEventArgs args)
 {
     args.OpenGL.ClearColor(135.0f/255, 206.0f/255, 250.0f/255, 1.0f);
     _graphics = new Drawing.GLImmediateGraphicsController(args.OpenGL, new GLThingSize(glControl));
     _grid = new Drawing.CanvasGridRenderer(_graphics);
     _controls = new Drawing.PlotterControls(glControl, _grid);
 }
        public PlotterControls(FrameworkElement c, CanvasGridRenderer graphics)
        {
            _gridRenderer = graphics;
            Recentre(c);

            var zoomLogic = new ZoomLogic();
            _zoom = zoomLogic;

            _lastMousePosition = new MousePositionService(this.PicturePosFromCanvasPos);

            _gridRenderer.Start(_zoom, _origin, _lastMousePosition);

            var zoomer = new ZoomController(zoomLogic, this.FocusPosition, _lastMousePosition);

            //----- I'm just gonna set up all the input control here because why not

            c.SizeChanged +=
                (object sender, System.Windows.SizeChangedEventArgs e) =>
                {
                    Recentre(c);
                };

            c.MouseMove +=
                (object sender, MouseEventArgs e) =>
                {
                    _lastMousePosition.P = PointConversions.CanvasFromMouse(e.MouseDevice, c);
                };

            c.MouseWheel +=
                (object sender, MouseWheelEventArgs e) =>
                {
                    var delta = e.Delta;

                    if (delta > 0)
                    {
                        zoomer.ZoomIn();
                    }
                    else
                    {
                        zoomer.ZoomOut();
                    }

                    e.Handled = true;
                };

            new MousePanningHandler(_origin, _zoom).AddDragHandler(c);
        }