10066 : 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)< ?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

    {

      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;

      }

    }

 

 

10066 : 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)< ?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

    {

      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;

      }

    }