Beispiel #1
0
        public void SubscribeToEvent(Interaction.InteractionTypeEnum interactionType)
        {
            //subscribe to the specified event type (selection, mouse etc.)
            object eventType = null;

            m_interaction.SubscribeToEvent(interactionType, ref eventType);

            if (eventType != null)
            {
                if (eventType is SelectEvents)
                {
                    m_selectEvents = (SelectEvents)eventType;
                }

                if (eventType is MouseEvents)
                {
                    m_mouseEvents = (MouseEvents)eventType;
                }

                if (eventType is TriadEvents)
                {
                    m_triadEvents = (TriadEvents)eventType;
                }
            }
        }
Beispiel #2
0
        public void UnsubscribeFromEvents()
        {
            //unsubscribe from all event objects (selection, mouse etc.)
            m_interaction.UnsubscribeFromEvents();

            m_selectEvents = null;
            m_mouseEvents  = null;
            m_triadEvents  = null;
        }
Beispiel #3
0
        public Interaction()
        {
            m_interactionTypes = new System.Collections.ArrayList();

            m_interactionEvents = null;
            m_selectEvents      = null;
            m_mouseEvents       = null;
            m_triadEvents       = null;
        }
Beispiel #4
0
        public TriadEventsLib(Application inventorApp,
                              InteractionEvents interactionEvents = null)
        {
            invApp = inventorApp;

            if (interactionEvents == null)
            {
                return;
            }
            localInteractionEvents = interactionEvents;
            triadEvents            = interactionEvents.TriadEvents;
            Activate();
        }
