Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic ResourceView: Results of the GetExactDateAt() method... (Read 4700 times)
Achim
Junior Member
**
Offline


MindFusion rocks!

Posts: 70
Location: Bayreuth, Germany
Joined: Jun 28th, 2012
ResourceView: Results of the GetExactDateAt() method...
Feb 25th, 2013 at 11:54am
Print Post  
Hi there,

for some CustomDrawing operations I need to know the exact visible Start and End DateTime of an item being drawn in the resourceview. In case the item is drawn completely these DateTimes should exactly match the Start and End time of the item given in args.Item. But I can't achieve this...

My test was as follows: I created an Item starting at 09:12:05. In the ItemDrawing event I called GetExactDateAt(args.Bounds.X, 10) assuming this should be the same as the start time (as long as the item is completely visible on the chart). But the result was 09:07:05. Then I thought, maybe it's an issue regarding the coordinate system of GDI+ but it isn't.

Code
Select All
var s1 = _ganttChart.GetExactDateAt(args.Bounds.X - 1, 10);
var s2 = _ganttChart.GetExactDateAt(args.Bounds.X + 1, 10);
 



s1 is 09:04:51 for the item
s2 is 09:10:45 for the item

I thought at least one of the calls to GetExactDateAt() should return a value equal or greater than 09:12:05 (the items start time).

Is this a bug or am I using the wrong method? For precise painting on the time line I need a way to precisely map between the drawn coordinates and the time values. Thanks in advance for any help on this topic.

Best regards
Achim
  
Back to top
WWW  
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: ResourceView: Results of the GetExactDateAt() method...
Reply #1 - Feb 25th, 2013 at 1:55pm
Print Post  
Hi,

I'm having difficulties reproducing this. What are your view settings, more specifically, what Unit are you using? I am testing with Unit=Hour and GetExactDateAt returns acceptable results. (By acceptable I mean with error within the current view's resolution. That is, GetExactDateAt accepts pixel coordinates as arguments and it is not possible to guarantee that the returned value will be exactly the same as the item's StartTime because the item's StartTime may not be precisely pixel-aligned in the current view resolution.)

However, the results you are getting appear to be wrong, so if you are able to provide me with your view settings or a small sample illustrating the issue, this will help.

Regards,
Meppy
  
Back to top
 
IP Logged
 
Achim
Junior Member
**
Offline


MindFusion rocks!

Posts: 70
Location: Bayreuth, Germany
Joined: Jun 28th, 2012
Re: ResourceView: Results of the GetExactDateAt() method...
Reply #2 - Feb 26th, 2013 at 11:59am
Print Post  
Meppy,

theoretically GetExactDateAt(), when accepting pixel coordinates, at least should return a TimeSpan because one pixel represents a range of time. Otherwise it should be well defined, which point in this TimeSpan the method returns, for example the starting point or the end point. Then, if I call the method with args.Bounds.X, it should return a value that lies within the range of one pixel. So I would be able to match the result of the method and evaluate if the a given DateTime lies within this range (or let it call the "scale" one pixel shows; can be expressed in Pixel/TimeUnit, e.g. px/hour).

BTW I have the following settings:
Code
Select All
var tlBottom = calendarControl.ResourceViewSettings.BottomTimelineSettings;
var tlMiddle = calendarControl.ResourceViewSettings.MiddleTimelineSettings;
var tlTop = calendarControl.ResourceViewSettings.TopTimelineSettings;

tlBottom.Format = "HH";
tlBottom.Unit = TimeUnit.Hour;
tlBottom.UnitCount = 1;

tlMiddle.Format = "dd.MM.";
tlMiddle.Unit = TimeUnit.Day;
tlMiddle.UnitCount = 1;

tlTop.Format = "MMMM yy";
tlTop.Unit = TimeUnit.Month;
tlTop.UnitCount = 1;

calendarControl.ResourceViewSettings.ScrollStep = new TimeSpan(0,30,0);
calendarControl.ResourceViewSettings.SnapUnit = TimeUnit.Minute;
calendarControl.ResourceViewSettings.SnapUnitCount = 10;
 



Thanks for your help
Achim
  
Back to top
WWW  
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: ResourceView: Results of the GetExactDateAt() method...
Reply #3 - Feb 27th, 2013 at 3:07pm
Print Post  
Hi,

We have implemented some improvements to the control to make the ItemDrawing event information and the result of the GetExactDateAt method more consistent. You can download the new version from the link below:

https://mindfusion.eu/_temp/MindFusion.Scheduling.trial.zip

Keep in mind that the remarks from my previous post still stand, that is, a single pixel corresponds to a range of dates and you should not expect GetExactDateAt(e.Bounds.Left) to match e.Item.StartTime exactly, unless the item's start is precisely pixel-aligned. However, the difference between the two values should now be within the current resolution.

Also, be advised that there might be errors in this build, because we had to make various modifications to the internal presentation of item and cell coordinates.

Regards,
Meppy
  
Back to top
 
IP Logged
 
Achim
Junior Member
**
Offline


MindFusion rocks!

Posts: 70
Location: Bayreuth, Germany
Joined: Jun 28th, 2012
Re: ResourceView: Results of the GetExactDateAt() method...
Reply #4 - Feb 28th, 2013 at 8:31am
Print Post  
Hi Meppy,

thank you for your help. I understand your advice - it's exactly the behavior I'm expecting Smiley

I'll try the new build and report here.

Best regards
Achim
  
Back to top
WWW  
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint