Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 10 Replies) Auto adjust displayed time (Read 5040 times)
elpuerco
Junior Member
**
Offline


Time?  What's time matta
to a pig?

Posts: 94
Joined: Oct 2nd, 2007
Auto adjust displayed time
Feb 11th, 2008 at 10:03am
Print Post  
I have too calendars, one in month view the other in timetable view.

When the user clicks on a date on the month view the timetable view is updated to point to the same date.

My time range is 07:00 - 18:00 and I have the current time bar displayed.

Is it possible to have the timetable view to always be displaying the cell at the current time?

So a user clicks a day in month view and the timetable view updates to that date and the current time?

I have been looking at the vscroll event and have tried setting the timetable view property between 0 - 33 which is the current range but not having much joy!

Thanks





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


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Auto adjust displayed time
Reply #1 - Feb 11th, 2008 at 11:43am
Print Post  
Try setting the vertical scroller position:

Code
Select All
calendar.VScrollPos = value; 


Meppy
  
Back to top
 
IP Logged
 
elpuerco
Junior Member
**
Offline


Time?  What's time matta
to a pig?

Posts: 94
Joined: Oct 2nd, 2007
Re: Auto adjust displayed time
Reply #2 - Feb 11th, 2008 at 12:28pm
Print Post  
yes I know how to do that, any number between 0 - 33 which is my scroll range.

But if it is 14:35 how to I convert that into a scroll value?
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Auto adjust displayed time
Reply #3 - Feb 11th, 2008 at 1:24pm
Print Post  
Divide the time of the the day until now to the value of the CellTime property. Here is an example:

Code
Select All
int value = (int)((double)DateTime.Now.TimeOfDay.Ticks / (double)calendar.TimetableSettings.CellTime.Ticks);

calendar.VScrollPos = value; 


Meppy
  
Back to top
 
IP Logged
 
elpuerco
Junior Member
**
Offline


Time?  What's time matta
to a pig?

Posts: 94
Joined: Oct 2nd, 2007
Re: Auto adjust displayed time
Reply #4 - Feb 12th, 2008 at 7:35am
Print Post  
Thanks Meppy,

this is how I got it to work for me:

Code
Select All
Dim l As Long = 600000000 * 420L

Me.calTimeTableView.VScrollPos = DateTime.Now.TimeOfDay.Ticks / (Me.calTimeTableView.CurrentTime.TimeOfDay.Ticks - l)
 



my calendar starts at 07:00 so I need to calculate the amount of ticks to remove from the calendar current time before doing the division to get the correct scroll position!

Thanks
  
Back to top
 
IP Logged
 
elpuerco
Junior Member
**
Offline


Time?  What's time matta
to a pig?

Posts: 94
Joined: Oct 2nd, 2007
Re: Auto adjust displayed time
Reply #5 - Feb 12th, 2008 at 12:44pm
Print Post  
Mmm?  seems my calculation is flawed!

It does not jump to the right scroll position at all?

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


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Auto adjust displayed time
Reply #6 - Feb 12th, 2008 at 2:37pm
Print Post  
It is possible that the scroll value is bigger than the maximum value of the scrollbar. In this case the position of the scrollbar will not be changed at all. We may add a fix when setting a value larger than the scrollbar's maximum, to use the scrollbar's maximum instead of ignoring the call.

Meppy
  
Back to top
 
IP Logged
 
elpuerco
Junior Member
**
Offline


Time?  What's time matta
to a pig?

Posts: 94
Joined: Oct 2nd, 2007
Re: Auto adjust displayed time
Reply #7 - Feb 12th, 2008 at 2:39pm
Print Post  
OK thanks meppy, I will remove this bit for now and tell the users to not be so lazy and scroll themselves lol  Grin
  
Back to top
 
IP Logged
 
elpuerco
Junior Member
**
Offline


Time?  What's time matta
to a pig?

Posts: 94
Joined: Oct 2nd, 2007
Re: Auto adjust displayed time
Reply #8 - Feb 13th, 2008 at 12:45pm
Print Post  
upon reflection I see my previous calculation was pants!  Grin

It does not make any sense to divide the current time by calendars time of day which is .... the current time of day!  hey ho

so I am now trying to get a calculation as follows:

set a long type variable to the ticks that equal 07:00 ie 250000000000

then using the .FromTicks method get the tick value from the current time as follows:

Code
Select All
Dim l As Long = 250000000000L

Dim ts As TimeSpan = New TimeSpan(Me.calTimeTableView.CurrentTime.TimeOfDay.FromTicks(l))
 



but no matter what I try I keep getting this error:

Access of shared member, constant member, enum member or nested type through an instance; qualifying expression will not be evaluated

Yoinks!


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


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Auto adjust displayed time
Reply #9 - Feb 13th, 2008 at 1:40pm
Print Post  
Thats the code I'm using (in C#):

Code
Select All
MindFusion.Scheduling.WinForms.TimetableSettings s =
	calendar1.TimetableSettings;

long value =
	(DateTime.Now.TimeOfDay.Ticks - TimeSpan.TicksPerMinute * s.StartTime) / s.CellTime.Ticks;

calendar1.VScrollPos = (int)value; 


Again, if its more than the maximum allowed value of the scrollbar, it will not scroll at all.

Meppy
  
Back to top
 
IP Logged
 
elpuerco
Junior Member
**
Offline


Time?  What's time matta
to a pig?

Posts: 94
Joined: Oct 2nd, 2007
Re: Auto adjust displayed time
Reply #10 - Feb 13th, 2008 at 1:55pm
Print Post  
Hi,

just came back to post my "how I did it code"

This seems to work so I might stick with it, although it does look a tad ugly!

Code
Select All
Const st As Long = 252000000000     ' 7am

Const ed As Long = 648000000000    ' 6pm

Dim t As Long = Me.calTimeTableView.CurrentTime.TimeOfDay.Ticks

Const v As Long = 11647058823.5     ' ticks per scroll value between 7am and 6pm

' if the app is run between 7am and 6pm do this

If t >= st And t <= ed Then

     Me.calTimeTableView.VScrollPos = (Me.calTimeTableView.CurrentTime.TimeOfDay.Ticks - st) / v

End If
 

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