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
300
re-painting / re-binding tasks in winganntview
posted

HI

I have implemented the solution by Georgi to show multiple tasks on one line (http://es.infragistics.com/community/forums/t/63942.aspx)

I have found though that when a sub group is shrunk (not expanded) and the time line is scrolled form left to right the original tasks do not get re-painted and stay in position.

My method

 public void AfterCreateChildElements(UIElement parent)
        {

            int LastLevel = 0;
            Boolean LevelVis = false;
            MyTask Level1Tasks = null;

            try
            {
                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;

                int xLoc = 0;

                if (El1 != null) tAreaEl = El1;
                if (El2 != null) tSlot = El2;
                foreach (UIElement ui in parent.ChildElements.Where(x => x.GetType() == typeof(TaskUIElement)))
                {
                    TaskUIElement Eln = ui as TaskUIElement;
                    

                    if (!xCords.ContainsKey(Eln.Task.StartDateTime.Date))
                    {
                        xCords.Add(Eln.Task.StartDateTime.Date, ui.Rect.X);

                    }
                    else
                    {

                        xCords.Remove(Eln.Task.StartDateTime.Date);
                        xCords.Add(Eln.Task.StartDateTime.Date, ui.Rect.X);

                    }

                }

                if (El != null && El.GetType() == typeof(TaskUIElement))
                {
                    MyTask mt = El.Task as MyTask;
                    if (mt != null && mt.MySubTask.Count > 0)
                    {
                        bool expanded = mt.Expanded;
                        foreach (Infragistics.Win.UltraWinSchedule.Task item in mt.MySubTask)
                        {
                             if (expanded)
                            {
                            
                            int Coord = xCords.FirstOrDefault(x => x.Key == item.StartDateTime.Date).Value;
                            var IntervalType = item.Name;
                            int newmultiplier = 1;
                            TimeSpan ts = item.StartDateTime.Date - mt.StartDateTime.Date;
                            TaskUIElement tb = new TaskUIElement(tAreaEl, item);
                          
                            tb.Rect = new Rectangle((Coord), ((TaskUIElement)El).Rect.Y, tSlot.Rect.Width * (int)(item.Duration.TotalHours) / 2, 19);
                            elementToAdd.Rect = new Rectangle((Coord), ((TaskUIElement)El).Rect.Y, tSlot.Rect.Width * (int)(item.Duration.TotalHours) / 2, 19);
                            tAreaEl.ChildElements.Add(tb)
                            xLoc += 1;

                             }
                             else
                             {
                                 TimeSpan Endts = mt.EndDateTime.Date - mt.StartDateTime.Date;

                                 TaskUIElement tb = new TaskUIElement(tAreaEl, item);
                                 tb.Rect = new Rectangle(xCords.FirstOrDefault().Value, ((TaskUIElement)El).Rect.Y, (int)(Endts.TotalDays) / 2, 19);
                                 
                                 tAreaEl.ChildElements.Add(tb);
                             }
                        }
                       

                    }

                }

            }
            catch (Exception ex)
            {

                throw;
            }

        }