private void FormDeviceInfoEdit_Load(object sender, EventArgs e) { //load the device file into the window try { DeviceInfoFileParser devInfoFileParser = new DeviceInfoFileParser(); devInfoFileParser.parseDeviceFile("");//file in root directory of app if (devInfoFileParser.doesFileHaveErrors() == false) { //add entrys to the drop down List <DeviceInfo> devList = devInfoFileParser.getDeviceList(); this.dataGridViewDeviceList.Rows.Clear(); this.dataGridViewDeviceList.Columns.Clear(); this.dataGridViewDeviceList.Columns.Add("DeviceName", "Device Name"); this.dataGridViewDeviceList.Columns.Add("DeviceSize", "Device Size"); for (int i = 0; i < devList.Count; i++) { this.dataGridViewDeviceList.Rows.Add(); this.dataGridViewDeviceList.Rows[i].Cells[0].Value = devList[i].getDeviceName(); this.dataGridViewDeviceList.Rows[i].Cells[1].Value = devList[i].getDeviceSize() + ""; } } else { } } catch { } }
private void loadDeviceFile() { //Load the Device List from file if (DeviceInfoFileParser.fileExists() == true) { this.richTextBoxTerm.AppendText("#Device info file found\n"); } else { this.richTextBoxTerm.AppendText("#Device info file NOT found, creating default file\n"); DeviceInfoFileParser.makeDefaultFile("");//file in root directory of app this.richTextBoxTerm.AppendText("#Device info file created\n"); } //open file and add contends to the list devInfoFileParser = new DeviceInfoFileParser(); devInfoFileParser.parseDeviceFile("");//file in root directory of app if (devInfoFileParser.doesFileHaveErrors() == false) { //add entrys to the drop down List <DeviceInfo> devList = devInfoFileParser.getDeviceList(); this.comboBoxDeviceList.Items.Clear(); for (int i = 0; i < devList.Count; i++) { String itemStr = devList[i].getDeviceName() + " [" + devList[i].getDeviceSize() + "]"; this.comboBoxDeviceList.Items.Add(itemStr); } } else { this.richTextBoxTerm.AppendText("#Device file has errors, deleted it from the application root directory and restart the application\n"); } }
private void buttonOK_Click(object sender, EventArgs e) { DeviceInfoFileParser.makeFileFromDataGridView(this.dataGridViewDeviceList); this.Close(); }