public AAMVADialogBox(AAMVAID id)
 {
     InitializeComponent();
     _id              = id;
     this.FormClosed += HandleClose;
     _infoDictionary  = (Dictionary <string, AAMVADataElementInfo>)AAMVADataElementInfo.RetrieveAll(id.Version);
     Populate();
 }
Пример #2
0
        private void AddDataElementRows(HashSet <string> values, int tabIndex)
        {
            _dataElementInfo = AAMVADataElementInfo.RetrieveAll(AAMVAVersion.Version2016);

            if (tabIndex == 0)
            {
                Label label = new Label();
                label.Text = "Per AAMVA CDS 2016 §D.12.5, mandatory data elements that call for variable length, alphabetical values will be filled with \"NONE\" if no value is provided.";
                label.Dock = DockStyle.Top;
                _tabControl.TabPages[tabIndex].Controls.Add(label);
                _tabControl.TabPages[tabIndex].Controls.SetChildIndex(label, 0);
            }

            if (tabIndex == 1)
            {
                _cbDHS                 = new CheckBox();
                _cbDHS.Text            = "DHS (REAL ID) Required Data Elements";
                _cbDHS.Dock            = DockStyle.Top;
                _cbDHS.CheckedChanged += (s, e) =>
                {
                    if (_cbDHS.Checked)
                    {
                        foreach (Control ctrl in _tabControl.TabPages[tabIndex].Controls)
                        {
                            if (ctrl is DataElementRowControl)
                            {
                                DataElementRowControl rowInner = (DataElementRowControl)ctrl;
                                if (DHSDataElements.Contains(rowInner.ElementID))
                                {
                                    rowInner.CheckBox.Checked = true;
                                }
                            }
                        }
                    }
                    else
                    {
                        bool shouldUncheckAll = true;
                        foreach (Control ctrl in _tabControl.TabPages[tabIndex].Controls)
                        {
                            if (ctrl is DataElementRowControl)
                            {
                                DataElementRowControl rowInner = (DataElementRowControl)ctrl;
                                if (DHSDataElements.Contains(rowInner.ElementID) && !rowInner.CheckBox.Checked)
                                {
                                    shouldUncheckAll = false;
                                }
                            }
                        }
                        if (shouldUncheckAll)
                        {
                            foreach (Control ctrl in _tabControl.TabPages[tabIndex].Controls)
                            {
                                if (ctrl is DataElementRowControl)
                                {
                                    DataElementRowControl rowInner = (DataElementRowControl)ctrl;
                                    if (DHSDataElements.Contains(rowInner.ElementID))
                                    {
                                        rowInner.CheckBox.Checked = false;
                                    }
                                }
                            }
                        }
                    }
                };
                _tabControl.TabPages[tabIndex].Controls.Add(_cbDHS);
                _tabControl.TabPages[tabIndex].Controls.SetChildIndex(_cbDHS, 0);
            }

            foreach (string elementID in values)
            {
                AAMVADataElementInfo info = _dataElementInfo[elementID];
                if ((info.ValidSubfileTypes & (int)_subfileSkeleton.SubfileType) == (int)_subfileSkeleton.SubfileType)
                {
                    DataElementRowControl row = new DataElementRowControl();
                    row.DataElementInfo          = _dataElementInfo;
                    row.Jurisdiction             = _jurisdiction;
                    row.ElementID                = elementID;
                    row.Dock                     = DockStyle.Top;
                    row.CheckBox.CheckedChanged += (s, e) =>
                    {
                        CheckBox cb = (CheckBox)s;
                        if (!cb.Checked && DHSDataElements.Contains(row.ElementID))
                        {
                            _cbDHS.Checked = false;
                        }
                    };
                    if (tabIndex == 1) //optional
                    {
                        row.CheckBox.Enabled = true;
                        row.CheckBox.Checked = false;
                    }
                    _tabControl.TabPages[tabIndex].Controls.Add(row);
                    _tabControl.TabPages[tabIndex].Controls.SetChildIndex(row, 0);
                }
            }
        }