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