Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic CustomDraw the complete Item in ResourceView (Read 4853 times)
Achim
Junior Member
**
Offline


MindFusion rocks!

Posts: 70
Location: Bayreuth, Germany
Joined: Jun 28th, 2012
CustomDraw the complete Item in ResourceView
Oct 26th, 2012 at 10:54am
Print Post  
Hi there,

I've tried to CustomDraw an Item in the ResourceView completely. What I want is full control over the Item's visible area. By drawing a filled rectangle over the bounds this should be easily achieved. But some parts of the ItemMoveBand are drawn later and so I cannot draw a complete custom representation of the item. For my custom items the move band is not needed, but for the other items on the ResourceView.

A very good way to improve the custom drawing features in general would perhaps be an event that is fired before the internal drawing is performed. Setting a cancel flag in this event could help saving resources for unneeded drawing and create more freedom for custom drawings.

The yellow item in the screenshot is created by custom drawing the bounding rectangle just like this:

Code
Select All
            calendar.CustomDraw |= CustomDrawElements.ResourceViewItem;
            calendar.Draw += delegate(object sender, DrawEventArgs args)
                {
                    if (args.Item is InfoItem)
                    {
                        args.Graphics.FillRectangle(Brushes.Gold, args.Bounds);
                    }
                };
 



Thanks for any help
Achim
  

Bildschirmfoto_2012-10-26_um_12_43_46.png (Attachment deleted)
Back to top
WWW  
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: CustomDraw the complete Item in ResourceView
Reply #1 - Oct 26th, 2012 at 2:28pm
Print Post  
Hi,

Check out the new version of the control:

https://mindfusion.eu/_temp/MindFusion.Scheduling.5.4.2.trial2.zip

It adds a new event to the Calendar class - ItemDrawing, which can be used to custom draw entire items and, optionally, cancel their default drawing.

I hope this helps.

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


MindFusion rocks!

Posts: 70
Location: Bayreuth, Germany
Joined: Jun 28th, 2012
Re: CustomDraw the complete Item in ResourceView
Reply #2 - Oct 29th, 2012 at 9:47am
Print Post  
Hi Meppy,

thank you for the fast response - I'm very impressed!

I've tried out the new version and it works for my case. But I have still seen some issues that might be interesting for you. I've used the following code to test it (the CustomDraw flags for ResourceViewItem and ItemMoveBand are set properly):

Code
Select All
        private void calendar1_ItemDrawing(object sender, DrawEventArgs e)
        {
            if (e.Element == CustomDrawElements.ResourceViewItem)
            {
                e.Handled = true;
                e.Graphics.FillRectangle(Brushes.Gold, e.Bounds);
            }

            if (e.Element == CustomDrawElements.ItemMoveBand)
            {
                e.Handled = true;
            }
        }
 



The first if-block draws the complete item with custom code - except the shadow of the item. When I remove the drawing code and just set e.Handled to true, a shadow for the item is left on the chart. Maybe the drawing of the shadows should also be piped through the custom drawing engine.

The second if-block never gets fired. Even when the first block is not executed (in fact I first tried the new event only having the second block implemented). It would be more intuitive firing the ItemDrawing event for the same elements as the Draw event. This way it becomes possible to just cancel the drawing for e.g. the ItemMoveBand and let the other things as they are.

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


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: CustomDraw the complete Item in ResourceView
Reply #3 - Oct 29th, 2012 at 11:22am
Print Post  
Hi again,

Here is an updated version of the control:

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

The ItemDrawing event will now be raised for item shadows as well, giving you a chance to perform custom rendering of the shadow or prevent it from being rendered. To distinguish if the event is raised for a shadow or for an actual item, use the new IsShadow property of the event argument.

Our initial design of the ItemDrawing event is that it is raised only for items. That is, the event is raised only for the following CustomDrawElements values: CalendarItem, TimetableItem, ResourceViewItem. Currently the event is never raised for the other CustomDrawElements, such as ItemMoveBand.

I hope this helps.

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


MindFusion rocks!

Posts: 70
Location: Bayreuth, Germany
Joined: Jun 28th, 2012
Re: CustomDraw the complete Item in ResourceView
Reply #4 - Oct 29th, 2012 at 12:53pm
Print Post  
Hi Meppy,

thanks a lot - now I am satisfied Smiley

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