コード例 #1
0
 /// <summary>
 /// Initializes a new instance of the CacheItem class.
 /// </summary>
 /// <param name="item">The ImageListViewItem associated
 /// with this request.</param>
 public CacheItem(ImageListItem item)
 {
     mItem           = item;
     mIsVirtualItem  = item.isVirtualItem;
     mVirtualItemKey = item.mVirtualItemKey;
     mFileName       = item.FileName;
 }
コード例 #2
0
 /// <summary>
 /// Adds the item to the cache queue.
 /// </summary>
 public void Add(ImageListItem item)
 {
     lock (lockObject)
     {
         toCache.Enqueue(new CacheItem(item));
         Monitor.Pulse(lockObject);
     }
 }
コード例 #3
0
            /// <summary>
            /// Loads and returns the image for the given item.
            /// </summary>
            public Image GetImageAsync(ImageListItem item, Size size)
            {
                Image img = mImageListView.cacheManager.GetRendererImage(item.Guid, size, mImageListView.UseEmbeddedThumbnails);

                if (img == null)
                {
                    mImageListView.cacheManager.AddToRendererCache(item.Guid, item.FileName, size, mImageListView.UseEmbeddedThumbnails);
                }

                return(img);
            }
コード例 #4
0
            /// <summary>
            /// Determines whether the item is highlighted.
            /// </summary>
            public ItemHighlightState HighlightState(ImageListItem item)
            {
                bool highlighted = false;

                if (highlightedItems.TryGetValue(item, out highlighted))
                {
                    if (highlighted)
                    {
                        return(ItemHighlightState.HighlightedAndSelected);
                    }
                    else
                    {
                        return(ItemHighlightState.HighlightedAndUnSelected);
                    }
                }
                return(ItemHighlightState.NotHighlighted);
            }
コード例 #5
0
 /// <summary>
 /// Draws the large preview image of the focused item in Gallery mode.
 /// </summary>
 /// <param name="g">The System.Drawing.Graphics to draw on.</param>
 /// <param name="item">The ImageListViewItem to draw.</param>
 /// <param name="image">The image to draw.</param>
 /// <param name="bounds">The bounding rectangle of the preview area.</param>
 public virtual void DrawGalleryImage(Graphics g, ImageListItem item, Image image, Rectangle bounds)
 {
     if (item != null && image != null)
     {
         // Calculate image bounds
         Size      itemMargin = MeasureItemMargin(View.Thumbnails);
         Rectangle pos        = Utility.GetSizedImageBounds(image, new Rectangle(bounds.Location + itemMargin, bounds.Size - itemMargin - itemMargin));
         // Draw image
         g.DrawImage(image, pos);
         // Draw image border
         if (Math.Min(pos.Width, pos.Height) > 32)
         {
             using (Pen pGray128 = new Pen(Color.FromArgb(128, Color.Gray)))
             {
                 g.DrawRectangle(pGray128, pos);
             }
             using (Pen pWhite128 = new Pen(Color.FromArgb(128, Color.White)))
             {
                 g.DrawRectangle(pWhite128, Rectangle.Inflate(pos, -1, -1));
             }
         }
     }
 }
コード例 #6
0
ファイル: Events.cs プロジェクト: code-mtnit/WPFSM
 /// <summary>
 /// Initializes a new instance of the ItemEventArgs class.
 /// </summary>
 /// <param name="item">The item that is the target of this event.</param>
 /// <param name="error">Determines whether an error occurred during thumbnail extraction.</param>
 public ThumbnailCachedEventArgs(ImageListItem item, bool error)
 {
     mItem  = item;
     mError = error;
 }
コード例 #7
0
ファイル: Events.cs プロジェクト: code-mtnit/WPFSM
 /// <summary>
 /// Initializes a new instance of the ItemEventArgs class.
 /// </summary>
 /// <param name="item">The currently hovered item.</param>
 /// <param name="previousItem">The previously hovered item.</param>
 public ItemHoverEventArgs(ImageListItem item, ImageListItem previousItem)
 {
     mItem         = item;
     mPreviousItem = previousItem;
 }
