C # Two device status tracking for Visio development

Source: Internet
Author: User

Discerning, in many cases, is very much needed, for example, if we improve a set of systems, to the Sichuan disaster relief funds to raise, procurement, distribution and other steps can be very discerning, I believe the world will be much quieter.

Similarly, for a program that uses Visio for two development, you need to know that the user has added those devices, removed those devices, and modified those devices, so that you can effectively control the entire system's data, otherwise "disaster relief" money may be lost, hehe.

So what can we do to effectively deal with these events and make the changes to the equipment more discerning?

I introduced an article "C # for Visio development event handling," which also describes the various event listening, we want to track the device, basically only need to listen to these events and deal with it.

const string sink = "";
Event newevent = null;
EventList applicationevents = eventapplication.eventlist;
EventList documentevents = eventdocument.eventlist;
Newevent = documentevents.addadvise (
(Unchecked (short) viseventcodes.visevtadd) + (short) Viseventcodes.visevtshape),
(IVisEventProc) This, sink, "shapeadd");
Newevent = Documentevents.addadvise (
(short) Viseventcodes.visevtdel + (short) Viseventcodes.visevtshape,
(IVisEventProc) This, sink, "shapedelete");
Newevent = Documentevents.addadvise (
(short) Viseventcodes.visevtmod + (short) Viseventcodes.visevtcell,
( IVisEventProc) This, sink, "cellchanged");

object IVisEventProc.VisEventProc(short eventCode, object source, int eventId,
int eventSequenceNumber, object subject, object moreInfo)
{
......
switch (eventCode)
{
case (short)VisEventCodes.visEvtShape + unchecked((short)VisEventCodes.visEvtAdd):
eventShape = (Shape)subject;
handleShapeAdd(eventShape);
break;
case (short)VisEventCodes.visEvtDel + (short)VisEventCodes.visEvtShape:
eventShape = (Shape)subject;
handleShapeDelete(eventShape);
break;
case (short)VisEventCodes.visEvtCell + (short)VisEventCodes.visEvtMod:
Visio.Cell cell = (Cell)subject;
if (cell.Name.IndexOf("Prop") >= 0)//限制只执行自定义事件一次
{
eventShape = cell.Shape;
handleCellModify(eventShape);
}
break;
default:
break;
}
return result;
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.