private void AddNewTab(string FileName, string Suffix = "") { //Create a new LogTabPage and add it to the TabControl LogTabPage Page = new LogTabPage(FileName, Suffix); MainTabControl.TabPages.Add(Page); //Enable the controls ClearButton.Enabled = true; FreezeButton.Enabled = true; DeleteButton.Enabled = true; //Subscribe to the changed event Page.Watcher.Changed += new FileSystemEventHandler(Watcher_Changed); //Select the new page Page.Select(); }
private void DeleteTab(int i) { //Create a reference to the tab that will be deleted LogTabPage Page = (LogTabPage)MainTabControl.TabPages[i]; //Unsubscribe from the event Page.Watcher.Changed -= new FileSystemEventHandler(Watcher_Changed); //Remove the page from the TabControl MainTabControl.TabPages.Remove(Page); //Dispose the objects Page.Watcher.Dispose(); Page.Dispose(); //If there are no tabs left then disable the controls and clear the LastUpdatedLabel if (MainTabControl.TabCount == 0) { ClearButton.Enabled = false; FreezeButton.Enabled = false; DeleteButton.Enabled = false; LastUpdatedLabel.Text = ""; } }