protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); ICalendarSelectableElement hitted = HitTest(e.Location); CalendarItem hittedItem = hitted as CalendarItem; bool shiftPressed = (ModifierKeys & Keys.Shift) == Keys.Shift; if (!Focused) { Focus(); } switch (State) { case CalendarState.Idle: if (hittedItem != null) { if (!shiftPressed) ClearSelectedItems(); hittedItem.SetSelected(true); Invalidate(hittedItem); OnItemSelected(new CalendarItemEventArgs(hittedItem)); itemOnState = hittedItem; itemOnStateChanged = false; if (AllowItemEdit) { if (itemOnState.ResizeStartDateZone(e.Location) && AllowItemResize) { SetState(CalendarState.ResizingItem); itemOnState.SetIsResizingStartDate(true); } else if (itemOnState.ResizeEndDateZone(e.Location) && AllowItemResize) { SetState(CalendarState.ResizingItem); itemOnState.SetIsResizingEndDate(true); } else { SetState(CalendarState.DraggingItem); } } SetSelectionRange(null, null); } else { ClearSelectedItems(); if (shiftPressed) { if (hitted != null && SelectedElementEnd == null && !SelectedElementEnd.Equals(hitted)) SelectedElementEnd = hitted; } else { if (SelectedElementStart == null || (hitted != null && !SelectedElementStart.Equals(hitted))) { SetSelectionRange(hitted, hitted); } } SetState(CalendarState.DraggingTimeSelection); } break; case CalendarState.DraggingTimeSelection: break; case CalendarState.DraggingItem: break; case CalendarState.ResizingItem: break; case CalendarState.EditingItemText: break; } }