/// <summary> /// This method initializes the CodeEditorBox property /// </summary> /// <param name="codeEditorBox"></param> public void InitializeCodeEditorBox(SyntaxHighlightBox codeEditorBox) { // It is necessary to null check, because the tab removal causes the CodeEditorBox_Loaded event and this method //to be raised/called again. So when the CodeEditorBox is already initialized we do not need to do initialization again. if (CodeEditorBox == null) { CodeEditorBox = codeEditorBox; // Just remove a temporal element by index 0, because it is useless now TabItemsSource.RemoveAt(0); } }
/// <summary> /// Removes the tab associated with the tabInfo parameter from the source list if the list contains more than 1 item /// </summary> /// <param name="tabInfo"></param> public void RemoveTab(TabInfo tabInfo) { if (TabItemsSource.Count == 1) { return; } var windowResult = ShowTabRemovalConfirmationWindow(tabInfo); if (windowResult != MessageBoxResult.Cancel) { TabItemsSource.Remove(tabInfo); } }
/// <summary> /// This method adds a new TabInfo object to the TabItemSource collection when there is no equal object, otherwise /// this method selects a tab based on tabInfo object that already exists in the source collection /// </summary> /// <param name="tabInfo">A TabInfo object on which the new tab should be based</param> private void AddOrSelectTab(TabInfo tabInfo) { // Search for item with the same LinkedFilePath and ShaderCode, foundItem will be null when there is no item with //the same file path and shader code in the source list var foundItem = TabItemsSource.Where(i => i.LinkedFilePath == tabInfo.LinkedFilePath && i.LinkedFilePath != string.Empty).FirstOrDefault(); if (foundItem != null) { SelectTabItemByInfo(foundItem); } else { TabItemsSource.Add(tabInfo); } }
/// <summary> /// Makes the tab associated with the tabinfo parameter an active tab /// </summary> /// <param name="tabInfo"></param> public void SelectTabItemByInfo(TabInfo tabInfo) { EditorTabControl.SelectedIndex = TabItemsSource.IndexOf(tabInfo); }