Exemplo n.º 1
0
        public override void Event(object sender, enumCanvasEventType eventType, DrawingMouseEventArgs e)
        {
            base.Event(sender, eventType, e);
            switch (eventType)
            {
            case enumCanvasEventType.MouseDown:
                _startLocation.X = e.ScreenX;
                _startLocation.Y = e.ScreenY;
                _canvas.DummyRenderModeSupport.SetToDummyRenderMode();
                break;

            case enumCanvasEventType.MouseMove:
                if (!_startLocation.IsEmpty)
                {
                    HandleBox(sender as ICanvas, e);
                }
                break;

            case enumCanvasEventType.MouseUp:
                if (!_startLocation.IsEmpty && !_endLocation.IsEmpty)
                {
                    _endLocation.X = e.ScreenX;
                    _endLocation.Y = e.ScreenY;
                    HandleZoom(sender as ICanvas, e);
                    _startLocation = PointF.Empty;
                    _endLocation   = PointF.Empty;
                    _canvas.DummyRenderModeSupport.SetToNomralRenderMode();
                    (sender as ICanvas).Refresh(enumRefreshType.FlyLayer);
                }
                break;
            }
        }
Exemplo n.º 2
0
        private void HandleZoom(ICanvas canvas, DrawingMouseEventArgs e)
        {
            CoordEnvelope srcEnvelope = canvas.CurrentEnvelope;
            CoordEnvelope dstEnvelope = GetDstEnvelope(canvas);

            //by chennan 上海 修改大红叉
            if (dstEnvelope == null)
            {
                return;
            }
            //
            switch (_zoomType)
            {
            case enumZoomType.ZoomIn:
                canvas.CurrentEnvelope = dstEnvelope;
                break;

            case enumZoomType.ZoomOut:
                double panzoomFactor = Math.Min(srcEnvelope.Width / dstEnvelope.Width, srcEnvelope.Height / dstEnvelope.Height);
                double inflateWidth  = srcEnvelope.Width * panzoomFactor;
                double inflateHeight = srcEnvelope.Height * panzoomFactor;
                srcEnvelope.Inflate(inflateWidth, inflateHeight);
                canvas.CurrentEnvelope = srcEnvelope;
                break;
            }
        }
Exemplo n.º 3
0
 private void HandleBox(ICanvas canvas, DrawingMouseEventArgs e)
 {
     _endLocation.X = e.ScreenX;
     _endLocation.Y = e.ScreenY;
     canvas.Refresh(enumRefreshType.FlyLayer);
 }
Exemplo n.º 4
0
        public virtual void Event(object sender, enumCanvasEventType eventType, DrawingMouseEventArgs e)
        {
            if (_canvas == null)
            {
                _canvas = sender as ICanvas;
            }
            switch (eventType)
            {
            case enumCanvasEventType.MouseDown:
                if (_enabledPan)
                {
                    _preLocation.X = e.ScreenX;
                    _preLocation.Y = e.ScreenY;
                    _canvas.DummyRenderModeSupport.SetToDummyRenderMode();
                }
                break;

            case enumCanvasEventType.MouseMove:
                if (_enabledPan)
                {
                    if (_preLocation.IsEmpty)
                    {
                        return;
                    }
                    float offsetX = e.ScreenX - _preLocation.X;
                    float offsetY = e.ScreenY - _preLocation.Y;
                    if ((_canvas as IDummyRenderModeSupport).IsDummyModel)
                    {
                        _hasChanged = true;
                    }
                    ApplyOffset(sender as ICanvas, offsetX, offsetY);
                    _preLocation.X = e.ScreenX;
                    _preLocation.Y = e.ScreenY;
                }
                break;

            case enumCanvasEventType.MouseUp:
                if (_enabledPan)
                {
                    _hasChanged  = false;
                    _preLocation = PointF.Empty;
                    _canvas.DummyRenderModeSupport.SetToNomralRenderMode();
                    //if (_hasChanged)
                    _canvas.Refresh(enumRefreshType.All);
                }
                break;

            case enumCanvasEventType.MouseWheel:
                if (!_beginWheel /*&& (_canvas as IDummyRenderModeSupport).IsEnabledDummyCache*/)
                {
                    _timerForWheel.Start();
                    (_canvas as IDummyRenderModeSupport).SetToDummyRenderMode();
                    _hasChanged = true;
                }
                ICanvas canvas = sender as ICanvas;
                //Console.WriteLine("Wheel:" + e.WheelDelta.ToString());
                int steps = 0;
                if (e.WheelDelta > 0)
                {
                    steps = _zoomStepsCalculator.GetZoomSteps(_canvas, e.WheelDelta, -1);
                    canvas.ZoomOutByStep(e.ScreenX, e.ScreenY, steps);
                }
                else
                {
                    steps = _zoomStepsCalculator.GetZoomSteps(_canvas, e.WheelDelta, 1);
                    canvas.ZoomInByStep(e.ScreenX, e.ScreenY, steps);
                }
                //Console.WriteLine("Steps:" + steps.ToString());
                _lastTicks = Environment.TickCount;
                break;
            }
        }