private List <TreeViewItemViewModel> CreateSearchFilePathsResult( FilePathSearchInfo searchInfo, DirectoryEntry fileResults, string description, string additionalWarning, bool expandAll) { Action <FileSystemEntryViewModel> setLineColumn = entry => { var fileEntry = entry as FileEntryViewModel; if (fileEntry != null && searchInfo.LineNumber >= 0) { fileEntry.SetLineColumn(searchInfo.LineNumber, searchInfo.ColumnNumber); } }; var rootNode = new RootTreeViewItemViewModel(StandarImageSourceFactory); var result = Enumerable .Empty <TreeViewItemViewModel>() .ConcatSingle(new TextItemViewModel(StandarImageSourceFactory, rootNode, description)) .ConcatSingle(new TextWarningItemViewModel(StandarImageSourceFactory, rootNode, additionalWarning), () => !string.IsNullOrEmpty(additionalWarning)) .Concat(fileResults.Entries.Select(x => FileSystemEntryViewModel.Create(this, rootNode, x, setLineColumn))) .ToList(); result.ForAll(rootNode.AddChild); TreeViewItemViewModel.ExpandNodes(result, expandAll); return(result); }
private List <TreeViewItemViewModel> CreateInfromationMessages(params string[] messages) { var result = new List <TreeViewItemViewModel>(); var rootNode = new RootTreeViewItemViewModel(StandarImageSourceFactory); foreach (var text in messages) { result.Add(new TextItemViewModel(StandarImageSourceFactory, rootNode, text)); } TreeViewItemViewModel.ExpandNodes(result, true); return(result); }
private List <TreeViewItemViewModel> CreateSearchCodeResultViewModel(DirectoryEntry searchResults, string description, bool expandAll) { var rootNode = new RootTreeViewItemViewModel(StandarImageSourceFactory); var result = new List <TreeViewItemViewModel> { new TextItemViewModel(StandarImageSourceFactory, rootNode, description) } .Concat(searchResults.Entries.Select(x => FileSystemEntryViewModel.Create(this, rootNode, x, _ => { }))) .ToList(); result.ForAll(rootNode.AddChild); TreeViewItemViewModel.ExpandNodes(result, expandAll); return(result); }
private List <TreeViewItemViewModel> CreateSearchCodeResultViewModel( DirectoryEntry searchResults, string description, string additionalWarning, bool expandAll) { var rootNode = new RootTreeViewItemViewModel(StandarImageSourceFactory); var result = Enumerable .Empty <TreeViewItemViewModel>() .ConcatSingle(new TextItemViewModel(StandarImageSourceFactory, rootNode, description)) .ConcatSingle(new TextWarningItemViewModel(StandarImageSourceFactory, rootNode, additionalWarning), () => !string.IsNullOrEmpty(additionalWarning)) .Concat(searchResults.Entries.Select(x => FileSystemEntryViewModel.Create(this, rootNode, x, _ => { }))) .ToList(); result.ForAll(rootNode.AddChild); TreeViewItemViewModel.ExpandNodes(result, expandAll); return(result); }
private List <TreeViewItemViewModel> CreateErrorResponseViewModel(ErrorResponse errorResponse) { var messages = new List <TreeViewItemViewModel>(); if (errorResponse.IsRecoverable()) { // For a recoverable error, the deepest exception contains the // "user friendly" error message. var rootError = new TextWarningItemViewModel( StandarImageSourceFactory, null, errorResponse.GetBaseError().Message); messages.Add(rootError); } else { var message = ViewModel.ServerHasStarted ? "There was an issue sending a request to the index server." : "There was an issue starting the index server."; // In case of non recoverable error, display a generic "user friendly" // message, with nested nodes for exception messages. var rootError = new TextErrorItemViewModel( StandarImageSourceFactory, null, message + " You may need to restart Visual Studio."); messages.Add(rootError); // Add all errors to the parent while (errorResponse != null) { rootError.Children.Add(new TextItemViewModel(StandarImageSourceFactory, rootError, errorResponse.Message)); errorResponse = errorResponse.InnerError; } } TreeViewItemViewModel.ExpandNodes(messages, true); return(messages); }