コード例 #8
0
ファイル: Events.cs プロジェクト: code-mtnit/WPFSM
 /// <summary>
 /// Initializes a new instance of the ItemClickEventArgs class.
 /// </summary>
 /// <param name="item">The item that is the target of this event.</param>
 /// <param name="location">The location of the mouse.</param>
 /// <param name="buttons">One of the System.Windows.Forms.MouseButtons values
 /// indicating which mouse button was pressed.</param>
 public ItemClickEventArgs(ImageListItem item, Point location, MouseButtons buttons)
 {
     mItem     = item;
     mLocation = location;
     mButtons  = buttons;
 }
コード例 #9
0
ファイル: Events.cs プロジェクト: code-mtnit/WPFSM
 /// <summary>
 /// Initializes a new instance of the ItemEventArgs class.
 /// </summary>
 /// <param name="item">The item that is the target of this event.</param>
 public ItemEventArgs(ImageListItem item)
 {
     mItem = item;
 }
コード例 #10
0
ファイル: Events.cs プロジェクト: code-mtnit/WPFSM
 public ImageLisViewItemEventArg(ImageListItem img)
 {
     ImageListViewItem = img;
 }
コード例 #11
0
            /// <summary>
            /// Draws the specified item on the given graphics.
            /// </summary>
            /// <param name="g">The System.Drawing.Graphics to draw on.</param>
            /// <param name="item">The ImageListViewItem to draw.</param>
            /// <param name="state">The current view state of item.</param>
            /// <param name="bounds">The bounding rectangle of item in client coordinates.</param>
            public virtual void DrawItem(Graphics g, ImageListItem item, ItemState state, Rectangle bounds)
            {
                Size itemPadding = new Size(4, 4);

                // Paint background
                using (Brush bItemBack = new SolidBrush(item.BackColor))
                {
                    g.FillRectangle(bItemBack, bounds);
                }
                //if ((mImageListView.Focused && ((state & ItemState.Selected) != ItemState.None)) ||
                //    (!mImageListView.Focused && ((state & ItemState.Selected) != ItemState.None) && ((state & ItemState.Hovered) != ItemState.None)))
                //{
                //    using (Brush bSelected = new LinearGradientBrush(bounds, Color.FromArgb(16, SystemColors.Highlight), Color.FromArgb(64, SystemColors.Highlight), LinearGradientMode.Vertical))
                //    {
                //        Utility.FillRoundedRectangle(g, bSelected, bounds, ( 4));
                //    }
                //}
                //else if (!mImageListView.Focused && ((state & ItemState.Selected) != ItemState.None))
                //{
                //    using (Brush bGray64 = new LinearGradientBrush(bounds, Color.FromArgb(16, SystemColors.GrayText), Color.FromArgb(64, SystemColors.GrayText), LinearGradientMode.Vertical))
                //    {
                //        Utility.FillRoundedRectangle(g, bGray64, bounds, ( 4));
                //    }
                //}
                //if ((state & ItemState.Hovered) != ItemState.None)
                //{
                //    using (Brush bHovered = new LinearGradientBrush(bounds, Color.FromArgb(8, SystemColors.Highlight), Color.FromArgb(32, SystemColors.Highlight), LinearGradientMode.Vertical))
                //    {
                //        Utility.FillRoundedRectangle(g, bHovered, bounds, ( 4));
                //    }
                //}

                //  if (mImageListView.View != View.Details)
                {
                    // Draw the image
                    Image img = item.ThumbnailImage;
                    if (img != null)
                    {
                        Rectangle pos = Utility.GetSizedImageBounds(img, new Rectangle(bounds.Location + itemPadding, mImageListView.ThumbnailSize));
                        g.DrawImage(img, pos);
                        // Draw image border
                        if (Math.Min(pos.Width, pos.Height) > 32)
                        {
                            using (Pen pGray128 = new Pen(Color.FromArgb(128, Color.Gray)))
                            {
                                g.DrawRectangle(pGray128, pos);
                            }
                            if (System.Math.Min(mImageListView.ThumbnailSize.Width, mImageListView.ThumbnailSize.Height) > 32)
                            {
                                using (Pen pWhite128 = new Pen(Color.FromArgb(128, Color.White)))
                                {
                                    g.DrawRectangle(pWhite128, Rectangle.Inflate(pos, -1, -1));
                                }
                            }
                        }
                    }

                    // Draw item text
                    SizeF      szt = TextRenderer.MeasureText(item.Text, mImageListView.Font);
                    RectangleF rt;
                    using (StringFormat sf = new StringFormat())
                    {
                        rt               = new RectangleF(bounds.Left + itemPadding.Width, bounds.Top + 2 * itemPadding.Height + mImageListView.ThumbnailSize.Height, mImageListView.ThumbnailSize.Width, szt.Height);
                        sf.Alignment     = StringAlignment.Center;
                        sf.FormatFlags   = StringFormatFlags.NoWrap;
                        sf.LineAlignment = StringAlignment.Center;
                        sf.Trimming      = StringTrimming.EllipsisCharacter;
                        using (Brush bItemFore = new SolidBrush(item.ForeColor))
                        {
                            g.DrawString(item.Text, mImageListView.Font, bItemFore, rt, sf);
                        }
                    }
                }


                // Item border
                using (Pen pWhite128 = new Pen(Color.FromArgb(128, Color.White)))
                {
                    Utility.DrawRoundedRectangle(g, pWhite128, bounds.Left + 1, bounds.Top + 1, bounds.Width - 3, bounds.Height - 3, (4));
                }
                //if (mImageListView.Focused && ((state & ItemState.Selected) != ItemState.None))
                //{
                //    using (Pen pHighlight128 = new Pen(Color.FromArgb(128, SystemColors.Highlight)))
                //    {
                //        Utility.DrawRoundedRectangle(g, pHighlight128, bounds.Left, bounds.Top, bounds.Width - 1, bounds.Height - 1, ( 4));
                //    }
                //}
                //else if (!mImageListView.Focused && ((state & ItemState.Selected) != ItemState.None))
                //{
                //    using (Pen pGray128 = new Pen(Color.FromArgb(128, SystemColors.GrayText)))
                //    {
                //        Utility.DrawRoundedRectangle(g, pGray128, bounds.Left, bounds.Top, bounds.Width - 1, bounds.Height - 1, ( 4));
                //    }
                //}
                //else if ( (state & ItemState.Selected) == ItemState.None)
                //{
                //    using (Pen pGray64 = new Pen(Color.FromArgb(64, SystemColors.GrayText)))
                //    {
                //        Utility.DrawRoundedRectangle(g, pGray64, bounds.Left, bounds.Top, bounds.Width - 1, bounds.Height - 1, ( 4));
                //    }
                //}

                //if (mImageListView.Focused && ((state & ItemState.Hovered) != ItemState.None))
                //{
                //    using (Pen pHighlight64 = new Pen(Color.FromArgb(64, SystemColors.Highlight)))
                //    {
                //        Utility.DrawRoundedRectangle(g, pHighlight64, bounds.Left, bounds.Top, bounds.Width - 1, bounds.Height - 1, ( 4));
                //    }
                //}

                //// Focus rectangle
                //if (mImageListView.Focused && ((state & ItemState.Focused) != ItemState.None))
                //{
                //    ControlPaint.DrawFocusRectangle(g, bounds);
                //}
            }
