~halega/+junk/sharpdevelop

« back to all changes in this revision

Viewing changes to src/AddIns/Misc/HelpViewer/Source/Controls/SearchPadControl.xaml.cs

  • Committer: sk
  • Date: 2011-09-10 05:17:57 UTC
  • Revision ID: halega@halega.com-20110910051757-qfouz1llya9m6boy
4.1.0.7915 Release Candidate 1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
 
2
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
 
3
 
 
4
using System;
 
5
using System.Collections.Generic;
 
6
using System.Collections.ObjectModel;
 
7
using System.Text;
 
8
using System.Windows;
 
9
using System.Windows.Controls;
 
10
using System.Windows.Data;
 
11
using System.Windows.Documents;
 
12
using System.Windows.Input;
 
13
using System.Windows.Media;
 
14
using MSHelpSystem.Core;
 
15
 
 
16
namespace MSHelpSystem.Controls
 
17
{
 
18
        public partial class SearchPadControl : UserControl
 
19
        {
 
20
                public SearchPadControl()
 
21
                {
 
22
                        InitializeComponent();
 
23
                        searchCB.IsEnabled = Help3Environment.IsHelp3ProtocolRegistered;
 
24
                        searchCB.ItemsSource = searchTerms;
 
25
                }
 
26
 
 
27
                ObservableCollection<string> searchTerms = new ObservableCollection<string>();
 
28
 
 
29
                void SearchCBPreviewKeyUp(object sender, KeyEventArgs e)
 
30
                {
 
31
                        doSearch.IsEnabled = (Help3Environment.IsHelp3ProtocolRegistered && !string.IsNullOrEmpty(searchCB.Text));
 
32
 
 
33
                        if (e.Key == Key.Return || e.Key == Key.Enter)
 
34
                                DoSearchClicked(null, null);
 
35
                }
 
36
 
 
37
                void DoSearchClicked(object sender, RoutedEventArgs e)
 
38
                {
 
39
                        string term = searchCB.Text;
 
40
                        if (!string.IsNullOrEmpty(term)) {
 
41
                                searchCB.Text = "";
 
42
                                if (searchTerms.IndexOf(term) < 0) searchTerms.Insert(0,term);
 
43
                                else searchTerms.Move(searchTerms.IndexOf(term), 0);
 
44
                                DisplayHelp.Search(term);
 
45
                        }
 
46
                }
 
47
        }
 
48
}