Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Auto scroll when dragging an appointment (Read 4711 times)
john6630
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 74
Joined: Sep 20th, 2010
Auto scroll when dragging an appointment
Mar 7th, 2011 at 10:06pm
Print Post  
I have a calendar showing 14 days. The user can move the visible days to see any 2 week interval they desire.

What I want to be able to do is let them drag an appointment and have the calendar scroll horizontally when they reach the edge of the current visible days. Is that possible and if so, how?

Thanks,
John
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Auto scroll when dragging an appointment
Reply #1 - Mar 8th, 2011 at 7:14am
Print Post  
The built-in autoscrolling only works in views with scrollers. You ca try to manually autoscroll by running a timer when the user starts modifying an appointment, then check the mouse position in each timer tick and perform the necessary scrolling if the mouse is near or beyond the edge of the control.

Regards,
Meppy
  
Back to top
 
IP Logged
 
john6630
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 74
Joined: Sep 20th, 2010
Re: Auto scroll when dragging an appointment
Reply #2 - Mar 14th, 2011 at 10:48pm
Print Post  
Hi Meppy,
How do I tell if the mouse is near the edge of the control?

Thanks,
John
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Auto scroll when dragging an appointment
Reply #3 - Mar 15th, 2011 at 6:57am
Print Post  
Check if the mouse position, expressed relatively to the calendar, is near the edge of the rectangle (0, 0, Width, Height) where Width/Height is the physical dimension of the calendar.

Let me know if this helps.

Regards,
Meppy
  
Back to top
 
IP Logged
 
john6630
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 74
Joined: Sep 20th, 2010
Re: Auto scroll when dragging an appointment
Reply #4 - Mar 15th, 2011 at 12:55pm
Print Post  
Is there a sample with code to do this?

Thanks,
John
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Auto scroll when dragging an appointment
Reply #5 - Mar 15th, 2011 at 2:14pm
Print Post  
Here is a sample approach.

Create and initialize a timer:

Code
Select All
private Timer timer;

// ...

timer = new Timer();
timer.Interval = 500;
timer.Tick += new EventHandler(timer_Tick); 


This timer will be enabled during item drag operations. In the Timer.Tick event handler check the position of the mouse relative to the Calendar control and perform the appropriate scrolling. For example the following code adjusts a MonthView to display the previous month when the mouse reaches the left side of the control:

Code
Select All
void timer_Tick(object sender, EventArgs e)
{
      Point p = calendar1.PointToClient(Cursor.Position);
      if (p.X <= 10)
      {
            // Scroll left
            calendar1.Date = calendar1.Date.AddMonths(-1);
      }
} 


Now handle the ItemModifying, ItemModified and ItemModificationCanceled events. In the ItemModifying event handler start the timer. In the ItemModified and ItemModificationCanceled event handlers stop the timer.

If you are using different view, you are free to employ different scrolling logic. The basic principle however will be the same.

Regards,
Meppy
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint