예제 #1
0
        /// <summary>
        /// When the appropriate rectangle button is clicked the button's OnExecute event handler
        /// calls this method to hook up the mouse click event which will wait for the user to select
        /// a point from which to start the drawing of the rectangle
        /// </summary>
        public virtual void StartRectangleInteraction()
        {
            _interactionEvents = _inventorApplication.CommandManager.CreateInteractionEvents();

            _rectangleInteractionGraphics = _interactionEvents.InteractionGraphics;
            _rectangleClientGraphics      = _rectangleInteractionGraphics.OverlayClientGraphics;
            _rectangleLineNode            = _rectangleClientGraphics.AddNode(1);
            _rectangleGraphicsDataSets    = _rectangleInteractionGraphics.GraphicsDataSets;
            _rectangleCoordSet            = _rectangleGraphicsDataSets.CreateCoordinateSet(1);
            _rectangleIndexSet            = _rectangleGraphicsDataSets.CreateIndexSet(1);

            _onTerminate_Delegate           = new InteractionEventsSink_OnTerminateEventHandler(StopInteraction);
            _interactionEvents.OnTerminate += _onTerminate_Delegate;

            _userInputEvents = _inventorApplication.CommandManager.UserInputEvents;
            _userInputEvents_OnContextMenuDelegate = new UserInputEventsSink_OnContextMenuEventHandler(UserInputEvents_OnContextMenu);
            _userInputEvents.OnContextMenu        += _userInputEvents_OnContextMenuDelegate;

            _mouseEvents = _interactionEvents.MouseEvents;
            _mouseEvents.PointInferenceEnabled = true;
            _onMouseClick_Delegate             = new MouseEventsSink_OnMouseClickEventHandler(OnMouseClick_CreateRectangle);
            _mouseEvents.OnMouseClick         += _onMouseClick_Delegate;

            _interactionEvents.StatusBarText = "Select a Point from which to start the rectangle";

            _interactionEvents.AllowCommandAliases = true;

            _interactionEvents.Start();
        }
예제 #2
0
        protected void ResetRectangle()
        {
            if (_mouseEvents != null)
            {
                _mouseEvents.OnMouseMove  -= _onMouseMove_Delegate;
                _onMouseMove_Delegate      = null;
                _mouseEvents.OnMouseClick -= _onMouseClick_Delegate;
                _onMouseClick_Delegate     = null;
                _mouseEvents = null;
            }

            _rectangleLines                        = null;
            _horizontalMidPointAlign               = null;
            _verticalMidPointAlign                 = null;
            _userInputEvents.OnContextMenu        -= _userInputEvents_OnContextMenuDelegate;
            _userInputEvents_OnContextMenuDelegate = null;
            _planarSketch  = null;
            _drawingSketch = null;
            _secondSelectedSketchEntity = null;
            _inferredOriginPoint        = null;
            _inferredFinalPositionPoint = null;
            _firstSelectedSketchEntity  = null;
            _pickedPoint2d                  = null;
            _pickedSketchPoint              = null;
            _rectangleOriginSketchPoint     = null;
            _rectangleCoordSet              = null;
            _rectanglePointCoords           = null;
            _rectangleInteractionGraphics   = null;
            _rectangleGraphicsColorSet      = null;
            _interactionEvents.OnTerminate -= _onTerminate_Delegate;
            _interactionEvents.Stop();
            _interactionEvents = null;
        }
        protected void ResetRectangle()
        {
            if (_mouseEvents != null)
            {
                _mouseEvents.OnMouseMove -= _onMouseMove_Delegate;
                _onMouseMove_Delegate = null;
                _mouseEvents.OnMouseClick -= _onMouseClick_Delegate;
                _onMouseClick_Delegate = null;
                _mouseEvents = null;
            }

            _rectangleLines = null;
            _horizontalMidPointAlign = null;
            _verticalMidPointAlign = null;
            _userInputEvents.OnContextMenu -= _userInputEvents_OnContextMenuDelegate;
            _userInputEvents_OnContextMenuDelegate = null;
            _planarSketch = null;
            _drawingSketch = null;
            _secondSelectedSketchEntity = null;
            _inferredOriginPoint = null;
            _inferredFinalPositionPoint = null;
            _firstSelectedSketchEntity = null;
            _pickedPoint2d = null;
            _pickedSketchPoint = null;
            _rectangleOriginSketchPoint = null;
            _rectangleCoordSet = null;
            _rectanglePointCoords = null;
            _rectangleInteractionGraphics = null;
            _rectangleGraphicsColorSet = null;
            _interactionEvents.OnTerminate -= _onTerminate_Delegate;
            _interactionEvents.Stop();
            _interactionEvents = null;
        }
        /// <summary>
        /// When the appropriate rectangle button is clicked the button's OnExecute event handler
        /// calls this method to hook up the mouse click event which will wait for the user to select 
        /// a point from which to start the drawing of the rectangle
        /// </summary>
        public virtual void StartRectangleInteraction()
        {
            _interactionEvents = _inventorApplication.CommandManager.CreateInteractionEvents();

            _rectangleInteractionGraphics = _interactionEvents.InteractionGraphics;
            _rectangleClientGraphics = _rectangleInteractionGraphics.OverlayClientGraphics;
            _rectangleLineNode = _rectangleClientGraphics.AddNode(1);
            _rectangleGraphicsDataSets = _rectangleInteractionGraphics.GraphicsDataSets;
            _rectangleCoordSet = _rectangleGraphicsDataSets.CreateCoordinateSet(1);
            _rectangleIndexSet = _rectangleGraphicsDataSets.CreateIndexSet(1);

            _onTerminate_Delegate = new InteractionEventsSink_OnTerminateEventHandler(StopInteraction);
            _interactionEvents.OnTerminate += _onTerminate_Delegate;

            _userInputEvents = _inventorApplication.CommandManager.UserInputEvents;
            _userInputEvents_OnContextMenuDelegate = new UserInputEventsSink_OnContextMenuEventHandler(UserInputEvents_OnContextMenu);
            _userInputEvents.OnContextMenu += _userInputEvents_OnContextMenuDelegate;

            _mouseEvents = _interactionEvents.MouseEvents;
            _mouseEvents.PointInferenceEnabled = true;
            _onMouseClick_Delegate = new MouseEventsSink_OnMouseClickEventHandler(OnMouseClick_CreateRectangle);
            _mouseEvents.OnMouseClick += _onMouseClick_Delegate;

            _interactionEvents.StatusBarText = "Select a Point from which to start the rectangle";

            _interactionEvents.AllowCommandAliases = true;

            _interactionEvents.Start();
        }