public override TextImage GenerateTextImage() { RemoveToolTipAdorner(); // If the modelitem tree was not changed since last time we generated the text image, // return the original TextImage and set the StartIndex to StartIndexUnchangeMark // means VS should use their own index. if (!this.isModelTreeChanged) { textImage.StartLineIndex = StartIndexUnchangeMark; return textImage; } this.entries.Clear(); this.textImageIndexEntryMapping.Clear(); this.index = 0; IEnumerable<ModelItem> itemsToSearch = this.GetItemsOnDesigner(preOrder: true, excludeRoot: true, excludeErrorActivity: true, excludeExpression: true, includeOtherObjects: false); foreach (ModelItem item in itemsToSearch) { this.objectsOnDesinger.Add(item.GetCurrentValue()); } Selection selection = this.editingContext.Items.GetValue<Selection>(); int startIndex = StartIndexUnchangeMark; // If and only if root is selected, start search from the beginning. if (selection.SelectionCount == 1 && selection.PrimarySelection == modelService.Root) { startIndex = 0; } AddEntriesForArguments(selection, ref startIndex); foreach (ModelItem modelItem in itemsToSearch) { // Do this check to make sure we start from the topmost selected item. if (startIndex == StartIndexUnchangeMark) { if (selection.SelectedObjects.Contains(modelItem) && modelItem != this.lastNavigatedItem) { // set the search start index to the next location of the current focus. startIndex = index; } } // Add the DisplayName property first. ModelProperty displayNameProperty = modelItem.Properties[DisplayNamePropertyName]; if (displayNameProperty != null) { AddEntriesForProperty(displayNameProperty, modelItem, null); } foreach (ModelProperty modelProperty in modelItem.Properties) { if (!ShouldIgnore(modelProperty)) { AddEntriesForProperty(modelProperty, modelItem, null); } } AddEntriesForVariables(modelItem); } AddBrowsableProperties(this.modelService.Root); List<string> searchableTexts = new List<string>(); int textImageIndex = 0; foreach (SearchableEntry entry in entries) { string text = entry.Text; if (text == null) { text = string.Empty; } foreach (string line in text.Split(new string[] { Environment.NewLine, "\n", "\r" }, StringSplitOptions.RemoveEmptyEntries)) { this.textImageIndexEntryMapping.Add(textImageIndex, entry); searchableTexts.Add(line); textImageIndex++; } } textImage = new TextImage() { StartLineIndex = startIndex, Lines = searchableTexts }; this.isModelTreeChanged = false; return textImage; }
public override TextImage GenerateTextImage() { RemoveToolTipAdorner(); // If the modelitem tree was not changed since last time we generated the text image, // return the original TextImage and set the StartIndex to StartIndexUnchangeMark // means VS should use their own index. if (!this.isModelTreeChanged) { textImage.StartLineIndex = StartIndexUnchangeMark; return(textImage); } this.entries.Clear(); this.textImageIndexEntryMapping.Clear(); this.index = 0; IEnumerable <ModelItem> itemsToSearch = this.GetItemsOnDesigner(preOrder: true, excludeRoot: true, excludeErrorActivity: true, excludeExpression: true, includeOtherObjects: false); foreach (ModelItem item in itemsToSearch) { this.objectsOnDesinger.Add(item.GetCurrentValue()); } Selection selection = this.editingContext.Items.GetValue <Selection>(); int startIndex = StartIndexUnchangeMark; // If and only if root is selected, start search from the beginning. if (selection.SelectionCount == 1 && selection.PrimarySelection == modelService.Root) { startIndex = 0; } AddEntriesForArguments(selection, ref startIndex); foreach (ModelItem modelItem in itemsToSearch) { // Do this check to make sure we start from the topmost selected item. if (startIndex == StartIndexUnchangeMark) { if (selection.SelectedObjects.Contains(modelItem) && modelItem != this.lastNavigatedItem) { // set the search start index to the next location of the current focus. startIndex = index; } } // Add the DisplayName property first. ModelProperty displayNameProperty = modelItem.Properties[DisplayNamePropertyName]; if (displayNameProperty != null) { AddEntriesForProperty(displayNameProperty, modelItem, null); } foreach (ModelProperty modelProperty in modelItem.Properties) { if (!ShouldIgnore(modelProperty)) { AddEntriesForProperty(modelProperty, modelItem, null); } } AddEntriesForVariables(modelItem); } AddBrowsableProperties(this.modelService.Root); List <string> searchableTexts = new List <string>(); int textImageIndex = 0; foreach (SearchableEntry entry in entries) { string text = entry.Text; if (text == null) { text = string.Empty; } foreach (string line in text.Split(new string[] { Environment.NewLine, "\n", "\r" }, StringSplitOptions.RemoveEmptyEntries)) { this.textImageIndexEntryMapping.Add(textImageIndex, entry); searchableTexts.Add(line); textImageIndex++; } } textImage = new TextImage() { StartLineIndex = startIndex, Lines = searchableTexts }; this.isModelTreeChanged = false; return(textImage); }