Example #1
0
        public void UpdateTasks(TaskList tasks, UIExtension.UpdateType type)
        {
            UInt32 selTaskId = SelectedAppointmentId;

            switch (type)
            {
            case UIExtension.UpdateType.Delete:
            case UIExtension.UpdateType.All:
                // Rebuild
                m_Items.Clear();
                SelectedAppointment = null;
                break;

            case UIExtension.UpdateType.New:
            case UIExtension.UpdateType.Edit:
                // In-place update
                break;
            }

            Task task = tasks.GetFirstTask();

            while (task.IsValid() && ProcessTaskUpdate(task, type))
            {
                task = task.GetNextTask();
            }

            SelectionStart = SelectionEnd;

            AdjustScrollbar();
            Invalidate();
        }
        public void UpdateTasks(TaskList tasks, UIExtension.UpdateType type)
        {
            HashSet <UInt32> changedTaskIds = null;

            switch (type)
            {
            case UIExtension.UpdateType.Delete:
            case UIExtension.UpdateType.All:
                // Rebuild
                m_Items.Clear();
                break;

            case UIExtension.UpdateType.New:
            case UIExtension.UpdateType.Edit:
                // In-place update
                changedTaskIds = new HashSet <UInt32>();
                break;
            }

            Task task = tasks.GetFirstTask();

            while (task.IsValid() && ProcessTaskUpdate(task, type, changedTaskIds))
            {
                task = task.GetNextTask();
            }

            UpdateWeightedWords(true);
            UpdateMatchList(changedTaskIds);
        }
        private bool ProcessTaskUpdate(Task task,
                                       UIExtension.UpdateType type,
                                       HashSet <UIExtension.TaskAttribute> attribs)
        {
            if (!task.IsValid())
            {
                return(false);
            }

            CloudTaskItem item;
            bool          newTask = !m_Items.TryGetValue(task.GetID(), out item);

            if (newTask)
            {
                item             = new CloudTaskItem(task.GetID());
                m_Items[item.Id] = item;
            }

            item.ProcessTaskUpdate(task, type, attribs, newTask);

            // Process children
            Task subtask = task.GetFirstSubtask();

            while (subtask.IsValid() && ProcessTaskUpdate(subtask, type, attribs))
            {
                subtask = subtask.GetNextTask();
            }

            return(true);
        }
        public void UpdateTasks(TaskList tasks,
                                UIExtension.UpdateType type,
                                System.Collections.Generic.HashSet <UIExtension.TaskAttribute> attribs)
        {
            switch (type)
            {
            case UIExtension.UpdateType.Delete:
            case UIExtension.UpdateType.Move:
            case UIExtension.UpdateType.All:
                // Rebuild
                break;

            case UIExtension.UpdateType.New:
            case UIExtension.UpdateType.Edit:
                // In-place update
                break;
            }

            Task task = tasks.GetFirstTask();

            while (task.IsValid() && ProcessTaskUpdate(task, type, attribs))
            {
                task = task.GetNextTask();
            }

            // Update
            UpdateWeightedWords();
        }
Example #5
0
        public void UpdateTasks(TaskList tasks,
                                UIExtension.UpdateType type,
                                System.Collections.Generic.HashSet <UIExtension.TaskAttribute> attribs)
        {
            switch (type)
            {
            case UIExtension.UpdateType.Delete:
            case UIExtension.UpdateType.Move:
            case UIExtension.UpdateType.All:
                // Rebuild
                m_Items.Clear();
                break;

            case UIExtension.UpdateType.New:
            case UIExtension.UpdateType.Edit:
                // In-place update
                break;
            }

            Task task = tasks.GetFirstTask();

            while (task.IsValid() && ProcessTaskUpdate(task, type, attribs))
            {
                task = task.GetNextTask();
            }


            // Clear selection
            m_DayView.SelectionStart = m_DayView.SelectionEnd;
            m_DayView.Invalidate();
        }
Example #6
0
        private bool ProcessTaskUpdate(Task task, UIExtension.UpdateType type)
        {
            if (!task.IsValid())
            {
                return(false);
            }

            CalendarItem item;
            UInt32       taskID = task.GetID();

            if (m_Items.TryGetValue(taskID, out item))
            {
                item.UpdateTaskAttributes(task, type, false);
            }
            else
            {
                item = new CalendarItem();
                item.UpdateTaskAttributes(task, type, true);
            }

            m_Items[taskID] = item;

            // Process children
            Task subtask = task.GetFirstSubtask();

            while (subtask.IsValid() && ProcessTaskUpdate(subtask, type))
            {
                subtask = subtask.GetNextTask();
            }

            return(true);
        }
