コード例 #1
0
        /// <summary>
        /// Event handler for subscribed events.
        /// </summary>
        /// <param name="eventCode">Code of the captured event.</param>
        /// <param name="source">Source object. In this case, it will always be the Visio application.</param>
        /// <param name="eventID">?</param>
        /// <param name="eventSequenceNumber">?</param>
        /// <param name="subject">The object which caused the event. This parameter is not set for marker events (which are raised by Visio).</param>
        /// <param name="moreInfo">?</param>
        /// <returns>Always null.</returns>
        public object VisEventProc(short eventCode, object source, int eventID, int eventSequenceNumber, object subject, object moreInfo)
        {
            VisioApplication visioApplication = null;

            try
            {
                visioApplication = (VisioApplication)source;

                if (_active == false)
                {
                    return(null);
                }

                if (visioApplication.IsUndoingOrRedoing == true)
                {
                    return(null);
                }

                /*
                 * Test eventCode.
                 * Yes, it's _so_ retarded to have to use if/else, but we can't switch
                 * since VisioEvent.* aren't constants. :/
                 */


                /*
                 * Called whenever one shape connects to another. Filter out
                 * connects which are not raised by QuartzProcess shapes.
                 */
                #region Shape Connect

                if (eventCode == VisioEvent.ShapeConnect)
                {
                    Connects connects = (Connects)subject;
                    HandleShapeConnect(connects);
                }

                #endregion


                /*
                 * Called whenever a shape is disconnected from another. Filter
                 * out disconnects which are not raised by QuartzProcess shapes.
                 */
                #region Shape Disconnect

                else if (eventCode == VisioEvent.ShapeDisconnect)
                {
                    Connects connects = (Connects)subject;
                    HandleShapeDisconnect(connects);
                }

                #endregion


                /*
                 * Called whenever a QueueMarkerEvent command is executed from
                 * the shape. Filter out events which are not raised by
                 * QuartzProcess app.
                 */
                #region Marker Events

                else if (eventCode == VisioEvent.ShapeEventMarker)
                {
                    string context = visioApplication.get_EventInfo(VisioEvent.IdMostRecent);

                    if (context == null)
                    {
                        return(null);
                    }

                    NameValueCollection nvc = VisioUtils.ParseContext(context);

                    HandleMarkerEvent(nvc);
                }

                #endregion
            }
            catch (Exception ex)
            {
                ESIMessageBox.ShowError(ex);
            }

            return(null);
        }