using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Internal.PropertyInspector;
using System.Runtime.InteropServices.ComTypes;
using ACPILib;
// This line is not mandatory, but improves loading performances
[assembly: CommandClass(typeof(Rivilis.OPMReactors))]
namespace Rivilis
{
public class OPMReactors
{
[CommandMethod("OPMReactorsStart")]
public void OPMReactorsStart()
{
Document doc = Application.DocumentManager.MdiActiveDocument;
if (doc == null) return;
Editor ed = doc.Editor;
PropertyInspectorEventManager pim = PropertyInspectorEventManager.Instance();
pim.propertyDialogInvoked += propertyDialogInvoked;
pim.propertyDialogDismissed += propertyDialogDismissed;
pim.propertyWillChange += propertyWillChange;
pim.propertyChanged += propertyChanged;
}
[CommandMethod("OPMReactorsStop")]
public void OPMReactorsStop()
{
PropertyInspectorEventManager pim = PropertyInspectorEventManager.Instance();
pim.propertyDialogInvoked -= propertyDialogInvoked;
pim.propertyDialogDismissed -= propertyDialogDismissed;
pim.propertyWillChange -= propertyWillChange;
pim.propertyChanged -= propertyChanged;
}
private void propertyChanged(object sender, PropertyInspectorEventArgs e)
{
Document doc = Application.DocumentManager.MdiActiveDocument;
if (doc == null) return;
Editor ed = doc.Editor;
ed.WriteMessage("\nProperty \"{0}\" Category = \"{1}\" Changed value = {2}",
((IAcPiPropertyIdentifier)e.Property).Name,
((IAcPiPropertyIdentifier)e.Property).Categories,
e.Value);
ed.PostCommandPrompt();
}
private void propertyWillChange(object sender, PropertyInspectorEventArgs e)
{
Document doc = Application.DocumentManager.MdiActiveDocument;
if (doc == null) return;
Editor ed = doc.Editor;
ed.WriteMessage("\nProperty \"{0}\" Category = \"{1}\" Will be change",
((IAcPiPropertyIdentifier)e.Property).Name,
((IAcPiPropertyIdentifier)e.Property).Categories);
ed.PostCommandPrompt();
}
private void propertyDialogInvoked(object sender, PropertyInspectorEventArgs e)
{
Document doc = Application.DocumentManager.MdiActiveDocument;
if (doc == null) return;
Editor ed = doc.Editor;
ed.WriteMessage("\nProperty \"{0}\" Category = \"{1}\" Dialog invoked",
((IAcPiPropertyIdentifier)e.Property).Name,
((IAcPiPropertyIdentifier)e.Property).Categories);
ed.PostCommandPrompt();
}
private void propertyDialogDismissed(object sender, PropertyInspectorEventArgs e)
{
Document doc = Application.DocumentManager.MdiActiveDocument;
if (doc == null) return;
Editor ed = doc.Editor;
ed.WriteMessage("\nProperty \"{0}\" Category = \"{1}\" Dialog dissmised",
((IAcPiPropertyIdentifier)e.Property).Name,
((IAcPiPropertyIdentifier)e.Property).Categories);
ed.PostCommandPrompt();
}
}
}