コード例 #12
0
            /// <summary>
            /// Renders the control.
            /// </summary>
            private void Render(Graphics graphics)
            {
                if (disposed)
                {
                    return;
                }

                if (bufferGraphics == null)
                {
                    if (!RecreateBuffer())
                    {
                        return;
                    }
                }

                // Update the layout
                mImageListView.layoutManager.Update();

                // Set drawing area
                Graphics g = bufferGraphics.Graphics;

                g.ResetClip();

                // Draw background
                g.SetClip(mImageListView.layoutManager.ClientArea);
                DrawBackground(g, mImageListView.layoutManager.ClientArea);



                // Draw items
                // Draw items
                if (mImageListView.Items.Count > 0 &&
                    mImageListView.layoutManager.FirstPartiallyVisible != -1 &&
                    mImageListView.layoutManager.LastPartiallyVisible != -1)
                {
                    List <DrawItemParams> drawItemParams = new List <DrawItemParams>();
                    for (int i = mImageListView.layoutManager.FirstPartiallyVisible; i <= mImageListView.layoutManager.LastPartiallyVisible; i++)
                    {
                        ImageListItem item = mImageListView.Items[i];

                        // Determine item state
                        ItemState          state          = ItemState.None;
                        ItemHighlightState highlightState = mImageListView.navigationManager.HighlightState(item);
                        if (highlightState == ItemHighlightState.HighlightedAndSelected ||
                            (highlightState == ItemHighlightState.NotHighlighted && item.Selected))
                        {
                            state |= ItemState.Selected;
                        }

                        if (ReferenceEquals(mImageListView.navigationManager.HoveredItem, item) &&
                            mImageListView.navigationManager.MouseSelecting == false)
                        {
                            state |= ItemState.Hovered;
                        }

                        if (item.Focused)
                        {
                            state |= ItemState.Focused;
                        }

                        // Get item bounds
                        Rectangle bounds = mImageListView.layoutManager.GetItemBounds(i);

                        // Add to params to be sorted and drawn
                        drawItemParams.Add(new DrawItemParams(item, state, bounds));
                    }

                    // Sort items by draw order
                    drawItemParams.Sort(new ItemDrawOrderComparer(mItemDrawOrder));

                    // Draw items
                    foreach (DrawItemParams param in drawItemParams)
                    {
                        if (mClip)
                        {
                            Rectangle clip = Rectangle.Intersect(param.Bounds, mImageListView.layoutManager.ItemAreaBounds);
                            g.SetClip(clip);
                        }
                        else
                        {
                            g.SetClip(mImageListView.layoutManager.ClientArea);
                        }
                        DrawItem(g, param.Item, param.State, param.Bounds);
                    }
                }



                // Draw the overlay image
                g.SetClip(mImageListView.layoutManager.ClientArea);
                DrawOverlay(g, mImageListView.layoutManager.ClientArea);

                // Draw the selection rectangle
                if (mImageListView.navigationManager.MouseSelecting)
                {
                    Rectangle sel = mImageListView.navigationManager.SelectionRectangle;
                    if (sel.Height > 0 && sel.Width > 0)
                    {
                        if (mClip)
                        {
                            Rectangle selclip = new Rectangle(sel.Left, sel.Top, sel.Width + 1, sel.Height + 1);
                            g.SetClip(selclip);
                        }
                        else
                        {
                            g.SetClip(mImageListView.layoutManager.ClientArea);
                        }
                        g.ExcludeClip(mImageListView.layoutManager.ColumnHeaderBounds);
                        DrawSelectionRectangle(g, sel);
                    }
                }

                // Draw the insertion caret
                if (mImageListView.navigationManager.DropTarget != null)
                {
                    Rectangle bounds = mImageListView.layoutManager.GetItemBounds(mImageListView.navigationManager.DropTarget.Index);

                    {
                        if (mImageListView.navigationManager.DropToRight)
                        {
                            bounds.Offset(mImageListView.layoutManager.ItemSizeWithMargin.Width, 0);
                        }
                        Size itemMargin = MeasureItemMargin(View.Thumbnails);
                        bounds.Offset(-(itemMargin.Width - 2) / 2 - 2, 0);
                        bounds.Width = 2;
                    }
                    if (mClip)
                    {
                        g.SetClip(bounds);
                    }
                    else
                    {
                        g.SetClip(mImageListView.layoutManager.ClientArea);
                    }
                    DrawInsertionCaret(g, bounds);
                }

                // Scrollbar filler
                if (mImageListView.hScrollBar.Visible && mImageListView.vScrollBar.Visible)
                {
                    Rectangle bounds = mImageListView.layoutManager.ClientArea;
                    Rectangle filler = new Rectangle(bounds.Right, bounds.Bottom, mImageListView.vScrollBar.Width, mImageListView.hScrollBar.Height);
                    g.SetClip(filler);
                    g.FillRectangle(SystemBrushes.Control, filler);
                }

                // Draw on to the control
                bufferGraphics.Render(graphics);
            }
