我觉得标题或问题已经够清楚了。我看到了有关EventSink的一些信息,但我发现它很难使用。任何提示?C# - Visio中是否有OnShapeMoved或OnShapeDeleted事件?
1
A
回答
0
我相信,你必须实现EvenSink以访问“ShapesDeleted”,即
(short)Microsoft.Office.Interop.Visio.VisEventCodes.visEvtCodeShapeDelete
上面的代码会帮助你,如果你正在寻找“BeforeShapeDelete”不“之后” ShapeDelete事件;)
3
Visio Primary Interop Assembly将这些事件公开为C#事件,因此您可以简单地将事件与代理挂钩。
看到这个简单的例子:
namespace VisioEventsExample
{
using System;
using Microsoft.Office.Interop.Visio;
class Program
{
public static void Main(string[] args)
{
Application app = new Application();
Document doc = app.Documents.Add("");
Page page = doc.Pages[1];
// Setup event handles for the events you are intrested in.
// Shape deleted is easy.
page.BeforeShapeDelete +=
new EPage_BeforeShapeDeleteEventHandler(onBeforeShapeDelete);
// To find out if a shape has moved hook the cell changed event
// and then check to see if PinX or PinY changed.
page.CellChanged +=
new EPage_CellChangedEventHandler(onCellChanged);
// In C# 4 for you can simply do this:
//
// page.BeforeShapeDelete += onBeforeShapeDelete;
// page.CellChanged += onCellChanged;
// Now wait for the events.
Console.WriteLine("Wait for events. Press any key to stop.");
Console.ReadKey();
}
// This will be called when a shape sheet cell for a
// shape on the page is changed. To know if the shape
// was moved see of the pin was changed. This will
// fire twice if the shape is moved horizontally and
// vertically.
private static void onCellChanged(Cell cell)
{
if (cell.Name == "PinX" || cell.Name == "PinY")
{
Console.WriteLine(
string.Format("Shape {0} moved", cell.Shape.Name));
}
}
// This will be called when a shape is deleted from the page.
private static void onBeforeShapeDelete(Shape shape)
{
Console.WriteLine(string.Format("Shape deleted {0}", shape.Name));
}
}
}
如果您还没有下载的Visio SDK你应该这样做。最近的SDK版本包含了许多有用的示例,其中包括一个名为“形状添加\删除事件”的示例。如果您拥有2010版本,可以转到“开始”菜单\程序\ Microsoft Office 2010开发人员资源\ Microsoft Visio 2010 SDK \ Microsoft Visio代码示例库来浏览示例。
相关问题
- 1. C++中是否有事件?
- 2. Visio VSTO中是否有任务窗格?
- 3. 是否有C#库的OnLoad事件?
- 4. 是否有document.onmodification事件或类似事件?
- 5. Visio选定页面事件
- 6. 在Visio中捕获FormulaChanged事件
- 7. 在C#中为Visio加载项拦截超链接事件
- 8. 是否有connect.static事件?
- 9. wx.DC行是否有事件?
- 10. Html.BeginForm是否有OnSuccess事件
- 11. pagerControls是否有onclick事件?
- 12. 是否有可能从Visio中的模具中获取图形?
- 13. NERDtree vim插件是否有autocmd事件?
- 14. C#中的事件或Lambdas?
- 15. BBC MicroPython中是否有事件回调?
- 16. Chrome中是否有模拟MozScrolledAreaChanged事件?
- 17. wpf中的TreeView ...是否有SelectedItemChanging事件?
- 18. 在Visio形状上双击事件
- 19. c#,列表框中是否有OnChange事件?
- 20. 是否有可能在UserControl中处理MasterPage事件(C#)
- 21. java和/或android事件是否并发?
- 22. 是或否分号在对象事件
- 23. visio insertlistmember in C#
- 24. Google Maps API v3:是否有setMap()事件的回调或事件侦听器?
- 25. QTP是否有任何事件处理程序或测试引擎事件?
- 26. 在C++(或C++ 11)中是否有类似于c#的东西?
- 27. Visio VBA函数查看在形状前面或后面是否有形状
- 28. dijit.TitlePane是否存在“onExpand”事件或类似事件?
- 29. Android MediaPlayer停止事件或类似事件是否存在?
- 30. ASP是否有当前事件?