using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
[CommandMethod("AddAppEvent")]
public void AddAppEvent()
{
Application.SystemVariableChanged +=
new Autodesk.AutoCAD.ApplicationServices.
SystemVariableChangedEventHandler(appSysVarChanged);
}
[CommandMethod("RemoveAppEvent")]
public void RemoveAppEvent()
{
Application.SystemVariableChanged -=
new Autodesk.AutoCAD.ApplicationServices.
SystemVariableChangedEventHandler(appSysVarChanged);
}
public void appSysVarChanged(object senderObj,
Autodesk.AutoCAD.ApplicationServices.
SystemVariableChangedEventArgs sysVarChEvtArgs)
{
object oVal = Application.GetSystemVariable(sysVarChEvtArgs.Name);
// Display a message box with the system variable name and the new value
Application.ShowAlertDialog(sysVarChEvtArgs.Name + " was changed." +
"\nNew value: " + oVal.ToString());
}