private void SelectItem(ThumbnailControlItem item, bool toggle, HashSet <ThumbnailControlItem> selected)
 {
     if (toggle)
     {
         if (selected.Contains(item))
         {
             m_selection.Remove(item);
         }
         else
         {
             m_selection.Add(item);
         }
     }
     else if (!selected.Contains(item))
     {
         m_selection.Add(item);
     }
 }
        /// <summary>
        /// Raises the MouseMove event</summary>
        /// <param name="e">Event args</param>
        protected override void OnMouseMove(MouseEventArgs e)
        {
            if (e.Button == MouseButtons.None)
            {
                ThumbnailControlItem thumbnail = PickThumbnail(new Point(e.X, e.Y));
                if (thumbnail != m_hoverThumbnail)
                {
                    m_hoverThumbnail = thumbnail;
                    m_hoverTimer.Start();
                }
            }

            if (m_multiSelecting)
            {
                m_mousePt = e.Location;
                Invalidate();
            }

            base.OnMouseMove(e);
        }
        /// <summary>
        /// Raises the MouseUp event</summary>
        /// <param name="e">Event args</param>
        protected override void OnMouseUp(MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                // extend/toggle selection?
                bool extend = (ModifierKeys & Keys.Shift) != 0;
                bool toggle = (ModifierKeys & Keys.Control) != 0;
                if (!extend && !toggle)
                {
                    m_selection.Clear();
                }

                HashSet <ThumbnailControlItem> selected = new HashSet <ThumbnailControlItem>(m_selection);
                if (m_multiSelecting)
                {
                    m_multiSelecting = false;

                    IEnumerable <ThumbnailControlItem> picked = Pick(GetSelectionRect());
                    foreach (ThumbnailControlItem item in picked)
                    {
                        SelectItem(item, toggle, selected);
                    }
                }
                else
                {
                    ThumbnailControlItem item = PickThumbnail(e.Location);
                    if (item != null)
                    {
                        SelectItem(item, toggle, selected);
                    }
                }

                OnSelectionChanged(EventArgs.Empty);
                Invalidate();
            }

            base.OnMouseUp(e);

            EndHover();
        }