コード例 #13
0
 public DrawItemParams(ImageListItem item, ItemState state, Rectangle bounds)
 {
     Item   = item;
     State  = state;
     Bounds = bounds;
 }
コード例 #14
0
            /// <summary>
            /// Handles control's DragOver event.
            /// </summary>
            public void DragOver(DragEventArgs e)
            {
                if (mImageListView.AllowDrop || (mImageListView.AllowDrag && selfDragging))
                {
                    if (mImageListView.Items.Count == 0)
                    {
                        if (selfDragging)
                        {
                            e.Effect = DragDropEffects.None;
                        }
                        else
                        {
                            e.Effect = DragDropEffects.Copy;
                        }
                    }
                    else
                    {
                        // Calculate the location of the insertion cursor
                        Point pt = new Point(e.X, e.Y);
                        pt = mImageListView.PointToClient(pt);

                        // Do we need to scroll the view?
                        if (mImageListView.ScrollOrientation == ScrollOrientation.VerticalScroll &&
                            pt.Y > mImageListView.ClientRectangle.Bottom - 20)
                        {
                            scrollTimer.Tag     = -120;
                            scrollTimer.Enabled = true;
                        }
                        else if (mImageListView.ScrollOrientation == ScrollOrientation.VerticalScroll &&
                                 pt.Y < mImageListView.ClientRectangle.Top + 20)
                        {
                            scrollTimer.Tag     = 120;
                            scrollTimer.Enabled = true;
                        }
                        else if (mImageListView.ScrollOrientation == ScrollOrientation.HorizontalScroll &&
                                 pt.X > mImageListView.ClientRectangle.Right - 20)
                        {
                            scrollTimer.Tag     = -120;
                            scrollTimer.Enabled = true;
                        }
                        else if (mImageListView.ScrollOrientation == ScrollOrientation.HorizontalScroll &&
                                 pt.X < mImageListView.ClientRectangle.Left + 20)
                        {
                            scrollTimer.Tag     = 120;
                            scrollTimer.Enabled = true;
                        }
                        else
                        {
                            scrollTimer.Enabled = false;
                        }

                        // Normalize to item area coordinates
                        pt.X -= mImageListView.layoutManager.ItemAreaBounds.Left;
                        pt.Y -= mImageListView.layoutManager.ItemAreaBounds.Top;

                        // Row and column mouse is over
                        bool dragCaretOnRight = false;
                        int  index            = 0;

                        if (mImageListView.ScrollOrientation == ScrollOrientation.HorizontalScroll)
                        {
                            index = (pt.X + mImageListView.ViewOffset.X) / mImageListView.layoutManager.ItemSizeWithMargin.Width;
                        }
                        else
                        {
                            int col = pt.X / mImageListView.layoutManager.ItemSizeWithMargin.Width;
                            int row = (pt.Y + mImageListView.ViewOffset.Y) / mImageListView.layoutManager.ItemSizeWithMargin.Height;
                            if (col > mImageListView.layoutManager.Cols - 1)
                            {
                                col = mImageListView.layoutManager.Cols - 1;
                                dragCaretOnRight = true;
                            }
                            index = row * mImageListView.layoutManager.Cols + col;
                        }

                        if (index < 0)
                        {
                            index = 0;
                        }
                        if (index > mImageListView.Items.Count - 1)
                        {
                            index            = mImageListView.Items.Count - 1;
                            dragCaretOnRight = true;
                        }

                        ImageListItem dragDropTarget = mImageListView.Items[index];

                        if (selfDragging && (dragDropTarget.Selected ||
                                             (!dragCaretOnRight && index > 0 && mImageListView.Items[index - 1].Selected) ||
                                             (dragCaretOnRight && index < mImageListView.Items.Count - 1 && mImageListView.Items[index + 1].Selected)))
                        {
                            e.Effect = DragDropEffects.None;

                            dragDropTarget = null;
                        }
                        else if (selfDragging)
                        {
                            e.Effect = DragDropEffects.Copy;
                        }
                        else
                        {
                            e.Effect = DragDropEffects.Copy;
                        }

                        if (!ReferenceEquals(dragDropTarget, DropTarget) || dragCaretOnRight != DropToRight)
                        {
                            DropTarget  = dragDropTarget;
                            DropToRight = dragCaretOnRight;
                            mImageListView.Refresh(true);
                        }
                    }
                }
                else
                {
                    e.Effect = DragDropEffects.None;
                }
            }
