Esempio n. 1
0
        /// <summary>
        /// Given the item and the subitem, calculate its bounds.
        /// </summary>
        /// <param name="item"></param>
        /// <param name="subItem"></param>
        /// <returns></returns>
        public virtual Rectangle CalculateItemBounds(OLVListItem item, OLVListSubItem subItem)
        {
            if (item == null)
            {
                return(Rectangle.Empty);
            }

            if (subItem == null)
            {
                return(item.Bounds);
            }

            return(item.GetSubItemBounds(item.SubItems.IndexOf(subItem)));
        }
Esempio n. 2
0
        /// <summary>
        /// Return bounds of the given subitem
        /// </summary>
        /// <remarks>This correctly calculates the bounds even for column 0.</remarks>
        public virtual Rectangle GetSubItemBounds(int subItemIndex)
        {
            if (subItemIndex == 0)
            {
                Rectangle r     = this.Bounds;
                Point     sides = NativeMethods.GetScrolledColumnSides(this.ListView, subItemIndex);
                r.X     = sides.X + 1;
                r.Width = sides.Y - sides.X;
                return(r);
            }

            OLVListSubItem subItem = this.GetSubItem(subItemIndex);

            return(subItem == null ? new Rectangle() : subItem.Bounds);
        }
        /// <summary>
        /// Create a OlvListViewHitTestInfo
        /// </summary>
        public OlvListViewHitTestInfo(OLVListItem olvListItem, OLVListSubItem subItem, int flags, OLVGroup group, int iColumn)
        {
            this.item              = olvListItem;
            this.subItem           = subItem;
            this.location          = ConvertNativeFlagsToDotNetLocation(olvListItem, flags);
            this.HitTestLocationEx = (HitTestLocationEx)flags;
            this.Group             = group;
            this.ColumnIndex       = iColumn;
            this.ListView          = olvListItem == null ? null : (ObjectListView)olvListItem.ListView;

            switch (location)
            {
            case ListViewHitTestLocations.StateImage:
                this.HitTestLocation = HitTestLocation.CheckBox;
                break;

            case ListViewHitTestLocations.Image:
                this.HitTestLocation = HitTestLocation.Image;
                break;

            case ListViewHitTestLocations.Label:
                this.HitTestLocation = HitTestLocation.Text;
                break;

            default:
                if ((this.HitTestLocationEx & HitTestLocationEx.LVHT_EX_GROUP_COLLAPSE) == HitTestLocationEx.LVHT_EX_GROUP_COLLAPSE)
                {
                    this.HitTestLocation = HitTestLocation.GroupExpander;
                }
                else if ((this.HitTestLocationEx & HitTestLocationEx.LVHT_EX_GROUP_MINUS_FOOTER_AND_BKGRD) != 0)
                {
                    this.HitTestLocation = HitTestLocation.Group;
                }
                else
                {
                    this.HitTestLocation = HitTestLocation.Nothing;
                }
                break;
            }
        }