Example #7
0
        public void UpdateTasks(TaskList tasks, UIExtension.UpdateType type)
        {
            // Make sure the selected task remains visible
            // after any changes if it was visible to start with
            var selItem = (SelectedAppointment as CalendarItem);

            bool selTaskWasVisible = (selItem != null) &&
                                     IsItemDisplayable(selItem) &&
                                     IsItemWithinRange(selItem, StartDate, EndDate);

            switch (type)
            {
            case UIExtension.UpdateType.Delete:
            case UIExtension.UpdateType.All:
                // Rebuild
                m_Items.Clear();
                m_MaxTaskID         = 0;
                SelectedAppointment = null;
                break;

            case UIExtension.UpdateType.New:
            case UIExtension.UpdateType.Edit:
                // In-place update
                break;
            }

            // Update the tasks
            Task task = tasks.GetFirstTask();

            while (task.IsValid() && ProcessTaskUpdate(task, type))
            {
                task = task.GetNextTask();
            }

            // Scroll to the selected item if it was modified and was 'visible'
            if (selTaskWasVisible && tasks.HasTask(m_SelectedTaskID))
            {
                EnsureVisible(SelectedAppointment, true);
            }

            SelectionStart = SelectionEnd;

            AdjustVScrollbar();
            Invalidate();
        }
        private bool ProcessTaskUpdate(Task task,
                                       UIExtension.UpdateType type,
                                       HashSet <UInt32> taskIds)
        {
            if (!task.IsValid())
            {
                return(false);
            }

            // Ignore reference tasks
            if (task.GetReferenceID() != 0)
            {
                return(true);
            }

            CloudTaskItem item;

            if (m_Items.TryGetValue(task.GetID(), out item))
            {
                item.ProcessTaskUpdate(task, type, false);
            }
            else
            {
                item = new CloudTaskItem(task.GetID());
                item.ProcessTaskUpdate(task, type, true);

                m_Items[item.Id] = item;
            }


            if (taskIds != null)
            {
                taskIds.Add(item.Id);
            }

            // Process children
            Task subtask = task.GetFirstSubtask();

            while (subtask.IsValid() && ProcessTaskUpdate(subtask, type, taskIds))
            {
                subtask = subtask.GetNextTask();
            }

            return(true);
        }
Example #9
0
        public void UpdateTasks(TaskList tasks, UIExtension.UpdateType type)
        {
            switch (type)
            {
            case UIExtension.UpdateType.Edit:
            case UIExtension.UpdateType.New:
                UpdateTaskAttributes(tasks);
                break;

            case UIExtension.UpdateType.Delete:
            case UIExtension.UpdateType.All:
                RebuildTreeView(tasks);
                break;

            case UIExtension.UpdateType.Unknown:
                return;
            }
        }
        public void UpdateTasks(TaskList tasks, UIExtension.UpdateType type)
        {
            switch (type)
            {
            case UIExtension.UpdateType.Edit:
            case UIExtension.UpdateType.New:
                if (RootNode == null)
                {
                    RebuildTreeView(tasks);
                }
                else
                {
                    UpdateTaskAttributes(tasks);
                }
                break;

            case UIExtension.UpdateType.Delete:
            case UIExtension.UpdateType.All:
                RebuildTreeView(tasks);
                break;

            case UIExtension.UpdateType.Unknown:
                return;
            }

            // If the root task is not a real task update the project name
            if (tasks.IsAttributeAvailable(Task.Attribute.ProjectName))
            {
                var rootItem = TaskItem(RootNode);

                if ((rootItem != null) && !rootItem.IsTask)
                {
                    var projName = GetProjectName(tasks);

                    if (!projName.Equals(rootItem.Title))
                    {
                        rootItem.Title = projName;
                        RootNode.Text  = projName;
                    }
                }
            }
        }
Example #11
0
        public void UpdateTasks(TaskList tasks, UIExtension.UpdateType type)
        {
            switch (type)
            {
            case UIExtension.UpdateType.Delete:
            case UIExtension.UpdateType.All:
                // Rebuild
                m_Items.Clear();
                m_MaxTaskID         = 0;
                SelectedAppointment = null;
                break;

            case UIExtension.UpdateType.New:
            case UIExtension.UpdateType.Edit:
                // In-place update
                break;
            }

            // Update the tasks
            Task task = tasks.GetFirstTask();

            while (task.IsValid() && ProcessTaskUpdate(task, type))
            {
                task = task.GetNextTask();
            }

            // Scroll to the selected item if it was modified and is 'visible'
            if (tasks.HasTask(m_SelectedTaskID) && IsTaskDisplayable(m_SelectedTaskID))
            {
                EnsureVisible(SelectedAppointment, true);
            }

            SelectionStart = SelectionEnd;

            AdjustVScrollbar();
            Invalidate();
        }
