
Christie Admin
Top achievements
Rank 1
Christie Admin
asked on 17 Jan 2014, 07:07 PM
Hi,
I'm using a WeekViewDefinition and I would like to know when I resize a spot if it's possible to resize more than 1 min at a time???
Thank's
Alain
I'm using a WeekViewDefinition and I would like to know when I resize a spot if it's possible to resize more than 1 min at a time???
Thank's
Alain
7 Answers, 1 is accepted
0
Hi Alain,
The desired scenario can be achieved by setting the SnapAppointments property of the ScheduleView to True. By default this will snap by the MinorTickLength of the current ViewDefition. You can also implement a custom SnapBehavior which will allow you to snap by a specific time not related to the used MinorTickLength. For more details please check the following article from our online help documentation:
http://www.telerik.com/help/wpf/radscheduleview-features-snapappointments.html
Hope this helps.
Regards,
Kalin
Telerik
The desired scenario can be achieved by setting the SnapAppointments property of the ScheduleView to True. By default this will snap by the MinorTickLength of the current ViewDefition. You can also implement a custom SnapBehavior which will allow you to snap by a specific time not related to the used MinorTickLength. For more details please check the following article from our online help documentation:
http://www.telerik.com/help/wpf/radscheduleview-features-snapappointments.html
Hope this helps.
Regards,
Kalin
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0

Christie Admin
Top achievements
Rank 1
answered on 22 Jan 2014, 07:23 PM
Thank's Kalin :)
The "SnapAppointment" do exactly what I need for the drag'n drop but for a resize operation I need to keep the "SnapAppointment=False" behaviour, is this possible?!?
Alain
The "SnapAppointment" do exactly what I need for the drag'n drop but for a resize operation I need to keep the "SnapAppointment=False" behaviour, is this possible?!?
Alain
0
Accepted
Hi Alain,
You will be able to achieve the desired by implementing a custom ScheduleView DragDropBehavior. Afterwards you will need to override the CanStartResize and Resize methods the following way:
This when the resize operation is starting the SnapAppointments property of the ScheduleView will be set on false and when the resize is finished the property is set back on true.
Hope this will work for you.
Regards,
Kalin
Telerik
You will be able to achieve the desired by implementing a custom ScheduleView DragDropBehavior. Afterwards you will need to override the CanStartResize and Resize methods the following way:
public
override
bool
CanStartResize(DragDropState state)
{
var scheduleView = state.ServiceProvider.GetService<IDialogProvider>()
as
RadScheduleView;
scheduleView.SnapAppointments =
false
;
return
base
.CanResize(state);
}
public
override
void
Resize(DragDropState state)
{
var scheduleView = state.ServiceProvider.GetService<IDialogProvider>()
as
RadScheduleView;
scheduleView.SnapAppointments =
true
;
base
.Resize(state);
}
This when the resize operation is starting the SnapAppointments property of the ScheduleView will be set on false and when the resize is finished the property is set back on true.
Hope this will work for you.
Regards,
Kalin
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0

Christie Admin
Top achievements
Rank 1
answered on 06 Feb 2014, 06:54 PM
Hi Kalin,
my needs change a little bit :) No matter what is the value of the MinorTickLength, the drag 'n' drop should always snap by 5 mins but the resize new to be by x mins, x is an int value in my appointment object.
Thank's
Alain
my needs change a little bit :) No matter what is the value of the MinorTickLength, the drag 'n' drop should always snap by 5 mins but the resize new to be by x mins, x is an int value in my appointment object.
Thank's
Alain
0

Christie Admin
Top achievements
Rank 1
answered on 06 Feb 2014, 08:12 PM
Kalin,
I found my solution, thank you in advance :)
Alain
I found my solution, thank you in advance :)
Alain
0

