Exemplo n.º 1
0
        private void GetFieldsFromXML(int itemSelected)
        {
            //clear the combobox
            comboboxFields.Items.Clear();

            //Build the dataset from the xml file
            AddRemoveField addRemoveField = new AddRemoveField();

            foreach (DataRow row in addRemoveField.buildDataSet(xmlFieldFile).Tables[0].Rows)
            {
                string comboField = row.ItemArray[0] + " - " + row.ItemArray[1] + " " + row.ItemArray[2];
                comboboxFields.Items.Add(comboField); //add the first column of data into the combo box
            }

            //decide which item to select in the combobox
            if (itemSelected == -1)                                            //we want the last element loaded
            {
                comboboxFields.SelectedIndex = comboboxFields.Items.Count - 1; //select the last item
            }
            else if (itemSelected == -2)                                       //we want the last field used before the program was closed
            {
                try
                {
                    ProgramSettings programStarted = new ProgramSettings();
                    comboboxFields.SelectedItem = programStarted.LoadSettings(dataPath, "LastSettings.xml");
                } catch //incase the field does not exist anymore
                {
                    comboboxFields.SelectedIndex = 0;
                }
            }
            else
            {
                comboboxFields.SelectedIndex = itemSelected; //load the first item
            }
        }
Exemplo n.º 2
0
        private void buttonAddField_Click(object sender, RoutedEventArgs e)
        {
            AddRemoveField addRemoveField = new AddRemoveField(); //add field class

            addRemoveField.addField(xmlFieldFile, textboxAddField.Text, textboxLatitude.Text, textboxLongitude.Text, textboxDate.Text, textboxTime.Text);
            //clear the textbox
            textboxAddField.Text = "";
            GetFieldsFromXML(-1); //reload the combobox with new xml data
        }