This commit is contained in:
Hugh Bellamy 2020-06-30 01:25:11 +01:00 коммит произвёл GitHub
Родитель a94d97cc72
Коммит 98a9e9c499
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
12 изменённых файлов: 252 добавлений и 164 удалений

Просмотреть файл

@ -0,0 +1,45 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
internal partial class Interop
{
internal static partial class Hhctl
{
public enum HH : uint
{
DISPLAY_TOPIC = 0x00,
HELP_FINDER = 0x00,
DISPLAY_TOC = 0x01,
DISPLAY_INDEX = 0x02,
DISPLAY_SEARCH = 0x03,
SET_WIN_TYPE = 0x04,
GET_WIN_TYPE = 0x05,
GET_WIN_HANDLE = 0x06,
ENUM_INFO_TYPE = 0x07,
SET_INFO_TYPE = 0x08,
SYNC = 0x09,
RESERVED1 = 0x0A,
RESERVED2 = 0x0B,
RESERVED3 = 0x0C,
KEYWORD_LOOKUP = 0x0D,
DISPLAY_TEXT_POPUP = 0x0E,
HELP_CONTEXT = 0x0F,
TP_HELP_CONTEXTMENU = 0x10,
TP_HELP_WM_HELP = 0x11,
CLOSE_ALL = 0x12,
ALINK_LOOKUP = 0x13,
GET_LAST_ERROR = 0x14,
ENUM_CATEGORY = 0x15,
ENUM_CATEGORY_IT = 0x16,
RESET_IT_FILTER = 0x17,
SET_INCLUSIVE_FILTER = 0x18,
SET_EXCLUSIVE_FILTER = 0x19,
INITIALIZE = 0x1C,
UNINITIALIZE = 0x1D,
SAFE_DISPLAY_TOPIC = 0x20,
PRETRANSLATEMESSAGE = 0xFD,
SET_GLOBAL_PROPERTY = 0xFC
}
}
}

Просмотреть файл

@ -0,0 +1,21 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
internal partial class Interop
{
internal static partial class Hhctl
{
public unsafe struct HH_ALINKW
{
public int cbStruct;
public BOOL fReserved;
public char* pszKeywords;
public char* pszUrl;
public char* pszMsgText;
public char* pszMsgTitle;
public char* pszWindow;
public BOOL fIndexOnFail;
}
}
}

Просмотреть файл

@ -0,0 +1,23 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
internal partial class Interop
{
internal static partial class Hhctl
{
public unsafe struct HH_FTS_QUERYW
{
public const int DEFAULT_PROXIMITY = -1;
public int cbStruct;
public BOOL fUniCodeStrings;
public char* pszSearchQuery;
public int iProximity;
public BOOL fStemmedSearch;
public BOOL fTitleOnly;
public BOOL fExecute;
public char* pszWindow;
}
}
}

Просмотреть файл

@ -0,0 +1,25 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Drawing;
internal partial class Interop
{
internal static partial class Hhctl
{
public unsafe struct HH_POPUPW
{
public int cbStruct;
public IntPtr hinst;
public uint idString;
public char* pszText;
public Point pt;
public int clrForeground;
public int clrBackground;
public RECT rcMargins;
public char* pszFont;
}
}
}

Просмотреть файл

@ -0,0 +1,38 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Runtime.InteropServices;
internal partial class Interop
{
internal static partial class Hhctl
{
[DllImport(Libraries.Hhctrl, CharSet = CharSet.Unicode, ExactSpelling = true)]
public static extern int HtmlHelpW(IntPtr hwndCaller, string pszFile, HH uCommand, IntPtr dwData);
public static int HtmlHelpW(HandleRef hwndCaller, string pszFile, HH uCommand, IntPtr dwData)
{
int result = HtmlHelpW(hwndCaller.Handle, pszFile, uCommand, dwData);
GC.KeepAlive(hwndCaller.Wrapper);
return result;
}
public static unsafe int HtmlHelpW(HandleRef hwndCaller, string pszFile, HH uCommand, string data)
{
fixed (char* dwData = data)
{
return HtmlHelpW(hwndCaller, pszFile, uCommand, (IntPtr)(void*)dwData);
}
}
public static unsafe int HtmlHelpW<T>(HandleRef hwndCaller, string pszFile, HH uCommand, ref T data) where T : unmanaged
{
fixed (void* dwData = &data)
{
return HtmlHelpW(hwndCaller, pszFile, uCommand, (IntPtr)dwData);
}
}
}
}

