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

In Timeline view, how to position according to current time?

6 Answers 330 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
Thomas
Top achievements
Rank 2
Thomas asked on 05 Oct 2012, 11:33 AM
Hi, I'm using the latest ScheduleView control, in timeline view mode only. I would really like to have a more "fluid" horizontally scrolling experience, rather than the default day-by-day scrolling.

Question 1: Is it possible to scroll the timeline view by using eg. hours? By default, it seems to insist on starting at 00:00 on the first day within view, and allows only scrolling day-by-day. (With LargeChangeInterval = "1d" - setting hours does not seem to work here).

Question 2: What I would really like is to have the timeline view positioning itself with the current time always at a fixed position, eg. towards the left of the screen. So it would appear to be "floating by" underneath. Have you seen/heard about anyone doing this before with your control?

Regards,
Thomas

6 Answers, 1 is accepted

Sort by
0
Thomas
Top achievements
Rank 2
answered on 06 Oct 2012, 12:13 PM
Think I've found a possible solution to both questions, after reading to the bottom of this thread.

By using the ScrollTimeRuler method of radScheduleView, I can scroll the horizontal scrollbar to the current time of day, minus eg. 6 hours to see a little of the "history" as well. Just need to do this periodically, and the positioning should be fine then.

I guess I also need to ensure that there is always eg. 3 days of future appointments in the view, maybe by reloading the dataset every hour or so.
0
Gurpreet
Top achievements
Rank 1
answered on 15 Oct 2012, 11:53 AM
Hi Thomas,

I'm attempting to do exactly the same thing here and I'm pretty new to the RadScheduleView.

I followed the link that you posted but can't get this to work. Maybe I'm missing something. Could you explain how you achieved this?

Any help would be much appreciated.

Regards,
Gurpreet
0
Thomas
Top achievements
Rank 2
answered on 19 Oct 2012, 06:56 AM
Hi Gurpreet.

Sorry for the delayed response here - I've been off for a bit of vacation...

Anyway, my current LayoutUpdate event handler looks like this:

private void radScheduleView1_LayoutUpdated(object sender, EventArgs e)
        {
            if (radScheduleView1 != null && radScheduleView1.ActiveViewDefinition is TimelineViewDefinition)
            {
                radScheduleView1.LayoutUpdated -= new EventHandler(radScheduleView1_LayoutUpdated);
                TimeSpan timeSpan = TimeSpan.FromTicks(DateTime.Now.AddHours(-6).TimeOfDay.Ticks);
                radScheduleView1.ScrollTimeRuler(timeSpan, true);
            }
        }

This causes the timeruler and horizontal scrollbar to display initially 6 hours of "history", leading up to the current time. Note that the event handler is removed in the first line of code, since the handler is fired a lot of times during the rendering. Using this code, it only fires once.

Now I have not implemented more than this currently, but I think I will need to do this positioning periodically, eg. every 1 minute, so the timeline will appear to "pass by" (by using a background timer event). However, this automatic update should only occur when the user is not working with the timeline. This requires some kind of "edit mode" flag that will disable the automatic updating until the user is done editing the timelines. But that is a different problem.

Hope this helps.
Regards,
Thomas
0
Gurpreet
Top achievements
Rank 1
answered on 19 Oct 2012, 08:33 AM
Hi Thomas,

Thanks for the reply.

I tried that exact same code previously but it doesn't seem to be doing anything. However if I comment out the bit where you disable the event handler it seems to snap to the selected timespan but the scrollbar can't be moved.
0
Thomas
Top achievements
Rank 2
answered on 19 Oct 2012, 08:41 AM
Hi,
If you do not detach the event handler, the code will fire a lot of times - also when the scroll bar is attempted moved. And since the code resets the timeruler and scrollbar position - you will see the behaviour you describe. You can verify this by inserting a breakpoint in the event handler. First, notice how many times the event handler is fired upon start. Second, notice that the event also fires when you move the scrollbar. So I think you need the event detach - or another way to achieve the same result.

With the event handler detach - does the scrollbar not move a bit forward, and the timeruler starts at another time than "00:00"? That is what happens on my side.

Thomas

Edit: Hmm... just tried it again - it seems to fire really often, that LayoutUpdate event - in fact, so often that it is a bit hard to get to the scrollbar with a breakpoint set. Maybe the LayoutUpdate event is not the best choice here - have you tried to do a simple button, which calls ScrollTimeRuler upon click? In my case, I think I'm going to move the ScrollTimeRule call into a timer event instead, as described earlier.
0
Gurpreet
Top achievements
Rank 1
answered on 19 Oct 2012, 09:47 AM
I was thinking I might just set the DayStartTime and DayEndTime in my ViewModel and bind those to the TimeLineViewDefinition rather than mess with scrolling. Since we only want to show hours selected from a combobox.

But thanks for your help!
Tags
ScheduleView
Asked by
Thomas
Top achievements
Rank 2
Answers by
Thomas
Top achievements
Rank 2
Gurpreet
Top achievements
Rank 1
Share this question
or