Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 10 Replies) Selection.Contact not working for Resource View (Read 9036 times)
TRB
Junior Member
**
Offline


Meppy knows all!!

Posts: 80
Location: Australia
Joined: Jun 7th, 2013
Selection.Contact not working for Resource View
Aug 14th, 2013 at 11:29am
Print Post  
Once again I have what is probably a stupid question but after serching the forums and the Programmers guide i can't get the selection.contact to work on the resource view. I have tried the same code with the timetable view and it works perfectly? I have also tried the GetContactAt method and it also works perfectly in the timetable view and not in the resource view.
  

Regards,
TRB
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Selection.Contact not working for Resource View
Reply #1 - Aug 14th, 2013 at 11:58am
Print Post  
Hi,

The GetContactAt method seems to be working well in my tests in both Resource and Timetable views. Are you able to provide me with a small sample illustrating the problem, maybe its something related to your view settings?

Regarding Selection.Contact, this property has been removed some time ago (replaced by Selection.Resource). Are you sure you are running with the most up-to-date version of the control? If you mean Selection.Resource, this property indeed returns null in Resource view; you can check the Selection.Resources property in this case. The reason for this is that the Resource view can be grouped by more than one resource at a time. We will refactor this property to return a value in Resource view as well, probably the last resource in the chain if the view is grouped by multiple resources.

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


Meppy knows all!!

Posts: 80
Location: Australia
Joined: Jun 7th, 2013
Re: Selection.Contact not working for Resource View
Reply #2 - Aug 14th, 2013 at 12:59pm
Print Post  
Sorry, I am using Selection.Resource not Selection.Contact and I do have the latest TRIAL Version of the control.
I did another quick test and for example:
Private Sub Calendar1_Click(sender As Object, e As EventArgs) Handles Calendar1.Click
MsgBox(Calendar1.GetContactAt(MousePosition).Id)
MsgBox(Calendar1.Selection.Resource.Id)
End Sub

Will both return the Contact Id in timetable view but will both throw an error "Object reference not set..." in the resource view.
  

Regards,
TRB
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Selection.Contact not working for Resource View
Reply #3 - Aug 14th, 2013 at 1:49pm
Print Post  
Hi,

Regarding Selection.Resource - this property is null in Resource view because this view supports grouping by multiple resources at once and this property could be ambiguous in certain scenarios. However, for the sake of consistency, we've made modifications to the control and this property should now return a valid reference in Resource view as well. In case of multiple grouping, this property should return the last resource in the chain. The modified version could be downloaded from the link below:

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

Regarding GetContactAt, note that this method expects its parameters to express client coordinates. If the MousePosition property in your code is the one inherited from Control, it is in screen coordinates and you need to convert it:

Code
Select All
MsgBox(Calendar1.GetContactAt(Calendar1.PointToClient(MousePosition)).Id) 



I hope this helps.

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


Meppy knows all!!

Posts: 80
Location: Australia
Joined: Jun 7th, 2013
Re: Selection.Contact not working for Resource View
Reply #4 - Aug 15th, 2013 at 7:24am
Print Post  
Thank you:
MsgBox(Calendar1.GetContactAt(Calendar1.PointToClient(MousePosition)).Id) worked well but the Modified version of the control still throws the same error. I repleced the dll files and recreated the references but nothing. I then deleted the control and added it new and still nothing.

So my question now is, is there somthing I am doing wrong with the modified control And/or is there a way to get an acurate draw point when creating an Item so the contacts aren't mixed up if the user drags the pointer out of the correct lane??
  

Regards,
TRB
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Selection.Contact not working for Resource View
Reply #5 - Aug 15th, 2013 at 8:25am
Print Post  
Hi,

The version of the control should be 5.4.4.27957. You can check in the reference properties if it matches. Keep in mind that GetContactAt may still return null (Nothing in VB) for portions of the view with no contact association (for example the timelines above the cells) or for points that are completely outside of the control's bounds. Selection.Resource can return null as well, if there is no selection. Regarding your question, replacing the referenced assemblies with the ones from the link above should be enough.

Quote:
...is there a way to get an acurate draw point when creating an Item so the contacts aren't mixed up if the user drags the pointer out of the correct lane??


I am not entirely sure what you mean. Can you rephrase this question or give an example of what you are trying to achieve?

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


Meppy knows all!!

Posts: 80
Location: Australia
Joined: Jun 7th, 2013
Re: Selection.Contact not working for Resource View
Reply #6 - Aug 15th, 2013 at 8:44am
Print Post  
When the user highlights a range in resource view to create a new item I need to get the resource Id of the resource who's lane the item is being created in(the resource that will be assigned to that item).
I'm out at the moment but when I get back I will check the version.
  

Regards,
TRB
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Selection.Contact not working for Resource View
Reply #7 - Aug 15th, 2013 at 10:10am
Print Post  
If by highlight you mean select, then Selection.Resource is exactly what you need for this purpose. Let me know how it goes with the new version.

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


Meppy knows all!!

Posts: 80
Location: Australia
Joined: Jun 7th, 2013
Re: Selection.Contact not working for Resource View
Reply #8 - Aug 16th, 2013 at 12:06pm
Print Post  
Hi,
I copied the dlls and removed the old ones and now get this error:
'Could not load file or assembly 'MindFusion.Scheduling, Version=5.4.4.27957, Culture=neutral, PublicKeyToken=9bbcdceda2685d38' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)'

  

Regards,
TRB
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Selection.Contact not working for Resource View
Reply #9 - Aug 16th, 2013 at 1:59pm
Print Post  
Can you check if this helps?

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


Meppy knows all!!

Posts: 80
Location: Australia
Joined: Jun 7th, 2013
Re: Selection.Contact not working for Resource View
Reply #10 - Aug 26th, 2013 at 12:21pm
Print Post  
Hi Meppy, Finally got back to this and it is now working!!!!! Thanks so much for the assistance. It was due to the blocked dlls.


While I am going, do you know what format the Header Brush Color is stored as in the database? It looks like HTML but has eight digits. I am unfamiliar with this format and the way to convert a System.Color to this format.
  

Regards,
TRB
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Selection.Contact not working for Resource View
Reply #11 - Aug 26th, 2013 at 2:21pm
Print Post  
Hi,

This is our internal format for brushes. For solid brushes it looks like this "s:#AARRGGBB", where AA, RR, GG, and BB are the respective channels of the color of the brush.

You can use the hidden MindFusion.Drawing.GraphicObject.Serialize and MindFusion.Drawing.GraphicObject.Deserialize static methods to convert MindFusion brushes and pens to strings and vice versa. For example, to convert a brush to a string, you can do the following:

Code
Select All
var stringRepresentation = MindFusion.Drawing.GraphicObject.Serialize(brush); 


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


Meppy knows all!!

Posts: 80
Location: Australia
Joined: Jun 7th, 2013
Re: Selection.Contact not working for Resource View
Reply #12 - Aug 27th, 2013 at 12:58pm
Print Post  
Thanks once again Meppy. It obviously worked. Have a good day.
  

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