コード例 #15
0
            /// <summary>
            /// Handles control's MouseMove event.
            /// </summary>
            public void MouseMove(MouseEventArgs e)
            {
                ImageListItem oldHoveredItem = HoveredItem;

                // ImageListView.ImageListViewColumnHeader oldHoveredColumn = HoveredColumn;
                // ImageListView.ImageListViewColumnHeader oldHoveredSeparator = HoveredSeparator;

                DoHitTest(e.Location);

                mImageListView.mRenderer.SuspendPaint();

                // Do we need to scroll the view?
                if (MouseSelecting && mImageListView.ScrollOrientation == ScrollOrientation.VerticalScroll && !scrollTimer.Enabled)
                {
                    if (e.Y > mImageListView.ClientRectangle.Bottom)
                    {
                        scrollTimer.Tag     = -120;
                        scrollTimer.Enabled = true;
                    }
                    else if (e.Y < mImageListView.ClientRectangle.Top)
                    {
                        scrollTimer.Tag     = 120;
                        scrollTimer.Enabled = true;
                    }
                }
                else if (MouseSelecting && mImageListView.ScrollOrientation == ScrollOrientation.HorizontalScroll && !scrollTimer.Enabled)
                {
                    if (e.X > mImageListView.ClientRectangle.Right)
                    {
                        scrollTimer.Tag     = -120;
                        scrollTimer.Enabled = true;
                    }
                    else if (e.X < mImageListView.ClientRectangle.Left)
                    {
                        scrollTimer.Tag     = 120;
                        scrollTimer.Enabled = true;
                    }
                }
                else if (scrollTimer.Enabled && mImageListView.ClientRectangle.Contains(e.Location))
                {
                    scrollTimer.Enabled = false;
                }

                if (DraggingSeperator)
                {
                    //int delta = e.Location.X - lastSeparatorDragLocation.X;
                    //int colwidth = SelectedSeperator.Width + delta;
                    //if (colwidth > 16)
                    //    lastSeparatorDragLocation = e.Location;
                    //else
                    //{
                    //    lastSeparatorDragLocation = new Point(e.Location.X - colwidth + 16, e.Location.Y);
                    //    colwidth = 16;
                    //}
                    //SelectedSeperator.Width = colwidth;

                    //HoveredItem = null;
                    //HoveredColumn = SelectedSeperator;
                    //HoveredSeparator = SelectedSeperator;
                    mImageListView.Refresh();
                }
                else if (ResizingPane)
                {
                    int delta = e.Location.X - lastPaneResizeLocation.X;
                    int width = mImageListView.mPaneWidth + delta;
                    if (width > 2)
                    {
                        lastPaneResizeLocation = e.Location;
                    }
                    else
                    {
                        lastPaneResizeLocation = new Point(e.Location.X - width + 2, e.Location.Y);
                        width = 2;
                    }
                    mImageListView.mPaneWidth = width;

                    HoveredItem = null;
                    //HoveredColumn = null;
                    //HoveredSeparator = null;
                    mImageListView.Refresh();
                }
                else if (MouseSelecting)
                {
                    //if (!ShiftKey && !ControlKey)
                    //    mImageListView.SelectedItems.Clear(false);

                    // Create the selection rectangle
                    Point viewOffset = mImageListView.ViewOffset;
                    Point pt1        = new Point(lastMouseDownLocation.X - (viewOffset.X - lastViewOffset.X),
                                                 lastMouseDownLocation.Y - (viewOffset.Y - lastViewOffset.Y));
                    Point pt2 = new Point(e.Location.X, e.Location.Y);
                    SelectionRectangle = new Rectangle(Math.Min(pt1.X, pt2.X), Math.Min(pt1.Y, pt2.Y), Math.Abs(pt1.X - pt2.X), Math.Abs(pt1.Y - pt2.Y));

                    // Normalize to item area coordinates
                    pt1 = new Point(SelectionRectangle.Left, SelectionRectangle.Top);
                    pt2 = new Point(SelectionRectangle.Right, SelectionRectangle.Bottom);
                    Point itemAreaOffset = new Point(-mImageListView.layoutManager.ItemAreaBounds.Left,
                                                     -mImageListView.layoutManager.ItemAreaBounds.Top);
                    pt1.Offset(itemAreaOffset);
                    pt2.Offset(itemAreaOffset);

                    // Determine which items are highlighted
                    highlightedItems.Clear();
                    int startRow = (int)Math.Floor((float)(Math.Min(pt1.Y, pt2.Y) + viewOffset.Y) /
                                                   (float)mImageListView.layoutManager.ItemSizeWithMargin.Height);
                    int endRow = (int)Math.Floor((float)(Math.Max(pt1.Y, pt2.Y) + viewOffset.Y) /
                                                 (float)mImageListView.layoutManager.ItemSizeWithMargin.Height);
                    int startCol = (int)Math.Floor((float)(Math.Min(pt1.X, pt2.X) + viewOffset.X) /
                                                   (float)mImageListView.layoutManager.ItemSizeWithMargin.Width);
                    int endCol = (int)Math.Floor((float)(Math.Max(pt1.X, pt2.X) + viewOffset.X) /
                                                 (float)mImageListView.layoutManager.ItemSizeWithMargin.Width);
                    if (mImageListView.ScrollOrientation == ScrollOrientation.HorizontalScroll &&
                        (startRow >= 0 || endRow >= 0))
                    {
                        for (int i = startCol; i <= endCol; i++)
                        {
                            for (int col = startCol; col <= endCol; col++)
                            {
                                if (i >= 0 && i <= mImageListView.Items.Count - 1 &&
                                    !highlightedItems.ContainsKey(mImageListView.Items[i]))
                                {
                                    highlightedItems.Add(mImageListView.Items[i],
                                                         (ControlKey ? !mImageListView.Items[i].Selected : true));
                                }
                            }
                        }
                    }
                    else if (mImageListView.ScrollOrientation == ScrollOrientation.VerticalScroll &&
                             (startCol >= 0 || endCol >= 0) && (startRow >= 0 || endRow >= 0) &&
                             (startCol <= mImageListView.layoutManager.Cols - 1 || endCol <= mImageListView.layoutManager.Cols - 1))
                    {
                        startCol = Math.Min(mImageListView.layoutManager.Cols - 1, Math.Max(0, startCol));
                        endCol   = Math.Min(mImageListView.layoutManager.Cols - 1, Math.Max(0, endCol));
                        for (int row = startRow; row <= endRow; row++)
                        {
                            for (int col = startCol; col <= endCol; col++)
                            {
                                int i = row * mImageListView.layoutManager.Cols + col;
                                if (i >= 0 && i <= mImageListView.Items.Count - 1 &&
                                    !highlightedItems.ContainsKey(mImageListView.Items[i]))
                                {
                                    highlightedItems.Add(mImageListView.Items[i],
                                                         (ControlKey ? !mImageListView.Items[i].Selected : true));
                                }
                            }
                        }
                    }

                    //HoveredColumn = null;
                    //HoveredSeparator = null;
                    //SelectedSeperator = null;

                    mImageListView.Refresh();
                }
                else if (!MouseSelecting && !DraggingSeperator && !ResizingPane &&
                         inItemArea && lastMouseDownInItemArea &&
                         (LeftButton || RightButton) &&
                         ((Math.Abs(e.Location.X - lastMouseDownLocation.X) > SelectionTolerance ||
                           Math.Abs(e.Location.Y - lastMouseDownLocation.Y) > SelectionTolerance)))
                {
                    if (!lastMouseDownOverItem && HoveredItem == null)
                    {
                        // Start mouse selection
                        MouseSelecting     = true;
                        SelectionRectangle = new Rectangle(lastMouseDownLocation, new Size(0, 0));
                        mImageListView.Refresh();
                    }
                    else if (lastMouseDownOverItem && HoveredItem != null && mImageListView.AllowDrag)
                    {
                        // Start drag&drop
                        if (!HoveredItem.Selected)
                        {
                            HoveredItem.mSelected = true;
                            mImageListView.OnSelectionChangedInternal();
                            DropTarget = null;
                            mImageListView.Refresh(true);
                        }

                        // Set drag data
                        List <string> filenames = new List <string>();

                        DataObject data = new DataObject(DataFormats.FileDrop, filenames.ToArray());
                        DropTarget   = null;
                        selfDragging = true;
                        mImageListView.DoDragDrop(data, DragDropEffects.Copy);
                        selfDragging = false;

                        // Since the MouseUp event will be eaten by DoDragDrop we will not receive
                        // the MouseUp event. We need to manually update mouse button flags after
                        // the drop.
                        if ((Control.MouseButtons & MouseButtons.Left) == MouseButtons.None)
                        {
                            LeftButton = false;
                        }
                        if ((Control.MouseButtons & MouseButtons.Right) == MouseButtons.None)
                        {
                            RightButton = false;
                        }
                    }
                }
                else if (!MouseSelecting && !DraggingSeperator && !ResizingPane &&
                         inHeaderArea && lastMouseDownInColumnHeaderArea && lastMouseDownOverSeparator && LeftButton)// &&
                // mImageListView.AllowColumnResize && HoveredSeparator != null)
                {
                    // Start dragging a separator
                    DraggingSeperator = true;
                    // SelectedSeperator = HoveredSeparator;
                    lastSeparatorDragLocation = e.Location;
                }
                else if (!MouseSelecting && !DraggingSeperator && !ResizingPane &&
                         inPaneArea && lastMouseDownInPaneArea && lastMouseDownOverPaneBorder && LeftButton &&
                         mImageListView.AllowPaneResize && HoveredPaneBorder != false)
                {
                    // Start dragging the pane
                    ResizingPane           = true;
                    lastPaneResizeLocation = e.Location;
                }
                else if (!ReferenceEquals(HoveredItem, oldHoveredItem))// ||
                //!ReferenceEquals(HoveredColumn, oldHoveredColumn) ||
                //!ReferenceEquals(HoveredSeparator, oldHoveredSeparator))
                {
                    // Hovered item changed
                    if (!ReferenceEquals(HoveredItem, oldHoveredItem))
                    {
                        mImageListView.OnItemHover(new ItemHoverEventArgs(HoveredItem, oldHoveredItem));
                    }

                    //if (!ReferenceEquals(HoveredColumn, oldHoveredColumn))
                    //    mImageListView.OnColumnHover(new ColumnHoverEventArgs(HoveredColumn, oldHoveredColumn));

                    mImageListView.Refresh();
                }

                mImageListView.mRenderer.ResumePaint();

                // Change to size cursor if mouse is over a column separator or pane border
                if (mImageListView.Cursor != Cursors.VSplit && mImageListView.Focused && !MouseSelecting)
                {
                    //if ((mImageListView.AllowColumnResize && HoveredSeparator != null) ||
                    //    (mImageListView.AllowPaneResize && HoveredPaneBorder != false))
                    //    mImageListView.Cursor = Cursors.VSplit;
                }
                else if (mImageListView.Cursor == Cursors.VSplit)
                {
                    //if (!((inHeaderArea && (DraggingSeperator || HoveredSeparator != null)) ||
                    //    (inPaneArea && (ResizingPane || HoveredPaneBorder != false))))
                    //    mImageListView.Cursor = Cursors.Default;
                }

                lastMouseMoveLocation = e.Location;
            }