public StandardHiddenRowCoordinator(RowsBase rows)
        {
            this.m_rows = rows;

            rows.RowVisibilityChanged += delegate(int rowIndex, bool becameVisible)
            {
                var range = new Range(rowIndex, 0, rowIndex, 1);
                if (becameVisible)
                {
                    m_rowMerger.RemoveRange(range);
                }
                else
                {
                    m_rowMerger.AddRange(range);
                }

                //rowmerger had the correct count of hidden rows.
                m_totalHiddenRows = m_rowMerger.GetRowsIndex().Count;
            };

            /*[email protected]: The below event handler was blindly incrementing or decrementing values.
             * The issue with this is :
             * Say after loading the grid with one hidden row, user sets the RowsCount of the same grid to 0.
             * Making the grid empty. At that time this event is not triggered and m_totalHiddenRows value will not be decremented.
             * Now if you load the grid again with 1 hidden row, this will get incremented to 2. Which is wrong*/
            //rows.RowVisibilityChanged += delegate(int rowIndex, bool becameVisible)
            //{
            //if (becameVisible == true)
            //    m_totalHiddenRows -= 1;
            //else
            //    m_totalHiddenRows += 1;
            //if (m_totalHiddenRows < 0)
            //    throw new SourceGridException("Total hidden rows becamse less than 0. This indicates a bug");
            //};
        }
예제 #2
0
        public StandardHiddenRowCoordinator(RowsBase rows)
        {
            this.m_rows = rows;

            rows.RowVisibilityChanged += delegate(int rowIndex, bool becameVisible)
            {
                var range = new GridRange(rowIndex, 0, rowIndex, 1);
                if (becameVisible)
                {
                    m_rowMerger.RemoveRange(range);
                }
                else
                {
                    m_rowMerger.AddRange(range);
                }
            };

            rows.RowVisibilityChanged += delegate(int rowIndex, bool becameVisible)
            {
                if (becameVisible == true)
                {
                    m_totalHiddenRows -= 1;
                }
                else
                {
                    m_totalHiddenRows += 1;
                }
                if (m_totalHiddenRows < 0)
                {
                    throw new SourceGridException("Total hidden rows becamse less than 0. This indicates a bug");
                }
            };
        }
예제 #3
0
        /// <summary>
        /// Returns all the selected rows index
        /// </summary>
        /// <returns></returns>
        public virtual int[] GetRowsIndex()
        {
            RangeMergerByRows merger = new RangeMergerByRows();

            foreach (Range range in this)
            {
                merger.AddRange(range);
            }

            IList <int> indexes = merger.GetRowsIndex();

            int[] ret = new int[indexes.Count];
            indexes.CopyTo(ret, 0);

            /*foreach (int in merger.GetRowsIndex())
             * {
             *
             * }
             *
             *
             * System.Collections.ArrayList indexList = new System.Collections.ArrayList();
             *
             * for (int iRange = 0; iRange < this.Count; iRange++)
             * {
             *      for (int r = this[iRange].Start.Row; r <= this[iRange].End.Row; r++)
             *      {
             *              if (indexList.Contains(r) == false)
             *                      indexList.Add(r);
             *      }
             * }
             * int[] ret = new int[indexList.Count];
             * indexList.CopyTo(ret, 0);*/

            return(ret);
        }
예제 #4
0
        /// <summary>
        /// Returns all the selected rows index
        /// </summary>
        /// <returns></returns>
        public virtual int[] GetRowsIndex()
        {
            RangeMergerByRows merger = new RangeMergerByRows();

            foreach (Range range in this)
            {
                merger.AddRange(range);
            }

            IList <int> indexes = merger.GetRowsIndex();

            int[] ret = new int[indexes.Count];
            indexes.CopyTo(ret, 0);

            return(ret);
        }
예제 #5
0
        public void AddRange_Merge_WhenOverlapped()
        {
            // single addition causes to range many rows at once

            // add separate ranges
            RangeMergerByRows list = new RangeMergerByRows()
                                     .AddRange(new Range(1, 1, 1, 1))
                                     .AddRange(new Range(3, 3, 3, 3))
                                     .AddRange(new Range(5, 5, 5, 5));

            Assert.AreEqual(3, list.GetSelectedRowRegions(0, 1).Count);

            // cause them all to merge
            list.AddRange(new Range(1, 1, 5, 1));
            Assert.AreEqual(1, list.GetSelectedRowRegions(0, 1).Count);
        }