Example #12
0
        public bool UpdateTaskAttributes(Task task, UIExtension.UpdateType type, bool newTask)
        {
            if (!task.IsValid())
            {
                return(false);
            }

            UInt32 taskID = task.GetID();

            if (newTask)
            {
                Title         = task.GetTitle();
                AllocTo       = String.Join(", ", task.GetAllocatedTo());
                HasIcon       = task.HasIcon();
                Id            = taskID;
                IsParent      = task.IsParent();
                TaskTextColor = task.GetTextDrawingColor();
                DrawBorder    = true;
                IsLocked      = task.IsLocked(true);

                Task.TimeUnits units = Task.TimeUnits.Unknown;
                TimeEstimate = task.GetTimeEstimate(ref units, false);
                TimeEstUnits = units;

                StartDate = task.GetStartDate(false);
                IsDone    = (task.IsDone() || task.IsGoodAsDone());

                m_PrevDueDate = task.GetDueDate(false);
                EndDate       = (IsDone ? task.GetDoneDate() : m_PrevDueDate);
            }
            else
            {
                if (task.IsAttributeAvailable(Task.Attribute.Title))
                {
                    Title = task.GetTitle();
                }

                if (task.IsAttributeAvailable(Task.Attribute.DueDate))
                {
                    m_PrevDueDate = task.GetDueDate(false);                     // always

                    if (!IsDone)
                    {
                        EndDate = m_PrevDueDate;
                    }
                }

                if (task.IsAttributeAvailable(Task.Attribute.DoneDate))
                {
                    bool wasDone = IsDone;
                    IsDone = (task.IsDone() || task.IsGoodAsDone());

                    if (IsDone)
                    {
                        if (!wasDone)
                        {
                            m_PrevDueDate = EndDate;
                        }

                        EndDate = task.GetDoneDate();
                    }
                    else if (wasDone && !IsDone)
                    {
                        EndDate = m_PrevDueDate;
                    }
                }

                if (task.IsAttributeAvailable(Task.Attribute.TimeEstimate))
                {
                    Task.TimeUnits units = Task.TimeUnits.Unknown;
                    TimeEstimate = task.GetTimeEstimate(ref units, false);
                    TimeEstUnits = units;
                }

                if (task.IsAttributeAvailable(Task.Attribute.StartDate))
                {
                    StartDate = task.GetStartDate(false);
                }

                if (task.IsAttributeAvailable(Task.Attribute.AllocatedTo))
                {
                    AllocTo = String.Join(", ", task.GetAllocatedTo());
                }

                if (task.IsAttributeAvailable(Task.Attribute.Icon))
                {
                    HasIcon = task.HasIcon();
                }

                TaskTextColor = task.GetTextDrawingColor();
                IsLocked      = task.IsLocked(true);
            }

            UpdateOriginalDates();

            return(true);
        }
            public void ProcessTaskUpdate(Task task, UIExtension.UpdateType type,
                                          HashSet <UIExtension.TaskAttribute> attribs, bool newTask)
            {
                if (newTask)
                {
                    Title        = task.GetTitle();
                    DoneDate     = SplitDate(task.GetDoneDateString());
                    DueDate      = SplitDate(task.GetDueDateString());
                    StartDate    = SplitDate(task.GetStartDateString());
                    AllocTo      = task.GetAllocatedTo();
                    AllocBy      = task.GetAllocatedBy();
                    Status       = task.GetStatus();
                    Category     = task.GetCategory();
                    Comments     = task.GetComments();
                    CreationDate = SplitDate(task.GetCreationDateString());
                    CreatedBy    = task.GetCreatedBy();
                    Version      = task.GetVersion();
                    Tags         = task.GetTag();
                }
                else
                {
                    if (attribs.Contains(UIExtension.TaskAttribute.Title))
                    {
                        Title = task.GetTitle();
                    }

                    if (attribs.Contains(UIExtension.TaskAttribute.DoneDate))
                    {
                        DoneDate = SplitDate(task.GetDoneDateString());
                    }

                    if (attribs.Contains(UIExtension.TaskAttribute.DueDate))
                    {
                        DueDate = SplitDate(task.GetDueDateString());
                    }

                    if (attribs.Contains(UIExtension.TaskAttribute.StartDate))
                    {
                        StartDate = SplitDate(task.GetStartDateString());
                    }

                    if (attribs.Contains(UIExtension.TaskAttribute.AllocTo))
                    {
                        AllocTo = task.GetAllocatedTo();
                    }

                    if (attribs.Contains(UIExtension.TaskAttribute.AllocBy))
                    {
                        AllocBy = task.GetAllocatedBy();
                    }

                    if (attribs.Contains(UIExtension.TaskAttribute.Status))
                    {
                        Status = task.GetStatus();
                    }

                    if (attribs.Contains(UIExtension.TaskAttribute.Category))
                    {
                        Category = task.GetCategory();
                    }

                    if (attribs.Contains(UIExtension.TaskAttribute.Comments))
                    {
                        Comments = task.GetComments();
                    }

                    if (attribs.Contains(UIExtension.TaskAttribute.CreationDate))
                    {
                        CreationDate = SplitDate(task.GetCreationDateString());
                    }

                    if (attribs.Contains(UIExtension.TaskAttribute.CreatedBy))
                    {
                        CreatedBy = task.GetCreatedBy();
                    }

                    if (attribs.Contains(UIExtension.TaskAttribute.Version))
                    {
                        Version = task.GetVersion();
                    }

                    if (attribs.Contains(UIExtension.TaskAttribute.Tag))
                    {
                        Tags = task.GetTag();
                    }
                }
            }
        public void ProcessTaskUpdate(Task task, UIExtension.UpdateType type,
                                      HashSet <UIExtension.TaskAttribute> attribs, Boolean newTask)
        {
            IsParent            = task.IsParent();
            IsLocked            = task.IsLocked(true);
            IsGoodAsDone        = task.IsGoodAsDone();
            HasSomeSubtasksDone = task.HasSomeSubtasksDone();

            if (newTask)
            {
                Title        = task.GetTitle();
                DoneDate     = SplitDate(task.GetDoneDateString());
                DueDate      = SplitDate(task.GetDueDateString(false));
                StartDate    = SplitDate(task.GetStartDateString(false));
                AllocTo      = task.GetAllocatedTo();
                AllocBy      = task.GetAllocatedBy();
                Status       = task.GetStatus();
                Category     = task.GetCategory();
                Comments     = task.GetComments();
                CreationDate = SplitDate(task.GetCreationDateString());
                CreatedBy    = task.GetCreatedBy();
                Version      = task.GetVersion();
                Tags         = task.GetTag();
                TextColor    = task.GetTextDrawingColor();

                HasIcon = (task.GetIcon().Length > 0);
            }
            else
            {
                if (attribs.Contains(UIExtension.TaskAttribute.Title))
                {
                    Title = task.GetTitle();
                }

                if (attribs.Contains(UIExtension.TaskAttribute.DoneDate))
                {
                    DoneDate = SplitDate(task.GetDoneDateString());
                }

                if (attribs.Contains(UIExtension.TaskAttribute.DueDate))
                {
                    DueDate = SplitDate(task.GetDueDateString(false));
                }

                if (attribs.Contains(UIExtension.TaskAttribute.StartDate))
                {
                    StartDate = SplitDate(task.GetStartDateString(false));
                }

                if (attribs.Contains(UIExtension.TaskAttribute.AllocTo))
                {
                    AllocTo = task.GetAllocatedTo();
                }

                if (attribs.Contains(UIExtension.TaskAttribute.AllocBy))
                {
                    AllocBy = task.GetAllocatedBy();
                }

                if (attribs.Contains(UIExtension.TaskAttribute.Status))
                {
                    Status = task.GetStatus();
                }

                if (attribs.Contains(UIExtension.TaskAttribute.Category))
                {
                    Category = task.GetCategory();
                }

                if (attribs.Contains(UIExtension.TaskAttribute.Comments))
                {
                    Comments = task.GetComments();
                }

                if (attribs.Contains(UIExtension.TaskAttribute.CreationDate))
                {
                    CreationDate = SplitDate(task.GetCreationDateString());
                }

                if (attribs.Contains(UIExtension.TaskAttribute.CreatedBy))
                {
                    CreatedBy = task.GetCreatedBy();
                }

                if (attribs.Contains(UIExtension.TaskAttribute.Version))
                {
                    Version = task.GetVersion();
                }

                if (attribs.Contains(UIExtension.TaskAttribute.Tag))
                {
                    Tags = task.GetTag();
                }

                if (attribs.Contains(UIExtension.TaskAttribute.Icon))
                {
                    HasIcon = (task.GetIcon().Length > 0);
                }

                if (attribs.Contains(UIExtension.TaskAttribute.Color))
                {
                    TextColor = task.GetTextDrawingColor();
                }
            }
        }
        public void UpdateTasks(TaskList tasks, UIExtension.UpdateType type)
        {
            Task           task = tasks.GetFirstTask();
            SampleListItem item = new SampleListItem();

            System.Collections.Generic.List <String> attrib = new System.Collections.Generic.List <String>();
            System.Collections.Generic.List <String> value  = new System.Collections.Generic.List <String>();

            if (tasks.IsAttributeAvailable(Task.Attribute.Title))
            {
                attrib.Add("Title");
                value.Add(task.GetTitle());
            }

            if (tasks.IsAttributeAvailable(Task.Attribute.DoneDate))
            {
                attrib.Add("Done Date");
                value.Add(task.GetDoneDateString());
            }

            if (tasks.IsAttributeAvailable(Task.Attribute.DueDate))
            {
                attrib.Add("Due Date");
                value.Add(task.GetDueDateString(false));
            }

            if (tasks.IsAttributeAvailable(Task.Attribute.StartDate))
            {
                attrib.Add("Start Date");
                value.Add(task.GetStartDateString(false));
            }

            if (tasks.IsAttributeAvailable(Task.Attribute.Priority))
            {
                attrib.Add("Priority");
                value.Add(task.GetPriority(false).ToString());
            }

            if (tasks.IsAttributeAvailable(Task.Attribute.Color))
            {
                attrib.Add("Color");
                value.Add(task.GetColor().ToString());
            }

            if (tasks.IsAttributeAvailable(Task.Attribute.AllocatedTo))
            {
                attrib.Add("Alloc To");
                value.Add(task.FormatAllocatedTo(", "));
            }

            if (tasks.IsAttributeAvailable(Task.Attribute.AllocatedBy))
            {
                attrib.Add("Alloc By");
                value.Add(task.GetAllocatedBy());
            }

            if (tasks.IsAttributeAvailable(Task.Attribute.Status))
            {
                attrib.Add("Status");
                value.Add(task.GetStatus());
            }

            if (tasks.IsAttributeAvailable(Task.Attribute.Category))
            {
                attrib.Add("Category");
                value.Add(task.FormatCategory(", "));
            }

            if (tasks.IsAttributeAvailable(Task.Attribute.Percent))
            {
                attrib.Add("Percent");
                value.Add(task.GetPercentDone(false).ToString());
            }

            if (tasks.IsAttributeAvailable(Task.Attribute.TimeEstimate))
            {
                attrib.Add("Time Estimate");

                Task.TimeUnits units = Task.TimeUnits.Hours;
                value.Add(task.GetTimeEstimate(ref units, false).ToString() + units);
            }

            if (tasks.IsAttributeAvailable(Task.Attribute.TimeSpent))
            {
                attrib.Add("Time Spent");

                Task.TimeUnits units = Task.TimeUnits.Hours;
                value.Add(task.GetTimeSpent(ref units, false).ToString() + units);
            }

            if (tasks.IsAttributeAvailable(Task.Attribute.FileLink))
            {
                attrib.Add("File Link");
                value.Add(task.FormatFileLink(", "));
            }

            if (tasks.IsAttributeAvailable(Task.Attribute.Comments))
            {
                attrib.Add("Comments");
                value.Add(task.GetComments());
            }

            if (tasks.IsAttributeAvailable(Task.Attribute.Flag))
            {
                attrib.Add("Flag");
                value.Add(task.IsFlagged(false).ToString());
            }

            if (tasks.IsAttributeAvailable(Task.Attribute.CreationDate))
            {
                attrib.Add("Creation Date");
                value.Add(task.GetCreationDateString());
            }

            if (tasks.IsAttributeAvailable(Task.Attribute.CreatedBy))
            {
                attrib.Add("Created By");
                value.Add(task.GetCreatedBy());
            }

            if (tasks.IsAttributeAvailable(Task.Attribute.Risk))
            {
                attrib.Add("Risk");
                value.Add(task.GetRisk(false).ToString());
            }

            if (tasks.IsAttributeAvailable(Task.Attribute.ExternalId))
            {
                attrib.Add("External ID");
                value.Add(task.GetExternalID());
            }

            if (tasks.IsAttributeAvailable(Task.Attribute.Cost))
            {
                attrib.Add("Cost");
                value.Add(task.GetCost(false).ToString());
            }

            if (tasks.IsAttributeAvailable(Task.Attribute.Dependency))
            {
                attrib.Add("Dependency");
                value.Add(task.FormatDependency(", "));
            }

            if (tasks.IsAttributeAvailable(Task.Attribute.Recurrence))
            {
                attrib.Add("Recurrence");
                //value.Add(task.GetRecurrence());
            }

            if (tasks.IsAttributeAvailable(Task.Attribute.Version))
            {
                attrib.Add("Version");
                value.Add(task.GetVersion());
            }

            if (tasks.IsAttributeAvailable(Task.Attribute.Position))
            {
                attrib.Add("Position");
                value.Add(task.GetPositionString());
            }

            if (tasks.IsAttributeAvailable(Task.Attribute.Id))
            {
                attrib.Add("ID");
                value.Add(task.GetID().ToString());
            }

            if (tasks.IsAttributeAvailable(Task.Attribute.LastModifiedDate))
            {
                attrib.Add("Last Modified");
                //value.Add(task.GetLastModifiedString());
            }

            if (tasks.IsAttributeAvailable(Task.Attribute.Icon))
            {
                attrib.Add("Icon");
                value.Add(task.GetIcon());
            }

            if (tasks.IsAttributeAvailable(Task.Attribute.Tags))
            {
                attrib.Add("Tag");
                value.Add(task.FormatTag(", "));
            }

            if (tasks.IsAttributeAvailable(Task.Attribute.CustomAttribute))
            {
                attrib.Add("Custom Attribute");
                //value.Add(task.GetCustomAttributeData());
            }

            item.Attrib = String.Join(",", attrib.ToArray());
            item.Value  = String.Join(",", value.ToArray());
            item.Tasks  = task.GetID().ToString();

            switch (type)
            {
            case UIExtension.UpdateType.Edit: item.Type = "Edit"; break;

            case UIExtension.UpdateType.New: item.Type = "Add Task"; break;

            case UIExtension.UpdateType.Delete: item.Type = "Move Tasks"; break;

            case UIExtension.UpdateType.All: item.Type = "All"; break;

            case UIExtension.UpdateType.Unknown: item.Type = "Unknown"; break;
            }

            m_Items.Add(item);
            m_ListView.Items.Refresh();
        }
