private void 加载左片同名点坐标ToolStripMenuItem_Click(object sender, EventArgs e) { if (openFileDialog2.ShowDialog() == DialogResult.OK) { RF1 = new ReadFile(openFileDialog2.FileName); point_ori1 = new Point(RF1.pname, RF1.px, RF1.py); } }
internal static void LoadFromFiles(Database database, Label selectedFilesLabel, DataGridView dataGridView) { List <string> filenameList = new List <string>(); OpenFileDialog openFileDialog = new OpenFileDialog(); StringBuilder stringBuilder = new StringBuilder(); openFileDialog.Filter = "Data Types (*.json;*.xml;*.csv)|*.json;*.xml;*.csv"; openFileDialog.Multiselect = true; if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { foreach (String file in openFileDialog.FileNames) { filenameList.Add(file); stringBuilder.Append(" " + file.Substring(file.LastIndexOf('\\'))); } foreach (string fileName in filenameList) { FileInfo fileInfo = new FileInfo(fileName); switch (fileInfo.Extension) { case ".csv": List <Request> requestListCSV = new List <Request>(); ReadFile.ReadCSV(requestListCSV, fileName); foreach (Request request in requestListCSV) { database.AddRowToDatabase(request); } break; case ".xml": List <Request> requestListXML = new List <Request>(); ReadFile.ReadXML(requestListXML, fileName); foreach (Request request in requestListXML) { database.AddRowToDatabase(request); } break; case ".json": List <Request> requestListJSON = new List <Request>(); ReadFile.ReadJSON(requestListJSON, fileName); foreach (Request request in requestListJSON) { database.AddRowToDatabase(request); } break; default: break; } } dataGridView.Rows.Clear(); dataGridView.Refresh(); database.RefreshDatabase(dataGridView); } string selectedFiles = stringBuilder.ToString(); selectedFilesLabel.Text = "Selected files: " + selectedFiles; }