Beispiel #5
0
        public void StartInteraction(Inventor.Application application, string interactionName, out InteractionEvents interactionEvents)
        {
            try
            {
                //-----------------------------------------------------
                //------------------InteractionEvents------------------
                //-----------------------------------------------------
                //create the InteractionEvents object
                m_interactionEvents = application.CommandManager.CreateInteractionEvents();

                //define that we want select events rather than mouse events
                m_interactionEvents.SelectionActive = true;

                //set the name for the interaction events
                m_interactionEvents.Name = interactionName;

                //connect the interaction event sink
                m_interaction_OnTerminate_Delegate = new InteractionEventsSink_OnTerminateEventHandler(InteractionEvents_OnTerminate);
                m_interactionEvents.OnTerminate   += m_interaction_OnTerminate_Delegate;

                //------------------SelectEvents--------------------
                //set a reference to the select events
                m_selectEvents = m_interactionEvents.SelectEvents;

                //connect the select event sink
                m_Select_OnSelect_Delegate = new SelectEventsSink_OnSelectEventHandler(SelectEvents_OnSelect);
                m_selectEvents.OnSelect   += m_Select_OnSelect_Delegate;

                m_Select_OnPreSelect_Delegate = new SelectEventsSink_OnPreSelectEventHandler(SelectEvents_OnPreSelect);
                m_selectEvents.OnPreSelect   += m_Select_OnPreSelect_Delegate;

                m_Select_OnPreSelectMouseMove_Delegate = new SelectEventsSink_OnPreSelectMouseMoveEventHandler(SelectEvents_OnPreSelectMouseMove);
                m_selectEvents.OnPreSelectMouseMove   += m_Select_OnPreSelectMouseMove_Delegate;

                m_Select_OnStopPreSelect_Delegate = new SelectEventsSink_OnStopPreSelectEventHandler(SelectEvents_OnStopPreSelect);
                m_selectEvents.OnStopPreSelect   += m_Select_OnStopPreSelect_Delegate;

                m_Select_OnUnSelect_Delegate = new SelectEventsSink_OnUnSelectEventHandler(SelectEvents_OnUnSelect);
                m_selectEvents.OnUnSelect   += m_Select_OnUnSelect_Delegate;

                //------------------MouseEvents--------------------
                //set a reference to the mouse events
                m_mouseEvents = m_interactionEvents.MouseEvents;

                //connect the mouse event sink
                m_Mouse_OnMouseMove_Delegate = new MouseEventsSink_OnMouseMoveEventHandler(MouseEvents_OnMouseMove);
                m_mouseEvents.OnMouseMove   += m_Mouse_OnMouseMove_Delegate;

                m_Mouse_OnMouseUp_Delegate = new MouseEventsSink_OnMouseUpEventHandler(MouseEvents_OnMouseUp);
                m_mouseEvents.OnMouseUp   += m_Mouse_OnMouseUp_Delegate;

                m_Mouse_OnMouseDown_Delegate = new MouseEventsSink_OnMouseDownEventHandler(MouseEvents_OnMouseDown);
                m_mouseEvents.OnMouseDown   += m_Mouse_OnMouseDown_Delegate;

                m_Mouse_OnMouseClick_Delegate = new MouseEventsSink_OnMouseClickEventHandler(MouseEvents_OnMouseClick);
                m_mouseEvents.OnMouseClick   += m_Mouse_OnMouseClick_Delegate;

                m_Mouse_OnMouseDoubleClick_Delegate = new MouseEventsSink_OnMouseDoubleClickEventHandler(MouseEvents_OnMouseDoubleClick);
                m_mouseEvents.OnMouseDoubleClick   += m_Mouse_OnMouseDoubleClick_Delegate;

                m_Mouse_OnMouseLeave_Delegate = new MouseEventsSink_OnMouseLeaveEventHandler(MouseEvents_OnMouseLeave);
                m_mouseEvents.OnMouseLeave   += m_Mouse_OnMouseLeave_Delegate;

                //------------------TriadEvents--------------------
                //set a reference to the triad events
                m_triadEvents = m_interactionEvents.TriadEvents;

                //connect the triad event sink
                m_Triad_OnActivate_Delegate = new TriadEventsSink_OnActivateEventHandler(TriadEvents_OnActivate);
                m_triadEvents.OnActivate   += m_Triad_OnActivate_Delegate;

                m_Triad_OnEndMove_Delegate = new TriadEventsSink_OnEndMoveEventHandler(TriadEvents_OnEndMove);
                m_triadEvents.OnEndMove   += m_Triad_OnEndMove_Delegate;

                m_Triad_OnEndSequence_Delegate = new TriadEventsSink_OnEndSequenceEventHandler(TriadEvents_OnEndSequence);
                m_triadEvents.OnEndSequence   += m_Triad_OnEndSequence_Delegate;

                m_Triad_OnMove_Delegate = new TriadEventsSink_OnMoveEventHandler(TriadEvents_OnMove);
                m_triadEvents.OnMove   += m_Triad_OnMove_Delegate;

                m_Triad_OnMoveTriadOnlyToggle_Delegate = new TriadEventsSink_OnMoveTriadOnlyToggleEventHandler(TriadEvents_OnMoveTriadOnlyToggle);
                m_triadEvents.OnMoveTriadOnlyToggle   += m_Triad_OnMoveTriadOnlyToggle_Delegate;

                m_Triad_OnSegmentSelectionChange_Delegate = new TriadEventsSink_OnSegmentSelectionChangeEventHandler(TriadEvents_OnSegmentSelectionChange);
                m_triadEvents.OnSegmentSelectionChange   += m_Triad_OnSegmentSelectionChange_Delegate;

                m_Triad_OnStartMove_Delegate = new TriadEventsSink_OnStartMoveEventHandler(TriadEvents_OnStartMove);
                m_triadEvents.OnStartMove   += m_Triad_OnStartMove_Delegate;

                m_Triad_OnStartSequence_Delegate = new TriadEventsSink_OnStartSequenceEventHandler(TriadEvents_OnStartSequence);
                m_triadEvents.OnStartSequence   += m_Triad_OnStartSequence_Delegate;

                m_Triad_OnTerminate_Delegate = new TriadEventsSink_OnTerminateEventHandler(TriadEvents_OnTerminate);
                m_triadEvents.OnTerminate   += m_Triad_OnTerminate_Delegate;

                //start the InteractionEvents
                m_interactionEvents.Start();
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.ToString());
            }
            finally
            {
                interactionEvents = m_interactionEvents;
            }
        }