Example #16
0
 public void UpdateTasks(TaskList tasks, UIExtension.UpdateType type)
 {
     m_DayView.UpdateTasks(tasks, type);
 }
Example #17
0
 public void UpdateTasks(TaskList tasks, UIExtension.UpdateType type)
 {
     m_MindMap.UpdateTasks(tasks, type);
 }
Example #18
0
 public void UpdateTasks(TaskList tasks,
                         UIExtension.UpdateType type,
                         HashSet <UIExtension.TaskAttribute> attribs)
 {
     m_DayView.UpdateTasks(tasks, type, attribs);
 }
Example #19
0
        private bool ProcessTaskUpdate(Task task,
                                       UIExtension.UpdateType type,
                                       System.Collections.Generic.HashSet <UIExtension.TaskAttribute> attribs)
        {
            if (!task.IsValid())
            {
                return(false);
            }

            CalendarItem item;

            if (m_Items.TryGetValue(task.GetID(), out item))
            {
                if (attribs.Contains(UIExtension.TaskAttribute.Title))
                {
                    item.Title = task.GetTitle();
                }

                if (attribs.Contains(UIExtension.TaskAttribute.DoneDate))
                {
                    item.EndDate = item.OrgEndDate = task.GetDoneDate();
                }

                if (attribs.Contains(UIExtension.TaskAttribute.DueDate))
                {
                    item.EndDate = item.OrgEndDate = task.GetDueDate();
                }

                if (attribs.Contains(UIExtension.TaskAttribute.StartDate))
                {
                    item.StartDate = item.OrgStartDate = task.GetStartDate();
                }

                if (attribs.Contains(UIExtension.TaskAttribute.AllocTo))
                {
                    item.AllocTo = String.Join(", ", task.GetAllocatedTo());
                }

                item.TaskTextColor = task.GetTextDrawingColor();
            }
            else
            {
                item = new CalendarItem();

                item.Title         = task.GetTitle();
                item.EndDate       = item.OrgEndDate = task.GetDueDate();
                item.StartDate     = item.OrgStartDate = task.GetStartDate();
                item.AllocTo       = String.Join(", ", task.GetAllocatedTo());
                item.Id            = task.GetID();
                item.IsParent      = task.IsParent();
                item.TaskTextColor = task.GetTextDrawingColor();
                item.DrawBorder    = true;
            }

            if (item.EndDate > item.StartDate)
            {
                m_Items[task.GetID()] = item;
            }

            // Process children
            Task subtask = task.GetFirstSubtask();

            while (subtask.IsValid() && ProcessTaskUpdate(subtask, type, attribs))
            {
                subtask = subtask.GetNextTask();
            }

            return(true);
        }
