Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1320
UltraDayView MouseWheel Behavior
posted

Hi to all.  I am trying to change the way that the UltraDayView behaves when the user scrolls the mousewheel while the Shift button is depressed.  Currently the UltraDayView will scroll up and down regardless of any concurrent keyboard actions, however I wish to have it so that the range of TimeSlots changes so that a ZoomIn/ZoomOut effect is achieved if the mousewheel is scrolled while the Shift button is held down.

So my question is: Is there any easy way to do this?  Or do I need to intercept an event somewhere to cancel the scroll action and force the UltraDayView control to changes its VisibleDaysCollection by manual means?

Cheers.

Parents
  • 69832
    Offline posted

    Interesting idea; here's one possible implementation:

    private void dayView_MouseWheel(object sender, MouseEventArgs e)
    {
        UltraDayView dayView = sender as UltraDayView;

        if ( (Control.ModifierKeys & Keys.Shift) == Keys.Shift )
        {
            int sign = e.Delta > 0 ? 1 : -1;
            int magnitude = Math.Abs(e.Delta / SystemInformation.MouseWheelScrollDelta);
            TimeSlotInterval currentValue = dayView.TimeSlotInterval;
            int index = this.allTimeSlotIntervals.IndexOf(currentValue);
            int newIndex = index + (sign * magnitude);
            newIndex = Math.Min( this.allTimeSlotIntervals.Count - 1, newIndex );
            newIndex = Math.Max( 0, newIndex );

            dayView.TimeSlotInterval = this.allTimeSlotIntervals[newIndex];

            HandledMouseEventArgs upcastedArgs = e as HandledMouseEventArgs;
            if ( upcastedArgs != null )
                upcastedArgs.Handled = true;
        }
    }

Reply Children
No Data