Browse Source

simple Search pad for the Help system included

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@5866 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
Mathias Simmack 15 years ago
parent
commit
837f5a2770
  1. 11
      src/AddIns/Misc/HelpViewer/HelpViewer.addin
  2. 5
      src/AddIns/Misc/HelpViewer/HelpViewer.csproj
  3. 11
      src/AddIns/Misc/HelpViewer/Source/Commands.cs
  4. 14
      src/AddIns/Misc/HelpViewer/Source/Controls/Pads.cs
  5. 10
      src/AddIns/Misc/HelpViewer/Source/Controls/SearchPadControl.xaml
  6. 42
      src/AddIns/Misc/HelpViewer/Source/Controls/SearchPadControl.xaml.cs

11
src/AddIns/Misc/HelpViewer/HelpViewer.addin

@ -31,6 +31,12 @@ @@ -31,6 +31,12 @@
icon = "HtmlHelp2.16x16.Toc"
class = "MSHelpSystem.Controls.Help3TocPad"
defaultPosition = "Right, Hidden" />
<Pad id = "Help3TocPad"
category = "Help3"
title = "${res:AddIns.HelpViewer.SearchPadTitle}"
icon = "HtmlHelp2.16x16.Search"
class = "MSHelpSystem.Controls.Help3SearchPad"
defaultPosition = "Right, Hidden" />
</Path>
<Path name = "/SharpDevelop/Workbench/MainMenu/Help">
@ -39,5 +45,10 @@ @@ -39,5 +45,10 @@
label = "${res:AddIns.HelpViewer.DisplayContentsCommand}"
shortcut = "Control|Alt|F1"
insertbefore = "Separator1" />
<MenuItem id = "Help3DisplaySearchCommand"
class = "MSHelpSystem.Commands.DisplaySearch"
label = "${res:AddIns.HelpViewer.DisplaySearchCommand}"
shortcut = ""
insertbefore = "Separator1" />
</Path>
</AddIn>

5
src/AddIns/Misc/HelpViewer/HelpViewer.csproj

@ -66,6 +66,10 @@ @@ -66,6 +66,10 @@
<Compile Include="Configuration\AssemblyInfo.cs" />
<Compile Include="Source\BrowserScheme.cs" />
<Compile Include="Source\Controls\Pads.cs" />
<Compile Include="Source\Controls\SearchPadControl.xaml.cs">
<DependentUpon>SearchPadControl.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="Source\Controls\TocEntry.cs" />
<Compile Include="Source\Controls\TocPadControl.xaml.cs">
<DependentUpon>TocPadControl.xaml</DependentUpon>
@ -95,6 +99,7 @@ @@ -95,6 +99,7 @@
<Folder Include="Source\Controls" />
</ItemGroup>
<ItemGroup>
<Page Include="Source\Controls\SearchPadControl.xaml" />
<Page Include="Source\Controls\TocPadControl.xaml" />
<Page Include="Source\Help3OptionsPanel.xaml" />
</ItemGroup>

11
src/AddIns/Misc/HelpViewer/Source/Commands.cs

@ -48,5 +48,14 @@ namespace MSHelpSystem.Commands @@ -48,5 +48,14 @@ namespace MSHelpSystem.Commands
if (toc != null) toc.BringPadToFront();
}
}
}
}
public class DisplaySearch : AbstractMenuCommand
{
public override void Run()
{
PadDescriptor search = WorkbenchSingleton.Workbench.GetPad(typeof(Help3SearchPad));
if (search != null) search.BringPadToFront();
}
}
}

14
src/AddIns/Misc/HelpViewer/Source/Controls/Pads.cs

@ -17,4 +17,18 @@ namespace MSHelpSystem.Controls @@ -17,4 +17,18 @@ namespace MSHelpSystem.Controls
get { return toc; }
}
}
public class Help3SearchPad : AbstractPadContent
{
public Help3SearchPad()
{
}
SearchPadControl search = new SearchPadControl();
public override object Control
{
get { return search; }
}
}
}

10
src/AddIns/Misc/HelpViewer/Source/Controls/SearchPadControl.xaml

@ -0,0 +1,10 @@ @@ -0,0 +1,10 @@
<UserControl x:Class="MSHelpSystem.Controls.SearchPadControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:core="http://icsharpcode.net/sharpdevelop/core"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<StackPanel>
<TextBlock Text="{core:Localize AddIns.HelpViewer.SearchLookForLabel}" Margin="5,2,5,1" />
<TextBox IsEnabled="False" Name="searchWord" Margin="5,1,5,5" Padding="2" SelectionChanged="SearchWordSelectionChanged" PreviewKeyUp="SearchWordPreviewKeyUp" />
<Button IsEnabled="False" Name="doSearch" Content="{core:Localize AddIns.HelpViewer.SearchDoSearchButton}" Margin="5" Width="80" Padding="1" HorizontalAlignment="Left" Click="DoSearchClicked" />
</StackPanel>
</UserControl>

42
src/AddIns/Misc/HelpViewer/Source/Controls/SearchPadControl.xaml.cs

@ -0,0 +1,42 @@ @@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using MSHelpSystem.Core;
namespace MSHelpSystem.Controls
{
public partial class SearchPadControl : UserControl
{
public SearchPadControl()
{
InitializeComponent();
searchWord.IsEnabled = Help3Environment.IsHelp3ProtocolRegistered;
}
void SearchWordSelectionChanged(object sender, RoutedEventArgs e)
{
doSearch.IsEnabled = (Help3Environment.IsHelp3ProtocolRegistered && !string.IsNullOrEmpty(searchWord.Text));
}
void SearchWordPreviewKeyUp(object sender, KeyEventArgs e)
{
if (e.Key == Key.Return || e.Key == Key.Enter)
DoSearchClicked(null, null);
}
void DoSearchClicked(object sender, RoutedEventArgs e)
{
string search = (string)searchWord.Text;
if (string.IsNullOrEmpty(search)) {
throw new ArgumentNullException("search");
}
DisplayHelp.Search(search);
}
}
}
Loading…
Cancel
Save