Пример #1
0
        public virtual void AddInnerBlock(Block innerBlock)
        {
            if (Ruler == null)
            {
                throw new NoRuleSetException();
            }
            if (innerBlock.StartValue == Ruler.StartValue)
            {
                throw new InnerBlockRequiresStartValue(innerBlock);
            }

            //for the first inner block added take the larger width (thiers or ours)
            if (_innerBlocks.Count == 0)
            {
                var gtWidth = Width > innerBlock.Width ? Width : innerBlock.Width;

                Width            = gtWidth;
                innerBlock.Width = gtWidth;
            }
            else//thereafter set the width as a sum
            {
                Width += innerBlock.Width + 1;
            }

            //back the inner block up by one line for printing the title
            var innerBlockIdx  = Ruler.CalcEntryIndex(innerBlock);
            var valForNextLine = Convert.ToInt32(Math.Floor(Ruler.GetIndexRule()[(innerBlockIdx.Item1 - 1)]));

            innerBlock.StartValue   = valForNextLine;
            innerBlock.MyOuterBlock = this;
            _innerBlocks.Add(innerBlock);
        }
Пример #2
0
        protected internal int CalcHeight()
        {
            if (StartValue == EndValue)
            {
                return(1);
            }
            if (Ruler == null)
            {
                return(1);
            }
            var idx = Ruler.CalcEntryIndex(this);

            var y = 0;
            var x = Ruler.Length;

            if (idx.Item1 >= 0)
            {
                x = idx.Item1;
            }
            if (idx.Item2 > 0)
            {
                y = idx.Item2;
            }

            return(y - x);
        }//end CalcHeight
Пример #3
0
        public override string ToString()
        {
            if (Ruler == null)
            {
                throw new NoRuleSetException();
            }

            var strBuilder = new StringBuilder();

            if (EmptyChar == '\0')
            {
                EmptyChar = (char)0x20;
            }

            var entryIndex = Ruler.CalcEntryIndex(this);

            strBuilder.Append(DrawHeader());
            for (var i = entryIndex.Item1 + 1; i <= entryIndex.Item2 - 1; i++)
            {
                strBuilder.AppendLine(new string(EmptyChar, Width));
            }
            strBuilder.Append(DrawBar());
            return(strBuilder.ToStringUnixNewline());
        }