This is a migrated thread and some comments may be shown as answers.

Restrict Start and End during Drag and drop

7 Answers 152 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
LE CORGUILLE
Top achievements
Rank 1
LE CORGUILLE asked on 01 Sep 2017, 02:27 PM

Hi,

I would like to restrict the start and end at the original value during drag and drop appointment.

I just need to change the slot by dragging.

How can i do that.

thanks in advance.

 

 

7 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 06 Sep 2017, 01:40 PM
Hi Bouly Michel,

Firstly, can you please review the Drag and Drop with RadScheduleView topic and the Drag and Drop WPF Demo if you didn't have the chance to do so already? If they do not help, may I kindly ask you to share some additional details regarding your requirement, as I am not sure I am understanding it completely?

Best Regards,
Stefan X1
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Craig
Top achievements
Rank 1
answered on 14 Apr 2018, 02:59 AM

Hi Stefan,

I have a situation where the appointments are actually Jobs in our operational system.  Initially every appointment does not have a resource allocated to it, but we need to build a 'line of work' i.e. multiple jobs that will be assigned to the same resource.  When we move these appointments (jobs) between lines (resources) we need to keep the time of the appointment i.e. it can not change times, only the resource that it is allocated to.  So in a time-line view ideally the appointment should only be able to be moved up-down not left-right, but we would be happy to just drop and have it reset the start-end times to the original regardless of where on the line it was dropped.

 

 

0
Stefan
Telerik team
answered on 18 Apr 2018, 01:22 PM
Hello Craig,

What I can propose you is to utilize a custom DragDropBehavior. By doing so you should be able to implement the needed logic for restricting the drop operation through the CanDrop method. The approach of implementing such behavior is demonstrated in the Custom DragDropBehavior SDK Example. It can be reviewed through the SDK Samples Browser. Can you please take a look at it?

I hope this helps.

Regards,
Stefan
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Craig
Top achievements
Rank 1
answered on 18 Apr 2018, 01:53 PM

Hi Stefan,

If you try to restrict it via the CanDrop method then you have to move the mouse precisely vertically.  If you move the mouse slightly to the left or right you get that it can't drop, our users are good but not that good.

What I ended up doing, is allowing drag anywhere BUT changing the time back to the original in the custom DragDrop.Drop method.

The following issues remain though in regards to UI behavior
1) while dragging the 'drag-cursor' moves (and displays the time of the slot it is being dragged over)

2) I am also checking for other appointments that overlap with this one, but once again unless you get the mouse precisely over the right spot, the methods to check the overlap fail (because it's using the current slot based on the drag position)

Is there any way that the 'drag-cursor' could remain in position and show the correct time, and thus (on a time-line view) basically only move vertically (up-down) in the appropriate time-slot.

Thanks
Craig

0
Stefan
Telerik team
answered on 23 Apr 2018, 10:15 AM
Hi Craig,

Thanks for the update.

I will go straight to your questions.

1. In order to control the position of the DragVisual, you can subscribe to the DragInitialize event. The event arguments provide the DragVisualOffset and the RelativeStartPoint properties through which you can achieve the desired behavior. The topic is discussed in greater detail in the DragVisual position relative to cursor forum thread. Can you please take a look at it and let me know whether it corresponds to your requirement?

2. As for avoiding the overlapping of the appointments, the approach is demonstrated in the Avoid Overlapping Appointments SDK Example. Can you please check it out?

Regards,
Stefan
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Craig
Top achievements
Rank 1
answered on 01 May 2018, 06:00 AM

Hi Stefan,

I have looked at the post, about subscribing to the DragInitialize event.  But the RadScheduleView does not seem to trigger this event (with a custom drag-drop behavior or without one).

I have in code (the DragDropManager appears in the constructor of the window after InitializeComponent():

DragDropManager.AddDragInitializeHandler(ScheduleView, SvDragInitHandler);
 
private void SvDragInitHandler(object sender, DragInitializeEventArgs dragInitializeEventArgs)
        {
            Console.WriteLine(
                $"Drag Start: X:{dragInitializeEventArgs.RelativeStartPoint.X} Y:{dragInitializeEventArgs.RelativeStartPoint.Y}");
            Console.WriteLine(
                $"Drag Offset: X:{dragInitializeEventArgs.DragVisualOffset.X} Y:{dragInitializeEventArgs.DragVisualOffset.Y}");
        }

In the WPF, on the ScheduleView control I have added the code:

telerik:DragDropManager.AllowCapturedDrag="True"

 

So if I can't capture this event to start with, I can't go any further down that line. 

Also my understanding from the article is that it gives an offset ultimately relative to the original, but I can't see how that can set say a static X (i.e. you can't move left-right) and keep a dynamic Y (you can move up-down).  It appears that this just gives a relative point to the mouse cursor?

 

0
Stefan
Telerik team
answered on 03 May 2018, 09:42 AM
Hello Craig,

As the DragInitialize event is used internally as well, you need to mark the handledEventsToo parameter to true. Please, excuse me for missing to clarify this.
DragDropManager.AddDragInitializeHandler(ScheduleView, SvDragInitHandler, true);

Can you please give it a try?

As to your second question, indeed the RelativeStartPoint gives information regarding the relative coordinates of the mouse. I am afraid, that I cannot suggest a concrete implementation for achieving the desired calculation.

Regards,
Stefan
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Tags
ScheduleView
Asked by
LE CORGUILLE
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Craig
Top achievements
Rank 1
Share this question
or