private void OpenFile() { OpenFileDialog ofd = new OpenFileDialog(); ofd.InitialDirectory = @"C:\"; ofd.Title = "Browse Text Files"; ofd.CheckFileExists = true; ofd.CheckPathExists = true; ofd.DefaultExt = "txt"; ofd.Filter = "Text files (*.txt)|*.txt|Megazord files (*.mgzd)|*.mgzd"; ofd.FilterIndex = 2; ofd.RestoreDirectory = true; ofd.ReadOnlyChecked = true; ofd.ShowReadOnly = true; if (ofd.ShowDialog() == DialogResult.OK) { System.IO.StreamReader sr = new System.IO.StreamReader(ofd.FileName); //richTextBox.Text = sr.ReadToEnd(); fileOpenNow = ofd.FileName; string filenameWithoutPath = Path.GetFileName(ofd.FileName); var tabControl = new CustomTab(filenameWithoutPath, sr.ReadToEnd(), fileOpenNow, this); richTextBox = tabControl.getRichTextBox(); tabControl1.TabPages.Add(tabControl); tabControl1.SelectedIndex = tabControl1.TabCount - 1; showHideItens(); sr.Close(); } }
private void NewFile() { if (tabControl1.TabPages.Count <= 0) { fileOpenNow = ""; } var tabControl = new CustomTab("New file", "", "", this); richTextBox = tabControl.getRichTextBox(); tabControl1.TabPages.Add(tabControl); tabControl1.SelectedIndex = tabControl1.TabCount - 1; showHideItens(); }