private void ListBoxMouseMove(object sender, MouseEventArgs e) { var day = listbox.Items.OfType <DayItem>() .FirstOrDefault(d => d.Bounds.Contains(e.Location)); CalendarPage page = null; if (day != null) { page = day.Pages.FirstOrDefault(p => p.Bounds.Contains(e.Location)); } if (page == hotpage) { if (hotpage != null) { Native.SetCursor(hand); } return; } if (hotpage != null) { using (var g = listbox.CreateGraphics()) { var index = listbox.Items.IndexOf(hotday); g.FillRectangle(index % 2 == 1 ? AppColors.RowBrush : Brushes.White, hotpage.Bounds); g.DrawString(hotpage.Title, hotpage.IsDeleted ? deletedFont : listbox.Font, hotpage.IsDeleted ? Brushes.Gray : Brushes.Black, hotpage.Bounds, format); } HoverPage?.Invoke(this, new CalendarPageEventArgs(null)); hotday = null; hotpage = null; } if (page != null) { using (var g = listbox.CreateGraphics()) { var index = listbox.Items.IndexOf(day); g.FillRectangle(index % 2 == 1 ? AppColors.RowBrush : Brushes.White, page.Bounds); g.DrawString(page.Title, page.IsDeleted ? deletedFont : hotFont, Brushes.DarkOrchid, page.Bounds, format); } HoverPage?.Invoke(this, new CalendarPageEventArgs(page)); hotday = day; hotpage = page; Native.SetCursor(hand); } }
protected override void OnMouseMove(MouseEventArgs e) { //base.OnMouseMove(e); var spot = hotspots.FirstOrDefault(h => h.Bounds.Contains(e.Location)); // moving within same spot? if (spot == hotspot) { if (hotspot != null) { Native.SetCursor(hand); } return; } var width = Width / 7 - 8; // clear previously active... if (hotspot != null) { if (hotspot.Type == Hottype.Page) { using (var g = CreateGraphics()) { g.FillRectangle( hotspot.Page.Modified.Month == date.Month ? Brushes.White : Brushes.WhiteSmoke, hotspot.Bounds); if (hotspot.Page.IsDeleted) { g.DrawString(hotspot.Page.Title, deletedFont, Brushes.Gray, new Rectangle(hotspot.Bounds.X, hotspot.Bounds.Y, width, hotspot.Bounds.Height), format); } else { var brush = hotspot.InMonth ? Brushes.Black : Brushes.Gray; g.DrawString(hotspot.Page.Title, Font, brush, hotspot.Bounds, format); } } HoverPage?.Invoke(this, new CalendarPageEventArgs(null)); } hotspot = null; Native.SetCursor(Cursors.Default.Handle); } // highlight hovered... if (spot != null) { if (spot.Type == Hottype.Page) { using (var g = CreateGraphics()) { var brush = spot.InMonth ? Brushes.White : Brushes.WhiteSmoke; g.FillRectangle(brush, spot.Bounds); g.DrawString(spot.Page.Title, spot.Page.IsDeleted ? deletedFont : hotFont, Brushes.DarkOrchid, new Rectangle(spot.Bounds.X, spot.Bounds.Y, width, spot.Bounds.Height), format); } HoverPage?.Invoke(this, new CalendarPageEventArgs(spot.Page)); } hotspot = spot; Native.SetCursor(hand); } }