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); }
}//end IsEmptyItems public virtual TextItem GetTextOrEmpty(int index, int emptyTextLen = Config.Numerics.DEFAULT_WIDTH) { if (Ruler == null) { throw new NoRuleSetException(); } var emptyText = new string(' ', emptyTextLen).ToCharArray().ToList(); if (IsEmptyItems() || Ruler.GetIndexRule().Count < index) { return(new TextItem() { Index = -1, Text = emptyText }); } var matchedItem = Items.FirstOrDefault(ti => ti.Index == index); return(matchedItem ?? new TextItem() { HashMarkValue = Ruler.GetIndexRule()[index], Index = index, Text = emptyText }); }//end GetTextOrEmpty