Exemplo n.º 1
0
        protected override void OnMouseClick(MouseEventArgs e)
        {
            base.OnMouseClick(e);

            Hotspot spot;

            if (e.Button == MouseButtons.Right)
            {
                spot = hotspots.FirstOrDefault(h => h.Bounds.Contains(e.Location));
                if (spot?.Type == Hottype.Page)
                {
                    SnappedPage?.Invoke(this,
                                        new CalendarSnapshotEventArgs(spot.Page, spot.Bounds));
                }

                return;
            }

            spot = hotspots.FirstOrDefault(h => h.Bounds.Contains(e.Location));
            switch (spot?.Type)
            {
            case Hottype.Page:
                ClickedPage?.Invoke(this, new CalendarPageEventArgs(spot.Page));
                break;

            case Hottype.Day:
                ClickedDay?.Invoke(this, new CalendarDayEventArgs(spot.Day.Date));
                break;
            }
        }
Exemplo n.º 2
0
        /*
         * Note that MouseClick event doesn't capture right-clicks but MouseUp does.
         * Also note that if the control overrides OnMouseClick then that *will* capture both
         * left and right buttons. Windows Forms is fun!
         *
         */
        private void ListBoxMouseUp(object sender, MouseEventArgs e)
        {
            var day = listbox.Items.OfType <DayItem>()
                      .FirstOrDefault(d => d.Bounds.Contains(e.Location));

            if (day != null)
            {
                var page = day.Pages.FirstOrDefault(p => p.Bounds.Contains(e.Location));
                if (page != null)
                {
                    if (e.Button == MouseButtons.Right)
                    {
                        SnappedPage?.Invoke(this, new CalendarSnapshotEventArgs(page, page.Bounds));
                    }
                    else
                    {
                        ClickedPage?.Invoke(this, new CalendarPageEventArgs(page));
                    }
                }
            }
        }