Home : I need is to be able to display various periods of calendar with several shifts (time periods) in a day..
Q10066 - FAQ: I need is to be able to display various periods of calendar with several shifts (time periods) in a day..

Question

Hi, i am currently evaluating phGantTime package and i would like to see is it possible to  a rosters with it. What i need is to be able to display various periods of calendar with several shifts (time periods) in a day..And i need to assign employees to shifts. Also i need to be able to draw holidays and weekends with different colors.

Can you please send me some sample code? Because there are alot of properties, and so far i cant find a way how to customize this top line which displays date

 

Answer

The sample code below draws a green background on Wednesdays and a red background on sunday. This sample is for GTP.NET but you can do the same thing in phGantTimePackage...

    private void gantt1_OnDateScalerPaintBackground(PlexityHide.GTP.OffscreenDraw aOffscreenDraw, PlexityHide.GTP.OffscreenDrawArgs e)

    {

      DoBack(e.G,gantt1.DateScaler.Height);

    }

    private void gantt1_OnTimeItemAreaPaintBackground(PlexityHide.GTP.OffscreenDraw aOffscreenDraw, PlexityHide.GTP.OffscreenDrawArgs e)

    {

      DoBack(e.G,gantt1.TimeItemArea.Height);

    }

 

    private void DoBack(Graphics G,int aHeight)

    {

      DateTime i=gantt1.DateScaler.StartTime;

      DateTime ii;

      Brush b_sunday=new SolidBrush(Color.Red);

      Brush b_wednesday=new SolidBrush(Color.Green);

      while (i<gantt1.DateScaler.StopTime)

      {

        ii=i.AddDays(1);

       

        int x1=gantt1.DateScaler.TimeToPixel(i.Subtract(i.TimeOfDay));

        int x2=gantt1.DateScaler.TimeToPixel(ii.Subtract(ii.TimeOfDay));

       

        if (i.DayOfWeek==DayOfWeek.Sunday )

          G.FillRectangle(b_sunday,x1,0,x2-x1,aHeight);

        else

        if (i.DayOfWeek==DayOfWeek.Wednesday)

          G.FillRectangle(b_wednesday,x1,0,x2-x1,aHeight);

       

       i=ii;

      }

    }

 

 

Related Articles
No Related Articles Available.

Article Attachments
No Attachments Available.

Related External Links
No Related Links Available.
Help us improve this article...
What did you think of this article?

poor 
1
2
3
4
5
6
7
8
9
10

 excellent
Tell us why you rated the content this way. (optional)
 
Approved Comments...
No user comments available for this article.
Created on 2005-02-11.
Last Modified on 2007-09-01.
Last Modified by Administrator.
Suggested by Eugene Goldberg
Article has been viewed 1947 times.
Rated 0 out of 10 based on 0 votes.
Print Article
Email Article