Page Index Toggle Pages: [1] 2  Send TopicPrint
Hot Topic (More than 10 Replies) Change the main backcolor of an appointment (Read 19815 times)
Jérôme Macé
Guest


Change the main backcolor of an appointment
Jun 22nd, 2006 at 8:12am
Print Post  
How can I change the back color of an appointment.
I need a different color for each appointment type.

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


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Change the main backcolor of an appointment
Reply #1 - Jun 22nd, 2006 at 10:41am
Print Post  
Set the Style.Brush and SelectedStyle.Brush property of the corresponding item in order to specify the fill color of the item when it is not selected and when it is selected respectively. The following code sets the item's fill color to green when the item is not selected and to red, when it is selected.

Code
Select All
item.Style.Brush = new MindFusion.Drawing.SolidBrush(Color.Green);
item.SelectedStyle.Brush = new MindFusion.Drawing.SolidBrush(Color.Red); 



Meppy
  
Back to top
 
IP Logged
 
Jerome Mace
YaBB Newbies
*
Offline



Posts: 5
Joined: Jun 22nd, 2006
Re: Change the main backcolor of an appointment
Reply #2 - Jun 23rd, 2006 at 8:15am
Print Post  
Thanks
  
Back to top
 
IP Logged
 
Jerome Mace
YaBB Newbies
*
Offline



Posts: 5
Joined: Jun 22nd, 2006
Re: Change the main backcolor of an appointment
Reply #3 - Jul 6th, 2006 at 8:25am
Print Post  
Where is the Style property for the WeekEnd columns in the TimeTable View ?

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


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Change the main backcolor of an appointment
Reply #4 - Jul 6th, 2006 at 11:52am
Print Post  
There is no explicit property for the weekend columns. Instead, there are two styles in the timetable - TimetableSettings.CellStyle and TimetableSettings.WorkTimeCellStyle. The later affects the appearance of the cells in all work days in the time interval defined by TimetableSettings.WorkTimeStartHour and TimetableSettings.WorkTimeEndHour (but only if TimetableSettings.ShowWorkTime is set to State.Enabled). The former affects the appearance of all other cells, including the weekend columns and the cells outside the worktime interval.

You can use custom drawing to custom-paint cells in weekend columns.

You would also be able to set TimetableSettings.WorkTimeStartHour to 0 and TimetableSettings.WorkTimeEndHour to 24 to use TimetableSettings.WorkTimeCellStyle for the whole working days and TimetableSettings.CellStyle for the weekend days, although in the current version the maximum allowed value for both properties is 23. This will be fixed in the next release.

Meppy
  
Back to top
 
IP Logged
 
andersco
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 17
Joined: Jan 25th, 2009
Re: Change the main backcolor of an appointment
Reply #5 - Feb 3rd, 2009 at 1:45am
Print Post  
I'm having trouble getting the backcolor set on appointments too.  Here is the code that isn't working:

Appointment appt = new Appointment();
appt.StartTime = DateTime.Now;
appt.EndTime = DateTime.Now.AddDays(1);
MindFusion.Drawing.SolidBrush brush = new MindFusion.Drawing.SolidBrush(System.Drawing.Color.Green);
appt.Style.Brush = brush; 
           calendarMindFusion.Schedule.Items.Add(appt);

Is there anything I am doing wrong?

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


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Change the main backcolor of an appointment
Reply #6 - Feb 3rd, 2009 at 7:27am
Print Post  
The background color is set differently for different views because in certain views only the item header is visible. Try setting the HeaderBrush instead. Also, if the item is selected, you should set the desired brushes in the item's SelectedStyle as well.

Meppy
  
Back to top
 
IP Logged
 
andersco
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 17
Joined: Jan 25th, 2009
Re: Change the main backcolor of an appointment
Reply #7 - Feb 4th, 2009 at 5:02pm
Print Post  
I am trying to do this on the "SingleMonth" view.  Is that supported?  I have tried setting the headerbrush and selecteditem style but had no luck.  Here is my code:

Appointment appt = new Appointment();
appt.StartTime = DateTime.Now;
appt.EndTime = DateTime.Now.AddDays(1);
MindFusion.Drawing.SolidBrush brush = new MindFusion.Drawing.SolidBrush(System.Drawing.Color.Green);
appt.Style.Brush = brush;
appt.Style.HeaderBrush = brush;
appt.SelectedStyle.HeaderBrush = brush;
           calendarMindFusion.Schedule.Items.Add(appt);
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Change the main backcolor of an appointment
Reply #8 - Feb 5th, 2009 at 8:22am
Print Post  
This code works well here. It is the Brush property that needs to be assigned in order to change the item's background in SingleMonth view. Can you ensure that the item is not selected or also assigned the brush to the SelectedStyle?

