Exemplo n.º 1
0
        private void SetValue(object value)
        {
            CheckInit();
            object value2 = m_value;

            m_value = value;
            m_cellRendererInstance.SetValue(value);
            this.OnValueChange?.Invoke(value2, value);
        }
Exemplo n.º 2
0
        private void Update()
        {
            //IL_02bf: Unknown result type (might be due to invalid IL or missing references)
            //IL_0368: Unknown result type (might be due to invalid IL or missing references)
            int num  = ToIndex(base.scrollPercentage);
            int num2 = Mathf.Clamp(num, 0, m_items.Count);
            int num3 = num + m_rows * m_columns - 1;

            if (m_needFullReLayout)
            {
                foreach (KeyValuePair <int, CellRenderer> item in m_elementsByItem)
                {
                    ReturnToPool(item.Value);
                }
                m_elementsByItem.Clear();
                for (int i = num2; i <= num3; i++)
                {
                    object       value    = (i < m_items.Count) ? m_items[i] : null;
                    CellRenderer fromPool = GetFromPool();
                    m_elementsByItem[i] = fromPool;
                    fromPool.SetValue(value);
                }
                m_needFullReLayout = false;
            }
            else
            {
                for (int j = m_previousFirstCellIndex; j < Math.Min(num2, m_previousLastCellIndex + 1); j++)
                {
                    if (m_elementsByItem.TryGetValue(j, out CellRenderer value2))
                    {
                        ReturnToPool(value2);
                        m_elementsByItem.Remove(j);
                    }
                }
                for (int num4 = m_previousLastCellIndex; num4 > Math.Max(num3, m_previousFirstCellIndex - 1); num4--)
                {
                    if (m_elementsByItem.TryGetValue(num4, out CellRenderer value3))
                    {
                        ReturnToPool(value3);
                        m_elementsByItem.Remove(num4);
                    }
                }
                for (int k = num2; k < Math.Min(m_previousFirstCellIndex, num3 + 1); k++)
                {
                    object       value4    = (k < m_items.Count) ? m_items[k] : null;
                    CellRenderer fromPool2 = GetFromPool();
                    m_elementsByItem[k] = fromPool2;
                    fromPool2.SetValue(value4);
                }
                for (int l = Math.Max(num2, m_previousLastCellIndex + 1); l <= num3; l++)
                {
                    object       value5    = (l < m_items.Count) ? m_items[l] : null;
                    CellRenderer fromPool3 = GetFromPool();
                    m_elementsByItem[l] = fromPool3;
                    fromPool3.SetValue(value5);
                }
            }
            float num5 = ToRowIndex(base.scrollPercentage);

            if (m_horizontal)
            {
                float num6 = num5 * (float)m_cellSize.get_x() % (float)m_cellSize.get_x();
                int   num7 = num2;
                for (int m = 0; m < m_columns; m++)
                {
                    float num8 = (float)(m_cellSize.get_x() * m) - num6;
                    for (int n = 0; n < m_rows; n++)
                    {
                        int num9 = m_totalHeight - m_cellSize.get_y() * (n + 1);
                        if (m_elementsByItem.TryGetValue(num7++, out CellRenderer value6))
                        {
                            value6.GetComponent <RectTransform>().set_anchoredPosition(new Vector2(num8, (float)num9));
                        }
                    }
                }
            }
            else
            {
                float num11 = num5 * (float)m_cellSize.get_y() % (float)m_cellSize.get_y();
                int   num12 = num2;
                for (int num13 = 0; num13 < m_rows; num13++)
                {
                    float num14 = (float)m_totalHeight - ((float)(m_cellSize.get_y() * (num13 + 1)) - num11);
                    for (int num15 = 0; num15 < m_columns; num15++)
                    {
                        int num16 = m_cellSize.get_x() * num15;
                        if (m_elementsByItem.TryGetValue(num12++, out CellRenderer value7))
                        {
                            value7.GetComponent <RectTransform>().set_anchoredPosition(new Vector2((float)num16, num14));
                        }
                    }
                }
            }
            m_previousFirstCellIndex = num2;
            m_previousLastCellIndex  = num3;
        }
