Example #1
0
        /// <summary>
        /// Метод собирает аналитику по ячекам (мин. и макс. значение для строк и колонок, мин. и макс. по длине строки и т.д.)
        /// </summary>
        public void BuildCellsAnalytic()
        {
            Cells_DisplayValueLength_MinMax.Clear();
            CellSetDataProvider cs;

            if (m_PivotGrid.m_LayoutProvider != null &&
                m_PivotGrid.m_LayoutProvider.PivotProvider.Provider != null &&
                m_PivotGrid.m_LayoutProvider.PivotProvider.Provider.CellSet_Description != null)
            {
                cs = m_PivotGrid.m_LayoutProvider.PivotProvider.Provider;

                // Сбор аналитики для колонок

                int start_col = 0;
                // Если колонок нет, то нужно проверить колонку с индексом -1 (Ячейка есть, а оси пустые)
                if (cs.Columns_Size == 0 && cs.CellSet_Description.Cells.Count > 0)
                {
                    start_col = -1;
                }
                for (int col = start_col; col < cs.Columns_Size; col++)
                {
                    // колонка ячеек
                    List <CellInfo> column_cells = new List <CellInfo>();
                    int             start_row    = 0;
                    // Если колонок нет, то нужно проверить колонку с индексом -1 (Ячейка есть, а оси пустые)
                    if (cs.Rows_Size == 0 && cs.CellSet_Description.Cells.Count > 0)
                    {
                        start_row = -1;
                    }
                    for (int row = start_row; row < cs.Rows_Size; row++)
                    {
                        var cell = cs.GetCellInfo(col, row);
                        if (cell != null)
                        {
                            column_cells.Add(cell);
                        }
                    }

                    if (column_cells.Count > 0)
                    {
                        // Сортируем колонку по длине DisplayValue ячейки
                        var sorted = from p in column_cells orderby StringExtensions.Measure(p.DisplayValue, m_PivotGrid.DefaultFontSize, null).Width select p;

                        MinMaxDescriptor <CellInfo> displayValueLength_MinMax = new MinMaxDescriptor <CellInfo>(sorted.First(), sorted.Last());

                        if (cs.Columns_LowestMembers.ContainsKey(col))
                        {
                            Cells_DisplayValueLength_MinMax[cs.Columns_LowestMembers[col]] = displayValueLength_MinMax;
                        }
                        else
                        {
                            if (col == -1)
                            {
                                Cells_DisplayValueLength_MinMax[MemberInfo.Empty] = displayValueLength_MinMax;
                            }
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Метод собирает аналитику по ячекам (мин. и макс. значение для строк и колонок, мин. и макс. по длине строки и т.д.)
        /// </summary>
        public void BuildCellsAnalytic()
        {
            Cells_DisplayValueLength_MinMax.Clear();
            CellSetDataProvider cs;
            if (m_PivotGrid.m_LayoutProvider != null &&
                m_PivotGrid.m_LayoutProvider.PivotProvider.Provider != null &&
                m_PivotGrid.m_LayoutProvider.PivotProvider.Provider.CellSet_Description != null)
            {
                cs = m_PivotGrid.m_LayoutProvider.PivotProvider.Provider;

                // Сбор аналитики для колонок

                int start_col = 0;
                // Если колонок нет, то нужно проверить колонку с индексом -1 (Ячейка есть, а оси пустые)
                if (cs.Columns_Size == 0 && cs.CellSet_Description.Cells.Count > 0)
                    start_col = -1;
                for (int col = start_col; col < cs.Columns_Size; col++)
                {
                    // колонка ячеек
                    List<CellInfo> column_cells = new List<CellInfo>();
                    int start_row = 0;
                    // Если колонок нет, то нужно проверить колонку с индексом -1 (Ячейка есть, а оси пустые)
                    if (cs.Rows_Size == 0 && cs.CellSet_Description.Cells.Count > 0)
                        start_row = -1;
                    for (int row = start_row; row < cs.Rows_Size; row++)
                    {
                        var cell = cs.GetCellInfo(col, row);
                        if (cell != null)
                        {
                            column_cells.Add(cell);
                        }
                    }

                    if (column_cells.Count > 0)
                    {
                        // Сортируем колонку по длине DisplayValue ячейки
                        var sorted = from p in column_cells orderby StringExtensions.Measure(p.DisplayValue, m_PivotGrid.DefaultFontSize, null).Width select p;
                        MinMaxDescriptor<CellInfo> displayValueLength_MinMax = new MinMaxDescriptor<CellInfo>(sorted.First(), sorted.Last());

                        if (cs.Columns_LowestMembers.ContainsKey(col))
                        {
                            Cells_DisplayValueLength_MinMax[cs.Columns_LowestMembers[col]] = displayValueLength_MinMax;
                        }
                        else
                        {
                            if (col == -1)
                                Cells_DisplayValueLength_MinMax[MemberInfo.Empty] = displayValueLength_MinMax;
                        }
                    }

                }
            }
        }