Beispiel #6
0
        public void UnsubscribeFromEvents()
        {
            int interactionEvtsCount;

            for (interactionEvtsCount = 0; interactionEvtsCount < m_interactionTypes.Count; interactionEvtsCount++)
            {
                switch ((InteractionTypeEnum)m_interactionTypes[interactionEvtsCount])
                {
                case InteractionTypeEnum.kSelection:

                    //disconnect selection events sink
                    if (m_selectEvents != null)
                    {
                        m_selectEvents.OnPreSelect          -= m_Select_OnPreSelect_Delegate;
                        m_selectEvents.OnPreSelectMouseMove -= m_Select_OnPreSelectMouseMove_Delegate;
                        m_selectEvents.OnStopPreSelect      -= m_Select_OnStopPreSelect_Delegate;
                        m_selectEvents.OnSelect             -= m_Select_OnSelect_Delegate;
                        m_selectEvents.OnUnSelect           -= m_Select_OnUnSelect_Delegate;

                        m_selectEvents = null;
                    }

                    break;

                case InteractionTypeEnum.kMouse:

                    //disconnect mouse events sink
                    if (m_mouseEvents != null)
                    {
                        m_mouseEvents.OnMouseUp          -= m_Mouse_OnMouseUp_Delegate;
                        m_mouseEvents.OnMouseDown        -= m_Mouse_OnMouseDown_Delegate;
                        m_mouseEvents.OnMouseClick       -= m_Mouse_OnMouseClick_Delegate;
                        m_mouseEvents.OnMouseDoubleClick -= m_Mouse_OnMouseDoubleClick_Delegate;
                        m_mouseEvents.OnMouseMove        -= m_Mouse_OnMouseMove_Delegate;
                        m_mouseEvents.OnMouseLeave       -= m_Mouse_OnMouseLeave_Delegate;

                        m_mouseEvents = null;
                    }

                    break;

                case InteractionTypeEnum.kTriad:

                    //disconnect triad events sink
                    if (m_triadEvents != null)
                    {
                        m_triadEvents.OnActivate               -= m_Triad_OnActivate_Delegate;
                        m_triadEvents.OnEndMove                -= m_Triad_OnEndMove_Delegate;
                        m_triadEvents.OnEndSequence            -= m_Triad_OnEndSequence_Delegate;
                        m_triadEvents.OnMove                   -= m_Triad_OnMove_Delegate;
                        m_triadEvents.OnMoveTriadOnlyToggle    -= m_Triad_OnMoveTriadOnlyToggle_Delegate;
                        m_triadEvents.OnSegmentSelectionChange -= m_Triad_OnSegmentSelectionChange_Delegate;
                        m_triadEvents.OnStartMove              -= m_Triad_OnStartMove_Delegate;
                        m_triadEvents.OnStartSequence          -= m_Triad_OnStartSequence_Delegate;
                        m_triadEvents.OnTerminate              -= m_Triad_OnTerminate_Delegate;

                        m_triadEvents = null;
                    }

                    break;
                }
            }

            m_interactionTypes.Clear();
        }
Beispiel #7
0
        public void SubscribeToEvent(InteractionTypeEnum interactionType, ref object eventType)
        {
            //check if already subscribed to
            int interactionEvtsCount;

            for (interactionEvtsCount = 0; interactionEvtsCount < m_interactionTypes.Count; interactionEvtsCount++)
            {
                if (interactionType == (InteractionTypeEnum)m_interactionTypes[interactionEvtsCount])
                {
                    return;
                }
            }

            //if not already subsribed to then, subscribe
            m_interactionTypes.Add(interactionType);

            switch (interactionType)
            {
            case InteractionTypeEnum.kSelection:

                //set a reference to the select events
                m_selectEvents = m_interactionEvents.SelectEvents;

                //connect the select event sink
                m_selectEvents.OnPreSelect          += m_Select_OnPreSelect_Delegate;
                m_selectEvents.OnPreSelectMouseMove += m_Select_OnPreSelectMouseMove_Delegate;
                m_selectEvents.OnStopPreSelect      += m_Select_OnStopPreSelect_Delegate;
                m_selectEvents.OnSelect             += m_Select_OnSelect_Delegate;
                m_selectEvents.OnUnSelect           += m_Select_OnUnSelect_Delegate;

                //specify burn through
                m_selectEvents.PreSelectBurnThrough = true;

                eventType = m_selectEvents;
                break;

            case InteractionTypeEnum.kMouse:

                //set a reference to the mouse events
                m_mouseEvents = m_interactionEvents.MouseEvents;

                //connect the mouse event sink
                m_mouseEvents.OnMouseUp          += m_Mouse_OnMouseUp_Delegate;
                m_mouseEvents.OnMouseDown        += m_Mouse_OnMouseDown_Delegate;
                m_mouseEvents.OnMouseClick       += m_Mouse_OnMouseClick_Delegate;
                m_mouseEvents.OnMouseDoubleClick += m_Mouse_OnMouseDoubleClick_Delegate;
                m_mouseEvents.OnMouseMove        += m_Mouse_OnMouseMove_Delegate;
                m_mouseEvents.OnMouseLeave       += m_Mouse_OnMouseLeave_Delegate;

                eventType = m_mouseEvents;
                break;

            case InteractionTypeEnum.kTriad:

                //set a reference to the triad events
                m_triadEvents = m_interactionEvents.TriadEvents;

                //connect the triad event sink
                m_triadEvents.OnActivate               += m_Triad_OnActivate_Delegate;
                m_triadEvents.OnEndMove                += m_Triad_OnEndMove_Delegate;
                m_triadEvents.OnEndSequence            += m_Triad_OnEndSequence_Delegate;
                m_triadEvents.OnMove                   += m_Triad_OnMove_Delegate;
                m_triadEvents.OnMoveTriadOnlyToggle    += m_Triad_OnMoveTriadOnlyToggle_Delegate;
                m_triadEvents.OnSegmentSelectionChange += m_Triad_OnSegmentSelectionChange_Delegate;
                m_triadEvents.OnStartMove              += m_Triad_OnStartMove_Delegate;
                m_triadEvents.OnStartSequence          += m_Triad_OnStartSequence_Delegate;
                m_triadEvents.OnTerminate              += m_Triad_OnTerminate_Delegate;

                eventType = m_triadEvents;
                break;
            }
        }
