private ArrayList Sort(ArrayList sourceList)
 {
     if (sourceList != null && sourceList.Count > 1)
     {
         ArrayList resultList = new ArrayList();
         foreach (RoadMapDate sd in sourceList)
         {
             bool isOk = false;
             int  i    = 0;
             while (i < resultList.Count && !isOk)
             {
                 RoadMapDate rd = (RoadMapDate)resultList[i];
                 if (sd.Date <= rd.Date)
                 {
                     resultList.Insert(i, sd);
                     isOk = true;
                 }
                 i++;
             }
             if (!isOk)
             {
                 resultList.Add(sd);
             }
         }
         return(resultList);
     }
     else
     {
         return(sourceList);
     }
 }
    private string CreateBar(DataRow dr)
    {
        string bar = string.Empty;

        // Build date list
        ArrayList dateListSorted = BuildPLCDates(dr);

        // Create bar
        if (dateListSorted != null && dateListSorted.Count > 0)
        {
            int      nbDays;
            double   colWidth;
            TimeSpan difDate;

            DateTime endDate = _StartDate.AddMonths(_NbMonths);
            dateListSorted = RetrieveIncludePeriod(dateListSorted, _StartDate, endDate); // Contains (startDate, d1, d2, ..., endDate)

            for (int i = 0; i < dateListSorted.Count; i++)
            {
                RoadMapDate currentDate = (RoadMapDate)dateListSorted[i];
                if (i < dateListSorted.Count - 1)
                {
                    RoadMapDate nextDate = (RoadMapDate)dateListSorted[i + 1];
                    nbDays = RetrieveNbDays(_StartDate, _NbMonths);

                    difDate  = nextDate.Date.Subtract(currentDate.Date);
                    colWidth = Math.Round((difDate.TotalDays * 100) / nbDays, 0);

                    if (colWidth == 0)
                    {
                        colWidth = 1;
                    }

                    if (nextDate.Date == endDate)
                    {
                        bar += "<td class='" + currentDate.CssClass + "' width='*'>&nbsp;</td>";
                    }
                    else
                    {
                        bar += "<td class='" + currentDate.CssClass + "' width='" + colWidth.ToString() + "%'>&nbsp;</td>";
                    }
                }
            }
        }
        else
        {
            bar += "<td class='rg' width='100%'>&nbsp;</td>";
        }

        return(bar);
    }