public override IInsightWindow ShowInsightWindow(IEnumerable<IInsightItem> items) { if (items == null) return null; var insightWindow = textEditor.ActiveInsightWindow; bool isNewWindow = false; if (insightWindow == null) { insightWindow = new SharpDevelopInsightWindow(this.TextEditor.TextArea); isNewWindow = true; } var adapter = new SharpDevelopInsightWindowAdapter(insightWindow); adapter.Items.AddRange(items); if (adapter.Items.Count > 0) { adapter.SelectedItem = adapter.Items[0]; } else { // don't open insight window when there are no items return null; } insightWindow.SetActiveAdapter(adapter, isNewWindow); if (isNewWindow) { textEditor.ShowInsightWindow(insightWindow); } return adapter; }
public override IInsightWindow ShowInsightWindow(IEnumerable <IInsightItem> items) { if (items == null) { return(null); } var insightWindow = textEditor.ActiveInsightWindow; bool isNewWindow = false; if (insightWindow == null) { insightWindow = new SharpDevelopInsightWindow(this.TextEditor.TextArea); isNewWindow = true; } var adapter = new SharpDevelopInsightWindowAdapter(insightWindow); adapter.Items.AddRange(items); if (adapter.Items.Count > 0) { adapter.SelectedItem = adapter.Items[0]; } else { // don't open insight window when there are no items return(null); } insightWindow.SetActiveAdapter(adapter, isNewWindow); if (isNewWindow) { textEditor.ShowInsightWindow(insightWindow); } return(adapter); }
public void SetActiveAdapter(SharpDevelopInsightWindowAdapter adapter, bool isNewWindow) { if (activeAdapter != null) { // tell the previous adapter that its window was closed, // but actually reuse the window for the new adapter activeAdapter.OnClosed(); } activeAdapter = adapter; this.Provider = adapter.Provider; if (!isNewWindow) { // reset insight window to initial state CloseAutomatically = true; StartOffset = EndOffset = this.TextArea.Caret.Offset; Dispatcher.BeginInvoke(DispatcherPriority.Loaded, new Action(SetPositionToStartOffset)); } }
public SDItemProvider(SharpDevelopInsightWindowAdapter insightWindow) { this.insightWindow = insightWindow; insightWindow.items.CollectionChanged += insightWindow_items_CollectionChanged; }