Exemple #1
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);
        }
Exemple #2
0
        private void OnDayViewAppointmentChanged(object sender, Calendar.AppointmentEventArgs args)
        {
            Calendar.MoveAppointmentEventArgs move = args as Calendar.MoveAppointmentEventArgs;

            // Ignore moves whilst they are occurring
            if ((move == null) || !move.Finished)
            {
                return;
            }

            CalendarItem item = args.Appointment as CalendarItem;

            if (item == null)
            {
                return;
            }

            UIExtension.ParentNotify notify = new UIExtension.ParentNotify(m_HwndParent);

            switch (move.Mode)
            {
            case Calendar.SelectionTool.Mode.Move:
                if (item.StartDateDiffersFromOriginal())
                {
                    if (notify.NotifyMod(UIExtension.TaskAttribute.OffsetTask, item.StartDate))
                    {
                        item.UpdateOriginalDates();
                    }
                    else
                    {
                        item.RestoreOriginalDates();
                        m_DayView.Invalidate();
                    }
                }
                break;

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

                    // Update the Time estimate if it is zero or
                    // it used to match the previous date range
                    bool modifyTimeEst = WantModifyTimeEstimate(item);

                    if (modifyTimeEst)
                    {
                        notify.AddMod(UIExtension.TaskAttribute.TimeEstimate, item.LengthAsTimeEstimate(false), item.TimeEstUnits);
                    }

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

                        if (modifyTimeEst)
                        {
                            item.TimeEstimate = item.LengthAsTimeEstimate(false);
                        }
                    }
                    else
                    {
                        item.RestoreOriginalDates();
                        m_DayView.Invalidate();
                    }
                }
                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(UIExtension.TaskAttribute.DoneDate, endDate);
                    }
                    else
                    {
                        notify.AddMod(UIExtension.TaskAttribute.DueDate, endDate);
                    }

                    // Update the Time estimate if used to match the previous date range
                    bool modifyTimeEst = WantModifyTimeEstimate(item);

                    if (modifyTimeEst)
                    {
                        notify.AddMod(UIExtension.TaskAttribute.TimeEstimate, item.LengthAsTimeEstimate(false), item.TimeEstUnits);
                    }

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

                        if (modifyTimeEst)
                        {
                            item.TimeEstimate = item.LengthAsTimeEstimate(false);
                        }
                    }
                    else
                    {
                        item.RestoreOriginalDates();
                        m_DayView.Invalidate();
                    }
                }
                break;
            }
        }