I want to detect when a user is zooming in a locked viewport.
I have try this :
public static void SystemVariableChanged(object o, Autodesk.AutoCAD.ApplicationServices.SystemVariableChangedEventArgs e)
{
if (e.Name.Equals("CVPORT") && (Int16)AcadApp.GetSystemVariable("TILEMODE") == 0 && ((Int16)AcadApp.GetSystemVariable("CVPORT") == 1))
{
...
}
}
but it's not good because if the user click outside the viewport, it will also go in this statement and I don't want that.
Then I have try this code to distinguish if the user is in a viewport or not :
public static void SystemVariableChanged(object o, Autodesk.AutoCAD.ApplicationServices.SystemVariableChangedEventArgs e)
{
if (e.Name.Equals("CVPORT") && (Int16)AcadApp.GetSystemVariable("TILEMODE") == 0 && ((Int16)AcadApp.GetSystemVariable("CVPORT") == 1))
{
try
{
Document doc = AcadApp.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Editor ed = doc.Editor;
Viewport vp = (Viewport)ed.ActiveViewportId.GetObject(OpenMode.ForWrite);
MessageBox.Show("Someone is zooming in a locked viewport");
}
catch
{
MessageBox.Show("No viewport was selected.");
}
}
}
but it's not working since there is no active viewport when the zoom is done in a locked viewport.