public void MouseDown(System.Windows.Forms.MouseEventArgs e) { if (dayView.SelectedAppointmentIsNew) { dayView.RaiseNewAppointment(); } if (dayView.CurrentlyEditing) { dayView.FinishEditing(false); } mode = GetMode(e); if (dayView.SelectedAppointment != null) { DateTime downPos = dayView.GetTimeAt(e.X, e.Y); // Calculate delta time between selection and clicked point delta = dayView.SelectedAppointment.StartDate - downPos; } else { delta = TimeSpan.Zero; } length = TimeSpan.Zero; }
public void MouseMove(System.Windows.Forms.MouseEventArgs e) { Appointment selection = dayView.SelectedAppointment; if ((selection != null) && (!selection.Locked)) { switch (e.Button) { case System.Windows.Forms.MouseButtons.Left: // Get time at mouse position DateTime m_Date = dayView.GetTimeAt(e.X, e.Y); switch (mode) { case Mode.Move: // add delta value m_Date = m_Date.Add(delta); if (length == TimeSpan.Zero) { startDate = selection.StartDate; length = selection.EndDate - startDate; } else { DateTime m_EndDate = m_Date.Add(length); if (m_EndDate.Day == m_Date.Day) { selection.StartDate = m_Date; selection.EndDate = m_EndDate; dayView.Invalidate(); dayView.RaiseAppointmentMove(new AppointmentEventArgs(selection)); } } break; case Mode.ResizeBottom: if (m_Date > selection.StartDate) { if (selection.EndDate.Day == m_Date.Day) { selection.EndDate = m_Date; dayView.Invalidate(); dayView.RaiseAppointmentMove(new AppointmentEventArgs(selection)); } } break; case Mode.ResizeTop: if (m_Date < selection.EndDate) { if (selection.StartDate.Day == m_Date.Day) { selection.StartDate = m_Date; dayView.Invalidate(); dayView.RaiseAppointmentMove(new AppointmentEventArgs(selection)); } } break; } break; default: Mode tmpNode = GetMode(e); switch (tmpNode) { case Mode.Move: dayView.Cursor = System.Windows.Forms.Cursors.Default; break; case Mode.ResizeBottom: case Mode.ResizeTop: dayView.Cursor = System.Windows.Forms.Cursors.SizeNS; break; } break; } } }
public void MouseMove(System.Windows.Forms.MouseEventArgs e) { if (e == null) { throw new ArgumentNullException("e"); } Appointment selection = dayView.SelectedAppointment; Rectangle viewrect = dayView.GetTrueRectangle(); Rectangle fdrect = dayView.GetFullDayApptsRectangle(); if (viewrect.Contains(e.Location) || fdrect.Contains(e.Location)) { if ((selection != null) && (!selection.Locked)) { switch (e.Button) { case System.Windows.Forms.MouseButtons.Left: // Get time at mouse position DateTime m_Date = dayView.GetTimeAt(e.X, e.Y); switch (mode) { case Mode.Move: // This works for regular (i.e. non full-day or multi-day appointments) if (!selection.AllDayEvent && viewrect.Contains(e.Location)) { // add delta value m_Date = m_Date.Add(delta); if (length == TimeSpan.Zero) { startDate = selection.StartDate; length = selection.EndDate - startDate; } else { DateTime m_EndDate = m_Date.Add(length); if (m_EndDate.Day == m_Date.Day) { selection.StartDate = m_Date; selection.EndDate = m_EndDate; dayView.Invalidate(); dayView.RaiseAppointmentMove(new AppointmentEventArgs(selection)); } } } else { if (fdrect.Contains(e.Location)) { m_Date = m_Date.Add(delta); int m_DateDiff = m_Date.Subtract(selection.StartDate).Days; if (m_DateDiff != 0) { if (selection.StartDate.AddDays(m_DateDiff) > dayView.StartDate) { selection.StartDate = selection.StartDate.AddDays(m_DateDiff); selection.EndDate = selection.EndDate.AddDays(m_DateDiff); dayView.Invalidate(); dayView.RaiseAppointmentMove(new AppointmentEventArgs(selection)); } } } } break; case Mode.ResizeBottom: if (m_Date > selection.StartDate) { if (selection.EndDate.Day == m_Date.Day) { selection.EndDate = m_Date; dayView.Invalidate(); dayView.RaiseAppointmentMove(new AppointmentEventArgs(selection)); } } break; case Mode.ResizeTop: if (m_Date < selection.EndDate) { if (selection.StartDate.Day == m_Date.Day) { selection.StartDate = m_Date; dayView.Invalidate(); dayView.RaiseAppointmentMove(new AppointmentEventArgs(selection)); } } break; case Mode.ResizeLeft: if (m_Date.Date < selection.EndDate.Date) { selection.StartDate = m_Date.Date; dayView.Invalidate(); dayView.RaiseAppointmentMove(new AppointmentEventArgs(selection)); } break; case Mode.ResizeRight: if (m_Date.Date >= selection.StartDate.Date) { selection.EndDate = m_Date.Date.AddDays(1); dayView.Invalidate(); dayView.RaiseAppointmentMove(new AppointmentEventArgs(selection)); } break; } break; default: Mode tmpNode = GetMode(e); switch (tmpNode) { case Mode.Move: dayView.Cursor = System.Windows.Forms.Cursors.Default; break; case Mode.ResizeBottom: case Mode.ResizeTop: if (!selection.AllDayEvent) { dayView.Cursor = System.Windows.Forms.Cursors.SizeNS; } break; case Mode.ResizeLeft: // changed by Gimlei case Mode.ResizeRight: if (selection.AllDayEvent) { DayView.Cursor = System.Windows.Forms.Cursors.SizeWE; } break; } break; } } } }