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;

      }

    }

 

 

10065 : Is it possible to make in the same TimeItem 2 different colors or shapes?

Question

Is it possible to make in the same TimeItem 2 different colors or shapes? Example to indicate the 25% completed?

Answer

You can do this with user draw, and implement any custom drawing of a time item;

Below is samples that show user draw for both phGantTimePackage and GTP.NET

 

In the phGantTimePackage you can use this code:

aGantTime.Style = tsUser ‘ Must be tsUser for the OnUserDrawTime to fire

< ?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /> 

Private Sub phGantX1_OnUserDrawTime(ByVal theGant As phGantXControl.IphGantX, ByVal theDataEntity As phGantXControl.IphDataEntity_GantTime, ByVal theHDC As Long, ByVal Left As Long, ByVal Top As Long, ByVal Right As Long, ByVal Bottom As Long)

    Dim aRect As Module1.RECT

    aRect.Bottom = Bottom

    aRect.Top = Top

    aRect.Right = Right

    aRect.Left = Left

   

    aBrush = Module1.CreateHatchBrush(4, ColorConstants.vbGreen)

    aDummy = Module1.FillRect(theHDC, aRect, aBrush)

    DeleteObject (aBrush)

   

    aBrush = Module1.CreateHatchBrush(4, ColorConstants.vbBlack)

    aDummy = Module1.FrameRect(theHDC, aRect, aBrush)

    DeleteObject (aBrush)

   

    ‘ you can draw stuff here

   

End Sub

 

In GTP.NET you can use this code:

      ti.TimeItemLayout.TimeItemStyle=TimeItemStyle.User; // Must be TimeItemStyle.User for OnTimeItem_UserDraw to fire

 

      private void gantt1_OnTimeItem_UserDraw(PlexityHide.GTP.Gantt aGantt, PlexityHide.GTP.TimeItemEventArgs e)

      {

        if (e.TimeItem.UserReference is BreakInfo)

        {

          BreakInfo breakInfo=e.TimeItem.UserReference as BreakInfo;

         

                          

        DateTime breakStart=e.TimeItem.Start.AddDays(breakInfo.startsDaysFromStart)+e.Diff;

        DateTime breakStop=breakStart.AddDays(breakInfo.breakLengthInDays);

         

        int breakStartPixel=gantt1.DateScaler.TimeToPixel(breakStart);

        int breakStopPixel=gantt1.DateScaler.TimeToPixel(breakStop);

       

       

        e.G.FillRectangle(new SolidBrush(Color.Blue),new Rectangle(e.Rect.Left,e.Rect.Top,breakStartPixel-e.Rect.Left,e.Rect.Height));

        e.G.FillRectangle(new SolidBrush(Color.Blue),Rectangle.FromLTRB(breakStopPixel,e.Rect.Top,e.Rect.Right,e.Rect.Bottom));

        e.G.DrawRectangle(new Pen(Color.Black),e.Rect);

         

         

        }

        else

        {

           e.G.DrawArc(new Pen(Color.RosyBrown,4),e.Rect,0,180);

           e.G.DrawArc(new Pen(Color.PowderBlue,6),e.Rect,180,180);

         }

      }

 

 

10064 : how to print multiple page in c# code, GTP.NET ?

Question

my Question is about GTP.NET component.
how to print multiple page on c# code?

Answer

.NET comes with a very good PrintDocument class. Use this when you want to print the Gantt.

You might wonder why we just did not wrap all this up in the componen?t The answer is flexibility. You will probably want to add a title and a page number or something we never could anticipate, and you can do all of this in the PrintPage event.

The sample below shows how the printing mechanism is splitting the print to many pages over the Y-axis (grid rows). To split the print to several pages over the X-Axis (different pages show different time), you should execute the print operation two (or many) times with different values set on the datescaler.

Like this:

     private void Print_Click(object sender, System.EventArgs e)< ?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

     {

 

        try

        {

         // Assumes the default printer.

         PrintDocument pd = new PrintDocument();

         pd.PrintPage += new PrintPageEventHandler(this.pd_PrintPage);

         pd.BeginPrint += new PrintEventHandler(this.pd_BeginPrint);

         pd.EndPrint += new PrintEventHandler(this.pd_EndPrint);

         printPreviewDialog1.Document=pd;

         printPreviewDialog1.ShowDialog(this);

 

        }

        catch(Exception ex)

        {

         MessageBox.Show(“An error occurred while printing”, ex.ToString());

        }

     }

 

      private void pd_PrintPage(object sender, PrintPageEventArgs ev)

      {

 

        bool hasMorePages=false;

        Rectangle r=Rectangle.FromLTRB(20,20,ev.MarginBounds.Right-20,ev.MarginBounds.Bottom-100);

        gantt1.PrintPage(ev.Graphics,r,100,50,ref hasMorePages);

        ev.HasMorePages=hasMorePages;

      }

 

     public void pd_BeginPrint(object sender,   PrintEventArgs e)

     {

           gantt1.PrintInit(null);

     }

 

     public void pd_EndPrint(object sender,PrintEventArgs e)

     {

        gantt1.PrintEnd();

     }

 

 

 

Ok, But how would you go about to print multiple pages in the x-direction (in the time direction)? Maybe you want to print like MSProject multiple pages along x axis and along y axis…

 

