10449 : How can I tell which nodes in my tree are visible to the user?

Question

How can I tell which nodes in my tree are visible to the user?

When the user expands a node, I would like to be able to adjust the display so that all the sub-nodes of that node are visible (without the user having to scroll up or down to see them).

Or is there a way of getting the Gant control to adjust the display automatically? I would ideally like the tree to work like the tree in Windows Explorer.

Answer

Both the phGantTimePackage and GTP.NET returns a rectangle of -1,-1,-1,-1 for the grid rect of cells that has not been drawn (because they are not currently on screen).

In phGantTimePackage you can use the IphGantRow3.GetRect method
and in GTP.NET you would use GridNode.Rect

The same applies to individual cells (that they return a -1 rect if not currently on screen).

10437 : Stopping time item move

Question

I would like to cancel a TimeItem move under certain conditions, and I tried using e.allow=false. It works in the sense that the TimeItem could not be moved horizontally, but it could still move vertically and would land itself on other rows (i.e. the X coordinate remained the same, but the Y coordinate has changed). Did I missed out any settings here? Thank you.

Answer

If you set e.Allow=false in the event OnTimeItem_Move the move in time will be stopped.
To Stop move in row you must implement the OnTimeItem_ChangeRow event and set e.Allow=false.

This way you can effectivly seperate the two kinds of move available.

To effectivly disallow row change you can set TimeItem.TimeItemLayout.AllowChangeRow=false (note that this will stop all time items charing the same TimeItemLayout to disallow row change)

10398 : Im using your GTP.NET – Control with ASP.NET. Id like to catch an Event when the User clicks on a cell-Text or Button in the Grid.

Question

Im using your GTP.NET – Control with ASP.NET. Id like to catch an
Event when the User clicks on a cell-Text or Button in the Grid.
I tried it with “…OnGridCellChanged”, the event is fired when i
click in the Gantt-Area, but not when i click in the Grid-Area.
What can i do?

Answer

To handle this you can add a html link to the cell data. So if you need “AAA” in the cell assign <a href=”onclick or postback”>AAA<a>, depending on what you want to do in the click-event, you might want a href pointing to a client side script, or you might want to do a postback and catch the click in the OnPostBackEvent of Gantt_ASP

10413 : Can I define some areas as a “break” (e.g. holiday) area?

Question

Can I define some areas as a “break” (e.g. holiday) area where I can color these areas with another color, and these areas do not allow items to be dropped (after being dragged.). These areas need to be different for each row. (e.g. Row1 – break areas are on Wednesdays; Row2 – Break areas are on Sundays and Mondays).

Answer

The GTP.NET object model does not currently contain this but as shown in the Gantt_TimeItem sample it can easily be achieved anyway;

First we define some standard time items and add our own BreakInfo object to the Userreference, then we implement the userDraw event and draw the time item and the break based on the info in our BreakInfo object.

