private AAMVAID BuildID() { using (AAMVAIDBuilder builder = new AAMVAIDBuilder()) { builder.SetJurisdiction((AAMVAJurisdiction)_comboBoxJurisdiction.SelectedValue, _textBoxIIN.Text) .SetVersion(AAMVAVersion.Version2016) .SetJurisdictionVersion(_textBoxJurisdictionVersion.Text) .SetNumberOfEntries(_subfiles.Count); for (int i = 0; i < _subfiles.Count; i++) { SubfileSkeleton skeleton = _subfiles[i]; builder.SetSubfileType(i, skeleton.SubfileType, skeleton.SubfileTypeCode); if (skeleton.SubfileType == AAMVASubfileType.JurisdictionSpecific) { ICollection <string> keys = skeleton.DataElements.Keys; string[] keyArray = keys.ToArray <string>(); Array.Sort(keyArray); foreach (string elementID in keyArray) { builder.AddDataElementToSubfile(i, elementID, skeleton.DataElements[elementID].Value); } } else { foreach (KeyValuePair <string, AAMVADataElement> kvp in skeleton.DataElements) { builder.AddDataElementToSubfile(i, kvp.Key, kvp.Value.Value); } } } AAMVAID id = builder.Build(); return(id); } }
public int AddSubfile(AAMVASubfileType subfileType, string subfileTypeCode) { SubfileSkeleton subfileSkeleton = new SubfileSkeleton(); subfileSkeleton.SubfileType = subfileType; subfileSkeleton.SubfileTypeCode = subfileTypeCode; subfileSkeleton.DataElements = new Dictionary <string, AAMVADataElement>(); _subfiles.Add(subfileSkeleton); _textBoxNumEntries.Text = _subfiles.Count.ToString(); SubfileRowControl subfileRow = new SubfileRowControl(); subfileRow.ParentMainForm = this; subfileRow.SubfileIndex = _subfiles.Count - 1; subfileRow.Jurisdiction = ((AAMVAJurisdiction)_comboBoxJurisdiction.SelectedValue); subfileRow.SubfileType = subfileType; subfileRow.Dock = DockStyle.Top; _panelSubfiles.Controls.Add(subfileRow); _panelSubfiles.Controls.SetChildIndex(subfileRow, 0); EnableWriteButtons(); if (subfileType == AAMVASubfileType.DL || subfileType == AAMVASubfileType.ID) { DisableJurisdiction(); } //return the index return(_subfiles.Count - 1); }
public void RemoveSubfile(int subfileIndex) { SubfileSkeleton skeleton = _subfiles[subfileIndex]; if (skeleton.SubfileType == AAMVASubfileType.DL || skeleton.SubfileType == AAMVASubfileType.ID) { EnableJurisdiction(); } for (int i = 0; i < _panelSubfiles.Controls.Count; i++) { Control ctrl = _panelSubfiles.Controls[i]; if (ctrl is SubfileRowControl) { SubfileRowControl row = (SubfileRowControl)ctrl; if (skeleton.SubfileType == row.SubfileType) { _panelSubfiles.Controls.Remove(row); } } } _subfiles.RemoveAt(subfileIndex); foreach (Control ctrl in _panelSubfiles.Controls) { if (ctrl is SubfileRowControl) { SubfileRowControl row = (SubfileRowControl)ctrl; if (row.SubfileIndex >= subfileIndex) { row.SubfileIndex--; } } } _textBoxNumEntries.Text = _subfiles.Count.ToString(); if (_subfiles.Count < 1) { DisableWriteButtons(); } }