Page Index Toggle Pages: [1] 2  Send TopicPrint
Hot Topic (More than 10 Replies) Appointment Tooltip (Read 12490 times)
Sam123
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 12
Joined: Nov 16th, 2011
Appointment Tooltip
Nov 16th, 2011 at 10:12am
Print Post  
Hi,,

I am new to mindfusion control. can you please tell me how to add tooltip for an appointment and applying different colour for the different appointments.

many thanks
Sam
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Appointment Tooltip
Reply #1 - Nov 16th, 2011 at 11:17am
Print Post  
To enable tooltips set Calendar.ShowToolTips to true. To customize the background of individual appointments, set the Brush or HeaderBrush property in their associated style. The following code sets the background of an appointment to red:

Code
Select All
a.Style.Brush = new MindFusion.Drawing.SolidBrush(Color.Red);
a.Style.HeaderBrush = new MindFusion.Drawing.SolidBrush(Color.Red); 


Keep in mind that there are different styles for the different states of the appointment, namely Style, SelectedStyle, PointedStyle, PointedSelectedStyle.

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


I love YaBB 1G - SP1!

Posts: 12
Joined: Nov 16th, 2011
Re: Appointment Tooltip
Reply #2 - Nov 16th, 2011 at 11:26am
Print Post  
Thank you meppy...
I like to know how can I colour the cells partially. for example non working works should be highlighted with some colour.


many thanks
sam
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Appointment Tooltip
Reply #3 - Nov 16th, 2011 at 11:55am
Print Post  
You can do this through custom drawing. To enable custom drawing, set Calendar.CustomDraw to the element(s) you wish to custom draw, then handle the Calendar.Draw event and perform the necessary drawing in the event handler.

If you let me know which view you are using, I may be able to provide additional information.

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


I love YaBB 1G - SP1!

Posts: 12
Joined: Nov 16th, 2011
Re: Appointment Tooltip
Reply #4 - Nov 16th, 2011 at 11:57am
Print Post  
I am using resource view..
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Appointment Tooltip
Reply #5 - Nov 16th, 2011 at 1:00pm
Print Post  
First, set Calendar.CustomDraw to ResourceViewCell:

Code
Select All
calendar1.CustomDraw = CustomDrawElements.ResourceViewCell; 


Then, handle the Calendar.Draw event and use custom drawing code similar to the following:

Code
Select All
if (e.Date.DayOfWeek == DayOfWeek.Saturday ||
      e.Date.DayOfWeek == DayOfWeek.Sunday)
{
      Rectangle bounds = e.Bounds;
      bounds.Width -= 1;
      bounds.Height -= 1;

      using (Brush brush = new SolidBrush(Color.Red))
            e.Graphics.FillRectangle(brush, bounds);
} 


The above code assumes that the resolution of the view is one day. If you are using different resolution you either have to change the if condition or resort to partial cell drawing.

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


I love YaBB 1G - SP1!

Posts: 12
Joined: Nov 16th, 2011
Re: Appointment Tooltip
Reply #6 - Nov 16th, 2011 at 3:20pm
Print Post  
calendar1.Draw += new EventHandler<DrawEventArgs>(CellColor);
      private void CellColor(object sender, DrawEventArgs e)
      {
          if (e.Date.DayOfWeek == DayOfWeek.Saturday || e.Date.DayOfWeek == DayOfWeek.Sunday)
          {
              Rectangle bounds = e.Bounds;
              bounds.Width -= 1;
              bounds.Height -= 1;
    using (Brush brush = new SolidBrush(Color.Red))
     e.Graphics.FillRectangle(brush, bounds);
          } 
      }

I am getting error in FillRectangle....

many thanks 
sam
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Appointment Tooltip
Reply #7 - Nov 16th, 2011 at 3:42pm
Print Post  
Do you have a compilation or run-time error? In either case what is the error message?

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


I love YaBB 1G - SP1!

Posts: 12
Joined: Nov 16th, 2011
Re: Appointment Tooltip
Reply #8 - Nov 16th, 2011 at 3:50pm
Print Post  
I am really sorry meppy its my mistake I didnt add mindfusion.common dll.. now its working fine.

many thanks
sam
  
Back to top
 
IP Logged
 
Sam123
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 12
Joined: Nov 16th, 2011
Re: Appointment Tooltip
Reply #9 - Nov 17th, 2011 at 2:27pm
Print Post  
Hi Meppy,

if (e.Date.DayOfWeek == DayOfWeek.Saturday ||
     e.Date.DayOfWeek == DayOfWeek.Sunday)

This works fine if I want to color the full cell. But If I need to color just a part of cell what can I do.. Like midnight 12 to morning 9 on a particular date.

Next I have two types of Appointment, where I like to have different MoveBandSize and ResizeBandSize value for different Appointments.

many thanks
sam
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Appointment Tooltip
Reply #10 - Nov 17th, 2011 at 2:44pm
Print Post  
You need to manually perform the necessary calculation based on the start and end time of the cell and its size. Here is a sample code to get you started:

Code
Select All
...
Rectangle bounds = e.Bounds;
bounds.Width -= 1;
bounds.Height -= 1;

float pixelsPerTick = (float)bounds.Width / (e.EndTime.Ticks - e.StartTime.Ticks);
float x12am = 0;
float x9am = TimeSpan.FromHours(9).Ticks * pixelsPerTick;

RectangleF newBounds = new RectangleF(bounds.X + x12am, bounds.Y, x9am - x12am, bounds.Height);

using (Brush brush = new SolidBrush(Color.Red))
      e.Graphics.FillRectangle(brush, newBounds);
... 


I hope this helps.

Quote:
Next I have two types of Appointment, where I like to have different MoveBandSize and ResizeBandSize value for different Appointments.

Unfortunately currently it is not possible to have different band sizes. You may be able to achieve this by removing the bands entirely and attempt to mimic their appearance using custom drawing.

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


I love YaBB 1G - SP1!

Posts: 12
Joined: Nov 16th, 2011
Re: Appointment Tooltip
Reply #11 - Nov 23rd, 2011 at 11:27am
Print Post  
Thank you... It works now..
Is there any way to speed up the custom draw event, because it takes long time to load the calender when months increases in resource view..
Any idea will be helpful.

many thanks
sam
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Appointment Tooltip
Reply #12 - Nov 23rd, 2011 at 12:06pm
Print Post  
Try setting Calendar.EnableOptimization to true. This will cause items to repaint themselves only when their size changes. Unfortunately the load time is one of the things that are unlikely to improve as a result. Interactions inside the control should be faster though.

Also make sure that all of the initializations of the control are wrapped in a BeginInit/EndInit block to avoid unnecessary repainting.

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


I love YaBB 1G - SP1!

Posts: 12
Joined: Nov 16th, 2011
Re: Appointment Tooltip
Reply #13 - Nov 24th, 2011 at 11:38am
Print Post  
The EndDate of the Calender in resource view automatically increases when I maximize the window.
When the window is in normal view it shows the exactly the start and end date given by me but when i maximize the window it increases the end date automatically. How to fix this issue.

many thanks
sam
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Appointment Tooltip
Reply #14 - Nov 24th, 2011 at 12:38pm
Print Post  
The cells in the Resource view have fixed size based on content and scaling therefore when the available space increases the number of displayed cells increases proportionally. If you want to have a fixed number of visible cells regardless of the size of the control, you have to play around with the TimelineScale property in the ResourceViewSettings class.

Check this topic and the associated sample. That's exactly what it does.

Regards,
Meppy
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: [1] 2 
Send TopicPrint