10231 : .NET 2005

Question

I would like to further enquire about the possibility of using your package in VB .NET 2005. If we buy a licence today, will we be able to upgrade to a version of GTP.NET compatible with it for free, or will there be a cost associated with it?

As you probably know, .NET 2005 is coming out very shortly, and we’re concerned about possible upgrade costs if we purchase today.

Answer

Regarding VS2005; This will be treated as a normal service release upgrade. We will support VS2003 and VS2005, until there is a VS2006 or -7. (no cost)

10266 : When I tried the examples (M$ Gantt) in Whidbey (Beta2) I could not set the DateScalerProperties.StartTime Propery.

Question

When I tried the examples (M$ Gantt) in Whidbey (Beta2) I could not set the DateScalerProperties.StartTime Propery. No error message, but the value always stayed at 5/8/2005?

Answer

We had a GTP.NET bug that stopped Start dates larger than stop dates. This is now fixed (Stop date is changed to start date in this case).

I have tried this in VS2005 Beta 2, and it works. Download the latest patch from here: https://plexityhide.com/pub/PlexityHide.GTP.zip

10212 : predecessor or the successor of a particular timeitem on a row?

Question

is there an efficient method to get the predecessor or the successor of a particular timeitem on a row?

Answer

TimeItems has an index property so accessing the time item in front in the layer list is easy:

prevtimeitem=timeitem.Layer[timeitem.Index-1] // Note: you will want to check Index>0 first

But I guess your question is how to find the time item closest to another based on Start or Stop. Currently we have no faster way in doing this than iterating the layer and looking for the best candidate….

 

10211 : How can I draw a rectangle on the TimeItemArea to a group of timeitems?

Question

How can I draw a rectangle on the TimeItemArea to  a group of timeitems?

Answer

The answer below explains how to use the user drawing mechanism to achieve a square that is dragged out with a mouse click… Once you have this functioning you want to iterate the time items and see if they are inside the rectangle, if so select them. That part is not shown in this sample…

      // What if I want to draw a square in time item area, starting from a click point and following the mouse?
      // The solution is marked with “#1”

      //#1
      private bool mouseisCurrentlyDown=false;
      private Point mousewaspressedat=new Point(0,0);
      private Point mouseisat=new Point(0,0);
      private void gantt1_OnTimeItemAreaMouseDown(object sender, MouseEventArgs e)
      {
        //#1
        mouseisCurrentlyDown=true;
        mousewaspressedat.X=e.X;
        mousewaspressedat.Y=e.Y;
      }

      private void gantt1_OnTimeItemAreaMouseUp(object sender, MouseEventArgs e)
      {
        //#1
        mouseisCurrentlyDown=false;
        gantt1.TimeItemArea.Invalidate();
      }

      private void gantt1_OnTimeItemAreaMouseMove(object sender, MouseEventArgs e)
      {
        //#1
        mouseisat.X=e.X;
        mouseisat.Y=e.Y;
        if (mouseisCurrentlyDown && gantt1.MouseMoveKind==MouseMoveKind.none)
        {
          // We do not want the frame to be drawn on normal Gantt actions, only when the Gantt is not doing anything else
          gantt1.TimeItemArea.Invalidate();
        }
      }

      private void gantt1_OnTimeItemAreaPaintForeground(OffscreenDraw aOffscreenDraw, OffscreenDrawArgs e)
      {
        // You can easily draw in the back- or foreground of the Grid, DateScaler or TimeItemArea
        e.G.FillRectangle(new SolidBrush(Color.Black),aOffscreenDraw.CalcLeft+100,aOffscreenDraw.CalcTop+100,90,90);
        e.G.DrawString(“Front”,new Font(“Helvetica”,14),new SolidBrush(Color.Red),aOffscreenDraw.CalcLeft+100,aOffscreenDraw.CalcTop+100);

        //#1
        if (mouseisCurrentlyDown && gantt1.MouseMoveKind==MouseMoveKind.none)
        {
          e.G.DrawRectangle(new Pen(Color.Green),mousewaspressedat.X,mousewaspressedat.Y,mouseisat.X-mousewaspressedat.X,mouseisat.Y-mousewaspressedat.Y);
        }
      }

10209 : Upgrading

Question

I just saw there is a new version of GTP.Net out, 2.01.
So I downloaded it, and installed it. I removed my old GTP Reference from my VB.NET and ed the new one, 2.01. After that I was asked for my serial number, so I pasted it into the form. But it still says Evaluation.

Could it be my license is to old (1,5 years ago I think) and do I need to buy it again just to get that ?

Or maybe I did something wrong?

Answer

