Example #1
0
        public void InitSelectContent(ICollection list, ICollection selectedList, SelectedObjCallBack onSelect = null, SelectedObjCallBack onDisSelect = null, Hashtable exhash = null)
        {
            _SelectedCallBack    = onSelect;
            _DisSelectedCallBack = onDisSelect;

            base.InitContentItem(list, OnSelectedObj, exhash);

            _Selecteds.Clear();
            if (selectedList != null)
            {
                foreach (var selectItem in selectedList)
                {
                    ContentPos selectPos = _ValueList.Find((pos) =>
                    {
                        if (pos.Obj == selectItem)
                        {
                            return(true);
                        }
                        return(false);
                    });
                    if (selectPos != null)
                    {
                        _Selecteds.Add(selectPos);
                    }
                }
            }
            ShowItems();
        }
Example #2
0
        public override void ShowItems()
        {
            base.ShowItems();

            foreach (var shoItem in _ItemPrefabList)
            {
                var        showObj   = shoItem._InitInfo;
                ContentPos selectPos = _Selecteds.Find((pos) =>
                {
                    if (pos.Obj == showObj)
                    {
                        return(true);
                    }
                    return(false);
                });

                if (selectPos != null)
                {
                    ((UIItemSelect)shoItem).Selected();
                }
                else
                {
                    ((UIItemSelect)shoItem).UnSelected();
                }
            }
        }
Example #3
0
    public void SetSelect(IEnumerable selectedList)
    {
        _SelectedList = selectedList;
        _Selecteds.Clear();
        if (selectedList != null)
        {
            foreach (var selectItem in selectedList)
            {
                ContentPos selectPos = _ValueList.Find((pos) =>
                {
                    if (pos.Obj.Equals(selectItem))
                    {
                        return(true);
                    }
                    return(false);
                });
                if (selectPos != null)
                {
                    _Selecteds.Add(selectPos);
                }
            }
        }


        foreach (var shoItem in _ItemPrefabList)
        {
            var        showObj   = shoItem._InitInfo;
            ContentPos selectPos = _Selecteds.Find((pos) =>
            {
                if (pos.Obj.Equals(showObj))
                {
                    return(true);
                }
                return(false);
            });

            if (selectPos != null)
            {
                ((UIItemSelect)shoItem).Selected();
                if (_SelectedCallBack != null)
                {
                    _SelectedCallBack(selectPos.Obj);
                }
            }
            else
            {
                ((UIItemSelect)shoItem).UnSelected();
            }
        }

        if (_Selecteds.Count > 0)
        {
            StartCoroutine(ShowSelectContainPos(_Selecteds[0].ShowItem));
        }
    }
Example #4
0
 /// <summary>
 /// 构造
 /// </summary>
 /// <param name="win">窗体</param>
 /// <param name="targetName">目标名字</param>
 /// <param name="content">内容</param>
 /// <param name="contentPos">内容位置</param>
 /// <param name="callBack">回调函数</param>
 /// <param name="force">是否强制引导</param>
 /// <param name="allowFail">是否允许失败</param>
 /// <param name="id">ID</param>
 public GuideInfo(LikeWindow win, string targetName, string content = "", ContentPos contentPos = ContentPos.Left, CallBackFunc callBack = null, bool force = true, bool allowFail = false, int id = 0)
 {
     m_Win           = win;
     m_WinComp       = win as Component;
     m_strTargetName = targetName;
     m_strContent    = content;
     m_ContentPos    = contentPos;
     m_CallBackFunc -= callBack;
     m_CallBackFunc += callBack;
     m_bForce        = force;
     m_bAllowFail    = allowFail;
     m_iID           = id;
 }
Example #5
0
        public void OnSelectedObj(object obj)
        {
            ContentPos selectPos = _ValueList.Find((pos) =>
            {
                if (pos.Obj == obj)
                {
                    return(true);
                }
                return(false);
            });

            if (_IsMultiSelect)
            {
                if (_Selecteds.Contains(selectPos))
                {
                    if (selectPos.ShowItem != null)
                    {
                        ((UIItemSelect)selectPos.ShowItem).UnSelected();
                    }
                    _Selecteds.Remove(selectPos);
                }
                else
                {
                    if (selectPos.ShowItem != null)
                    {
                        ((UIItemSelect)selectPos.ShowItem).Selected();
                    }
                    _Selecteds.Add(selectPos);
                }
            }
            else
            {
                if (_Selecteds.Count > 0)
                {
                    ((UIItemSelect)_Selecteds[0].ShowItem).UnSelected();
                }
                _Selecteds.Clear();

                _Selecteds.Add(selectPos);
                ((UIItemSelect)_Selecteds[0].ShowItem).Selected();
            }

            if (_SelectedCallBack != null && _Selecteds.Contains(selectPos))
            {
                _SelectedCallBack(obj);
            }
            else if (_DisSelectedCallBack != null && !_Selecteds.Contains(selectPos))
            {
                _DisSelectedCallBack(obj);
            }
        }
