Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic D&D on Resourceview (Read 6430 times)
koreson
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 4
Joined: Apr 25th, 2009
D&D on Resourceview
May 5th, 2009 at 12:42am
Print Post  
Hallo,

while my exercises with D&D operations i have a little problem. I have made a simple resource management for cars and rooms.

In the resource view I have grouped for all available resources on left and 2 timelines on the top. According your D&D example I tried to drop new appointments on the view
Code
Select All
if (e.Element == CustomDrawElements.ResourceViewCell)
            {
                if (_pointedDate > DateTime.Now)
                {

                    TimeSpan segment = TimeSpan.FromHours(1);
                    DateTime cellStart = e.Date + e.StartTime;
                    DateTime cellEnd = e.Date + e.EndTime;
                    Rectangle bounds = e.Bounds;

                    string _resName = string.Empty;
                    if (_res != null) //comes from dragover
                        _resName = _res.Name;

                    bounds.Width -= 1;
                    bounds.Height -= 1;
                    if (cellStart <= _pointedDate && _pointedDate < cellEnd)
                    {
                        e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(190, 250, 190)), bounds);
                        bounds.Y += 1;
                        bounds.Height -= 1;

                        string interval = _resName + " " + cellStart.ToString("HH:mm");
                        e.Graphics.DrawString(interval, Font, Brushes.Gray, bounds.Left + 2, bounds.Top + 2);
                    }

                }
            }
 




I want to draw my rectangle only on the lane where the mouse is over. But unfortunaly my solution draw multiple rectangles over all the lanes while the drag operation.
How can I attain that?

best regards
koreson

screenshot while dragging

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


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: D&D on Resourceview
Reply #1 - May 5th, 2009 at 6:20am
Print Post  
You will have to take into consideration the resource corresponding to the mouse position during the drag operation. To obtain the resource, use the appropriate Calendar method - GetResourceAt, GetLocationAt, GetContactAt or GetTaskAt, depending on the type of resources you are using.

For example, use code similar to the following during dragging to remember the resource the mouse points to:

Code
Select All
...
_resource = calendar.GetContactAt(mouse);
... 


Where _resource is a private member of your class. Then, add the following condition in your Draw event handler:

Code
Select All
...
if (e.Resource == _resource)
... 


Finally, instead of processing ResourceViewCell elements, you might want to process ResourceViewCellComplete elements. This will ensure that the Draw event is raised only once for all lanes of a single resource (rather than once for each lane).

Regards,
Meppy
  
Back to top
 
IP Logged
 
koreson
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 4
Joined: Apr 25th, 2009
Re: D&D on Resourceview
Reply #2 - May 5th, 2009 at 12:02pm
Print Post  
Hallo Meppy,

thank you very much for this hint.
It was a logical issue only.


In this context i have another question.
I need more space for an hour in my bottomtimeline.
Is there a way to set a fixed or minimal width for the hour ticks in my bottomtimeline. Appointments shorter than 1 hour are truncated.
I need about 80px for one hour at least.
All properties tested! Cant find it.


best regards

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


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: D&D on Resourceview
Reply #3 - May 5th, 2009 at 12:52pm
Print Post  
Try using the ResourceViewSettings.TimelineScale property with a value larger than 100.

Regards,
Meppy
  
Back to top
 
IP Logged
 
DoctorsDad
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 20
Joined: May 19th, 2011
Re: D&D on Resourceview
Reply #4 - May 20th, 2011 at 2:04pm
Print Post  
I'm trying to do the

if _resource = e.Resource

trick as outlined above but I get

'operator = is not defined for type'

I expected to just be able to test e.pointed in this scenario but it never seems to be set.

Do I need to set some other property somewhere?

DoctorsDad
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: D&D on Resourceview
Reply #5 - May 20th, 2011 at 4:04pm
Print Post  
I'm not much into VB.NET, but shouldn't you use the "is" operator to compare objects by reference?
  
Back to top
 
IP Logged
 
DoctorsDad
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 20
Joined: May 19th, 2011
Re: D&D on Resourceview
Reply #6 - May 20th, 2011 at 4:14pm
Print Post  
Thank you!

Some days I feel very old and stupid.

I blame the constant switching between VB, C# and C++ but it could just be senility.

DoctorsDad
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: D&D on Resourceview
Reply #7 - May 20th, 2011 at 4:18pm
Print Post  
perhaps just a Friday thing Smiley
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint