private void OpenExistingFile(string pathToFile) { // Is this file already open? // foreach (FileEditorTab page in TabPages) { if (page.FileLocation == pathToFile) { return; } } // Read file & Open a new Tab // try { String txt = File.ReadAllText(pathToFile); FileEditorTab newPage = new FileEditorTab(); newPage.FileLocation = pathToFile; newPage.Content = txt; this.TabPages.Add(newPage); SelectedIndex = TabCount - 1; } catch (IOException ex) { Console.WriteLine("Unable to open file: {0}", ex.Message); } }
public void AddNewFile() { // Add a new FileEditorTab (which has a FastColoredTextbox inside it) FileEditorTab newPage = new FileEditorTab(); newPage.Padding = new System.Windows.Forms.Padding(3); this.TabPages.Add(newPage); SelectedIndex = TabCount - 1; }
public void CloseFile(FileEditorTab fileTab) { // TODO: Make AskToSaveFile so that it also has a CANCEL button // fileTab.AskToSaveFile(); TabPages.Remove(fileTab); if (TabCount == 0) { this.AddNewFile(); } }
private void OpenExistingFile(string pathToFile) { // Is this file already open? // foreach (FileEditorTab page in TabPages) { if (page.FileLocation == pathToFile) return; } // Read file & Open a new Tab // try { String txt = File.ReadAllText(pathToFile); FileEditorTab newPage = new FileEditorTab(); newPage.FileLocation = pathToFile; newPage.Content = txt; this.TabPages.Add(newPage); SelectedIndex = TabCount - 1; } catch (IOException ex) { Console.WriteLine("Unable to open file: {0}", ex.Message); } }