Exemplo n.º 1
0
        private bool CanResizeTask(CalendarItem taskItem, Calendar.SelectionTool.Mode mode)
        {
            switch (mode)
            {
            // Disable start date editing for tasks with dependencies that are auto-calculated
            case Calendar.SelectionTool.Mode.ResizeTop:
            case Calendar.SelectionTool.Mode.ResizeLeft:
            case Calendar.SelectionTool.Mode.Move:
                return(!taskItem.HasDependencies || !AutoCalculateDependencyDates);

            case Calendar.SelectionTool.Mode.ResizeBottom:
            case Calendar.SelectionTool.Mode.ResizeRight:
                return(true);
            }

            // catch all
            return(false);
        }
Exemplo n.º 2
0
        private void ProcessTaskAppointmentChange(CalendarItem item, Calendar.SelectionTool.Mode mode)
        {
            var notify = new UIExtension.ParentNotify(m_HwndParent);

            if (PrepareTaskNotify(item, mode, notify))
            {
                bool modifyTimeEst = WantModifyTimeEstimate(item);

                if (notify.NotifyMod())
                {
                    item.UpdateOriginalDates();

                    if (modifyTimeEst)
                    {
                        item.TimeEstimate = item.LengthAsTimeEstimate(m_WorkWeek, false);
                    }

                    return;
                }
            }

            item.RestoreOriginalDates();
            m_DayView.Invalidate();
        }
Exemplo n.º 3
0
        private bool PrepareTaskNotify(CalendarItem item, Calendar.SelectionTool.Mode mode, UIExtension.ParentNotify notify, bool includeTimeEstimate = true)
        {
            switch (mode)
            {
            case Calendar.SelectionTool.Mode.Move:
                if (item.LengthDiffersFromOriginal())
                {
                    // Start date WITHOUT TIME ESTIMATE
                    PrepareTaskNotify(item, Calendar.SelectionTool.Mode.ResizeLeft, notify, false);

                    // End date WITHOUT TIME ESTIMATE
                    PrepareTaskNotify(item, Calendar.SelectionTool.Mode.ResizeRight, notify, false);

                    if (includeTimeEstimate && WantModifyTimeEstimate(item))
                    {
                        notify.AddMod(Task.Attribute.TimeEstimate, item.LengthAsTimeEstimate(m_WorkWeek, false), item.TimeEstUnits);
                    }

                    return(true);
                }
                else if (item.StartDateDiffersFromOriginal())
                {
                    notify.AddMod(Task.Attribute.OffsetTask, item.StartDate);

                    return(true);
                }
                break;

            case Calendar.SelectionTool.Mode.ResizeLeft:
            case Calendar.SelectionTool.Mode.ResizeTop:
                if (item.StartDateDiffersFromOriginal())
                {
                    notify.AddMod(Task.Attribute.StartDate, item.StartDate);

                    if (includeTimeEstimate && WantModifyTimeEstimate(item))
                    {
                        notify.AddMod(Task.Attribute.TimeEstimate, item.LengthAsTimeEstimate(m_WorkWeek, false), item.TimeEstUnits);
                    }

                    return(true);
                }
                break;

            case Calendar.SelectionTool.Mode.ResizeRight:
            case Calendar.SelectionTool.Mode.ResizeBottom:
                if (item.EndDateDiffersFromOriginal())
                {
                    // Allow for end of day
                    var endDate = item.EndDate;

                    if (endDate == endDate.Date)
                    {
                        endDate = endDate.AddDays(-1);
                    }

                    if (item.IsDone)
                    {
                        notify.AddMod(Task.Attribute.DoneDate, endDate);
                    }
                    else
                    {
                        notify.AddMod(Task.Attribute.DueDate, endDate);
                    }

                    if (includeTimeEstimate && WantModifyTimeEstimate(item))
                    {
                        notify.AddMod(Task.Attribute.TimeEstimate, item.LengthAsTimeEstimate(m_WorkWeek, false), item.TimeEstUnits);
                    }

                    return(true);
                }
                break;
            }

            return(false);
        }