Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic remove header text? (Read 2585 times)
tomk
YaBB Newbies
*
Offline


Yaos!

Posts: 29
Joined: Apr 25th, 2006
remove header text?
Oct 30th, 2006 at 7:09pm
Print Post  

We are customizing the headers (in Timetable view for now but I could see this possibly occurring in Month view in particular as well) in the Calendar, drawing some custom text.  Is it currently possible to enter a header format string or use some setting (which I have been unable to find so far) in order to prevent the [date or resource] from drawing in the [TimetableGroup or Column]Header?  We are already drawing the date or resource information in the format we need it upon handling Draw. 

Another option I guess would be to have Draw events handleable, and we could just draw the backgrounds as well, then mark it already drawn so the Calendar does not need to do anything further paintwise.  Or, if the control has already painted (I am not sure if Draw is called before or after the basic default info has painted), perhaps we just need to put a rectangle over the top of what is painted.


What do you think the best way for us to handle this is?

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


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: remove header text?
Reply #1 - Oct 31st, 2006 at 6:15am
Print Post  
The Draw event is fired after the element is drawn by the control to give you the opportunity to add your own drawing above what has already been painted. You can repaint the entire cell by using the same brush, then you can draw your custom text using the same font and color as the original text in the cell.

Here is a sample Draw event handler that demonstrates how to do this:

Code
Select All
private void calendar_Draw(object sender, MindFusion.Scheduling.WinForms.CustomDrawArgs e)
{
  if (e.Element == CustomDrawElements.TimetableColumnHeader)
  {
    MindFusion.Drawing.Brush brush =
	calendar.TimetableSettings.Style.HeaderBrush;
    Color color =
	calendar.TimetableSettings.Style.HeaderTextColor;
    Font font =
	calendar.TimetableSettings.Style.HeaderFont;

    StringFormat format = new StringFormat();
    format.Alignment = StringAlignment.Center;
    format.LineAlignment = StringAlignment.Center;

    Graphics g = e.Graphics;
    Rectangle b = e.Bounds;
    b.Inflate(-1, -1);

    Brush textBrush = new SolidBrush(color);

    g.FillRectangle(brush.CreateGdiBrush(b), b);
    g.DrawString("Custom text", font, textBrush,
	new RectangleF(b.X, b.Y, b.Width, b.Height), format);
  }
} 



Note: In the code above the alignment of the text is always centered, but you can inspect the HeaderTextAlignment property from the appropriate style.

Meppy
  
Back to top
 
IP Logged
 
tomk
YaBB Newbies
*
Offline


Yaos!

Posts: 29
Joined: Apr 25th, 2006
Re: remove header text?
Reply #2 - Oct 31st, 2006 at 2:35pm
Print Post  

Ok, thanks again Meppy.  We will just repaint the cell/header to control the behavior.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint