private async Task OpenFileAsync(string name) { var fileTab = _fileTabs.FirstOrDefault(z => string.Equals(z.Name, name, StringComparison.OrdinalIgnoreCase)); if (fileTab == null) { var tabPage = new TabPage(); SuspendLayout(); _tabControl.TabPages.Add(tabPage); fileTab = new FileTab(name, this, _fileManager, tabPage); await fileTab.InitializeAsync(); _fileTabs.Add(fileTab); _tabControl.SelectTab(tabPage); fileTab.SelectRtb(); ResumeLayout(); Opacity = 1; } else { _tabControl.SelectTab(fileTab.TabPage); } if (_fileTabs.Count > Env.Config.MaxTextEditorTabs) { await((FileTab)_tabControl.GetLastTabPageInOrder().Tag).SaveAndCloseAsync(); } }
public void RemoveFileTab(FileTab fileTab) { _tabControl.TabPages.Remove(fileTab.TabPage); _fileTabs.Remove(fileTab); if (_fileTabs.Count == 0) { Opacity = 0; } }