Christie Admin
Top achievements
Rank 1
answered on 26 Feb 2014, 04:18 PM
Hi Kalin,
regarding the following link: http://www.telerik.com/help/wpf/radscheduleview-features-snapappointments.html
I think there is an issue with the piece of code....
If you have a period which start at 12:05 and finish at 12:38 and you need to resize the end by 11 mins, the first resize step increase the ending of the period by 5 mins then the next one will be ok....
Thank's
Alain
public class CreateScheduleCustomSnapBehavior : SnapBehavior
{
#region Protected methods.
protected override System.Windows.Freezable CreateInstanceCore()
{
return null;
}
#endregion
#region Public methods.
public override DateTime SnapEnd(SnapData pSnapData, DateTime pTimeToSnap)
{
RadScheduleView scheduleView = pSnapData.ServiceProvider.GetService<IDialogProvider>() as RadScheduleView;
CreateScheduleSpot theSpot = pSnapData.OriginalData as CreateScheduleSpot;
int minutes = scheduleView.SnapAppointments ? 5 : Convert.ToInt32(theSpot.SpotsDuration.TotalMinutes);
// We don't need a divide by zero exception in the "SnapToTimeSpan" method!!!
if (minutes == 0)
{
minutes = 15;
}
if (pTimeToSnap >= pSnapData.OriginalData.End)
{
return SnapToTimeSpan(TimeSpan.FromMinutes(minutes), pTimeToSnap, true);
}
else
{
return SnapToTimeSpan(TimeSpan.FromMinutes(minutes), pTimeToSnap, false);
}
}
public override DateTime SnapStart(SnapData pSnapData, DateTime pTimeToSnap)
{
RadScheduleView scheduleView = pSnapData.ServiceProvider.GetService<IDialogProvider>() as RadScheduleView;
CreateScheduleSpot theSpot = pSnapData.OriginalData as CreateScheduleSpot;
int minutes = scheduleView.SnapAppointments ? 5 : Convert.ToInt32(theSpot.SpotsDuration.TotalMinutes);
// We don't need a divide by zero exception in the "SnapToTimeSpan" method!!!
if (minutes == 0)
{
minutes = 15;
}
if (pTimeToSnap >= pSnapData.OriginalData.End)
{
return SnapToTimeSpan(TimeSpan.FromMinutes(minutes), pTimeToSnap, true);
}
else
{
return SnapToTimeSpan(TimeSpan.FromMinutes(minutes), pTimeToSnap, false);
}
}
public static DateTime SnapToTimeSpan(TimeSpan pTimeSpan, DateTime pTimeToSnap, bool pRoundToBiggestNumber)
{
var difference = pTimeToSnap.Ticks % pTimeSpan.Ticks;
if (pRoundToBiggestNumber)
{
return pTimeToSnap.AddTicks(pTimeSpan.Ticks - difference);
}
return pTimeToSnap.AddTicks(-difference);
}
#endregion
}
regarding the following link: http://www.telerik.com/help/wpf/radscheduleview-features-snapappointments.html
I think there is an issue with the piece of code....
If you have a period which start at 12:05 and finish at 12:38 and you need to resize the end by 11 mins, the first resize step increase the ending of the period by 5 mins then the next one will be ok....
Thank's
Alain
public class CreateScheduleCustomSnapBehavior : SnapBehavior
{
#region Protected methods.
protected override System.Windows.Freezable CreateInstanceCore()
{
return null;
}
#endregion
#region Public methods.
public override DateTime SnapEnd(SnapData pSnapData, DateTime pTimeToSnap)
{
RadScheduleView scheduleView = pSnapData.ServiceProvider.GetService<IDialogProvider>() as RadScheduleView;
CreateScheduleSpot theSpot = pSnapData.OriginalData as CreateScheduleSpot;
int minutes = scheduleView.SnapAppointments ? 5 : Convert.ToInt32(theSpot.SpotsDuration.TotalMinutes);
// We don't need a divide by zero exception in the "SnapToTimeSpan" method!!!
if (minutes == 0)
{
minutes = 15;
}
if (pTimeToSnap >= pSnapData.OriginalData.End)
{
return SnapToTimeSpan(TimeSpan.FromMinutes(minutes), pTimeToSnap, true);
}
else
{
return SnapToTimeSpan(TimeSpan.FromMinutes(minutes), pTimeToSnap, false);
}
}
public override DateTime SnapStart(SnapData pSnapData, DateTime pTimeToSnap)
{
RadScheduleView scheduleView = pSnapData.ServiceProvider.GetService<IDialogProvider>() as RadScheduleView;
CreateScheduleSpot theSpot = pSnapData.OriginalData as CreateScheduleSpot;
int minutes = scheduleView.SnapAppointments ? 5 : Convert.ToInt32(theSpot.SpotsDuration.TotalMinutes);
// We don't need a divide by zero exception in the "SnapToTimeSpan" method!!!
if (minutes == 0)
{
minutes = 15;
}
if (pTimeToSnap >= pSnapData.OriginalData.End)
{
return SnapToTimeSpan(TimeSpan.FromMinutes(minutes), pTimeToSnap, true);
}
else
{
return SnapToTimeSpan(TimeSpan.FromMinutes(minutes), pTimeToSnap, false);
}
}
public static DateTime SnapToTimeSpan(TimeSpan pTimeSpan, DateTime pTimeToSnap, bool pRoundToBiggestNumber)
{
var difference = pTimeToSnap.Ticks % pTimeSpan.Ticks;
if (pRoundToBiggestNumber)
{
return pTimeToSnap.AddTicks(pTimeSpan.Ticks - difference);
}
return pTimeToSnap.AddTicks(-difference);
}
#endregion
}
0
Hi Alain,
I tested the code from the article and didn't observe any issues there. However you won't be able to resize the Appointment with 11 minutes as the snap behavior is set to 5 minutes and it is also rounding the time. Please share some more details on what you need to achieve so we can help you further.
I'm looking forward to hearing from you.
Regards,
Kalin
Telerik
I tested the code from the article and didn't observe any issues there. However you won't be able to resize the Appointment with 11 minutes as the snap behavior is set to 5 minutes and it is also rounding the time. Please share some more details on what you need to achieve so we can help you further.
I'm looking forward to hearing from you.
Regards,
Kalin
Telerik