示例#1
0
 protected override void OnMouseClick(MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         var pt = _mapTransform.MapToWorld(e.X, e.Y);
         _mapTransform = new MapTransform(pt, _mapTransform.Resolution, Width, Height);
         RenderToBuffer();
     }
     base.OnMouseClick(e);
 }
示例#2
0
        protected override void OnMouseWheel(MouseEventArgs e)
        {
            if (_mapTransform == null)
            {
                return;
            }

            var   res = _mapTransform.Resolution;
            float factor;

            if (e.Delta < 0)
            {
                factor = 1.2f;
            }
            else if (e.Delta > 0)
            {
                factor = 1 / 1.2f;
            }
            else
            {
                return;
            }

            var center = new PointF(picMap.Width * 0.5f, picMap.Height * 0.5f);
            var point  = new PointF(e.X, e.Y);

            var dx = (center.X - point.X) * factor;
            var dy = (center.Y - point.Y) * factor;

            var newCenter = _mapTransform.MapToWorld(point.X + dx, point.Y + dy);

            var transform = new MapTransform(newCenter, res * factor, picMap.Width, picMap.Height);

            _mapTransform = transform;
            RenderToBuffer();

            base.OnMouseWheel(e);
        }