/// <summary> /// Add a checkbox field /// </summary> /// <param name="name_value">Name of field</param> /// <param name="field_value">Value of field</param> /// <param name="on_value">On value (checked)</param> /// <param name="off_value">Off value (uncheked)</param> public void AddCheckbox(string name_value, string field_value, string on_value, string off_value) { TemplateField _tfNewField = TemplateField.CreateCheckBox(name_value, field_value, on_value, off_value); _lstFields.Add(_tfNewField); }
/// <summary> /// Fill set of grouped fields /// </summary> /// <param name="group_index">Index of group</param> /// <param name="values">Values</param> /// <seealso cref="FieldsExpansion"/> /// <returns>True if new page is needed false otherwise</returns> public bool FillSet(int group_index, bool format, params object[] values) { if ((group_index >= _lstGroups.Count) || (group_index < 0)) { throw new IndexOutOfRangeException("Group index out of range"); } TemplateFieldsGroup _tfgGroup = _lstGroups[group_index]; int _values_idx = 0; int _nStep = 0; int _nElements = 0; foreach (string _sFieldNamePattern in _tfgGroup.FieldIds) { string _sFieldName; _sFieldName = String.Format(_sFieldNamePattern, _tfgGroup.CurrentIndex); TemplateField _tfField = null; _tfField = this[_sFieldName]; if (_tfField != null) { if ((_tfField.Expansion == TemplateFieldExpansion.Vertical) && (_tfField.Type == TemplateFieldType.Text) && (values[_values_idx] is string) && ((_tfField.SplitPolicy == SplitType.ByChar) || ((_tfField.SplitPolicy == SplitType.BySize) && (_tfField.Size < ((string)values[_values_idx]).Length)))) { // Overflow on row string[] _sValues = null; switch (_tfField.SplitPolicy) { case SplitType.BySize: _sValues = ((string)values[_values_idx]).Split(_tfField.Size); break; case SplitType.ByChar: _sValues = ((string)values[_values_idx]).Split(_tfField.SplitChar); break; default: throw new ArgumentException("SplitType " + _tfField.SplitPolicy + " not managed"); } if ((_tfgGroup.HighIndex - _tfgGroup.LowIndex) < _sValues.Length) { throw new SetTooHighException("Set will not fit in this page"); } if (_tfgGroup.CurrentIndex + _sValues.Length > _tfgGroup.HighIndex) { return(true); } _nElements = 0; foreach (string _sValue in _sValues) { string _sFieldId; _sFieldId = String.Format(_sFieldNamePattern, _tfgGroup.CurrentIndex + _nElements); if (format && !String.IsNullOrWhiteSpace(this[_sFieldId].Format)) { this[_sFieldId].Set(_sValue); } else { this[_sFieldId].Value = _sValue; } _nElements++; } //_nElements--; } else { if (_tfgGroup.CurrentIndex + 1 > _tfgGroup.HighIndex) { return(true); } if (format && !String.IsNullOrWhiteSpace(_tfField.Format)) { _tfField.Set(values[_values_idx]); } else if (values[_values_idx] is string) { _tfField.Value = (string)values[_values_idx]; } else { _tfField.Value = values[_values_idx].ToString(); } _nElements = 1; } } else { throw new ArgumentException("Field identifier unknown"); } _values_idx++; if (_nElements > _nStep) { _nStep = _nElements; } } _tfgGroup.CurrentIndex += _nStep; return(false); }
/// <summary> /// Add a text field /// </summary> /// <param name="name_value">Name of field</param> /// <param name="field_value">Value of field</param> /// <param name="format_value">Format of field</param> /// <param name="padding_value">Padding flag</param> /// <param name="size_value">Size of field</param> public void AddText(string name_value, string field_value, string format_value, bool padding_value, int size_value) { TemplateField _tfNewField = TemplateField.CreateText(name_value, field_value, format_value, padding_value, size_value); _lstFields.Add(_tfNewField); }