public bool TryShowTab(string filepath, Variable currentVar = null) { try { foreach (var tab in from TabPage tab in _tabControl.TabPages let fileControl = tab.Controls.Find("FileControl", false) .FirstOrDefault(foundTab => foundTab is FileControl) as FileControl where fileControl != null && fileControl.CobolFile.FileReference.FilePath == filepath select tab) { _tabControl.SelectedTab = tab; Logger.Info("Switching to tab {0}: {1}", tab.TabIndex, tab.Text); if (currentVar != null) { CurrentFileControl.FindInCodeBox(currentVar.VariableName, false, false, false, true); } return(true); } return(false); } catch (Exception exception) { Logger.Error("Error trying to show tab {0}: {1}.", filepath, exception.Message); return(false); } }
public bool TryShowTab(string filepath, Variable currentVar = null, string lineText = null) { try { foreach (var tab in from TabPage tab in _tabControl.TabPages let fileControl = tab.Controls.Find("FileControl", false) .FirstOrDefault(foundTab => foundTab is FileControl) as FileControl where fileControl != null && fileControl.CobolFile.FileReference.FilePath == filepath select tab) { _tabControl.SelectedTab = tab; Logger.Info("Switching to tab {0}: {1}", tab.TabIndex, tab.Text); // Idea: Set codebox to line with named lineText and then search the variable name again to have only that marked. If the // text selection is not set to the given line, the first occurence of the given variable will be selected regardless which number // of appearance was meant to be selected. // This is not done here because functionality from the not yet merged fuzzy search branch is needed. // if (lineText != null) // CurrentFileControl.FindInCodeBox(lineText, false, false, false, true); if (lineText != null && currentVar != null) { CurrentFileControl.FindInCodeBoxAfterGivenString(currentVar.VariableName, lineText); } else if (currentVar != null) { CurrentFileControl.FindInCodeBox(currentVar.VariableName, false, false, false, true); } return(true); } return(false); } catch (Exception exception) { Logger.Error("Error trying to show tab {0}: {1}.", filepath, exception.Message); return(false); } }