Просмотреть файл

@ -9,6 +9,7 @@ internal static partial class Interop
public const string Comctl32 = "comctl32.dll";
public const string Comdlg32 = "comdlg32.dll";
public const string Gdi32 = "gdi32.dll";
public const string Hhctrl = "hhctrl.ocx";
public const string Imm32 = "imm32.dll";
public const string Kernel32 = "kernel32.dll";
public const string NtDll = "ntdll.dll";

Просмотреть файл

@ -0,0 +1,15 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Runtime.InteropServices;
using System.Text;
internal static partial class Interop
{
internal static partial class Kernel32
{
[DllImport(Libraries.Kernel32, ExactSpelling = true, SetLastError = true, CharSet = CharSet.Unicode)]
public unsafe static extern uint GetShortPathNameW(string lpszLongPath, char* lpszShortPath, uint cchBuffer);
}
}

Просмотреть файл

@ -8,7 +8,6 @@ namespace System
{
public const string Comdlg32 = "comdlg32.dll";
public const string Gdi32 = "gdi32.dll";
public const string Hhctrl = "hhctrl.ocx";
public const string Kernel32 = "kernel32.dll";
public const string User32 = "user32.dll";
}

Просмотреть файл

@ -93,50 +93,6 @@ namespace System.Windows.Forms
public const string WinFormFrameworkId = "WinForm";
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public class HH_AKLINK
{
internal int cbStruct = Marshal.SizeOf<HH_AKLINK>();
internal bool fReserved = false;
internal string? pszKeywords = null;
internal string? pszUrl = null;
internal string? pszMsgText = null;
internal string? pszMsgTitle = null;
internal string? pszWindow = null;
internal bool fIndexOnFail = false;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public class HH_POPUP
{
internal int cbStruct = Marshal.SizeOf<HH_POPUP>();
internal IntPtr hinst = IntPtr.Zero;
internal int idString = 0;
internal IntPtr pszText;
internal Point pt;
internal int clrForeground = -1;
internal int clrBackground = -1;
internal RECT rcMargins = new RECT(-1, -1, -1, -1); // amount of space between edges of window and text, -1 for each member to ignore
internal string? pszFont = null;
}
public const int HH_FTS_DEFAULT_PROXIMITY = -1;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public class HH_FTS_QUERY
{
internal int cbStruct = Marshal.SizeOf<HH_FTS_QUERY>();
internal bool fUniCodeStrings = false;
[MarshalAs(UnmanagedType.LPStr)]
internal string? pszSearchQuery = null;
internal int iProximity = NativeMethods.HH_FTS_DEFAULT_PROXIMITY;
internal bool fStemmedSearch = false;
internal bool fTitleOnly = false;
internal bool fExecute = true;
[MarshalAs(UnmanagedType.LPStr)]
internal string? pszWindow = null;
}
public delegate IntPtr WndProc(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam);
public delegate int ListViewCompareCallback(IntPtr lParam1, IntPtr lParam2, IntPtr lParamSort);

Просмотреть файл

@ -1,30 +0,0 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Drawing;
using System.Runtime.InteropServices;
using System.Text;
using static Interop;
using static Interop.UxTheme;
namespace System.Windows.Forms
{
internal static class SafeNativeMethods
{
[DllImport(ExternDll.Hhctrl, CharSet = CharSet.Auto)]
public static extern int HtmlHelp(HandleRef hwndCaller, [MarshalAs(UnmanagedType.LPTStr)]string pszFile, int uCommand, int dwData);
[DllImport(ExternDll.Hhctrl, CharSet = CharSet.Auto)]
public static extern int HtmlHelp(HandleRef hwndCaller, [MarshalAs(UnmanagedType.LPTStr)]string pszFile, int uCommand, string dwData);
[DllImport(ExternDll.Hhctrl, CharSet = CharSet.Auto)]
public static extern int HtmlHelp(HandleRef hwndCaller, [MarshalAs(UnmanagedType.LPTStr)]string pszFile, int uCommand, [MarshalAs(UnmanagedType.LPStruct)]NativeMethods.HH_POPUP dwData);
[DllImport(ExternDll.Hhctrl, CharSet = CharSet.Auto)]
public static extern int HtmlHelp(HandleRef hwndCaller, [MarshalAs(UnmanagedType.LPTStr)]string pszFile, int uCommand, [MarshalAs(UnmanagedType.LPStruct)]NativeMethods.HH_FTS_QUERY dwData);
[DllImport(ExternDll.Hhctrl, CharSet = CharSet.Auto)]
public static extern int HtmlHelp(HandleRef hwndCaller, [MarshalAs(UnmanagedType.LPTStr)]string pszFile, int uCommand, [MarshalAs(UnmanagedType.LPStruct)]NativeMethods.HH_AKLINK dwData);
}
}

Просмотреть файл

@ -49,9 +49,6 @@ namespace System.Windows.Forms
[DllImport(ExternDll.Comdlg32, SetLastError = true, CharSet = CharSet.Auto)]
public static extern bool GetSaveFileName([In, Out] NativeMethods.OPENFILENAME_I ofn);
[DllImport(ExternDll.Kernel32, CharSet = CharSet.Auto)]
public static extern uint GetShortPathName(string lpszLongPath, StringBuilder lpszShortPath, uint cchBuffer);
[DllImport(ExternDll.Kernel32, CharSet = CharSet.Auto)]
public static extern void GetTempFileName(string tempDirName, string prefixName, int unique, StringBuilder sb);

Просмотреть файл

@ -4,6 +4,7 @@
#nullable disable
using System.Buffers;
using System.Diagnostics;
using System.Drawing;
using System.Globalization;
@ -11,6 +12,7 @@ using System.IO;
using System.Runtime.InteropServices;
using System.Text;
using static Interop;
using static Interop.Hhctl;
namespace System.Windows.Forms
{
@ -25,15 +27,6 @@ namespace System.Windows.Forms
internal static readonly TraceSwitch WindowsFormsHelpTrace;
#endif
private const int HH_DISPLAY_TOPIC = 0x0000;
private const int HH_DISPLAY_TOC = 0x0001; // not currently implemented
private const int HH_DISPLAY_INDEX = 0x0002; // not currently implemented
private const int HH_DISPLAY_SEARCH = 0x0003; // not currently implemented
private const int HH_KEYWORD_LOOKUP = 0x000D;
private const int HH_DISPLAY_TEXT_POPUP = 0x000E; // display string resource id or text in a popup window
private const int HH_HELP_CONTEXT = 0x000F; // display mapped numeric value in dwData
private const int HH_ALINK_LOOKUP = 0x0013; // ALink version of HH_KEYWORD_LOOKUP
private const int HTML10HELP = 2;
private const int HTMLFILE = 3;
@ -81,7 +74,7 @@ namespace System.Windows.Forms
/// </summary>
public static void ShowHelp(Control parent, string url, HelpNavigator command, object parameter)
{
Debug.WriteLineIf(Help.WindowsFormsHelpTrace.TraceVerbose, "Help:: ShowHelp");
Debug.WriteLineIf(WindowsFormsHelpTrace.TraceVerbose, "Help:: ShowHelp");
switch (GetHelpFileType(url))
{
@ -99,7 +92,7 @@ namespace System.Windows.Forms
/// </summary>
public static void ShowHelpIndex(Control parent, string url)
{
Debug.WriteLineIf(Help.WindowsFormsHelpTrace.TraceVerbose, "Help:: ShowHelpIndex");
Debug.WriteLineIf(WindowsFormsHelpTrace.TraceVerbose, "Help:: ShowHelpIndex");
ShowHelp(parent, url, HelpNavigator.Index, null);
}
@ -107,39 +100,31 @@ namespace System.Windows.Forms
/// <summary>
/// Displays a Help pop-up window.
/// </summary>
public static void ShowPopup(Control parent, string caption, Point location)
public unsafe static void ShowPopup(Control parent, string caption, Point location)
{
Debug.WriteLineIf(Help.WindowsFormsHelpTrace.TraceVerbose, "Help:: ShowPopup");
Debug.WriteLineIf(WindowsFormsHelpTrace.TraceVerbose, "Help:: ShowPopup");
NativeMethods.HH_POPUP pop = new NativeMethods.HH_POPUP();
// We have to marshal the string ourselves to prevent access violations.
IntPtr pszText = Marshal.StringToCoTaskMemAuto(caption);
try
var pop = new HH_POPUPW
{
cbStruct = sizeof(HH_POPUPW),
pt = location,
rcMargins = new RECT(-1, -1, -1, -1), // Ignore
clrForeground = -1, // Ignore
clrBackground = COLORREF.ColorToCOLORREF(SystemColors.Window)
};
fixed (char* pszText = caption)
{
pop.pszText = pszText;
pop.idString = 0;
pop.pt = location;
// Looks like a windows
pop.clrBackground = Color.FromKnownColor(KnownColor.Window).ToArgb() & 0x00ffffff;
ShowHTML10Help(parent, null, HelpNavigator.Topic, pop);
}
finally
{
Marshal.FreeCoTaskMem(pszText);
}
}
/// <summary>
/// Displays HTML 1.0 Help with the specified parameters
/// </summary>
private static void ShowHTML10Help(Control parent, string url, HelpNavigator command, object param)
private unsafe static void ShowHTML10Help(Control parent, string url, HelpNavigator command, object param)
{
Debug.WriteLineIf(Help.WindowsFormsHelpTrace.TraceVerbose, "Help:: ShowHTML10Help:: " + url + ", " + command.ToString("G") + ", " + param);
Debug.WriteLineIf(WindowsFormsHelpTrace.TraceVerbose, "Help:: ShowHTML10Help:: " + url + ", " + command.ToString("G") + ", " + param);
// See if we can get a full path and file name and if that will
// resolve the out of memory condition with file names that include spaces.
@ -155,18 +140,22 @@ namespace System.Windows.Forms
}
if (file == null || file.IsFile)
{
StringBuilder newPath = new StringBuilder();
string localPath = (file != null && file.IsFile) ? file.LocalPath : url;
// If this is a local path, convert it to a short path name. Pass 0 as the length the first time
uint requiredStringSize = UnsafeNativeMethods.GetShortPathName(localPath, newPath, 0);
// If this is a local path, convert it to a short path name. Pass 0 as the length the first time
uint requiredStringSize = Kernel32.GetShortPathNameW(localPath, null, 0);
if (requiredStringSize > 0)
{
//It's able to make it a short path. Happy day.
newPath.Capacity = (int)requiredStringSize;
requiredStringSize = UnsafeNativeMethods.GetShortPathName(localPath, newPath, requiredStringSize);
//If it can't make it a short path, just leave the path we had.
pathAndFileName = newPath.ToString();
// It's able to make it a short path.
char[] shortName = ArrayPool<char>.Shared.Rent((int)requiredStringSize);
fixed (char* pShortName = shortName)
{
requiredStringSize = Kernel32.GetShortPathNameW(localPath, pShortName, requiredStringSize);
// If it can't make it a short path, just leave the path we had.
pathAndFileName = new string(pShortName, 0, (int)requiredStringSize);
}
ArrayPool<char>.Shared.Return(shortName);
}
}
@ -183,41 +172,48 @@ namespace System.Windows.Forms
object htmlParam;
if (param is string stringParam)
{
int htmlCommand = MapCommandToHTMLCommand(command, stringParam, out htmlParam);
HH htmlCommand = MapCommandToHTMLCommand(command, stringParam, out htmlParam);
if (htmlParam is string stringHtmlParam)
{
SafeNativeMethods.HtmlHelp(handle, pathAndFileName, htmlCommand, stringHtmlParam);
HtmlHelpW(handle, pathAndFileName, htmlCommand, stringHtmlParam);
}
else if (htmlParam is int)
else if (htmlParam is int intParam)
{
SafeNativeMethods.HtmlHelp(handle, pathAndFileName, htmlCommand, (int)htmlParam);
HtmlHelpW(handle, pathAndFileName, htmlCommand, (IntPtr)intParam);
}
else if (htmlParam is NativeMethods.HH_FTS_QUERY)
else if (htmlParam is HH_FTS_QUERYW query)
{
SafeNativeMethods.HtmlHelp(handle, pathAndFileName, htmlCommand, (NativeMethods.HH_FTS_QUERY)htmlParam);
fixed (char* pszSearchQuery = stringParam)
{
query.pszSearchQuery = pszSearchQuery;
HtmlHelpW(handle, pathAndFileName, htmlCommand, ref query);
}
}
else if (htmlParam is NativeMethods.HH_AKLINK)
else if (htmlParam is HH_ALINKW aLink)
{
// According to MSDN documentation, we have to ensure that the help window is up
// before we call ALINK lookup.
//
SafeNativeMethods.HtmlHelp(NativeMethods.NullHandleRef, pathAndFileName, HH_DISPLAY_TOPIC, (string)null);
SafeNativeMethods.HtmlHelp(handle, pathAndFileName, htmlCommand, (NativeMethods.HH_AKLINK)htmlParam);
HtmlHelpW(IntPtr.Zero, pathAndFileName, HH.DISPLAY_TOPIC, IntPtr.Zero);
fixed (char* pszKeywords = stringParam)
{
aLink.pszKeywords = pszKeywords;
HtmlHelpW(handle, pathAndFileName, htmlCommand, ref aLink);
}
}
else
{
Debug.Fail("Cannot handle HTML parameter of type: " + htmlParam.GetType());
SafeNativeMethods.HtmlHelp(handle, pathAndFileName, htmlCommand, (string)param);
HtmlHelpW(handle, pathAndFileName, htmlCommand, (string)param);
}
}
else if (param == null)
{
SafeNativeMethods.HtmlHelp(handle, pathAndFileName, MapCommandToHTMLCommand(command, null, out htmlParam), 0);
HtmlHelpW(handle, pathAndFileName, MapCommandToHTMLCommand(command, null, out htmlParam), IntPtr.Zero);
}
else if (param is NativeMethods.HH_POPUP)
else if (param is HH_POPUPW popup)
{
SafeNativeMethods.HtmlHelp(handle, pathAndFileName, HH_DISPLAY_TEXT_POPUP, (NativeMethods.HH_POPUP)param);
HtmlHelpW(handle, pathAndFileName, HH.DISPLAY_TEXT_POPUP, ref popup);
}
else if (param.GetType() == typeof(int))
{
@ -230,7 +226,7 @@ namespace System.Windows.Forms
/// </summary>
private static void ShowHTMLFile(Control parent, string url, HelpNavigator command, object param)
{
Debug.WriteLineIf(Help.WindowsFormsHelpTrace.TraceVerbose, "Help:: ShowHTMLHelp:: " + url + ", " + command.ToString("G") + ", " + param);
Debug.WriteLineIf(WindowsFormsHelpTrace.TraceVerbose, "Help:: ShowHTMLHelp:: " + url + ", " + command.ToString("G") + ", " + param);
Uri file = Resolve(url);
@ -265,13 +261,13 @@ namespace System.Windows.Forms
handle = new HandleRef(null, User32.GetActiveWindow());
}
Debug.WriteLineIf(Help.WindowsFormsHelpTrace.TraceVerbose, "\tExecuting '" + file.ToString() + "'");
Debug.WriteLineIf(WindowsFormsHelpTrace.TraceVerbose, "\tExecuting '" + file.ToString() + "'");
Shell32.ShellExecuteW(handle, null, file.ToString(), null, null, User32.SW.NORMAL);
}
private static Uri Resolve(string partialUri)
{
Debug.WriteLineIf(Help.WindowsFormsHelpTrace.TraceVerbose, "Help:: Resolve " + partialUri);
Debug.WriteLineIf(WindowsFormsHelpTrace.TraceVerbose, "Help:: Resolve " + partialUri);
Debug.Indent();
Uri file = null;
@ -290,8 +286,8 @@ namespace System.Windows.Forms
if (file != null && file.Scheme == "file")
{
string localPath = NativeMethods.GetLocalPath(partialUri);
Debug.WriteLineIf(Help.WindowsFormsHelpTrace.TraceVerbose, "file, check for existence");
string localPath = file.LocalPath + file.Fragment;
Debug.WriteLineIf(WindowsFormsHelpTrace.TraceVerbose, "file, check for existence");
if (!File.Exists(localPath))
{
@ -303,7 +299,7 @@ namespace System.Windows.Forms
if (file == null)
{
Debug.WriteLineIf(Help.WindowsFormsHelpTrace.TraceVerbose, "try appbase relative");
Debug.WriteLineIf(WindowsFormsHelpTrace.TraceVerbose, "try appbase relative");
try
{
// try relative to AppBase...
@ -319,7 +315,7 @@ namespace System.Windows.Forms
if (file != null && file.Scheme == "file")
{
string localPath = file.LocalPath + file.Fragment;
Debug.WriteLineIf(Help.WindowsFormsHelpTrace.TraceVerbose, "file, check for existence");
Debug.WriteLineIf(WindowsFormsHelpTrace.TraceVerbose, "file, check for existence");
if (!File.Exists(localPath))
{
// clear - file isn't there...
@ -335,11 +331,11 @@ namespace System.Windows.Forms
private static int GetHelpFileType(string url)
{
Debug.WriteLineIf(Help.WindowsFormsHelpTrace.TraceVerbose, "Help:: GetHelpFileType " + url);
Debug.WriteLineIf(WindowsFormsHelpTrace.TraceVerbose, "Help:: GetHelpFileType " + url);
if (url == null)
{
Debug.WriteLineIf(Help.WindowsFormsHelpTrace.TraceVerbose, "\tnull, must be Html File");
Debug.WriteLineIf(WindowsFormsHelpTrace.TraceVerbose, "\tnull, must be Html File");
return HTMLFILE;
}
@ -347,81 +343,83 @@ namespace System.Windows.Forms
if (file == null || file.Scheme == "file")
{
Debug.WriteLineIf(Help.WindowsFormsHelpTrace.TraceVerbose, "\tfile");
Debug.WriteLineIf(WindowsFormsHelpTrace.TraceVerbose, "\tfile");
string ext = Path.GetExtension(file == null ? url : file.LocalPath + file.Fragment).ToLower(CultureInfo.InvariantCulture);
if (ext == ".chm" || ext == ".col")
{
Debug.WriteLineIf(Help.WindowsFormsHelpTrace.TraceVerbose, "\tchm or col, HtmlHelp 1.0 file");
Debug.WriteLineIf(WindowsFormsHelpTrace.TraceVerbose, "\tchm or col, HtmlHelp 1.0 file");
return HTML10HELP;
}
}
Debug.WriteLineIf(Help.WindowsFormsHelpTrace.TraceVerbose, "\tnot file, or odd extension, but be HTML");
Debug.WriteLineIf(WindowsFormsHelpTrace.TraceVerbose, "\tnot file, or odd extension, but be HTML");
return HTMLFILE;
}
/// <summary>
/// Maps one of the COMMAND_* constants to the HTML 1.0 Help equivalent.
/// </summary>
private static int MapCommandToHTMLCommand(HelpNavigator command, string param, out object htmlParam)
private unsafe static HH MapCommandToHTMLCommand(HelpNavigator command, string param, out object htmlParam)
{
htmlParam = param;
if ((string.IsNullOrEmpty(param)) &&
(command == HelpNavigator.AssociateIndex || command == HelpNavigator.KeywordIndex))
if (string.IsNullOrEmpty(param) && (command == HelpNavigator.AssociateIndex || command == HelpNavigator.KeywordIndex))
{
return HH_DISPLAY_INDEX;
return HH.DISPLAY_INDEX;
}
switch (command)
{
case HelpNavigator.Topic:
return HH_DISPLAY_TOPIC;
return HH.DISPLAY_TOPIC;
case HelpNavigator.TableOfContents:
return HH_DISPLAY_TOC;
return HH.DISPLAY_TOC;
case HelpNavigator.Index:
return HH_DISPLAY_INDEX;
return HH.DISPLAY_INDEX;
case HelpNavigator.Find:
{
NativeMethods.HH_FTS_QUERY ftsQuery = new NativeMethods.HH_FTS_QUERY
var ftsQuery = new HH_FTS_QUERYW
{
pszSearchQuery = param
cbStruct = sizeof(HH_FTS_QUERYW),
iProximity = HH_FTS_QUERYW.DEFAULT_PROXIMITY,
fExecute = BOOL.TRUE,
fUniCodeStrings = BOOL.TRUE
};
htmlParam = ftsQuery;
return HH_DISPLAY_SEARCH;
return HH.DISPLAY_SEARCH;
}
case HelpNavigator.TopicId:
{
try
{
htmlParam = int.Parse(param, CultureInfo.InvariantCulture);
return HH_HELP_CONTEXT;
return HH.HELP_CONTEXT;
}
catch
{
// default to just showing the index
return HH_DISPLAY_INDEX;
return HH.DISPLAY_INDEX;
}
}
case HelpNavigator.KeywordIndex:
case HelpNavigator.AssociateIndex:
{
NativeMethods.HH_AKLINK alink = new NativeMethods.HH_AKLINK
var alink = new HH_ALINKW
{
pszKeywords = param,
fIndexOnFail = true,
fReserved = false
cbStruct = sizeof(HH_ALINKW),
fIndexOnFail = BOOL.TRUE,
fReserved = BOOL.FALSE
};
htmlParam = alink;
return (command == HelpNavigator.KeywordIndex) ? HH_KEYWORD_LOOKUP : HH_ALINK_LOOKUP;
return command == HelpNavigator.KeywordIndex ? HH.KEYWORD_LOOKUP : HH.ALINK_LOOKUP;
}
default:
return (int)command;
return (HH)command;
}
}
}