class CadCommand : Rtm.IExtensionApplication
{
/// <summary>
/// Gets or sets a value indicating whether this instance is lisp.
/// </summary>
/// <value>
/// <c>true</c> if this instance is lisp; otherwise, <c>false</c>.
/// </value>
internal static bool IsLisp { get; set; }
/// <summary>
/// LWSs the specified sender.
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="args">The <see cref="LispWillStartEventArgs"/> instance containing the event data.</param>
private void lws(object sender, LispWillStartEventArgs args)
{
IsLisp = true;
}
/// <summary>
/// Lwes the specified sender.
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="args">The <see cref="EventArgs"/> instance containing the event data.</param>
private void lwe(object sender, EventArgs args)
{
IsLisp = false;
}
/// <summary>
/// LispCancelled хз когда вызывается
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="args">The <see cref="EventArgs"/> instance containing the event data.</param>
private void lwc(object sender, EventArgs args)
{
IsLisp = false;
}
#region INIT
public void Initialize()
{
App.DocumentCollection dm = App.Application.DocumentManager;
Ed.Editor ed = dm.MdiActiveDocument.Editor;
dm.MdiActiveDocument.LispWillStart += new LispWillStartEventHandler(lws);
dm.MdiActiveDocument.LispEnded += new EventHandler(lwe);
dm.MdiActiveDocument.LispCancelled += new EventHandler(lwc);
}
public void Terminate()
{
// throw new System.NotImplementedException();
}
/// <summary>
/// Saves the mod.
/// </summary>
[Rtm.CommandMethod("drz_save")]
public void drzSaveMod()
{
saveMod.SaveMod();
}
}
public class saveMod
{
/// <summary>
/// Saves the mod.
/// </summary>
[CommandMethod("drz_save")]
public static void SaveMod()
{
Database db = HostApplicationServices.WorkingDatabase;
Document doc = Application.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
if (CadCommand.IsLisp)
{
ed.WriteMessage("Lisp started");
}
else
{
ed.WriteMessage("Lisp stopped");
}
}
}