This is explained in this slightly changed sample:

 

        private void PrintPreview_Click(object sender, System.EventArgs e)

        {

            try

            {

                PrintDocument pd = new PrintDocument();

                pd.PrinterSettings.FromPage = 5;         // You can start from a given page

                pd.BeginPrint += new PrintEventHandler(this.pd_BeginPrint); // Called first

                pd.PrintPage += new PrintPageEventHandler(this.pd_PrintPage); // called for each page

                pd.EndPrint += new PrintEventHandler(this.pd_EndPrint); // called last

                firstInx = true;    // In this sample I want to print two pages along the x-axis with different time shown and grid supressed on the latter

                printPreviewDialog1.Document = pd;

                printPreviewDialog1.ShowDialog(this);  // And show it in a preview

 

            }

            catch (Exception ex)

            {

                MessageBox.Show(“An error occurred while printing”, ex.ToString());

            }

        }

 

        private DateTime start, stop;

        private bool firstInx;

 

        public void pd_BeginPrint(object sender, PrintEventArgs e)

        {

            gantt1.PrintInit(null); // Prepare for print

        }

 

        private void pd_PrintPage(object sender, PrintPageEventArgs ev)

        {

            bool hasMorePages = false;

            Rectangle r = Rectangle.FromLTRB(20, 20, ev.MarginBounds.Right – 20, ev.MarginBounds.Bottom – 100);

 

            // In this print I choose to divide the time axel into two pages.

            // Then I must call PrintPage once with SuppressGrid=false and doNotStepGridWillPrintTheSameRowsOneMoreTime=true

            // and once with SuppressGrid=true and doNotStepGridWillPrintTheSameRowsOneMoreTime=false

            // In the second call I change the DateScaler intervall to reflect another area in time, then I set it back

            // after the print to prepare for the first page in time (x) direction

 

            if (firstInx /*This is the first page in X-direction*/)

            {

                gantt1.PrintPage(ev.Graphics, r, 100, 50, false, ref hasMorePages, true /* IMPORTANT FOR MULTI X PRINT: PrintTheSameBatchOfRowsNextTime=true*/);

                start = gantt1.DateScaler.StartTime;

                stop = gantt1.DateScaler.StopTime;

                firstInx = false;  // Signals that the next print will be the same

            }

            else

            {

                // This is the second page in X-direction

                gantt1.DateScaler.TimeSpanSet(stop, stop.Add(stop.Subtract(start))); 

                gantt1.PrintPage(ev.Graphics, r, 100, 50, true, ref hasMorePages, false);

                gantt1.DateScaler.TimeSpanSet(start, stop);

                firstInx = true;

            }

            ev.HasMorePages = hasMorePages; // When this is false the print document will not all PrintPage anymore

        }

 

 

        public void pd_EndPrint(object sender, PrintEventArgs e)

        {

            gantt1.PrintEnd(); // clean up after print

        }

 

 

 

10060 : The pyjamas between Grid and Gantt are not the same.

Question

Since we have got the registered version the pyjamas between Grid and Gantt are not the same. We need to have the same color for each row in grid and gantt, how to do this ?

Answer

Four different properties control this:

PlexityHide.GTP.Gantt.PyjamasColor, PlexityHide.GTP.Gantt.PyjamasGradientColor, PlexityHide.GTP.Grid.PyjamasColor, PlexityHide.GTP.Grid.PyjamasGradientColor

You want to set these all of these to the same color to get a clean, straight line.

You reach the grid properties like this: Gantt.Grid.PyjamasColor=Color.Blue

Also, if you use CellLayouts on your cells you should set the CellLayout.BackgroundUse=false to stop the the cell background.

10061 : Hide the grid

Question

I truly love your amazing component, but never the less I need to hide the grid and replace it with another control. Is this at all possible?

Answer

The grid is vital to the Gantt, it controls the Y-axis and manages scrolling and collapse one GanttRow per GridNode. Having said that you can hide the grid by hi-jacking it to a panel that you keep out of sight:

private void HideGrid_Click(object sender, System.EventArgs e)
{
  gantt1.Grid.Parent=panel1;
}

10056 : Trial period is over.

Question

I’ve a problem with my gantt chart, I get the message trial period is over. FYI it is licensed, and I need your advise.

Answer

With your purchase you got a license code that looks somewhat like this:

plexXXXX11 = 461XXXX807920A11DE82XXXXAF409

Do you have it? If not let me know the date of purchase and the contact email that you used for the purchase.

These are the standard instructions for the registration:

The key is divided by an equal sign (‘=’). The first part is your registration name and the second part is the key. Once you have entered these keys in the GTP.NET splash screen you should restart your .NET environment. After a successful registration the splash screen will not show.

10053 : How can I implement this behavior: moving mouse with left button down on TimeItemArea (not just DateScaler) will move the datescaler?

Question

 
how can I implement this behavior: moving mouse with left button down on TimeItemArea (not just DateScaler) will move the datescaler?

 
Answer
. You can implement OnTimeItemAreaMouseMove and check that Gantt.MouseMoveKind==MouseMoveKind.none (so that you not break any other mouse action) and track how much the mouse has moved (Get the original position in the OnTimeItemAreaMouseDown event). When you have the shift of pixels (x-direction) you can use this in the PlexityHide.GTP.DateScaler.Pan(pixels) method.
 
 

10052 : It is possible to link Start and Stop of TimeItem to datasource. Is it possible to link TimeItemText as well?

Question
– It is possible to link Start and Stop of TimeItem to datasource. Is it possible to link TimeItemText as well? Or at least to link TimeItemTexts in an automated way to UserReference object properties?
 
Answer
– One approach is to implement the TimeItemDataConnect.OnBeforeDSToTimeItem. This event fires when a change has occurred on the datarow that contains the time item. You can then extract additional attributes from this row (or sub-rows) and create time item texts etc.