From ca47896204482bf4a6979e3838bf7f09f61cebeb Mon Sep 17 00:00:00 2001
From: giy <giy@omp-system.ru>
Date: Fri, 02 Sep 2022 14:16:56 +0300
Subject: [PATCH] Обновление до версии 2.9.0

---
 QtVsTools.Package/Package/QtHelpLinkChooser.xaml.cs |   28 ++++++++++++++++++----------
 1 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/QtVsTools.Package/Package/QtHelpLinkChooser.xaml.cs b/QtVsTools.Package/Package/QtHelpLinkChooser.xaml.cs
index 290f966..8d71431 100644
--- a/QtVsTools.Package/Package/QtHelpLinkChooser.xaml.cs
+++ b/QtVsTools.Package/Package/QtHelpLinkChooser.xaml.cs
@@ -1,6 +1,6 @@
 /****************************************************************************
 **
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2022 The Qt Company Ltd.
 ** Contact: https://www.qt.io/licensing/
 **
 ** This file is part of the Qt VS Tools.
@@ -32,10 +32,14 @@
 using System.Windows.Controls;
 using System.Windows.Data;
 using System.Windows.Input;
+using Microsoft.VisualStudio.PlatformUI;
+using Microsoft.VisualStudio.Shell;
+using Microsoft.VisualStudio.Shell.Interop;
+using QtVsTools.VisualStudio;
 
 namespace QtVsTools
 {
-    partial class QtHelpLinkChooser : VsToolsDialogWindow
+    partial class QtHelpLinkChooser : DialogWindow
     {
         public QtHelpLinkChooser()
         {
@@ -46,28 +50,32 @@
         }
 
         public string Link { get; set; }
+        public string SearchText { get; set; }
+
         public string Keyword { private get; set; }
         public Dictionary<string, string> Links { private get; set; }
 
         private void OnLoaded(object sender, RoutedEventArgs e)
         {
+            ThreadHelper.ThrowIfNotOnUIThread();
+
             var view = CollectionViewSource.GetDefaultView(linkListBox.ItemsSource);
             view.Filter = obj =>
             {
-                if (string.IsNullOrEmpty(searchBox.Text))
+                if (string.IsNullOrEmpty(SearchText))
                     return true;
 
                 var item = (KeyValuePair<string, string>)obj;
-                return item.Key.IndexOf(searchBox.Text, StringComparison.OrdinalIgnoreCase) >= 0;
+                return item.Key.IndexOf(SearchText, StringComparison.OrdinalIgnoreCase) >= 0;
             };
             linkListBox.SelectedIndex = 0;
-        }
 
-        private void OnSearchBox_TextChanged(object sender, TextChangedEventArgs e)
-        {
-            CollectionViewSource.GetDefaultView(linkListBox.ItemsSource).Refresh();
-            if (linkListBox.Items.Count == 1 || linkListBox.SelectedItem == null)
-                linkListBox.SelectedIndex = 0;
+            var factory = VsServiceProvider
+                .GetService<SVsWindowSearchHostFactory, IVsWindowSearchHostFactory>();
+            var host = factory.CreateWindowSearchHost(searchControlHost);
+
+            host.SetupSearch(new ListBoxSearch(linkListBox, value => SearchText = value));
+            host.Activate(); // set focus
         }
 
         private void OnListBoxItem_DoubleClick(object sender, MouseButtonEventArgs e)

--
Gitblit v1.9.1