void m_clearButton_Click(object sender, RoutedEventArgs e)
 {
     if (MessageBox.Show("Are you sure you want to values?", "Clear All Entries?", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
     {
         List <checkedData> addToGrid = new List <checkedData>();
         checkedData        add_new   = new checkedData();
         addToGrid.Add(add_new);
         m_dataGridChamleon.ItemsSource = addToGrid;
     }
 }
 void m_clearButton_Click(object sender, RoutedEventArgs e)
 {
     if (MessageBox.Show("Are you sure you want to values?", "Clear All Entries?", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
     {
         List<checkedData> addToGrid = new List<checkedData>();
         checkedData add_new = new checkedData();
         addToGrid.Add(add_new);
         m_dataGridChamleon.ItemsSource = addToGrid;
     }
 }
 void m_clearButton_Click(object sender, RoutedEventArgs e)
 {
     if (MessageBox.Show("Are you sure you want to clear all values?", "Clear All Entries?", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
     {
         if (allOneRecord)
         {
             m_recordCombo.ItemsSource = null;
             m_recordCombo.IsEnabled   = false;;
             m_sourcePathBox.Text      = "";
             string[]           column_names = { "Column Name", "80", "XML Path", "150" };
             List <checkedData> addToGrid    = new List <checkedData>();
             foreach (IDataTableField field in tableToEdit.DataTableDesigns.Items.FirstOrDefault().DataTableFields.Items)
             {
                 checkedData add_new = new checkedData()
                 {
                     Column_Name = field.Name
                 };
                 addToGrid.Add(add_new);
             }
             m_dataGridChamleon.ItemsSource = addToGrid;
             m_dataGridChamleon.ItemsSource = addToGrid;
         }
         else
         {
             string[]             column_names = { "Column Name", "80", "Source URL", "150", "XML Path", "150", "Triggerable?", "75", "Trigger ID", "150" };
             List <uncheckedData> addToGrid    = new List <uncheckedData>();
             foreach (IDataTableField field in tableToEdit.DataTableDesigns.Items.FirstOrDefault().DataTableFields.Items)
             {
                 uncheckedData add_new = new uncheckedData()
                 {
                     column_name = field.Name
                 };
                 addToGrid.Add(add_new);
             }
             m_dataGridChamleon.ItemsSource = addToGrid;
             m_dataGridChamleon.ItemsSource = addToGrid;
         }
     }
 }
        void m_recordBox_Checked(object sender, RoutedEventArgs e)
        {
            allOneRecord = true;
            m_sourcePathBox.IsEnabled     = true;
            m_recordCombo.IsEnabled       = true;
            m_rowNumber.Visibility        = System.Windows.Visibility.Hidden;
            m_numRowsTextBlock.Visibility = System.Windows.Visibility.Hidden;
            string[]           column_names = { "Column Name", "80", "XML Path", "150" };
            List <checkedData> addToGrid    = new List <checkedData>();

            foreach (IDataTableField field in tableToEdit.DataTableDesigns.Items.FirstOrDefault().DataTableFields.Items)
            {
                checkedData add_new = new checkedData()
                {
                    Column_Name = field.Name
                };
                addToGrid.Add(add_new);
            }
            m_dataGridChamleon.ItemsSource = addToGrid;
            int i = 0;

            foreach (DataGridColumn col in m_dataGridChamleon.Columns)
            {
                if (i > (column_names.Length - 1))
                {
                    break;
                }
                col.Header = column_names[i];
                if (i == 0)
                {
                    col.IsReadOnly = true;
                }
                col.Width = Convert.ToInt32(column_names[i + 1]);
                i        += 2;
            }
        }
        void form_Init(bool editing, string db_path)
        {
            m_recordCombo.ItemsSource = pos_xml_paths;
            /* Edit Init */
            if (editing)
            {
                SetConfig init_config = new SetConfig(db_path);
                ns_to_write  = init_config.ns_list;
                allOneRecord = init_config.allOneRecord;
                if (allOneRecord)
                {
                    m_sourcePathBox.IsEnabled     = true;
                    m_recordCombo.IsEnabled       = false;
                    m_sourcePathBox.Text          = init_config.sourceUrl;
                    m_recordCombo.Text            = init_config.itemOfRec;
                    m_rowNumber.Visibility        = System.Windows.Visibility.Hidden;
                    m_numRowsTextBlock.Visibility = System.Windows.Visibility.Hidden;
                    string[]           column_names = { "Column Name", "80", "XML Path", "150" };
                    List <checkedData> addToGrid    = new List <checkedData>();
                    int k = 0;
                    /* BOBNI: Here is an example of data being added to a DataTable, though in this configuration, it is being added from file */
                    foreach (IDataTableField field in tableToEdit.DataTableDesigns.Items.FirstOrDefault().DataTableFields.Items)
                    {
                        colConf this_config = init_config.cols[k];

                        /* BOBNI: We create a string that represents the XML path to the specified object: concat_path
                         * Concat_path is comprised of the item of record (a generic path for simplifying paths for end users)
                         * the 'description' which is the rest of the full XML path
                         * and possibly an attribute (attributes are not encoded into XML's text data field, instead the values are stored like an
                         * attribute of an HTML tag) */
                        string concat_path = init_config.itemOfRec + this_config.description + (String.IsNullOrEmpty(this_config.attrib) ? "" : ("@" + this_config.attrib));

                        /* BOBNI: Once we have the concatenated path, we add it the checkedData, data structure */
                        checkedData add_new = new checkedData()
                        {
                            Column_Name = field.Name, Xml_Path = concat_path
                        };

                        /* BOBNI: Your mission, should you choose to accept it, is to modify the CheckedData structure and this little segment of code so that, instead of
                         * a plain text path, the data table only displays a drop-down box that has been populated by following the URL, getting a list of all paths,
                         * and then eliminating all paths that do not start with the "item of record".
                         * An example of the drop-down box can be found at the comment labeled BOBEX */
                        addToGrid.Add(add_new);
                        k++;
                    }
                    m_dataGridChamleon.ItemsSource = addToGrid;
                    m_dataGridChamleon.ItemsSource = addToGrid;
                    int i = 0;
                    foreach (DataGridColumn col in m_dataGridChamleon.Columns)
                    {
                        if (i > (column_names.Length - 1))
                        {
                            break;
                        }
                        col.Header = column_names[i];
                        if (i == 0)
                        {
                            col.IsReadOnly = true;
                        }
                        col.Width = Convert.ToInt32(column_names[i + 1]);
                        i        += 2;
                    }
                    List <int> row_num_options = new List <int>();
                    for (int j = 1; j < 100; j++)
                    {
                        row_num_options.Add(j);
                    }
                    m_rowNumber.ItemsSource = row_num_options;
                }
                else
                {
                    /* Clean up from previous state */
                    m_sourcePathBox.IsEnabled     = false;
                    m_recordCombo.IsEnabled       = false;
                    m_recordBox.IsChecked         = false;
                    m_rowNumber.Visibility        = System.Windows.Visibility.Visible;
                    m_numRowsTextBlock.Visibility = System.Windows.Visibility.Visible;

                    /* Add names of data sources */
                    string[]             column_names = { "Column Name", "80", "Source URL", "150", "XML Path", "150", "Triggerable?", "75", "Trigger ID", "150" };
                    List <uncheckedData> addToGrid    = new List <uncheckedData>();
                    int k = 0;
                    foreach (IDataTableField field in tableToEdit.DataTableDesigns.Items.FirstOrDefault().DataTableFields.Items)
                    {
                        colConf       this_config = init_config.cols[k];
                        string        concat_path = this_config.description + (String.IsNullOrEmpty(this_config.attrib) ? "" : ("@" + this_config.attrib));
                        uncheckedData add_new     = new uncheckedData()
                        {
                            column_name    = field.Name,
                            source         = this_config.source,
                            xml_path       = concat_path,
                            is_triggerable = this_config.firesTrigger,
                            trigger_source = this_config.triggerID
                        };
                        k++;
                        addToGrid.Add(add_new);
                    }
                    m_dataGridChamleon.ItemsSource = addToGrid;
                    m_dataGridChamleon.ItemsSource = addToGrid;

                    /* Update column names */
                    int i = 0;
                    foreach (DataGridColumn col in m_dataGridChamleon.Columns)
                    {
                        if (i > (column_names.Length - 1))
                        {
                            break;
                        }
                        col.Header = column_names[i];
                        if (i == 0)
                        {
                            col.IsReadOnly = true;
                        }                                      // So that the column_name (which is determined by the table) cannot be altered
                        col.Width = Convert.ToInt32(column_names[i + 1]);
                        if (column_names[i] == "Triggerable")
                        {
                            col.IsReadOnly = true;
                        }
                        i += 2;
                    }
                    List <int> row_num_options = new List <int>();
                    for (int j = 1; j < 100; j++)
                    {
                        row_num_options.Add(j);
                    }
                    m_rowNumber.ItemsSource   = row_num_options;
                    m_rowNumber.SelectedIndex = init_config.numRows - 1;
                }
            }
            else /* Add Init */
            {
                allOneRecord = true;
                m_sourcePathBox.IsEnabled     = true;
                m_recordCombo.IsEnabled       = false;
                m_rowNumber.Visibility        = System.Windows.Visibility.Hidden;
                m_numRowsTextBlock.Visibility = System.Windows.Visibility.Hidden;
                string[]           column_names = { "Column Name", "80", "XML Path", "150" };
                List <checkedData> addToGrid    = new List <checkedData>();
                foreach (IDataTableField field in tableToEdit.DataTableDesigns.Items.FirstOrDefault().DataTableFields.Items)
                {
                    checkedData add_new = new checkedData()
                    {
                        Column_Name = field.Name
                    };
                    addToGrid.Add(add_new);
                }
                m_dataGridChamleon.ItemsSource = addToGrid;
                m_dataGridChamleon.ItemsSource = addToGrid;
                int i = 0;
                foreach (DataGridColumn col in m_dataGridChamleon.Columns)
                {
                    if (i > (column_names.Length - 1))
                    {
                        break;
                    }
                    col.Header = column_names[i];
                    if (i == 0)
                    {
                        col.IsReadOnly = true;
                    }
                    col.Width = Convert.ToInt32(column_names[i + 1]);
                    i        += 2;
                }
                List <int> row_num_options = new List <int>();
                for (int j = 1; j < 100; j++)
                {
                    row_num_options.Add(j);
                }
                m_rowNumber.ItemsSource = row_num_options;
            }
        }
        void form_Init(bool editing, string db_path)
        {
            m_recordCombo.ItemsSource = pos_xml_paths;
            /* Edit Init */
            if (editing)
            {
                SetConfig init_config = new SetConfig(db_path);
                ns_to_write = init_config.ns_list;
                allOneRecord = init_config.allOneRecord;
                if (allOneRecord)
                {
                    m_sourcePathBox.IsEnabled = true;
                    m_recordCombo.IsEnabled = false;
                    m_sourcePathBox.Text = init_config.sourceUrl;
                    m_recordCombo.Text = init_config.itemOfRec;
                    m_rowNumber.Visibility = System.Windows.Visibility.Hidden;
                    m_numRowsTextBlock.Visibility = System.Windows.Visibility.Hidden;
                    string[] column_names = { "Column Name", "80", "XML Path", "150" };
                    List<checkedData> addToGrid = new List<checkedData>();
                    int k = 0;
                    /* BOBNI: Here is an example of data being added to a DataTable, though in this configuration, it is being added from file */
                    foreach (IDataTableField field in tableToEdit.DataTableDesigns.Items.FirstOrDefault().DataTableFields.Items)
                    {
                        colConf this_config = init_config.cols[k];
                        /* BOBNI: We create a string that represents the XML path to the specified object: concat_path
                         * Concat_path is comprised of the item of record (a generic path for simplifying paths for end users)
                         * the 'description' which is the rest of the full XML path
                         * and possibly an attribute (attributes are not encoded into XML's text data field, instead the values are stored like an
                         * attribute of an HTML tag) */
                        string concat_path = init_config.itemOfRec + this_config.description + (String.IsNullOrEmpty(this_config.attrib) ? "" : ("@" + this_config.attrib));

                        /* BOBNI: Once we have the concatenated path, we add it the checkedData, data structure */
                        checkedData add_new = new checkedData() { Column_Name = field.Name, Xml_Path = concat_path };

                        /* BOBNI: Your mission, should you choose to accept it, is to modify the CheckedData structure and this little segment of code so that, instead of
                         * a plain text path, the data table only displays a drop-down box that has been populated by following the URL, getting a list of all paths,
                         * and then eliminating all paths that do not start with the "item of record".
                         * An example of the drop-down box can be found at the comment labeled BOBEX */
                        addToGrid.Add(add_new);
                        k++;
                    }
                    m_dataGridChamleon.ItemsSource = addToGrid;
                    m_dataGridChamleon.ItemsSource = addToGrid;
                    int i = 0;
                    foreach (DataGridColumn col in m_dataGridChamleon.Columns)
                    {
                        if (i > (column_names.Length - 1)) { break; }
                        col.Header = column_names[i];
                        if (i == 0) { col.IsReadOnly = true; }
                        col.Width = Convert.ToInt32(column_names[i + 1]);
                        i += 2;
                    }
                    List<int> row_num_options = new List<int>();
                    for (int j = 1; j < 100; j++)
                    {
                        row_num_options.Add(j);
                    }
                    m_rowNumber.ItemsSource = row_num_options;
                }
                else
                {
                    /* Clean up from previous state */
                    m_sourcePathBox.IsEnabled = false;
                    m_recordCombo.IsEnabled = false;
                    m_recordBox.IsChecked = false;
                    m_rowNumber.Visibility = System.Windows.Visibility.Visible;
                    m_numRowsTextBlock.Visibility = System.Windows.Visibility.Visible;

                    /* Add names of data sources */
                    string[] column_names = { "Column Name", "80", "Source URL", "150", "XML Path", "150", "Triggerable?", "75", "Trigger ID", "150" };
                    List<uncheckedData> addToGrid = new List<uncheckedData>();
                    int k = 0;
                    foreach (IDataTableField field in tableToEdit.DataTableDesigns.Items.FirstOrDefault().DataTableFields.Items)
                    {
                        colConf this_config = init_config.cols[k];
                        string concat_path = this_config.description + (String.IsNullOrEmpty(this_config.attrib) ? "" : ("@" + this_config.attrib));
                        uncheckedData add_new = new uncheckedData()
                        {
                            column_name = field.Name,
                            source = this_config.source,
                            xml_path = concat_path,
                            is_triggerable = this_config.firesTrigger,
                            trigger_source = this_config.triggerID
                        };
                        k++;
                        addToGrid.Add(add_new);
                    }
                    m_dataGridChamleon.ItemsSource = addToGrid;
                    m_dataGridChamleon.ItemsSource = addToGrid;

                    /* Update column names */
                    int i = 0;
                    foreach (DataGridColumn col in m_dataGridChamleon.Columns)
                    {
                        if (i > (column_names.Length - 1)) { break; }
                        col.Header = column_names[i];
                        if (i == 0) { col.IsReadOnly = true; } // So that the column_name (which is determined by the table) cannot be altered
                        col.Width = Convert.ToInt32(column_names[i + 1]);
                        if (column_names[i] == "Triggerable") { col.IsReadOnly = true; }
                        i += 2;
                    }
                    List<int> row_num_options = new List<int>();
                    for (int j = 1; j < 100; j++)
                    {
                        row_num_options.Add(j);
                    }
                    m_rowNumber.ItemsSource = row_num_options;
                    m_rowNumber.SelectedIndex = init_config.numRows - 1;
                }
            }
            else /* Add Init */
            {
                allOneRecord = true;
                m_sourcePathBox.IsEnabled = true;
                m_recordCombo.IsEnabled = false;
                m_rowNumber.Visibility = System.Windows.Visibility.Hidden;
                m_numRowsTextBlock.Visibility = System.Windows.Visibility.Hidden;
                string[] column_names = { "Column Name", "80", "XML Path", "150" };
                List<checkedData> addToGrid = new List<checkedData>();
                foreach (IDataTableField field in tableToEdit.DataTableDesigns.Items.FirstOrDefault().DataTableFields.Items)
                {
                    checkedData add_new = new checkedData() { Column_Name = field.Name };
                    addToGrid.Add(add_new);
                }
                m_dataGridChamleon.ItemsSource = addToGrid;
                m_dataGridChamleon.ItemsSource = addToGrid;
                int i = 0;
                foreach (DataGridColumn col in m_dataGridChamleon.Columns)
                {
                    if (i > (column_names.Length - 1)) { break; }
                    col.Header = column_names[i];
                    if (i == 0) { col.IsReadOnly = true; }
                    col.Width = Convert.ToInt32(column_names[i + 1]);
                    i += 2;
                }
                List<int> row_num_options = new List<int>();
                for (int j = 1; j < 100; j++)
                {
                    row_num_options.Add(j);
                }
                m_rowNumber.ItemsSource = row_num_options;
            }
        }
 void m_recordBox_Checked(object sender, RoutedEventArgs e)
 {
     allOneRecord = true;
     m_sourcePathBox.IsEnabled = true;
     m_recordCombo.IsEnabled = true;
     m_rowNumber.Visibility = System.Windows.Visibility.Hidden;
     m_numRowsTextBlock.Visibility = System.Windows.Visibility.Hidden;
     string[] column_names = { "Column Name", "80", "XML Path", "150" };
     List<checkedData> addToGrid = new List<checkedData>();
     foreach (IDataTableField field in tableToEdit.DataTableDesigns.Items.FirstOrDefault().DataTableFields.Items)
     {
         checkedData add_new = new checkedData() { Column_Name = field.Name };
         addToGrid.Add(add_new);
     }
     m_dataGridChamleon.ItemsSource = addToGrid;
     int i = 0;
     foreach (DataGridColumn col in m_dataGridChamleon.Columns)
     {
         if (i > (column_names.Length - 1)) { break; }
         col.Header = column_names[i];
         if (i == 0) { col.IsReadOnly = true; }
         col.Width = Convert.ToInt32(column_names[i + 1]);
         i += 2;
     }
 }
        void m_clearButton_Click(object sender, RoutedEventArgs e)
        {
            if (MessageBox.Show("Are you sure you want to clear all values?", "Clear All Entries?", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
            {

                if (allOneRecord)
                {
                    m_recordCombo.ItemsSource = null;
                    m_recordCombo.IsEnabled = false; ;
                    m_sourcePathBox.Text = "";
                    string[] column_names = { "Column Name", "80", "XML Path", "150" };
                    List<checkedData> addToGrid = new List<checkedData>();
                    foreach (IDataTableField field in tableToEdit.DataTableDesigns.Items.FirstOrDefault().DataTableFields.Items)
                    {
                        checkedData add_new = new checkedData() { Column_Name = field.Name };
                        addToGrid.Add(add_new);
                    }
                    m_dataGridChamleon.ItemsSource = addToGrid;
                    m_dataGridChamleon.ItemsSource = addToGrid;
                }
                else
                {
                    string[] column_names = { "Column Name", "80", "Source URL", "150", "XML Path", "150", "Triggerable?", "75", "Trigger ID", "150" };
                    List<uncheckedData> addToGrid = new List<uncheckedData>();
                    foreach (IDataTableField field in tableToEdit.DataTableDesigns.Items.FirstOrDefault().DataTableFields.Items)
                    {
                        uncheckedData add_new = new uncheckedData() { column_name = field.Name };
                        addToGrid.Add(add_new);
                    }
                    m_dataGridChamleon.ItemsSource = addToGrid;
                    m_dataGridChamleon.ItemsSource = addToGrid;
                }

            }
        }