Beispiel #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();
        }
Beispiel #2
0
        public void Deactivate()
        {
            // Release objects.
            if (_activeProjectType == MultiUserModeEnum.kVaultMode)
            {
                UnSubscribeEvents();
            }

            _applicationEvents.OnActiveProjectChanged -= ApplicationEvents_OnActiveProjectChanged;

            _userInputEvents       = null;
            _dockableWindowsEvents = null;
            _applicationEvents     = null;

            _vaultAddin = null;

            _myVaultBrowserButton = null;
            _myVaultBrowser       = null;

            _hwndDic = null;
            Hook.Clear();

            Marshal.ReleaseComObject(_inventorApplication);
            _inventorApplication = null;

            GC.Collect();
            GC.WaitForPendingFinalizers();
        }
Beispiel #3
0
        public DragPointCmd()
        {
            m_userInputEvents = null;

            m_interactionGrapgics = null;

            m_workPoint = null;
        }
Beispiel #4
0
        protected AdnCommand(Inventor.Application application)
        {
            this.Application = application;

            _userInputEvents = application.CommandManager.UserInputEvents;

            _userInputEvents.OnLinearMarkingMenu +=
                new UserInputEventsSink_OnLinearMarkingMenuEventHandler(
                    OnLinearMarkingMenu);

            _userInputEvents.OnRadialMarkingMenu +=
                new UserInputEventsSink_OnRadialMarkingMenuEventHandler(
                    OnRadialMarkingMenu);
        }
Beispiel #5
0
        private void AlignAutoButton_Click(object sender, RoutedEventArgs e)
        {
            _userInputEvents = InventorApplication.CommandManager.UserInputEvents;
            ActiveDocument   = InventorApplication.ActiveDocument as DrawingDocument;
            if (ActiveDocument == null)
            {
                Close();
            }

            double posX = 0;
            double posY = 0;

            //TODO find out how to select all the drawing view labels and automatically align them.

            foreach (var drawingViewlabel in SelectSet.OfType <DrawingViewLabel>())
            {
                var nothingyet = posX + posY;
            }
        }
Beispiel #6
0
        private void AlignVerticalButton_Click(object sender, RoutedEventArgs e)
        {
            _userInputEvents = InventorApplication.CommandManager.UserInputEvents;
            ActiveDocument   = InventorApplication.ActiveDocument as DrawingDocument;
            if (ActiveDocument == null)
            {
                Close();
            }

            double posX = 0;

            foreach (var drawingViewLabel in SelectSet.OfType <DrawingViewLabel>())
            {
                if (Math.Abs(posX) < 0.1)
                {
                    posX = Math.Round(drawingViewLabel.Position.X, 1);
                }
                drawingViewLabel.Position = InventorApplication.TransientGeometry.CreatePoint2d(posX, drawingViewLabel.Position.Y);
            }
        }
Beispiel #7
0
        public void Activate(ApplicationAddInSite addInSiteObject, bool firstTime)
        {
            // This method is called by Inventor when it loads the addin.
            // The AddInSiteObject provides access to the Inventor Application object.
            // The FirstTime flag indicates if the addin is loaded for the first time.

            // Initialize AddIn members.
            _inventorApplication = addInSiteObject.Application;

            try
            {
                _vaultAddin = _inventorApplication.ApplicationAddIns.ItemById["{48b682bc-42e6-4953-84c5-3d253b52e77b}"];
            }
            catch
            {
                MessageBox.Show(Resources.VaultAddinNotFound, @"MyVaultBrowser", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                throw;
            }

            _applicationEvents     = _inventorApplication.ApplicationEvents;
            _dockableWindowsEvents = _inventorApplication.UserInterfaceManager.DockableWindows.Events;
            _userInputEvents       = _inventorApplication.CommandManager.UserInputEvents;

            _activeProjectType = _inventorApplication.DesignProjectManager.ActiveDesignProject.ProjectType;

            _hwndDic = new Dictionary <Document, IntPtr>();
            Hook.Initialize(this);

            _myVaultBrowser =
                _inventorApplication.UserInterfaceManager.DockableWindows.Add("{ffbbb57a-07f3-4d5c-97b0-e8e302247c7a}",
                                                                              "myvaultbrowser", "MyVaultBrowser");
            _myVaultBrowser.Title                 = "Vault";
            _myVaultBrowser.ShowTitleBar          = true;
            _myVaultBrowser.DisabledDockingStates = DockingStateEnum.kDockBottom | DockingStateEnum.kDockTop;
            _myVaultBrowser.SetMinimumSize(200, 150);

            _myVaultBrowserButton = _inventorApplication.CommandManager.ControlDefinitions.AddButtonDefinition(
                "MyVaultBrowser", "myvaultbrowserbutton", CommandTypesEnum.kQueryOnlyCmdType, "{ffbbb57a-07f3-4d5c-97b0-e8e302247c7a}",
                "Toggle MyVaultBrowser", "", "", "", ButtonDisplayEnum.kNoTextWithIcon);
            _myVaultBrowserButton.OnExecute += _myVaultBrowserButton_OnExecute;

            if (!_myVaultBrowser.IsCustomized)
            {
                _myVaultBrowser.DockingState = DockingStateEnum.kDockRight;
                _myVaultBrowser.Visible      = true;
            }

            _applicationEvents.OnActiveProjectChanged += ApplicationEvents_OnActiveProjectChanged;

            if (_inventorApplication.Ready)
            {
                if (_activeProjectType == MultiUserModeEnum.kVaultMode)
                {
                    TryLoadVaultAddin();
                }
            }
            else
            {
                _applicationEvents.OnReady += ApplicationEvents_OnReady;
            }
        }
        /// <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();
        }
Beispiel #9
0
 public void Initialize()
 {
     m_userInputEvents           = m_inventorApplication.CommandManager.UserInputEvents;
     m_UserInput_OnDrag_Delegate = new UserInputEventsSink_OnDragEventHandler(OnDrag);
     m_userInputEvents.OnDrag   += m_UserInput_OnDrag_Delegate;
 }