Example #20
0
        public void UpdateTasks(TaskList tasks, UIExtension.UpdateType type)
        {
/*
 *          Task task = tasks.GetFirstTask();
 *          SampleListItem item = new SampleListItem();
 *
 *          System.Text.StringBuilder attrib = new System.Text.StringBuilder();
 *          System.Text.StringBuilder value = new System.Text.StringBuilder();
 *
 *          if (tasks.IsAttributeAvailable(Task.Attribute.Title))
 *          {
 *              attrib.Append("Title");
 *              value.Append(task.GetTitle());
 *          }
 *
 *          if (tasks.IsAttributeAvailable(Task.Attribute.DoneDate))
 *          {
 *              attrib.Append("Done Date");
 *              value.Append(task.GetDoneDateString());
 *          }
 *
 *          if (tasks.IsAttributeAvailable(Task.Attribute.DueDate))
 *          {
 *              attrib.Append("Due Date");
 *              value.Append(task.GetDueDateString());
 *          }
 *
 *          if (tasks.IsAttributeAvailable(Task.Attribute.StartDate))
 *          {
 *              attrib.Append("Start Date");
 *              value.Append(task.GetStartDateString());
 *          }
 *
 *          if (tasks.IsAttributeAvailable(Task.Attribute.Priority))
 *          {
 *              attrib.Append("Priority");
 *              value.Append(task.GetPriority().ToString());
 *          }
 *
 *          if (tasks.IsAttributeAvailable(Task.Attribute.Color))
 *          {
 *              attrib.Append("Color");
 *              value.Append(task.GetColor().ToString());
 *          }
 *
 *          if (tasks.IsAttributeAvailable(Task.Attribute.AllocTo))
 *          {
 *              attrib.Append("Alloc To");
 *              value.Append(task.GetAllocatedTo(0));
 *          }
 *
 *          if (tasks.IsAttributeAvailable(Task.Attribute.AllocBy))
 *          {
 *              attrib.Append("Alloc By");
 *              value.Append(task.GetAllocatedBy());
 *          }
 *
 *          if (tasks.IsAttributeAvailable(Task.Attribute.Status))
 *          {
 *              attrib.Append("Status");
 *              value.Append(task.GetStatus());
 *          }
 *
 *          if (tasks.IsAttributeAvailable(Task.Attribute.Category))
 *          {
 *              attrib.Append("Category");
 *              value.Append(task.GetCategory(0));
 *          }
 *
 *          if (tasks.IsAttributeAvailable(Task.Attribute.Percent))
 *          {
 *              attrib.Append("Percent");
 *              value.Append(task.GetPercentDone().ToString());
 *          }
 *
 *          if (tasks.IsAttributeAvailable(Task.Attribute.TimeEstimate))
 *          {
 *              attrib.Append("Time Estimate");
 *
 *              Task.TimeUnits units = Task.TimeUnits.Hours;
 *              value.Append(task.GetTimeEstimate(ref units).ToString() + units);
 *          }
 *
 *          if (tasks.IsAttributeAvailable(Task.Attribute.TimeSpent))
 *          {
 *              attrib.Append("Time Spent");
 *
 *              Task.TimeUnits units = Task.TimeUnits.Hours;
 *              value.Append(task.GetTimeSpent(ref units).ToString() + units);
 *          }
 *
 *          if (tasks.IsAttributeAvailable(Task.Attribute.FileReference))
 *          {
 *              attrib.Append("File Reference");
 *              value.Append(task.GetFileReference(0));
 *          }
 *
 *          if (tasks.IsAttributeAvailable(Task.Attribute.Comments))
 *          {
 *              attrib.Append("Comments");
 *              value.Append(task.GetComments());
 *          }
 *
 *          if (tasks.IsAttributeAvailable(Task.Attribute.Flag))
 *          {
 *              attrib.Append("Flag");
 *              value.Append(task.IsFlagged().ToString());
 *          }
 *
 *          if (tasks.IsAttributeAvailable(Task.Attribute.CreationDate))
 *          {
 *              attrib.Append("Creation Date");
 *              value.Append(task.GetCreationDateString());
 *          }
 *
 *          if (tasks.IsAttributeAvailable(Task.Attribute.CreatedBy))
 *          {
 *              attrib.Append("Created By");
 *              value.Append(task.GetCreatedBy());
 *          }
 *
 *          if (tasks.IsAttributeAvailable(Task.Attribute.Risk))
 *          {
 *              attrib.Append("Risk");
 *              value.Append(task.GetRisk().ToString());
 *          }
 *
 *          if (tasks.IsAttributeAvailable(Task.Attribute.ExternalId))
 *          {
 *              attrib.Append("External ID");
 *              value.Append(task.GetExternalID());
 *          }
 *
 *          if (tasks.IsAttributeAvailable(Task.Attribute.Cost))
 *          {
 *              attrib.Append("Cost");
 *              value.Append(task.GetCost().ToString());
 *          }
 *
 *          if (tasks.IsAttributeAvailable(Task.Attribute.Dependency))
 *          {
 *              attrib.Append("Dependency");
 *              value.Append(task.GetDependency(0));
 *          }
 *
 *          if (tasks.IsAttributeAvailable(Task.Attribute.Recurrence))
 *          {
 *              attrib.Append("Recurrence");
 *              //value.Append(task.GetRecurrence());
 *          }
 *
 *          if (tasks.IsAttributeAvailable(Task.Attribute.Version))
 *          {
 *              attrib.Append("Version");
 *              value.Append(task.GetVersion());
 *          }
 *
 *
 *          if (tasks.IsAttributeAvailable(Task.Attribute.Position))
 *          {
 *              attrib.Append("Position");
 *              value.Append(task.GetPositionString());
 *          }
 *
 *          if (tasks.IsAttributeAvailable(Task.Attribute.Id))
 *          {
 *              attrib.Append("ID");
 *              value.Append(task.GetID().ToString());
 *          }
 *
 *          if (tasks.IsAttributeAvailable(Task.Attribute.LastModified))
 *          {
 *              attrib.Append("Last Modified");
 *              //value.Append(task.GetLastModifiedString());
 *          }
 *
 *          if (tasks.IsAttributeAvailable(Task.Attribute.Icon))
 *          {
 *              attrib.Append("Icon");
 *              value.Append(task.GetIcon());
 *          }
 *
 *          if (tasks.IsAttributeAvailable(Task.Attribute.Tag))
 *          {
 *              attrib.Append("Tag");
 *              value.Append(task.GetTag(0));
 *          }
 *
 *          if (tasks.IsAttributeAvailable(Task.Attribute.CustomAttribute))
 *          {
 *              attrib.Append("Custom Attribute");
 *              //value.Append(task.GetCustomAttributeData());
 *          }
 *
 *          item.Attrib = attrib.ToString();
 *          item.Value = value.ToString();
 *          item.Tasks = task.GetID().ToString();
 *
 *          switch (type)
 *          {
 *              case UIExtension.UpdateType.Edit: item.Type = "Edit"; break;
 *              case UIExtension.UpdateType.New: item.Type = "Add Task"; break;
 *              case UIExtension.UpdateType.Delete: item.Type = "Move Task(s)"; break;
 *              case UIExtension.UpdateType.Move: item.Type = "Delete Task(s)"; break;
 *              case UIExtension.UpdateType.All: item.Type = "All"; break;
 *              case UIExtension.UpdateType.Unknown: item.Type = "Unknown"; break;
 *          }
 */
        }
        public bool UpdateTaskAttributes(Task task,
                                         UIExtension.UpdateType type,
                                         System.Collections.Generic.HashSet <UIExtension.TaskAttribute> attribs)
        {
            if (!task.IsValid())
            {
                return(false);
            }

            UInt32 taskID = task.GetID();

            if (attribs != null)
            {
                if (attribs.Contains(UIExtension.TaskAttribute.Title))
                {
                    Title = task.GetTitle();
                }

                if (attribs.Contains(UIExtension.TaskAttribute.DueDate))
                {
                    m_PrevDueDate = task.GetDueDate(false);                     // always

                    if (!IsDone)
                    {
                        EndDate = CheckGetEndOfDay(m_PrevDueDate);
                    }
                }

                if (attribs.Contains(UIExtension.TaskAttribute.DoneDate))
                {
                    bool wasDone = IsDone;
                    IsDone = (task.IsDone() || task.IsGoodAsDone());

                    if (IsDone)
                    {
                        if (!wasDone)
                        {
                            m_PrevDueDate = CheckGetEndOfDay(EndDate);
                        }

                        EndDate = CheckGetEndOfDay(task.GetDoneDate());
                    }
                    else if (wasDone && !IsDone)
                    {
                        EndDate = CheckGetEndOfDay(m_PrevDueDate);
                    }
                }

                if (attribs.Contains(UIExtension.TaskAttribute.TimeEstimate))
                {
                    Task.TimeUnits units = Task.TimeUnits.Unknown;
                    TimeEstimate = task.GetTimeEstimate(ref units, false);
                    TimeEstUnits = units;
                }

                if (attribs.Contains(UIExtension.TaskAttribute.StartDate))
                {
                    StartDate = task.GetStartDate(false);
                }

                if (attribs.Contains(UIExtension.TaskAttribute.AllocTo))
                {
                    AllocTo = String.Join(", ", task.GetAllocatedTo());
                }

                if (attribs.Contains(UIExtension.TaskAttribute.Icon))
                {
                    HasIcon = task.HasIcon();
                }

                TaskTextColor = task.GetTextDrawingColor();
                IsLocked      = task.IsLocked(true);
            }
            else
            {
                Title         = task.GetTitle();
                AllocTo       = String.Join(", ", task.GetAllocatedTo());
                HasIcon       = task.HasIcon();
                Id            = taskID;
                IsParent      = task.IsParent();
                TaskTextColor = task.GetTextDrawingColor();
                DrawBorder    = true;
                IsLocked      = task.IsLocked(true);

                Task.TimeUnits units = Task.TimeUnits.Unknown;
                TimeEstimate = task.GetTimeEstimate(ref units, false);
                TimeEstUnits = units;

                StartDate = task.GetStartDate(false);
                IsDone    = (task.IsDone() || task.IsGoodAsDone());

                m_PrevDueDate = CheckGetEndOfDay(task.GetDueDate(false));
                EndDate       = (IsDone ? CheckGetEndOfDay(task.GetDoneDate()) : m_PrevDueDate);
            }

            UpdateOriginalDates();

            return(true);
        }