示例#1
0
        public static RawShapeBlocksGroup MergeBlocks(this RawShapeBlocksGroup elem)
        {
            var blocks = elem.Collection;

            if (blocks.Count < 2)
            {
                return(elem);
            }

            var newElem = new RawShapeBlocksGroup(new List <RawShapeBlock>(), elem.RowIndex);

            var currentBlock = blocks[0];

            for (int i = 1; i < blocks.Count; i++)
            {
                var nextBlock = blocks[i];

                if (nextBlock.Offsetx == 0)
                {
                    currentBlock.Length += nextBlock.Length;
                }
                else
                {
                    newElem.Collection.Add(new RawShapeBlock(currentBlock.Offsetx, currentBlock.Length));

                    currentBlock = nextBlock;
                }
            }

            newElem.Collection.Add(new RawShapeBlock(currentBlock.Offsetx, currentBlock.Length));

            return(newElem);
        }
示例#2
0
        public static RawShapeBlocksGroup MergeBlocks(this RawShapeBlocksGroup elem)
        {
            var blocks = elem.Collection;

            if (blocks.Count < 2) return elem;

            var newElem = new RawShapeBlocksGroup(new List<RawShapeBlock>(), elem.RowIndex);

            var currentBlock = blocks[0];

            for (int i = 1; i < blocks.Count; i++)
            {
                var nextBlock = blocks[i];

                if (nextBlock.Offsetx == 0)
                {
                    currentBlock.Length += nextBlock.Length;
                }
                else
                {
                    newElem.Collection.Add(new RawShapeBlock(currentBlock.Offsetx, currentBlock.Length));

                    currentBlock = nextBlock;
                }
            }

            newElem.Collection.Add(new RawShapeBlock(currentBlock.Offsetx, currentBlock.Length));

            return newElem;
        }
示例#3
0
        public void MergeBlockHelperShouldWorkCorrectly()
        {
            var elem = new RawShapeBlocksGroup(new List<RawShapeBlock>
            {
                new RawShapeBlock (12, 100),
                new RawShapeBlock (0, 1),
                new RawShapeBlock (12, 50),
                new RawShapeBlock (0, 2),
                new RawShapeBlock (0, 3),
                new RawShapeBlock (1, 3)
            }, 0);

            var merged = elem.MergeBlocks();

            merged.Collection.ShouldBeEquivalentTo(new Collection<RawShapeBlock>
            {
                new RawShapeBlock (12, 101),
                new RawShapeBlock (12, 55),
                new RawShapeBlock (1, 3)
            });
        }
示例#4
0
 public static bool Equals(RawShapeBlocksGroup one, RawShapeBlocksGroup two)
 {
     return(one.Collection.SequenceEqual(two.Collection));
 }
示例#5
0
 public static bool Equals(RawShapeBlocksGroup one, RawShapeBlocksGroup two)
 {
     return one.Collection.SequenceEqual(two.Collection);
 }