Example #6
0
    public virtual void InitContentItem(IEnumerable valueList, UIItemBase.ItemClick onClick = null, Hashtable exhash = null, UIItemBase.PanelClick onPanelClick = null)
    {
        //CalculateRect(valueList);
        _ValueList.Clear();
        //ClearPrefab();
        int i = 0;

        if (valueList == null)
        {
            ClearPrefab();
            return;
        }
        var enumerator = valueList.GetEnumerator();

        enumerator.Reset();
        while (enumerator.MoveNext())
        {
            var contentPos = new ContentPos();
            contentPos.Obj = enumerator.Current;
            _ValueList.Add(contentPos);

            ++i;
        }

        _InitItemCount = 50;
        _InitItemCount = Math.Min(_InitItemCount, _ValueList.Count);

        _HasInit      = false;
        _OnClickItem  = onClick;
        _OnClickPanel = onPanelClick;
        _ExHash       = exhash;
        if (isActiveAndEnabled)
        {
            StartInitContainer();
        }

        //_LayoutGroup.enabled = false;
    }
Example #7
0
    private void CalculateRect(ICollection items)
    {
        int itemCount = items.Count;

        _ViewPortWidth  = _ScrollTransform.sizeDelta.x;
        _ViewPortHeight = _ScrollTransform.sizeDelta.y;

        _ContentColumn = 1;
        _ContentRow    = 1;
        if (_LayoutGroup.constraint == GridLayoutGroup.Constraint.FixedRowCount)
        {
            _ContentColumn = _LayoutGroup.constraintCount;
            _ContentRow    = itemCount / _ContentColumn;
            if (itemCount % _ContentColumn > 0)
            {
                ++_ContentRow;
            }
        }
        else if (_LayoutGroup.constraint == GridLayoutGroup.Constraint.FixedColumnCount)
        {
            _ContentRow    = _LayoutGroup.constraintCount;
            _ContentColumn = itemCount / _ContentRow;
            if (itemCount % _ContentRow > 0)
            {
                ++_ContentColumn;
            }
        }

        _ValueList.Clear();
        int i          = 0;
        var enumerator = items.GetEnumerator();

        enumerator.Reset();
        while (enumerator.MoveNext())
        //for (int i = 0; i < itemCount; ++i)
        {
            int column = i / _ContentRow;
            int row    = i % _ContentRow;

            var contentPos = new ContentPos();
            contentPos.Pos = new Vector2(
                row * (_LayoutGroup.cellSize.x + _LayoutGroup.spacing.x) + _LayoutGroup.cellSize.x * 0.5f,
                -column * (_LayoutGroup.cellSize.y + _LayoutGroup.spacing.y) - _LayoutGroup.cellSize.y * 0.5f);
            contentPos.Obj = enumerator.Current;
            _ValueList.Add(contentPos);

            ++i;
        }


        _ContentCanvasWidth  = _LayoutGroup.cellSize.x * _ContentRow + _LayoutGroup.spacing.x * (_ContentRow - 1);
        _ContentCanvasHeight = _LayoutGroup.cellSize.y * _ContentColumn + _LayoutGroup.spacing.y * (_ContentColumn - 1);

        if (_BG != null)
        {
            _BG.rectTransform.sizeDelta = new Vector2(_ContentCanvasWidth + 20, _ContentCanvasHeight + 20);
        }

        if (_ContainerBaseLarge)
        {
            _ContentCanvasWidth  = Math.Max(_ScrollTransform.sizeDelta.x, _ContentCanvasWidth);
            _ContentCanvasHeight = Math.Max(_ScrollTransform.sizeDelta.y, _ContentCanvasHeight);
        }

        _ShowRowCount    = (int)Math.Ceiling((_ViewPortWidth + _LayoutGroup.spacing.x) / (_LayoutGroup.cellSize.x + _LayoutGroup.spacing.x));
        _ShowColumnCount = (int)Math.Ceiling((_ViewPortHeight + _LayoutGroup.spacing.y) / (_LayoutGroup.cellSize.y + _LayoutGroup.spacing.y));

        _InitItemCount = _ShowColumnCount * _ShowRowCount;
        _InitItemCount = Math.Min(_InitItemCount, itemCount);

        _ContainerObj.sizeDelta = new Vector2(_ContentCanvasWidth, _ContentCanvasHeight);

        float containerPosX = 0;
        float containerPosY = 0;

        if (_ContainerObj.sizeDelta.x < _ScrollTransform.sizeDelta.x)
        {
            containerPosX = (_ScrollTransform.sizeDelta.x - _ContainerObj.sizeDelta.x) * 0.5f;
        }
        if (_ContainerObj.sizeDelta.y < _ScrollTransform.sizeDelta.y)
        {
            containerPosY = (_ContainerObj.sizeDelta.y - _ScrollTransform.sizeDelta.y) * 0.5f;
        }
        _ContainerObj.transform.localPosition = new Vector3(containerPosX, containerPosY, 0);

        //Debug.Log("CalculateRect viewPortWidth:" + _ShowRowCount + "," + _ShowColumnCount + "," + _ContentCanvasWidth + "," + _ContentCanvasHeight);
    }