private void abrirArchivoToolStripMenuItem_Click(object sender, EventArgs e) { using (var openFileDialog1 = new OpenFileDialog()) { openFileDialog1.Filter = "PyUsac files (*.pyusac)|*.pyusac|All files (*.*)|*.*"; openFileDialog1.Multiselect = true; openFileDialog1.FilterIndex = 0; openFileDialog1.RestoreDirectory = true; var dialogResult = openFileDialog1.ShowDialog(); if (dialogResult == DialogResult.OK) { string fileName, content; PyUsac.Ast.Base.PyPath pyPath; PyTabPage pyTabPage = null; foreach (var file in openFileDialog1.FileNames) { fileName = file; content = File.ReadAllText(fileName); pyPath = new PyUsac.Ast.Base.PyPath(fileName); pyTabPage = new PyTabPage(pyPath.GetPathName(), pyPath); pyTabPage.FastColoredTextBox.Text = content; tabControl2.TabPages.Add(pyTabPage); } if (pyTabPage != null) { tabControl2.SelectedTab = pyTabPage; } } } }
private void nuevoArToolStripMenuItem_Click(object sender, EventArgs e) { using (var saveFileDialog1 = new SaveFileDialog()) { Stream myStream; saveFileDialog1.Filter = "PyUsac files (*.pyusac)|*.pyusac|All files (*.*)|*.*"; saveFileDialog1.FilterIndex = 0; saveFileDialog1.RestoreDirectory = true; var dialogResult = saveFileDialog1.ShowDialog(); if (dialogResult == DialogResult.OK) { if ((myStream = saveFileDialog1.OpenFile()) != null) { var pyPath = new PyUsac.Ast.Base.PyPath(saveFileDialog1.FileName); var newPage = new PyTabPage(pyPath.GetPathName(), pyPath); tabControl2.TabPages.Add(newPage); tabControl2.SelectedTab = newPage; myStream.Close(); } } } }