protected void OnHorizontalStretchChanged(bool oldvalue, bool newvalue) { if (this.IsCustomLength == false) { this.length = this.CalcTableLength(); } }
public LengthCollection Clone() { var c = new LengthCollection(); this.Items.ForEach(v => c.Import(v.Clone())); return(c); }
protected RowConf(LengthCollection length, params string[] columns) { this.RealLength = length; this.Data = columns; if (this.RealLength.Count > this.Data.Length) { throw new ArgumentException("Not all column have length definitions!"); } }
public static void WriteBorderRow(BorderConf bconf, LengthCollection lconf) { Write("" + bconf.CharLeft + ("".PadLeft(TableCellPadding, bconf.CharBody))); for (int i = 0; i < lconf.Count; i++) { Write("".PadLeft(lconf.BorderedLength.Items[i].Length + TableCellPadding, bconf.CharBody)); if (i < lconf.Count - 1) { Write("" + bconf.CharCorner + ("".PadLeft(TableCellPadding, bconf.CharBody))); } } Write("" + bconf.CharRight); WriteLine(); }
public static RowConf Create(params string[] columns) { int column = CoEx.Width / columns.Length; LengthCollection length = new LengthCollection(); for (int i = 0; i < columns.Length; i++) { length.Items.Add(new LengthConf() { Length = column, Index = i }); } return(Create(length, columns)); }
protected void Import(RowConf item, int?index) { var temp = item.Clone(); temp.Parent = this; if (index.HasValue && index.Value >= 0) { this.Items.Insert(index.Value, temp); } else { this.Items.Add(temp); } if (this.IsCustomLength == false) { this.length = this.CalcTableLength(); } }
/// <summary> /// Write columns with the title color scheme on full width /// </summary> /// <param name="length">The length for each columns</param> /// <param name="s">The column contents</param> public static void WriteTitleLarge(LengthCollection length, string[] s) { WriteColumns(RowConf.Create(length, s).PresetTitle().SetBordered(false).SetAlignment(RowConf.ALIGNCENTER).SetHlPadding(true)); }
/// <summary> /// Write columns with the title color scheme /// </summary> /// <param name="length">The length for each columns</param> /// <param name="s">The column contents</param> public static void WriteTitle(LengthCollection length, string[] s) { WriteColumns(RowConf.Create(length, s).PresetTitle().SetBordered(false)); }
/// <summary> /// Write columns with the highlight color scheme /// </summary> /// <param name="length">The length for each columns</param> /// <param name="s">The column contents</param> public static void WriteHl(LengthCollection length, params string[] s) { WriteColumns(RowConf.Create(length, s).PresetHL()); }
public RowCollection SetLength(LengthCollection len) { this.Length = len; return(this); }
protected LengthCollection CalcTableLength() { // Console width int maxlength = CoEx.Width; // Items var items = this.Items.ToArray().ToList(); // initialize array with one field per column LengthCollection collection = new LengthCollection(); for (int i = 0; i < this.Items.Max(v => v.Data.Length); i++) { collection.Import(new LengthConf() { Index = i }); } // iterate rows for (int i = 0; i < this.Items.Count; i++) { // iterate columns for (int j = 0; j < this.Items[i].Data.Length; j++) { // when length of cell > current length if (this.Items[i].Data[j] != null && this.Items[i].Data[j].Length > (collection.Items[j].Length)) { collection.Items[j].Length = collection.Items[j].OriginalLength = this.Items[i].Data[j].Length; } } } // fix overflow by percentage if (collection.TotalLength > maxlength) { // diffrence int diff = collection.TotalLength - maxlength; foreach (var item in collection.BigItems) { // remove i percent of diff in column i if percent>=minperc item.Length -= ((int)Math.Round((diff * item.BigLengthPercent / 100))); } } if (this.Settings.StretchHorizontal) { // add remaining length to last column if (collection.TotalLength < maxlength) { int diff = maxlength - collection.TotalLength; collection.Items.Last().Length += diff; } } else { // add length for padding and border to last column int borderpadding = (3 * (collection.Items.Count - 1)) + 4; if (collection.TotalLength + borderpadding < maxlength) { collection.Items.Last().Length += borderpadding; } } return(collection); }
public RowConf SetLength(LengthCollection length) { this.RealLength = length; return(this); }
public static RowConf Create(LengthCollection length, params string[] columns) { return(new RowConf(length, columns)); }