예제 #1
0
        public void AddLine(params Field[] fields)
        {
            try
            {
                string line = string.Empty;

                foreach (Field field in fields)
                {
                    string      label = field.Label ?? "";
                    string      value = field.Text ?? "";
                    Util.eAlign align = (Util.eAlign)field.Align;
                    int         width = (field.Width <= 0) ? this.Width : field.Width;
                    int         wAux  = width;

                    switch (align)
                    {
                    case Util.eAlign.CENTER:
                        wAux -= (label.Length + 1);

                        if (wAux > 0)
                        {
                            if (label.Length > 0)
                            {
                                align = Util.eAlign.RIGHT;
                            }
                            else
                            {
                                align = Util.eAlign.CENTER;
                            }
                        }

                        value = Util.TextAlign(value, wAux, align);
                        value = (label.Trim() + " " + value);
                        break;

                    default:
                        value = (label + " " + value);
                        value = Util.TextAlign(value, wAux, align);
                        break;
                    }

                    line += value;
                }

                if (line.Length > this.Width)
                {
                    throw new Exception(String.Format("La linea '{0}' L={1} supera al ancho ({2}) del formato",
                                                      line, line.Length, this.Width));
                }

                this.Format.AppendLine(line);
            }
            catch { throw; }
        }
예제 #2
0
        public void AddMuliLine(Field field)
        {
            try
            {
                string      label = field.Label ?? "";
                string      value = field.Text ?? "\r\n";
                Util.eAlign align = (Util.eAlign)field.Align;
                int         width = (field.Width <= 0) ? this.Width : field.Width;

                string lines = Util.MultilineText((label + " " + value), width, align);
                this.Format.Append(lines);
            }
            catch { throw; }
        }