Ejemplo n.º 1
0
        public override string ToString()
        {
            string aidText = null;

            if (this.AidKey != null)
            {
                aidText = this.AidKey.Value.ToString();
            }
            else
            {
                aidText = "Invalid aid byte " + this.AidByte.ToHex();
            }

            return("Row:" + RowNum.ToString() + " Column:" + ColNum.ToString()
                   + " AID: " + aidText);
        }
Ejemplo n.º 2
0
        protected override void ResetItems()
        {
            CItemRender item;
            bool        isSameHeight    = true;
            float       realTotalHeight = 0;

            for (int i = 0; i < _allItem.Count; i++)
            {
                item      = _allItem[i];
                item.name = "Item" + i;
                CItemRender w = item;
                if (_dataCondition != null)
                {
                    w.SetCondition(_dataCondition);
                }
                w.Data = _dataProvider[i];
                //默认为itemHeight(等高情况)
                //不等高情况,请自行设置CItemRender的height属性
                float realItemHeight = 0;
                if (w.height == 0)
                {
                    realItemHeight = _itemHeight;
                }
                else
                {
                    realItemHeight = w.height;
                    isSameHeight   = false;
                }
                int   offX = i / RowNum;
                int   offY = i / ColNum;
                float itemX, itemY;
                if (horizon)
                {
                    itemY = -(itemHeight + 5) * (i % RowNum);  //一列一列的顺序?
                    itemX = offX * itemWidth;
                }
                else
                {
                    if (isSameHeight)
                    {
                        itemY = (offY * _itemHeight * -1);
                    }
                    else
                    {
                        itemY = (realTotalHeight * -1);
                    }
                    itemX = (itemWidth + 5) * (i % ColNum);
                }
                item.tran.localPosition = new Vector3(PaddingLeft + itemX, -PaddingTop + itemY, 0);

                realTotalHeight += realItemHeight;

                UIEventListener listener = UIEventListener.Get(item.go);
                //listener.onHover = OnItemHover;
                EventUtil.AddHover(item.go, OnItemHover, item.go);
                listener.onClick = OnItemPress;
            }
            if (_dataProvider == null)
            {
                TotalWidth  = 0;
                TotalHeight = 0;
            }
            else
            {
                if (horizon)
                {
                    var itemW = _itemWidth * _dataProvider.Count / (float)RowNum;
                    TotalWidth = PaddingLeft * 2 + Mathf.CeilToInt(itemW);
                }
                else
                {
                    float itemH = 0;
                    if (isSameHeight)
                    {
                        itemH = _itemHeight * _dataProvider.Count / float.Parse(ColNum.ToString());
                    }
                    else
                    {
                        itemH = realTotalHeight;
                    }
                    TotalHeight = PaddingTop + Mathf.CeilToInt(itemH) + PaddingBottom;
                }
            }
            if (keepCurPos == false)
            {
                UpdateScrollBar();
            }
            else
            {
                if (ShowBar)
                {
                    bool needShowBar = TotalHeight > height || TotalWidth > width;
                    Bar.gameObject.SetActive(needShowBar);
                }
                else
                {
                    Bar.gameObject.SetActive(false);
                }
            }
        }