Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Dragging Appointment Events (Read 4284 times)
punkcoder
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 8
Joined: Nov 9th, 2006
Dragging Appointment Events
Mar 28th, 2007 at 3:31pm
Print Post  
When a user drags an appointment (in timetable view) from one location on the calendar to another, what event is fired when they let go of the mouse button?  Here's the issue I am running into.  Our application is used to build a schedule for our networks television shows.  Since you of course can not have two television shows scheduled to air at the same time on a network, when a user drags a show (an appointment) that's already on the schedule from one time slot to another I have to check if a show is already scheduled at the time they are trying to drag the show to.  If a show is already scheduled at that time I need to remove the scheduled show and replace it with the one they dragged.  I have that working with the code below:

void ScheduleCalendar_ItemModified(object sender, ItemModifiedEventArgs e)
{
           FranchiseAiring airing = e.Item.Tag as FranchiseAiring;

           DeleteOverlappedItem(airing);
}

The DeleteOverlappedItem() method checks to see if an airing is already scheduled in the time slot.

The issue I am running into is it appears the ItemModified event fires off before the user releases the mouse button, causing them to delete an overlapping show when they don't want to.  So is there a different event I should be using to determine when a user is done dragging a show from one location to another?  I can't use ItemStartTimeChanged() or ItemEndTimeChanged() because those fire off multiple times, not just at the end of a drag and drop.

Thanks.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Dragging Appointment Events
Reply #1 - Mar 28th, 2007 at 3:57pm
Print Post  
You could check the state of the left mouse button using the Control.MouseButtons property. Delete the overlapping item only when the property value shows the button is up.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
punkcoder
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 8
Joined: Nov 9th, 2006
Re: Dragging Appointment Events
Reply #2 - Mar 28th, 2007 at 4:40pm
Print Post  
I updated the ItemModified() event to include a check for if no mousebutton is down like so:

void ScheduleCalendar_ItemModified(object sender, ItemModifiedEventArgs e)
{
           FranchiseAiring airing = e.Item.Tag as FranchiseAiring;

           if (Control.MouseButtons == MouseButtons.None)
               DeleteOverlappedItem(airing);
}

unfortunately this only works if you drag an appointment from one location on a schedule to another and release the mouse button right away.  If you drag an appointment from one location to another and then keep the mouse button held down for a second or two the ItemModified() event will execute and the Control.MouseButtons will equal MouseButtons.Left and the DeleteOverlappedItem() method won't get executed, giving me two shows in the same cell.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Dragging Appointment Events
Reply #3 - Mar 28th, 2007 at 5:26pm
Print Post  
I thought you need to keep the two items while the mouse is still down? The two shows in the same cell will exist only for a while, until the user releases the buton. Or does the dragging stops automatically after a few seconds, even if the mouse is still down?

Stoyan
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Dragging Appointment Events
Reply #4 - Mar 29th, 2007 at 4:05am
Print Post  
The ItemModified event should not be fired before the user releases the mouse button while dragging an item. If the event is fired before the user releases the mouse button, there might be something else causing this.

What I understand you want to achieve is letting users drag an item around without affecting the rest of the scheduled appointments. Once the item is dropped (i.e. the left mouse button is released) you wish to remove all overlapping appointments, leaving only the dragged item in its new time frame.

I am using the following code to achieve this and it is working well:

Code
Select All
private void calendar1_ItemModified(object sender, MindFusion.Scheduling.WinForms.ItemModifiedEventArgs e)
{
    ItemCollection items =
	  calendar1.Schedule.GetAllItems(e.Item.StartTime, e.Item.EndTime);

    foreach (Item item in items)
    {
	  if (item != e.Item)
		calendar1.Schedule.Items.Remove(item);
    }
} 


Meppy
  
Back to top
 
IP Logged
 
punkcoder
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 8
Joined: Nov 9th, 2006
Re: Dragging Appointment Events
Reply #5 - Mar 29th, 2007 at 10:05am
Print Post  
"What I understand you want to achieve is letting users drag an item around without affecting the rest of the scheduled appointments. Once the item is dropped (i.e. the left mouse button is released) you wish to remove all overlapping appointments, leaving only the dragged item in its new time frame."

That's correct.  Maybe it's an issue with the version we are running.  The Calendar.dll shows version 4.0.2357.25099.

If I take the code you provided and I place a break point inside it and drag an appointment on the schedule the break point will be triggered while I am still sitting there with the mouse button down.
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Dragging Appointment Events
Reply #6 - Mar 29th, 2007 at 10:30am
Print Post  
Does the same thing happen if you create a blank project with Planner.NET on it and try to handle the ItemModified event? I was just wondering whether there is a property set somewhere else in your project, which might be causing this behavior to occur. If the same thing happen in this new project as well, then the problem is definitely in the version of Planner.NET you are using.

Meppy
  
Back to top
 
IP Logged
 
punkcoder
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 8
Joined: Nov 9th, 2006
Re: Dragging Appointment Events
Reply #7 - Mar 29th, 2007 at 1:08pm
Print Post  
I should have tried that first.  I threw together a quick test application and I can't replicate the issue in it.  Looks like we have something set up incorrectly somewhere in our application, so I will look into that.

Thank you for you help.
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Dragging Appointment Events
Reply #8 - Mar 30th, 2007 at 3:30am
Print Post  
If you can send me your application or an application which reproduces this problem, I will be able to look into what might be causing it.

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