protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);
            ReminderHitInfo hitInfo = CalcHitInfo(e.Location);

            UpdateButton(hitInfo, State.Hot);
        }
        protected override void OnMouseDown(MouseEventArgs e)
        {
            base.OnMouseDown(e);
            ReminderHitInfo hitInfo = CalcHitInfo(e.Location);

            HotTrackButtonInfo = null;
            UpdateButton(hitInfo, State.Pressed);
            if (HotTrackButtonInfo != null)
            {
                ButtonClickEventArgs eventArgs = new ButtonClickEventArgs()
                {
                    Handled = false, Button = HotTrackButtonInfo.Owner
                };
                RaiseButtonClick(this, eventArgs);
                if (!eventArgs.Handled)
                {
                    if (eventArgs.Button.Kind == ButtonKind.HeaderAdd)
                    {
                        Notes.AddNote("New Note", DateTime.Now, RepeatMode.EveryDay);
                        ReminderListBox.SelectedIndex = ReminderListBox.Items.Count - 1;
                    }
                    else if (eventArgs.Button.Kind == ButtonKind.Note)
                    {
                        View = ViewKind.Edit;
                    }
                    else
                    {
                        View = ViewKind.View;
                    }
                }
            }
        }
        protected override void OnMouseUp(MouseEventArgs e)
        {
            base.OnMouseUp(e);
            ReminderHitInfo hitInfo = CalcHitInfo(e.Location);

            HotTrackButtonInfo = null;
            UpdateButton(hitInfo, State.Normal);
        }
 private void UpdateButton(ReminderHitInfo hitInfo, State state)
 {
     if (hitInfo.HitInfoType == HitInfoType.HeaderAddButton)
     {
         HeaderButton.ButtonViewInfo.ButtonState = state;
         HotTrackButtonInfo = HeaderButton.ButtonViewInfo;
     }
     else if (hitInfo.HitInfoType == HitInfoType.HeaderBackButton)
     {
         BackButton.ButtonViewInfo.ButtonState = state;
         HotTrackButtonInfo = BackButton.ButtonViewInfo;
     }
     else if (hitInfo.HitInfoType == HitInfoType.NoteButton)
     {
         ButtonViewInfo buttonViewInfo = ReminderListBox.ButtonsInfo[hitInfo.NoteIndex];
         buttonViewInfo.ButtonState = state;
         HotTrackButtonInfo         = buttonViewInfo;
     }
     else
     {
         HotTrackButtonInfo = null;
     }
 }
        public ReminderHitInfo CalcHitInfo(Point point)
        {
            point = Owner.PointToClient(point);
            ReminderHitInfo hitInfo = new ReminderHitInfo()
            {
                HitInfoType = HitInfoType.None, Point = point
            };

            if (!ReminderListBox.Bounds.Contains(point))
            {
                if (HeaderTextBounds.Contains(point))
                {
                    hitInfo = new ReminderHitInfo()
                    {
                        HitInfoType = HitInfoType.HeaderText, Point = point
                    }
                }
                ;
                if (HeaderButton.Visible && HeaderButton.ButtonViewInfo.Bounds.Contains(point))
                {
                    hitInfo = new ReminderHitInfo()
                    {
                        HitInfoType = HitInfoType.HeaderAddButton, Point = point
                    }
                }
                ;
                if (BackButton.Visible && BackButton.ButtonViewInfo.Bounds.Contains(point))
                {
                    hitInfo = new ReminderHitInfo()
                    {
                        HitInfoType = HitInfoType.HeaderBackButton, Point = point
                    }
                }
                ;
            }
            else
            {
                point.Offset(0, -ReminderListBox.Bounds.Y);
                int index = ReminderListBox.IndexFromPoint(point);
                if (index != -1)
                {
                    Rectangle itemRect = ReminderListBox.GetItemRectangle(index);
                    Point     pt       = point;
                    pt.Offset(itemRect.X, -itemRect.Y);
                    if (NoteButton.ButtonViewInfo.Bounds.Contains(pt))
                    {
                        hitInfo = new ReminderHitInfo()
                        {
                            HitInfoType = HitInfoType.NoteButton, Note = ReminderListBox.Items[index] as Note, Point = point, NoteIndex = index
                        }
                    }
                    ;
                    else
                    {
                        hitInfo = new ReminderHitInfo()
                        {
                            HitInfoType = HitInfoType.Note, Note = ReminderListBox.Items[index] as Note, Point = point, NoteIndex = index
                        }
                    };
                }
            }
            return(hitInfo);
        }
    }
}