This describes to hold break info in specific time items, if you would rather draw some information on the time item background take a look at this article: http://plexityhide.dyndns.org/InstantKB13/article.aspx?id=10278


    private void SetUpTimeItemAdvancedUserDraw()
    {
      GridNode gn=gantt1.Grid.GridStructure.RootNodes.AddNode();
      gn.GetCell(0).Content.Value="Sample of time item advanced user draw";
      GanttRow gr = GanttRow.FromGridNode(gn);
      gr.CollisionDetect=false;
      TimeItem ti1=gr.Layers[0].AddNewTimeItem();
      TimeItem ti2=gr.Layers[0].AddNewTimeItem();
      TimeItem ti3=gr.Layers[0].AddNewTimeItem();

      ti1.Start=gantt1.DateScaler.StartTime.AddDays(1);
      ti1.Stop=ti1.Start.AddDays(3);
      ti1.TimeItemLayout=new TimeItemLayout();
      ti1.TimeItemLayout.SelectHandles=Color.Black;
      ti1.TimeItemLayout.TimeItemStyle=TimeItemStyle.User;
      ti1.UserReference=new BreakInfo(1,0.5);
      
      ti2.Start=ti1.Stop.AddDays(1);
      ti2.Stop=ti2.Start.AddDays(4);
      ti2.TimeItemLayout=new TimeItemLayout();
      ti2.TimeItemLayout.SelectHandles=Color.Black;
      ti2.TimeItemLayout.TimeItemStyle=TimeItemStyle.User;
      ti2.UserReference=new BreakInfo(2,0.5);
}
private void gantt1_OnTimeItem_UserDraw(PlexityHide.GTP.Gantt aGantt, PlexityHide.GTP.TimeItemEventArgs e)
{
        if (e.TimeItem.UserReference is BreakInfo)
        {
                // I have put my own object of class BreakInfo in the UserReferenece of the time item
                // And now I retrieve it and use the information within when drawing the time item
                BreakInfo breakInfo=e.TimeItem.UserReference as BreakInfo;


                DateTime breakStart=e.TimeItem.Start.AddDays(breakInfo.startsDaysFromStart).Add(e.Diff);
                DateTime breakStop=breakStart.AddDays(breakInfo.breakLengthInDays);

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


                if (gantt1.ScheduleMode)
                {
                        e.G.FillRectangle(new SolidBrush(Color.Blue),new Rectangle(e.Rect.Left,e.Rect.Top,e.Rect.Width,breakStartPixel-e.Rect.Top));
                        e.G.FillRectangle(new SolidBrush(Color.Blue),Rectangle.FromLTRB(e.Rect.Left,breakStopPixel,e.Rect.Right,e.Rect.Bottom));
                        e.G.DrawRectangle(new Pen(Color.Black),e.Rect);
                }
                else
                {
                        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);
                }

        }
}

10391 : Can I have a System.Windows.Forms.Button in a Grid cell?

Question

Hi,
it is possible to place a System.Windows.Forms.Button in a GridCell? It seems that there only some types (BoolCheck for Checkboxes, and ComboText for a Combobox), but I need a Button there.

I tried it with CustomCell and its Draw Event, but you can only use a Graphics Object to draw.

Content.Value = new Button() doesn’t work either.

Thanks!

Answer

In GTP.NET we currently have no Button cell ready, but to handle this and any other special cell that you might need in the future we added the CellType.CustomCell.

grid1.GridStructure.Columns.AddNew(CellType.CustomCell);

When you use this CellType you can implement some events to handle the different modes that a cell needs to handle:

 OnCustomCellDraw  Draw the content of the cell when not in edit mode 
 OnCustomCellEditStartByKey  Edit is started by key 
 OnCustomCellEditStartByMouse  Edit is started by clicking 
 OnCustomCellEndEdit  Edit is finished 
 OnCustomCellHeight 

I would suggest to only keep one button and put it in the cell when the cell enters edit mode (OnCustomCellEditStartByKey and OnCustomCellEditStartByMouse ), and when not in edit mode I would draw an image of a button (OnCustomCellDraw ), this way you will not overload windows with a button per row.

This is similair to how we do things internally with TextBox, ComboBox, DateTimePickar and checkbox.

 

10394 : What kind of event fired when TimeItemLink.Action = TimeItemLinkAction.Event ? How can i subscribe to it?

Question

Hi.
What kind of event fired when TimeItemLink.Action = TimeItemLinkAction.Event ?
How can i subscribe to it?

Im trying to use OnLinkAction Event but it doesnt work…

tnx!

Answer

When you set TimeItemLinkAction.Event on a link action the event Gantt.OnLinkAction will fire when the target is moved.

 

10379 : Does the phGantTimePackage support the export of the GantTime to PowerPoint?

Question

Does the phGantTimePackage support the export of the GantTime to PowerPoint?

Answer

Not powerpoint directly. BUT since win32 and .NET allowes for recording of meta files by sending in a graphic context, you can use win32 features and create a meta file hdc and use the PrintToHdc. PowerPoint handles meta files (emf and wmf) and files created this way are vector based so they scale nicely.

10338 : OnScalerString Upper or lower band?

Question

Hello,
i’d like to ask something about the issue http://plexityhide.dyndns.org/InstantKB13/article.aspx?id=10282

