示例#1
0
        private void ScListViewItem_SizeChanged(object sender, SizeF oldSize)
        {
            if (ReLayoutEvent != null)
            {
                ReLayoutEvent(this);
            }
            else
            {
                TableEx    layoutTable = listView.itemContentLayoutTable;
                ScLayer    elem;
                int        rowIdx;
                int        colIdx;
                RectangleF rect;
                float      y;

                for (int i = 0; i < controls.Count(); i++)
                {
                    elem   = controls[i];
                    rowIdx = i / layoutTable.colAmount;
                    colIdx = i % layoutTable.colAmount;
                    rect   = layoutTable.GetCellRect(rowIdx, colIdx);

                    y                  = rect.Height / 2 - elem.Height / 2;
                    rect.Y             = (float)Math.Ceiling(y);
                    rect.X             = (float)Math.Ceiling(rect.X);
                    rect.Width         = (float)Math.Ceiling(rect.Width);
                    rect.Height        = (float)Math.Ceiling(elem.Height);
                    elem.DirectionRect = rect;
                }
            }
        }
示例#2
0
        public void AddItem(ScLayer[] fieldElemLayers, ScListViewItem.ReLayoutEventHandler itemReLayoutEvent = null)
        {
            CreateItemLayoutTable(wrapper.controls.Count() + 1);

            int        idx    = wrapper.controls.Count();
            int        rowIdx = idx / colItemCount;
            int        colIdx = idx % colItemCount;
            RectangleF r      = itemLayoutTable.GetCellRect(rowIdx, colIdx);

            r = itemLayoutTable.TransToGlobalRect(r);

            ScListViewItem item = new ScListViewItem(fieldElemLayers);

            item.ReLayoutEvent += itemReLayoutEvent;
            item.listView       = this;
            item.DirectionRect  = r;

            item.GotFocus        += Item_GotFocus;
            item.MouseHoverEvent += Item_MouseHoverEvent;
            item.LostFocus       += Item_LostFocus;

            AddContentControl(item);
            item.Focus();
            Refresh();
        }