Code
Select All
appt.Style.Brush = brush;
appt.SelectedStyle.Brush = brush;
 


Meppy
  
Back to top
 
IP Logged
 
andersco
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 17
Joined: Jan 25th, 2009
Re: Change the main backcolor of an appointment
Reply #9 - Feb 5th, 2009 at 6:27pm
Print Post  
Okay, I figured there might be something up with my project, but even when I try to modify your demo project I cannot get this to work. In the constructor for MindFusion.Scheduling.Compact.Samples.CS.Demo.MainForm
I added:

_calendar.CurrentTime = DateTime.Now;
_calendar.Date = DateTime.Now;
Appointment appt = new Appointment();
appt.StartTime = DateTime.Now;
appt.EndTime = DateTime.Now.AddDays(1);
MindFusion.Drawing.SolidBrush brush = new MindFusion.Drawing.SolidBrush(System.Drawing.Color.Green);
appt.Style.Brush = brush;
appt.SelectedStyle.Brush = brush;
appt.HeaderText = "test";
appt.DescriptionText = "this is a test";
_calendar.Schedule.Items.Add(appt);

But I do not see anything in the SingleMonth view. I can see the appointment in other views such as List and Timetable, but not in SingleMonth. There must be some step I am skipping. Can you post the full sample code?

Thanks.

--edit:
I also tried adding these lines with no success:

appt.Style.HeaderBrush = brush;
appt.SelectedStyle.HeaderBrush = brush;
appt.Style.BorderBottomColor = Color.Red;
appt.Style.BorderLeftColor = Color.Red;
appt.Style.BorderRightColor = Color.Red;
appt.Style.BorderTopColor = Color.Red;
appt.SelectedStyle.BorderBottomColor = Color.Red;
appt.SelectedStyle.BorderLeftColor = Color.Red;
appt.SelectedStyle.BorderRightColor = Color.Red;
appt.SelectedStyle.BorderTopColor = Color.Red;
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Change the main backcolor of an appointment
Reply #10 - Feb 6th, 2009 at 7:13am
Print Post  
If the appointment is not visible at all, there is another reason for this. In a SingleMonth view the items are not displayed by default since the day headers cover the entire day cells. In order to reduce the size of the day headers, and thus ensure that there will be space for items, set a value different than 0 to the Calendar.MonthSettings.DaySettings.HeaderSize property.

Let me know if this works.

Meppy
  
Back to top
 
IP Logged
 
andersco
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 17
Joined: Jan 25th, 2009
Re: Change the main backcolor of an appointment
Reply #11 - Feb 6th, 2009 at 5:19pm
Print Post  
Okay that was the step I was missing to see the appointment.  When I add this line:

_calendar.MonthSettings.DaySettings.HeaderSize = 10;

I see the appointment with the brush applied to it.  What I want to see is the brush applied to the entire cell if there is an appointment on the date.  Is that possible?

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


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Change the main backcolor of an appointment
Reply #12 - Feb 9th, 2009 at 7:26am
Print Post  
Yes, but you need a slightly different approach. Probably the easiest way to do this is to use the so-called date styles. The following example shows how to apply custom colors to the calendar cell representing Feb 9th, 2009:

Code
Select All
DateStyle style = new DateStyle();
style.Style.Brush = new MindFusion.Drawing.SolidBrush(Color.Red);
style.Style.HeaderBrush = new MindFusion.Drawing.SolidBrush(Color.Red);
style.From = new DateTime(2009, 2, 9);
style.To = new DateTime(2009, 2, 9);
calendar1.DayStyles.Add(style); 


An alternative of this method would be to use custom drawing of day cells.

Meppy
  
Back to top
 
IP Logged
 
andersco
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 17
Joined: Jan 25th, 2009
Re: Change the main backcolor of an appointment
Reply #13 - Feb 10th, 2009 at 2:19am
Print Post  
That does exactly what I wanted.

Thanks!
  
Back to top
 
IP Logged
 
andersco
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 17
Joined: Jan 25th, 2009
Re: Change the main backcolor of an appointment
Reply #14 - May 8th, 2009 at 4:43pm
Print Post  
I am trying to do a similar thing now, but I want to make the font bold instead of changing the back color.

I tried:

DateStyle style = new DateStyle();
style.Style.Font = new Font(calendar1.Font.Name, calendar1.Font.Size + 1, FontStyle.Bold);
style.From = new DateTime(2009, 5, 8);
style.To = new DateTime(2009, 5, 8);
calendar1.DayStyles.Add(style);

but it is not working...any suggestions?
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: [1] 2 
Send TopicPrint