Exemplo n.º 3
0
        private void Update()
        {
            //IL_02ca: Unknown result type (might be due to invalid IL or missing references)
            //IL_035d: Unknown result type (might be due to invalid IL or missing references)
            int num  = ToIndex(base.scrollPercentage, normalize: false) - m_rows / 2;
            int num2 = num + m_rows;

            if (m_needFullReLayout)
            {
                foreach (KeyValuePair <int, CellRenderer> item in m_elementsByItem)
                {
                    ReturnToPool(item.Value);
                }
                m_elementsByItem.Clear();
                for (int i = num; i <= num2; i++)
                {
                    int          num3     = NormalizeItemIndex(i, m_items.Count);
                    object       value    = (num3 >= 0) ? m_items[num3] : null;
                    CellRenderer fromPool = GetFromPool();
                    m_elementsByItem[i] = fromPool;
                    fromPool.SetValue(value);
                }
                m_needFullReLayout = false;
            }
            else
            {
                for (int j = m_previousFirstCellIndex; j < Math.Min(num, m_previousLastCellIndex + 1); j++)
                {
                    if (m_elementsByItem.TryGetValue(j, out CellRenderer value2))
                    {
                        ReturnToPool(value2);
                        m_elementsByItem.Remove(j);
                    }
                }
                for (int num4 = m_previousLastCellIndex; num4 > Math.Max(num2, m_previousFirstCellIndex - 1); num4--)
                {
                    if (m_elementsByItem.TryGetValue(num4, out CellRenderer value3))
                    {
                        ReturnToPool(value3);
                        m_elementsByItem.Remove(num4);
                    }
                }
                for (int k = num; k < Math.Min(m_previousFirstCellIndex, num2 + 1); k++)
                {
                    int          num5      = NormalizeItemIndex(k, m_items.Count);
                    object       value4    = (num5 >= 0) ? m_items[num5] : null;
                    CellRenderer fromPool2 = GetFromPool();
                    m_elementsByItem[k] = fromPool2;
                    fromPool2.SetValue(value4);
                }
                for (int l = Math.Max(num, m_previousLastCellIndex + 1); l <= num2; l++)
                {
                    int          num6      = NormalizeItemIndex(l, m_items.Count);
                    object       value5    = (num6 >= 0) ? m_items[num6] : null;
                    CellRenderer fromPool3 = GetFromPool();
                    m_elementsByItem[l] = fromPool3;
                    fromPool3.SetValue(value5);
                }
            }
            float num7 = ToRowIndex(base.scrollPercentage, normalize: false);

            if (m_horizontal)
            {
                float num8 = num7 * (float)m_cellSize.get_x() % (float)m_cellSize.get_x();
                int   num9 = num;
                for (int m = 0; m <= m_rows; m++)
                {
                    float num10 = (float)(-(m_rows / 2) * m_cellSize.get_x()) - num8 + (float)(m_cellSize.get_x() * m);
                    int   num11 = 0;
                    if (m_elementsByItem.TryGetValue(num9++, out CellRenderer value6))
                    {
                        value6.GetComponent <RectTransform>().set_anchoredPosition(new Vector2(num10, (float)num11));
                    }
                }
            }
            else
            {
                float num13 = num7 * (float)m_cellSize.get_y() % (float)m_cellSize.get_y();
                int   num14 = num;
                for (int n = 0; n <= m_rows; n++)
                {
                    float num15 = (float)(m_rows / 2 * m_cellSize.get_y()) + num13 - (float)(m_cellSize.get_y() * n);
                    int   num16 = 0;
                    if (m_elementsByItem.TryGetValue(num14++, out CellRenderer value7))
                    {
                        value7.GetComponent <RectTransform>().set_anchoredPosition(new Vector2((float)num16, num15));
                    }
                }
            }
            m_previousFirstCellIndex = num;
            m_previousLastCellIndex  = num2;
        }