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;

      }

    }

 

 

10070 : Can you change the format of the date on the date scaler?

Question

Can you change the format of the date on the date scaler?
We would like to change for example, “0502-08” to “May 02-08”, when at one week resolution.

Answer

Sure;
In GTP.NET you can set DateScaler.CultureInfoDateTimeFormat to change the date format to another cultural style to get the same effect in phGantTimePackage you must change the locales setting…

BUT you probably want to override the suggested output;
In GTP.NET Implement the event DateScaler.OnDateScalerDrawString and override the output by changing the argument e.OutputText.

Like this:
    private void dateScaler1_OnDateScalerDrawString(PlexityHide.GTP.DateScaler dateScaler, PlexityHide.GTP.DateScalerDrawStringEventArgs e)
    {
      
      if (checkBoxMyOwnWeekPres.Checked)
      {
        // If you want to customize the way the date scaler draws its strings, you can…
          if ((e.LongIntervall && e.Resolution==NonLinearTime.TimeResolution.days) && (!dateScaler1.UseDayNumbersNotWeeks))
          {
            // In this case we override the long intervall presentation when the resolution of the lower is Days ;
            e.OutputText=e.DateTime.ToString(“MMdd”)+” – “+e.DateTime.AddDays(6).ToString(“MMdd”);
            e.ContinueDraw=true;
          }        
      }
    }

Additional information from our friend Uli: I would like to change the DateScaler string. FAQ Q10070 describes a solution but there is a problem with the displayed DateTime which doesn´t agree to the displayed days. There is a small offset of three days. I did the following:

this.gantt1.DateScaler.OnDateScalerDrawString+=new DateScalerDrawStringEventHandler(DateScaler_OnDateScalerDrawString);
      this.gantt1.DateScaler.TimeSpanSet(DateTime.Today, DateTime.Today.AddDays(20));
      this.gantt1.DateScaler.UseDayNumbersNotWeeks=false;
      this.gantt1.DateScaler.ShowWeekNumbers=false;

void DateScaler_OnDateScalerDrawString(DateScaler dateScaler, DateScalerDrawStringEventArgs e)
    {
        if((e.LongIntervall&&e.Resolution==NonLinearTime.TimeResolution.days)&&(!this.gantt1.DateScaler.UseDayNumbersNotWeeks))
        {
            e.OutputText=e.DateTime.ToString(“dd.MM”)+” – “+e.DateTime.AddDays(6).ToString(“dd.MM”);
            e.ContinueDraw=true;
        }
    }

Supports answer: The answer to this is that weeks presentation is performed when drawMarker.DayOfWeek == timeLine.MidWeek, so Uli is correct. For week presentation the supplied date will need an AddDays(-3) for displaying the start of the week correctly. This was a bit unexpected in the design phase but we are keeping this behaviour so you can safely substract 3 days to get the start and add 3 days to get the end of the week (all cultures have 7 days a week right?!).

 

In phGantTimePackage you implement the event OnScalerStringShort and OnScalerStringLong to change the short and long intervall representation.

Also; the Gantt.DateScaler.ShowWeekNumbers=true and the Gantt.DateScaler.StartOfWeek property is an easy way to an alternative week presentation.

 

 

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);

         }

      }

 

 

10062 : How in VB6 do you iterate through the nodes/cells of the tree view

Question

How in VB6 do you iterate through the nodes/cells of the tree view located on the left.

I cant seem to find any structure which says something like:

For each node in treeviewnodes
     Node.cell0 = “”
     Node.cell1 = “”
     Node.cell2 = “”
Next

Answer

Like this:

Private Sub CommandIterate_Click()< ?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Dim activity As IphDataEntity_Tree

 

    Set activity = Nothing

    IterateActivity phGantX1.RootDataEntitiesTree, activity

   

   

End Sub

 

Public Sub IterateActivity(aphDataList As IphDataList, aOwner As IphDataEntity_Tree)

