예제 #1
0
 protected void OnHorizontalStretchChanged(bool oldvalue, bool newvalue)
 {
     if (this.IsCustomLength == false)
     {
         this.length = this.CalcTableLength();
     }
 }
예제 #2
0
        public LengthCollection Clone()
        {
            var c = new LengthCollection();

            this.Items.ForEach(v => c.Import(v.Clone()));
            return(c);
        }
예제 #3
0
        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!");
            }
        }
예제 #4
0
 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();
 }
예제 #5
0
        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));
        }
예제 #6
0
        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();
            }
        }
예제 #7
0
 /// <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));
 }
예제 #8
0
 /// <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));
 }
예제 #9
0
 /// <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());
 }
예제 #10
0
 public RowCollection SetLength(LengthCollection len)
 {
     this.Length = len;
     return(this);
 }
예제 #11
0
        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);
        }
예제 #12
0
 public RowConf SetLength(LengthCollection length)
 {
     this.RealLength = length;
     return(this);
 }
예제 #13
0
 public static RowConf Create(LengthCollection length, params string[] columns)
 {
     return(new RowConf(length, columns));
 }