Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
225
Custom summary rows
posted

I am trying to replace the standard summary row so that all TaskUIElements of subtasks are drawn in the summary task row. I tried the DrawFilter and had some luck with that: As soon as the summary is drawn (DrawElement-Method) I get the UIElements of the subtasks, offset them to the Y-position of the summary and call DrawElement of the subtask UIElement. Then I offset the subtasks back to their normal position and let them draw the regular way.

Code looks like this:

public bool DrawElement(Infragistics.Win.DrawPhase drawPhase, ref Infragistics.Win.UIElementDrawParams drawParams)
{
 Task t = (Task)drawParams.Element.GetContext(typeof(Task), true);

 if (t != null && t.IsSummary)
 {
  foreach (Task tsub in t.Tasks)
  {
   UIElement tsubUI = this.ultraGanttView1.UIElement.GetDescendant(typeof(TaskUIElement), tsub);

   if (tsubUI == null)
    continue;

   int deltaY = drawParams.Element.Rect.Y - tsubUI.Rect.Y;

   tsubUI.Offset(0, deltaY);
   tsubUI.DrawElement(ref drawParams);
   tsubUI.Offset(0, -deltaY);
  }

  return true;
 }
}

The only problem is, that as soon as I close up the summary in the grid part of the UltraGanttView, no UIElements are created for the Subtasks. I understand that behavior, but is it possible to create TaskUIElements manually for the subtasks like the GanttView would do and paint them in the summary row? I have tried this but can't figure out the correct TaskUIElement.Rect dimensions. As soon as I create the TaskUIElement for the subtask the Rect is 0,0,0,0. Is there a way to calculate the dimensions of the rectangle?

Parents
  • 53790
    posted

    Hello Stafan,

    I`m not sure that I understand your scenario, but maybe you could use a CreationFilter and set the Rectangle of your TaskUIElement. For example:

     public void AfterCreateChildElements(UIElement parent)
            {
                TaskAreaUIElement El1 = parent as TaskAreaUIElement;
                TimeSlotUIElement El2 = parent as TimeSlotUIElement;
                TaskUIElement El = parent as TaskUIElement;

                if (El1 != null) tAreaEl = El1;
                if (El2 != null) tSlot = El2;

                if (El != null && El.GetType() == typeof(TaskUIElement))
                {
                    MyTask mt = El.Task as MyTask;
                    if (mt != null && mt.MySubTask.Count > 0)
                    {
                        foreach (Task item in mt.MySubTask)
                        {

                            TimeSpan ts = item.StartDateTime - mt.StartDateTime;
                            TaskUIElement tb = new TaskUIElement(tAreaEl, item);
                            tb.Rect = new Rectangle(((TaskUIElement)El).Rect.X + (mt.Duration.Days * tSlot.Rect.Width * ts.Days), ((TaskUIElement)El).Rect.Y, tSlot.Rect.Width * item.Duration.Days, 19);
                            tAreaEl.ChildElements.Add(tb);

                           
                            TaskDependencyLineUIElement line = new TaskDependencyLineUIElement(tAreaEl, item, mt, TaskDependencyType.FinishToStart, Orientation.Horizontal);
                            line.Rect = new Rectangle(((TaskUIElement)El).Rect.X + (mt.Duration.Days * tSlot.Rect.Width), ((TaskUIElement)El).Rect.Y + 8, tSlot.Rect.Width * ts.Days, 19);
                            tAreaEl.ChildElements.Add(line);
                        }
                    }
                }
            }

    Please let me know if you think that I misunderstood your scenario or if you have any questions.

Reply Children