Dim activity As IphDataEntity_Tree2

   

        For i = 0 To aphDataList.Count – 1

            Set activity = aphDataList.Items(i)

                       

            For ii = 0 To phGantX1.GridColumnCount – 1

               

                Dim s As String

                s = phGantX1.GetGridCellString(ii, activity.GridRowIndex)

                        

            Next

           

           

            IterateActivity activity.SubDataList, activity ‘ traverse owned nodes

        Next

       

 

End Sub

 

10057 : Zooming phGant

Question

Currently evaluating the PHGantTimePackage for VB6 and would like to know how you can zoom in and out programatically without having to drag the scaler left and right?

Answer

For starters you just set the Gantt.Start and Gantt.Stop to values of your liking and the view will adapt.

You can also use the function IphGantX3.AnimateScaleTransition(newScale,steps). The scale is basically a decimal value that is calculated by (Stop-Start)/WidthInPixels  So if you want to zoom out, to show more time, you can do Gantt.AnimateScaleTransition(Gantt.Scale*2,50). And to show less time Gantt.AnimateScaleTransition(Gantt.Scale/2,50)

To get a feel for the AnimateScaleTransition you can check the Gantt.Scale property… As you zoom this parameter changes. Zoom to year and check the value of Scale. Zoom to weeks and check the value of Scale.

Now add two buttons “Year” and “Weeks”, in each button you call AnimateScaleTransition(value,50) where value is the for year and weeks respectivly, You will see how to scale animates the transition from the current setting to the year or week setting in 50 steps.

 

10059 : I cant get anything display in the grid when using Windows 98.

Question

I have a problem while using the grid. It seems that since I downloaded the latest available version, I cant get anything display in the grid when using Windows 98. Do you have any information about how to solve this problem ?

Answer

This was an issue that was fixed in a recent patch. Download it here : http://www.plexityHide.com/pub/phGantXControl.zip

10049 : Hiding a time item

Question

I m using phGantTimePackage and I would like to know how to hide a time item. I tried to set Visible property to false, but the gant item does not dissapear.

Answer

The Visible feature is regretfully not implemented for time item. You will need to remove the time item, and later create it, or move it it time. One suggestion is to add ten years to the start date 

 

10045 : The function (COM) MousePositionGantArea returns 0,0 for the last known mouseposition.

Question

I’ve returned from a 2-year, 18,000 mile bicycle tour of South American Bicycle and find myself working at the same company. I’ve been tasked to build yet another scheduling application.

I’m using some code that I had developed back in 2000. All works fine except for one thing.

The function (COM) MousePositionGantArea returns 0,0 for the last known mouseposition. Do you know if there is a problem using this method on Windows XP?

Answer

We made a code breaking change here at one point (totally against our policy and it will not happen again (?!)). The change we made was to switch from using reference integer values, to reference Variant values as parameters for the call.

We made this change to allow the call to made from VB-Script that only supports Variants as return parameters.

So you need to change the code from

dim x,y as int

to

dim x,y as Variant

 

10046 : converting a program from vb6 to vb.net. Everything seems to go fine, exept for the userdraw ackground part.

Question

i am converting a program from vb6 to vb.net. Everything seems to go fine, exept for the userdraw ackground part. I know how to create graphics in .net But the function returns a Hdc and how can i convert this to a graphic object (so i can paint a today line for example).

Answer

You can convert a Hdc to a Graphic object like in the sample below.

private void axphSchemaX1_OnUserDrawTime(object sender, AxphGantXControl.IphSchemaXEvents_OnUserDrawTimeEvent e)
{
  Graphics gr=System.Drawing.Graphics.FromHdc((IntPtr)e.theHDC);
 
gr.DrawLine(new Pen(Color.Beige,5),e.left,e.top,e.right,e.bottom);
  gr.DrawLine(
new Pen(Color.BlueViolet,5),e.right,e.top,e.left,e.bottom);
}