Пример #1
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.StartDate - item.OrgStartDate).TotalSeconds != 0.0)
                {
                    item.OrgStartDate = item.StartDate;
                    notify.NotifyMod(UIExtension.TaskAttribute.OffsetTask, args.Appointment.StartDate);
                }
                break;

            case Calendar.SelectionTool.Mode.ResizeTop:
                if ((item.StartDate - item.OrgStartDate).TotalSeconds != 0.0)
                {
                    item.OrgStartDate = item.StartDate;
                    notify.NotifyMod(UIExtension.TaskAttribute.StartDate, args.Appointment.StartDate);
                }
                break;

            case Calendar.SelectionTool.Mode.ResizeBottom:
                if ((item.EndDate - item.OrgEndDate).TotalSeconds != 0.0)
                {
                    item.OrgEndDate = item.EndDate;
                    notify.NotifyMod(UIExtension.TaskAttribute.DueDate, args.Appointment.EndDate);
                }
                break;
            }
        }
Пример #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;
            }
        }