private void visioEventSink_OnShapeDelete(object sender, EventArgs e)
{
Shape shape = (Shape)sender;
string strDeviceType = string.Empty;
string strDeviceName = string.Empty;
string strDeviceID = string.Empty;
strDeviceType = VisioUtility.GetShapeCellValue(shape, "設備類型");
strDeviceID = VisioUtility.GetShapeCellValue(shape, "GUID");
ShapeLogInfo logInfo = new ShapeLogInfo();
logInfo.ShapeType = strDeviceType;
logInfo.ShapeID = shape.NameID;
logInfo.ShapeName = VisioUtility.GetShapeCellValue(shape, "名稱");
if (shape.Application.IsUndoingOrRedoing)
{
ShapeLogInfo info = Portal.gc.gOperationLog.GetShape(strDeviceType, shape.NameID);
if (info != null)
{
strDeviceID = info.ShapeGuid;
}
}
logInfo.ShapeGuid = strDeviceID;
logInfo.ShapeStatus = ShapeStatus.DeleteShape;
Portal.gc.gOperationLog.AddLog(logInfo);
}
其中if (shape.Application.IsUndoingOrRedoing)是為了判斷該操作是否為Undo或者Redo導致的操作,如果是,我們獲取它之前Shape的GUID即可。
記錄了設備的這些修改信息,我們就可以在保存數據的時候,根據這些信息移除相關的關系,添加或者刪除相關的設備信息了,而且這些信息,對於我們記錄用戶的圖紙修訂記錄也是必須要做的事情。