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


I love YaBB 1G - SP1!

Posts: 12
Joined: Nov 16th, 2011
Re: Appointment Tooltip
Reply #15 - Dec 6th, 2011 at 3:04pm
Print Post  
Hi Meppy,

I like to know how to make the Appointment transparent and Is it possible to fill two colours on single appointment. for example first half with one colour and second half with another colour in Resource view.

I like to know how to draw the dependency line between the appointments in  the resource view.

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


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Appointment Tooltip
Reply #16 - Dec 6th, 2011 at 4:37pm
Print Post  
Hi Sam,

Before I move on to answering your questions, I would like to entreat you to start new topics in the forum when you have questions that are unrelated to an existing topic (such is the current case), rather than dumping everything into one big topic. This way the forum is kept more organized and can be helpful to others too. Thank you.

Regarding your questions:

To make appointments fully or partially transparent try assigning a brush with the appropriate alpha channel as a background. Overall transparency can be achieved through custom drawing. You can have a look at the AdvancedItemDrawing sample, which illustrates how to do this in more details. To fill an item in two colors you can use custom drawing as well. However, this can probably be achieved by using a linear gradient brush with very sharp transition from one of the colors to the other. By using this approach however, you may experience some artifacts in GDI+.

Quote:
I like to know how to draw the dependency line between the appointments in the resource view.


If you are trying to draw dependency lines between different appointments such as the dependencies in a Gantt chart, I don't think this can be easily achieved with MindFusion.Scheduling for WinForms. The only option I can think of is to use custom drawing on the entire component (for example, handle the Control.Paint event). Then you can acquire the bounding rectangles of related appointments through the Calendar.GetItemBounds method and draw the dependencies as lines connecting those rectangles.

I hope this helps.

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 #17 - Dec 6th, 2011 at 4:50pm
Print Post  
Thank you meppy.. From next Time I will start a new topic for different issues.
It works with the Alpha channel of the colour.
Can you please tell me how can I fill two colour in an Item using custom drawing.
I like to draw dependency line between the appointment  like Activity dependency line in WPF mindfusion scheduling.


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


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Appointment Tooltip
Reply #18 - Dec 7th, 2011 at 7:46am
Print Post  
You can custom-draw items using the same technique we discussed earlier. Set the Calendar.CustomDraw property to the appropriate value, then handle the Calendar.Draw event and perform the custom drawing in the event handler. In this case set Calendar.CustomDraw to CalendarItem. Keep in mind that filling an item with new color will cause the item contents (such as text, icons, etc) to be lost. So you may need to custom draw these too. Here is a small example that works relatively well in SingleMonth view:

Code
Select All
if (e.Element == CustomDrawElements.CalendarItem)
{
      Rectangle left = new Rectangle(
            e.Bounds.X, e.Bounds.Y, e.Bounds.Width / 2, e.Bounds.Height);
      Rectangle right = new Rectangle(
            e.Bounds.X + e.Bounds.Width / 2, e.Bounds.Y, e.Bounds.Width - e.Bounds.Width / 2, e.Bounds.Height);
      e.Graphics.FillRectangle(Brushes.Orange, left);
      e.Graphics.FillRectangle(Brushes.PaleGoldenrod, right);

      Rectangle bounds = new Rectangle(
            e.Bounds.X, e.Bounds.Y, e.Bounds.Width - 1, e.Bounds.Height - 1);
      using (Pen pen = new Pen(e.Style.BorderLeftColor, 0))
            e.Graphics.DrawRectangle(pen, bounds);
      using (Brush brush = new SolidBrush(e.Style.HeaderTextColor))
      {
            StringFormat format = new StringFormat();
            format.Alignment = StringAlignment.Center;
            format.LineAlignment = StringAlignment.Center;
            e.Graphics.DrawString(e.Text, e.Style.HeaderFont, brush, bounds, format);
            format.Dispose();
      }
} 


Regarding the dependency lines, the only way (I can think of) to draw Gantt-like dependencies in WinForms is by using global custom drawing as described in my previous post.

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 #19 - Dec 7th, 2011 at 4:40pm
Print Post  
Thank you meppy.

Can you please give me the sample code for drawing dependency line between the appointment.
Because I dont know how to proceed with that issue further.

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


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Appointment Tooltip
Reply #20 - Dec 8th, 2011 at 9:16am
Print Post  
The following code draws a dependency line between the first two appointments of calendar1. The code will work only when both appointments are visible on screen. Otherwise the returned bounding rectangles will not be accurate. You have to manually handle such cases.

Code
Select All
Rectangle originBounds = calendar1.GetItemBounds(calendar1.Schedule.Items[0]);
Rectangle destBounds = calendar1.GetItemBounds(calendar1.Schedule.Items[1]);

if (originBounds.Width == 0 || originBounds.Height == 0 ||
      destBounds.Width == 0 || destBounds.Height == 0)
      return;

Point[] points = null;
if (originBounds.Right < destBounds.Left)
{
      points = new Point[]
      {
            new Point(originBounds.Right, originBounds.Top + originBounds.Height / 2),
            new Point(destBounds.Left, originBounds.Top + originBounds.Height / 2),
            new Point(destBounds.Left, destBounds.Top - calendar1.ItemSettings.MoveBandSize),
      };
}
else
{
      points = new Point[]
      {
      new Point(originBounds.Right, originBounds.Top + originBounds.Height / 2),
            new Point(originBounds.Right + 6, originBounds.Top + originBounds.Height / 2),
            new Point(originBounds.Right + 6, originBounds.Bottom + 1),
            new Point(destBounds.Left, originBounds.Bottom + 1),
            new Point(destBounds.Left, destBounds.Top - calendar1.ItemSettings.MoveBandSize),
      };
}

if (points != null)
      e.Graphics.DrawLines(Pens.Red, points);
 


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