Exemplo n.º 1
0
 public IEventResult OnMouseWheel(IMouseWheelEventArgs e)
 {
     return(null);
 }
Exemplo n.º 2
0
        private void Zoom(IMouseWheelEventArgs e)
        {
            CADPoint globalPnt_UnderMouse = _drawing.CanvasToModel(new CADPoint(e.X, e.Y));
            CADPoint localPnt_UnderMouse  = new CADPoint(e.X, e.Y);
            //
            // Mouse wheel was spinned.
            // Calculate new scale.
            double currentScale = Scale;

            //
            // Delta > 0 - scrolling to user
            // Delta < 0 - from user
            if (e.Delta > 0)
            {
                // zoom out
                if (currentScale >= m_ScaleList[m_ScaleList.Count - 1])
                {
                    return;
                }

                foreach (double rVal in m_ScaleList)
                {
                    if (currentScale < rVal)
                    {
                        Scale = rVal;
                        break;
                    }
                }
            }
            else
            {
                // zoom in
                if (currentScale <= m_ScaleList[0])
                {
                    return;
                }

                int iIndex = m_ScaleList.Count - 1;
                while (iIndex >= 0)
                {
                    if (currentScale > m_ScaleList[iIndex])
                    {
                        Scale = m_ScaleList[iIndex];
                        break;
                    }
                    --iIndex;
                }
            }

            //
            // Need to save cursor position - cursor should been placed over same point in global coordiantes.
            globalPnt_UnderMouse.X *= Scale;
            globalPnt_UnderMouse.Y *= Scale;

            // reverse Y
            // read comment in GetLocalPoint()
            globalPnt_UnderMouse.Y *= -1;

            _drawing.Origin = globalPnt_UnderMouse - localPnt_UnderMouse;

            // reverse Y
            _drawing.Origin.Y *= -1;

            // m_TempOffsetVector.X = 0;
            //  m_TempOffsetVector.Y = 0;

            _drawing.Canvas.Redraw();
        }