/// <summary> /// 打开一个文件 /// </summary> /// <param name="filePath">如果等于null就打开FileDialog选择文件</param> private void OpenFile(string filePath = null) { if (m_CSVForm != null && !m_CSVForm.IsDisposed) { m_BeforeCloseCSVFormEventType = BeforeCloseCSVFormEventType.OpenFile; m_BeforeCloaseCSVFormOpenFilePath = filePath; m_CSVForm.Close(); return; } if (filePath == null) { if (m_OpenCSVFileDialog.ShowDialog() == DialogResult.OK && m_OpenCSVFileDialog.FileNames.Length > 0) { filePath = m_OpenCSVFileDialog.FileName; } else { return; } } LoadFile(filePath); }
private void OnForm_FormClosing(object sender, FormClosingEventArgs e) { if (m_CSVForm != null && !m_CSVForm.IsDisposed) { m_BeforeCloseCSVFormEventType = BeforeCloseCSVFormEventType.CloseForm; m_CSVForm.Close(); e.Cancel = true; } }
public void OnCSVForm_FormClosed() { UpdateFormText(); switch (m_BeforeCloseCSVFormEventType) { case BeforeCloseCSVFormEventType.OpenFile: OpenFile(m_BeforeCloaseCSVFormOpenFilePath); break; case BeforeCloseCSVFormEventType.CloseForm: Close(); break; } m_BeforeCloseCSVFormEventType = BeforeCloseCSVFormEventType.None; }