Beispiel #8
0
        public void EnableInteraction()
        {
            //enable events
            int interactionEvtsCount;

            for (interactionEvtsCount = 0; interactionEvtsCount < m_interactionTypes.Count; interactionEvtsCount++)
            {
                switch ((InteractionTypeEnum)m_interactionTypes[interactionEvtsCount])
                {
                case InteractionTypeEnum.kSelection:

                    //re-subscribe to selection events
                    if (m_selectEvents == null)
                    {
                        //set a reference to the select events
                        m_selectEvents = m_interactionEvents.SelectEvents;

                        //connect the select event sink
                        m_selectEvents.OnPreSelect          += m_Select_OnPreSelect_Delegate;
                        m_selectEvents.OnPreSelectMouseMove += m_Select_OnPreSelectMouseMove_Delegate;
                        m_selectEvents.OnStopPreSelect      += m_Select_OnStopPreSelect_Delegate;
                        m_selectEvents.OnSelect             += m_Select_OnSelect_Delegate;
                        m_selectEvents.OnUnSelect           += m_Select_OnUnSelect_Delegate;

                        //specify burn through
                        m_selectEvents.PreSelectBurnThrough = true;
                    }

                    break;

                case InteractionTypeEnum.kMouse:

                    //re-subscribe to mouse events
                    if (m_mouseEvents == null)
                    {
                        //set a reference to the mouse events
                        m_mouseEvents = m_interactionEvents.MouseEvents;

                        //connect the mouse event sink
                        m_mouseEvents.OnMouseUp          += m_Mouse_OnMouseUp_Delegate;
                        m_mouseEvents.OnMouseDown        += m_Mouse_OnMouseDown_Delegate;
                        m_mouseEvents.OnMouseClick       += m_Mouse_OnMouseClick_Delegate;
                        m_mouseEvents.OnMouseDoubleClick += m_Mouse_OnMouseDoubleClick_Delegate;
                        m_mouseEvents.OnMouseMove        += m_Mouse_OnMouseMove_Delegate;
                        m_mouseEvents.OnMouseLeave       += m_Mouse_OnMouseLeave_Delegate;
                    }

                    break;

                case InteractionTypeEnum.kTriad:

                    //re-subscribe to triad events
                    if (m_triadEvents == null)
                    {
                        //set a reference to the triad events
                        m_triadEvents = m_interactionEvents.TriadEvents;

                        //connect the triad event sink
                        m_triadEvents.OnActivate               += m_Triad_OnActivate_Delegate;
                        m_triadEvents.OnEndMove                += m_Triad_OnEndMove_Delegate;
                        m_triadEvents.OnEndSequence            += m_Triad_OnEndSequence_Delegate;
                        m_triadEvents.OnMove                   += m_Triad_OnMove_Delegate;
                        m_triadEvents.OnMoveTriadOnlyToggle    += m_Triad_OnMoveTriadOnlyToggle_Delegate;
                        m_triadEvents.OnSegmentSelectionChange += m_Triad_OnSegmentSelectionChange_Delegate;
                        m_triadEvents.OnStartMove              += m_Triad_OnStartMove_Delegate;
                        m_triadEvents.OnStartSequence          += m_Triad_OnStartSequence_Delegate;
                        m_triadEvents.OnTerminate              += m_Triad_OnTerminate_Delegate;
                    }

                    break;
                }
            }
        }