Example #1
0
            protected override void OnMouseDown(MouseEventArgs e)
            {
                Point p          = new Point(e.X, e.Y);
                Size  cellSize   = parent.cellSize;
                Size  parentDims = parent.calendarDims;
                int   nextPage   = parentDims.Width * parentDims.Height;

                // Fix: Handle long clicks with a timer like ScrollBar does
                if (prevBtnRect.Contains(p))
                {
                    parent.SetDate(GetNewMonthView(parent.selectionStart, -nextPage));
                }
                if (nextBtnRect.Contains(p))
                {
                    parent.SetDate(GetNewMonthView(parent.selectionStart, nextPage));
                }
                if (dayRect.Contains(p))
                {
                    int count = ((p.X - dayRect.Left) / cellSize.Width +
                                 (p.Y - dayRect.Top) / cellSize.Height * 7);
                    if (posHasDate[count])
                    {
                        // Note: monthEndPos denotes the position where
                        // the next month starts
                        if (count >= monthStartPos && count < monthEndPos)
                        {
                            DateTime next = firstDateCell.AddDays(count);
                            parent.SetSelectionInternal(next, next, this.index, false);
                        }
                        else
                        {
                            // refresh all dates
                            DateTime next = firstDateCell.AddDays(count);
                            parent.SetSelectionInternal(next, next, this.index, true);
                        }
                    }
                }
            }