Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Best advice (Read 5587 times)
Milo
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 29
Joined: Jul 16th, 2007
Best advice
Jul 23rd, 2007 at 7:36am
Print Post  
I'm writing a scheduling system, to allow the user to book time against the calendar, for the requirements I've plumbed for the week view, with unlimited scrolling..

I would like to show the calendar, and allow the user to book, full day, AM, or PM. When they book this, I'ld like it to look like a bowling score card, so a AM is the day with the upper part shaded, PM the low and all day, all of it... also the operator is only allowed to single appointments for any day.

Whats the best way for going about this, and will I hit problem with my type of calendar view?

Thanks for any help.


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


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Best advice
Reply #1 - Jul 23rd, 2007 at 9:57am
Print Post  
The shading part can be achieved through custom drawing. You have to set the Calendar.CustomDraw property to CustomDrawElements.DayContents, then handle the Calendar.Draw event. Below is a sample event handler body:

Code
Select All
if (e.Element == CustomDrawElements.DayContents)
{
    // Obtain the type of the date represented by the cell
    // we are about to draw
    int type = 0;

    Rectangle b = e.Bounds;

    switch (type)
    {

	  case 0: // AM
		e.Graphics.DrawRectangle(Pens.Red, b.X, b.Y, b.Width, b.Height / 2);
		break;

	  // etc.
    }
}
 


The sample draws a red rectangle around the date cell. You can modify this part to match your particular needs.

As for the '1 item per day' restriction, you can handle the Calendar.ItemModifying event and check whether the modified item is moved within a cell which already contains another item. You can also handle the Calendar.ItemCreating event to prevent items from being interactively created in occupied cells.

Meppy
  
Back to top
 
IP Logged
 
Milo
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 29
Joined: Jul 16th, 2007
Re: Best advice
Reply #2 - Jul 24th, 2007 at 6:52am
Print Post  
Thanks Meppy, your the man.

I got the draw item event working great, problem is the draw occurs over the item text. Is there any way to arrange this underneath?

Thanks.


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


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Best advice
Reply #3 - Jul 24th, 2007 at 7:17am
Print Post  
The event should be fired before the items are rendered by the control. Are you certain you specify CustomDrawElements.DayContents as a value of the Calendar.CustomDraw property?

Meppy
  
Back to top
 
IP Logged
 
Milo
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 29
Joined: Jul 16th, 2007
Re: Best advice
Reply #4 - Jul 24th, 2007 at 9:26am
Print Post  
The custom draw property is set to CalendarItem. Which is ideally what I want..

This is how its appearing....

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


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Best advice
Reply #5 - Jul 24th, 2007 at 9:46am
Print Post  
In this case you might have to draw the entire item yourself, since the event is fired when the item is already rendered by the control and there will be no way to draw underneath the text. You can also use semitransparent brush when drawing the triangle.

Meppy
  
Back to top
 
IP Logged
 
Milo
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 29
Joined: Jul 16th, 2007
Re: Best advice
Reply #6 - Jul 25th, 2007 at 5:59pm
Print Post  
Nice one Meppy, nearly there...

If I choose to use a custom draw, how do I turn off the regular draw?
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Best advice
Reply #7 - Jul 26th, 2007 at 4:43am
Print Post  
You can turn off regular item drawing by setting the ItemSettings.EnableDefaultRendering property to State.Disabled.

Meppy
  
Back to top
 
IP Logged
 
Milo
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 29
Joined: Jul 16th, 2007
Re: Best advice
Reply #8 - Jul 26th, 2007 at 5:00am
Print Post  
Thanks Meppy,

really starting to understand this control. So many properties....  8)
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint