#define AUTOCAD_NEWER_THAN_2012
#define AUTOCAD_NEWER_THAN_2014
using System;
using System.Reflection;
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;
using cad = Autodesk.AutoCAD.ApplicationServices.Application;
using Ap = Autodesk.AutoCAD.ApplicationServices;
using Db = Autodesk.AutoCAD.DatabaseServices;
using Ed = Autodesk.AutoCAD.EditorInput;
using Rt = Autodesk.AutoCAD.Runtime;
[assembly: Rt.CommandClass(typeof(Help.Commands))]
namespace Help
{
///<summary>
/// Help File
///</summary>
public sealed class Commands
{
#region PInvoke
#if AUTOCAD_NEWER_THAN_2012
const String fnc_location = "accore.dll";
#else
const String fnc_location = "acad.exe";
#endif
#if AUTOCAD_NEWER_THAN_2014
const String x86_Prefix = "_";
#else
const String x86_Prefix = "";
#endif
#region acedSetFunHelp
const String acedSetFunHelp_Name = "acedSetFunHelp";
[DllImport(fnc_location, CharSet = CharSet.Auto,
CallingConvention = CallingConvention.Cdecl,
private static extern Int32 acedSetFunHelp_x64(
String functionName,
String helpFile,
String helpTopic,
Int32 cmd);
[DllImport(fnc_location, CharSet = CharSet.Auto,
CallingConvention = CallingConvention.Cdecl,
private static extern Int32 acedSetFunHelp_x86(
String functionName,
String helpFile,
String helpTopic,
Int32 cmd);
internal static Int32 acedSetFunHelp(
String functionName,
String helpFile,
String helpTopic,
Int32 cmd)
{
if (IntPtr.Size == 4)
return acedSetFunHelp_x86(functionName,
helpFile,
helpTopic,
cmd);
else
return acedSetFunHelp_x64(functionName,
helpFile,
helpTopic,
cmd);
}
#endregion // acedSetFunHelp
#endregion // PInvoke
const String commandGroup = "MyCommand";
internal const String throughAcedSetFunHelp = "ThroughAcedSetFunHelp";
const String helpPageExtension = ".htm";
/*Place the Chm file where .NET dll is resourced*/
const String chmFileName = "MyHelp.chm";
internal static readonly String asm_location =
Path.GetDirectoryName(Assembly.GetExecutingAssembly()
.Location);
// chm-file is in the directory of dll-file.
internal static readonly String chmFileFullName =
Path.Combine(asm_location, chmFileName);
const String f1_msg =
"\nPress F1 for opening of " +
"help system.\n";
///<summary>
///<summary>
/// Registaration with calling acedSetFunHelp
///</summary>
[Rt.CommandMethod(commandGroup,
throughAcedSetFunHelp,
Rt.CommandFlags.Session
public void ThroughAcedSetFunHelp_Command()
{
Ap.Document doc =
cad.DocumentManager.MdiActiveDocument;
if (null == doc)
{
return;
}
string CmdName = "c:" +
throughAcedSetFunHelp.ToUpper();
acedSetFunHelp(CmdName, chmFileFullName, "", 0);
doc.Editor.GetPoint(f1_msg);
}
}
}