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

ScheduleView determine position from time

12 Answers 136 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
Alexander
Top achievements
Rank 1
Alexander asked on 28 Apr 2011, 02:25 PM
Hi,

is there a method to determine the current screen position (e.g. relative to the control) for a given time value? We need to draw some adorning visuals (lines) to show the current time.

Thanks,
Alexander

12 Answers, 1 is accepted

Sort by
0
Konstantina
Telerik team
answered on 03 May 2011, 11:02 AM
Hello Alexander,

Unfortunately, this cannot be achieved with the current implementation of the control. However, you can use the VisibleRange and the CurrentDate properties, which will give you all the information about the date in the view.

Hope this information helps.

Best wishes,
Konstantina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Alexander
Top achievements
Rank 1
answered on 03 May 2011, 02:13 PM
Hi Konstantina,

thank you for your reply.

This (and some other, forthcoming requirements) would actually be easy to implement if the internal classes PositioningData and PositioningHelper were externally accessible. Any thoughts on this?

Thanks,
Alexander


0
Konstantina
Telerik team
answered on 04 May 2011, 11:09 AM
Hello Alexander,

Thank you for your question.

We will expose an Interface of the PositioningHelper in order to be usable.

Best wishes,
Konstantina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Alexander
Top achievements
Rank 1
answered on 04 May 2011, 11:16 AM
Hi Konstantina,

while we are at it :) , here is one more suggestion: Public access to time information of a TimeRulerItemBase instance?

Thanks again,
Alexander
0
Yana
Telerik team
answered on 09 May 2011, 01:16 PM
Hello Alexander,

Could you please explain in more details your scenario and why you need to access TimeRulerItemBase? Thanks in advance

Kind regards,
Yana
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Alexander
Top achievements
Rank 1
answered on 09 May 2011, 01:50 PM
Hello Yana,

this was related to an early attempt to solve my initial problem (see above). I could find the TimeRulerItem's via visual tree walking. But there was no way (short of reflection) to access the associated time information.

Anyway, we found a better solution.

Thanks,
Alexander
0
Kristian
Top achievements
Rank 1
answered on 28 Jun 2011, 09:31 AM
Aleksander: I want to implement this feature in my calendar as well, and I am therefore wondering if you can give me some hints about how you did it?

Thanks,
Kristian
0
Alexander
Top achievements
Rank 1
answered on 28 Jun 2011, 11:11 AM
Hi Kristian,

first, we got a reference (_scrollBar) to the ScheduleView ScrollBar via VisualTree walking and looking for "PART_HorizontalScrollBar".
then, assuming the names SchedulerView for RadScheduleView and ViewDef for TimelineViewDefinition:

var scale = ViewDef.MinTimeRulerExtent / SchedulerView.VisibleRange.Duration().TotalMinutes;
var elapsed = ((DateTime.Now - SchedulerView.VisibleRange.Start).TotalMinutes) * scale;
var x = elapsed - _scrollBar.Value;
            

x is the horizontal position for the current time, relative to the ScheduleView. You could put a transparent canvas in front of it and position a marker.

Hope this helps,
Alexander
0
Kristian
Top achievements
Rank 1
answered on 29 Jun 2011, 07:40 AM
Hi Alexander,

Thank you for the hints! I am able to find the position for the current time now, but after that, I am kind of stuck.
Did you find a good way of updating the markers position every time the user scrolls the scrollbar? I can not seem to find any methods or events in RadScheduleView that can be useful for this kind of situation.

Thanks,
Kristian
0
Alexander
Top achievements
Rank 1
answered on 29 Jun 2011, 07:52 AM
Hi Kristian,

you can use the Scroll event. Assuming the the reference to the scrollbar is in _scrollBar:

_scrollBar.Scroll += SchedulerView_Scroll;

And then implement an event handler to refresh your visuals.

Cheers,
Alexander
0
Kristian
Top achievements
Rank 1
answered on 29 Jun 2011, 01:47 PM
Hi Alexander,

Thank you for the help! I had completely forgotten the events on the scrollbar itself.
I ended up subscribing to the ScrollBar's ValueChanged event, as this enabled me to update the marker when the user moves the scrollbar by using the mouse, the scrollwheel on the mouse, or when the user uses the up/down keys on the keyboard to navigate.

I also found a different, and maybe easier, way of obtaining the reference to the ScrollBar object:
Scrollbar verticalScrollBar = RadSchedule.ChildrenOfType<ScrollBar>().Where(s => s.Orientation == Orientation.Vertical).First();
RadSchedule is a reference to an RadScheduleView object.

You can read more about this way of obtaining the ScrollBar (and all other objects) in this blog post.

Cheers,
Kristian
0
Alexander
Top achievements
Rank 1
answered on 29 Jun 2011, 02:38 PM
Hi Kristian,

this will be really useful, thanks!

Alexander
Tags
ScheduleView
Asked by
Alexander
Top achievements
Rank 1
Answers by
Konstantina
Telerik team
Alexander
Top achievements
Rank 1
Yana
Telerik team
Kristian
Top achievements
Rank 1
Share this question
or