Ejemplo n.º 1
0
 public void ColumnWidth(int position, float width)
 {
     _columnDefinitions[position] = new FixedWidthColumn(width);
 }
 //***************************************************************************
 // Private Methods
 // 
 private string ParseField(FixedWidthColumn col, string value)
 {
     string fVal = (value.Length <= col.Width) ? value : value.Substring(0, col.Width);
     switch (col.Alignment)
     {
         case StringAlignment.Left:
             fVal = fVal.PadRight(col.Width, col.BlankCharacter);
             break;
         case StringAlignment.Center:
             fVal = fVal.PadLeft((int)System.Math.Floor((double)(col.Width / 2)), col.BlankCharacter).PadRight((int)System.Math.Ceiling((double)(col.Width / 2)), col.BlankCharacter);
             break;
         case StringAlignment.Right:
             fVal = fVal.PadLeft(col.Width, col.BlankCharacter);
             break;
     }
     return fVal;
 }
 public void Remove(FixedWidthColumn value)
 {
     List.Remove(value);
 }
 public bool Contains(FixedWidthColumn value)
 {
     return InnerList.Contains(value);
 }
 public void Add(FixedWidthColumn value)
 {
     if (string.IsNullOrEmpty(value.ColumnName))
         value.ColumnName = "Column" + Convert.ToString(List.Count + 1).PadLeft(4, '0');
     if (this.IndexOf(value.ColumnName) > -1)
         throw new ArgumentException("A column with the specified name already exists.", "value.ColumnName");
     List.Add(value);
 }