I’ve picked (min_date) as start date a year where the first day of january is monday (es the 2007) and start from it to count.
I’ve set the UseDayNumbersNotWeeks to false to show the week counting.

after that i’ve implemented the function OnDateScalerDrawString

if(min_date != null)
{
 TimeSpan days = e.DateTime – (DateTime)min_date;

 switch(e.Resolution.ToString())
 {     
  case “days”:
  {
   e.OutputText = (days.Days>=0) ? “Day ” + (days.Days+1).ToString() : “”;
  }break;
  case “weeks”:
  {
   Int32 weeks = ((days.Days) / 7)+1;
   e.OutputText = weeks>0 ? “Week ” + weeks.ToString() : “”;
  }break;
  default:
   e.OutputText = “”;
   break;
 }
}

the problem is that the Resolution property give the minimum resolution of the bars in the DateScaler so if i can show in the lower bar the days in the above bar i can see the the middle day of the week (4, 11, etc). How can i check in what bar e is referring to?
Also i’d like to disable the resolution above the weeks, because in my  situation is not possible to count months, years and so on (the months have differents number of days), is this possible?

Answer

To find out if the event has been called for the long inverval (the top band) or the short interval (the bottom band) you can check the e.LongIntervall (true? then the top band).

To limit the resolution you can implement the OnBeforeScaleOrSpanChange event and stop any action you do not want to allow. You can also set DateScaler.MinSpan and MaxSpan to control this.

 

10378 : With GTP.Net.Web why must the GTPImg, minus.png and plus.png be within the same directory of as where Im using GTP.Net on a aspx page.

Question

With GTP.Net.Web why must the GTPImg, minus.png and plus.png be within the same directory of as where I’m using GTP.Net on a aspx page. It would be a great improvement where if there was multiple charts in one application that are located in different areas that all those different charts could point to the same GTPImg.aspx,minus.png, and plus.png.

Answer

…eh… no good answer. We will add a new property PathToStaticImages with the following documentation:

The path to get to the static images like plus and minus pngs in the tree and the GTPImg.aspx that is used to deliver images to the client. Default is “./”

Thanks for the constructive feedback.

10688 : Critical path

Question

Does the phGantTimePackage and GTP.NET calculate the Critical Path?

Answer

WikiPedia on Critical path:

“The Critical Path Method, abbreviated CPM, is a mathematically based algorithm for scheduling a set of project activities. It is a very important tool for effective project management. It was developed in the 1950’s in a joint venture between DuPont Corporation and Remington Rand Corporation for managing plant maintenance projects. Today, it is commonly used with all forms of projects, including construction, software development, research projects, product development, engineering, plant maintenance, among others. Any project with interdependent activities can apply this method of scheduling.

The essential technique for using CPM is to construct a model of the project that includes the following:

A list of all activities required to complete the project,
The time (duration) that each activity will take to completion, and
The dependencies between the activities.
Using these values, CPM calculates the starting and ending times for each activity, determines which activities are critical to the completion of a project (called the critical path), and reveals those activities with “float time” (are less critical). In project management, a critical path is the sequence of project network activities with the longest overall duration, determining the shortest time possible to complete the project. Any delay of an activity on the critical path directly impacts the planned project completion date (i.e. there is no float on the critical path). A project can have several, parallel critical paths. An additional parallel path through the network with the total durations shorter than the critical path is called a sub-critical or non-critical path.”

Our components are used in many different types of applications and even when they are used for strict project planning it is common that multiple types of time items are used that symbolize different aspects of time. Planned time is only one aspect. Work time can be another (the actual performed work amount). And scheduled time can be a third (when the resource is available for any work at all).

So to simply say that we support a Critical Path analysis would not be correct. We do however support the harbouring of all the information needed to perform Critical Path calculations in what ever application you may build and this is what is important to us.

Critical Path calculation is to us only another domain specific usage of the information presented by the GTP.NET and the phGantTimePackage. You can easily go from one TimeItem to another over its timeItemLinks (relations) and you can easily add logic to iterate these paths and perform actions (like actually moving overlapping timeItems etc) or present bottlenecks by changing the presentation any way you may require (color, form and content).