/// <summary> /// Open a file or reload the file if it has been opened. /// </summary> /// <param name="filePath">file to be opened or reloaded</param> public void OpenFileByReloading(string filePath) { EditorTabItem tab = TabPanels.FirstOrDefault(x => x.EditorTabContentViewModel.CurrentFilePath == filePath); if (tab != null) { tab.EditorTabContentViewModel.Load(filePath); OpeningTabEvent?.Invoke(tab); } else { FilesToLoad.Add(filePath); LoadNextFile(); } }
/// <summary> /// Open an editor tab. /// </summary> /// <param name="filePath"></param> /// <returns>true: new tab created</returns> public Tuple <bool, EditorTabItem> OpenEditorTab(string filePath) { bool isNewTab = false; EditorTabItem tab = TabPanels.FirstOrDefault(x => x.EditorTabContentViewModel.CurrentFilePath == filePath); if (tab == null) { tab = TabPanels.FirstOrDefault(x => x.EditorTabContentViewModel.IsEmptyFile()); if (tab != null) { tab.EditorTabContentViewModel.Load(filePath); AdjustTabOrder(tab); } else { isNewTab = true; tab = CreateNewTab(filePath); } } OpeningTabEvent?.Invoke(tab); m_AppSettings.LastUsedFile = filePath; return(Tuple.Create(isNewTab, tab)); }