We ask for a small upgrade fee (25% percent of price of a new license) for the 2.0 version. The 1.0 keys will not work for 2.0.

The upgrade can be bought from the normal shop page, or via componentSource. You will be asked to identify the old lilcense (using the 1.x key)

10210 : Progress in my timeitem

Question

Is it possible (with version 1.1 or 2.0 or both) to have a progress in my timeitem, lets say x percent are blue, and 100-x percent are red or something like this?

I have a timeitem, it last 20 hours, and 15 hours are already finished, so can I see that progress somehow?

Answer

One way to visualize progress in a time items is to make the time item TimeItemStyle.User and implement the user draw, in this sample I have put the percent value in the UserReference property of the time item. I calculate the size of the progress bar as a function of the rectangle width.

Note that I choose to re-use the standard drawing of a TimeItemStyle.Square time item

   private void gantt1_OnTimeItem_UserDraw(PlexityHide.GTP.Gantt aGantt, PlexityHide.GTP.TimeItemEventArgs e)
    {
      e.TimeItem.TimeItemLayout.TimeItemStyle=TimeItemStyle.Square;
      TimeItemDraw.Draw(e.G,e.TimeItem,e.Rect,e.TimeItem.Selected,e.TimeItem.TimeItemLayout);
      e.TimeItem.TimeItemLayout.TimeItemStyle=TimeItemStyle.User;
     
      if (e.TimeItem.UserReference is Double)
      {
       
        System.Drawing.Point xy1=new System.Drawing.Point(e.Rect.Left,(int)(e.Rect.Top+e.Rect.Height/2));
        System.Drawing.Point xy2=new System.Drawing.Point(xy1.X+(int)(((double)e.TimeItem.UserReference)/100*e.Rect.Width),xy1.Y);
        e.G.DrawLine(new Pen(Color.YellowGreen,3),xy1,xy2);
      }
    }

 

10229 : Changing the snapping functionality

Question

I’ve noticed that when moving TimeItems in GTP.NET that if I have a snap interval specified for both start and end it only obeys the start snap so what I want to do is if the user moves the item to the left it honors the start snap and if the user moves the item to the right it honors the end snap.

This is the code that I have but it doesn’t do what I want it to do.

Private Sub Gantt_OnTimeItem_Move(ByVal aGantt As PlexityHide.GTP.Gantt, ByVal e As PlexityHide.GTP.TimeItemEventArgs) Handles GanttPurchasing.OnTimeItem_Move, GanttProduction.OnTimeItem_Move, GanttPlanning.OnTimeItem_Move
  If e.Diff.TotalSeconds > 0 Then
    e.TimeItem.TimeItemLayout.SnapStartTime = New TimeSpan(0, 0, 0, 0)
    e.TimeItem.TimeItemLayout.SnapStopTime = New TimeSpan(1, 0, 0, 0)
  Else
    e.TimeItem.TimeItemLayout.SnapStartTime = New TimeSpan(1, 0, 0, 0)
    e.TimeItem.TimeItemLayout.SnapStopTime = New TimeSpan(0, 0, 0, 0)
  End If

End Sub

Answer

Yes, move is considered as a change of the start time. The Stop snap comes into play only when the user resize by dragging the east side of a time item (changing length).

Nevertheless it will be no problem to change the snapping functionality to your liking. You need to intercept the values that are about to be applied to the time item and snap them. You can adhere your own rules depending on the MouseMoveKind property of the Gantt. Implement the Gantt.OnTimeItem_StopValueResize event and use the Snapping functionality available here  Gantt.DateScaler.SnapTime and simply update the stop value of the time item that you get access to in the arguments of the event .

 

 

10192 : DateTime from a point on the TimeItemArea which is selected by the mouse ptr?

Question

I would like to get the DateTime from a point on the TimeItemArea which is selected by the mouse ptr. Therefore I implemented the OnTimeItemAreaMouseDown method but how do I get the DateTime from e.X and e.Y?

Answer

You use the Gantt.DateScaler.PixelToTime(int pix) method… If you have a datetime and need the a pixel there is a Gantt.DateScaler.TimeToPixel

10287 : Deleting links by keyboard. Key events does not fire.

Question

I want to  delete a link when the user presses a key. Ive implemented all the key_down/key_up/on_datescaler_key_up/… events, but none of them seems to fire.

Answer

In order for a control to actually receive and handle the key events it must be focused. If you were to add this line in a TimeItemArea MouseDown event: Gantt1.TimeItemArea.Focus(), you will find that the key events are executed as expected.

Another good way to get key events would be to add a context menu and add shortcut-keys to the menuitems.

(We have key handling on our list for future development, we will implement key navigation in datescaler and to jump between time items etc.)