public FeatureMigratorDockWnd(
            Inventor.ApplicationAddInSite addInSite,
            Inventor.DockingStateEnum initialDockingState)
        {
            if (addInSite == null) // We can't build the dockable window without the add-in site object.
            {
                throw new ArgumentNullException("addInSite");
            }

            _addInSite = addInSite;

            _applicationEvents = addInSite.Application.ApplicationEvents;

            _applicationEvents.OnActivateDocument += ApplicationEvents_OnActivateDocument;

            _applicationEvents.OnCloseDocument += _applicationEvents_OnCloseDocument;

            InitializeComponent();

            _browserControl.Initialize();

            _browserControl.RefreshControl(addInSite.Application.ActiveDocument);

            // Make sure the components object is created. (The designer doesn't always create it.)
            if (components == null)
            {
                components = new Container();
            }

            // Create the DockableWindow using a managed wrapper and add it to the components collection.
            components.Add(
                new DockableWindowWrapper(addInSite, this, initialDockingState),
                typeof(DockableWindowWrapper).Name);
        }
示例#2
0
            /// <summary>Initializes the <see cref="DockableWindowWrapper"/>.</summary>
            /// <param name="addInSite">The ApplicationAddInSite object supplied by Inventor.</param>
            /// <param name="form">The managed form to add to the DockableWindow.</param>
            /// <param name="initialDockingState">The initial docking state of the DockableWindow
            /// if it is created for the first time.</param>
            internal DockableWindowWrapper(
                Inventor.ApplicationAddInSite addInSite,
                Form form,
                Inventor.DockingStateEnum initialDockingState)
            {
                System.Diagnostics.Debug.Assert(addInSite != null && form != null);

                _form = form;

                // Set up the parameters.
                string clientId     = addInSite.Parent.ClientId;
                string internalName = _form.GetType().FullName + "." + form.Name;
                string title        = _form.Text;

                // We don't want the border to show since the form will be docked inside the DockableWindow.
                _form.FormBorderStyle = FormBorderStyle.None;

                // Retrieve or create the dockable window.
                try
                {
                    dockableWindow = addInSite.Application.UserInterfaceManager.DockableWindows[internalName];
                }
                catch
                {
                    dockableWindow = addInSite.Application.UserInterfaceManager.DockableWindows.Add(
                        clientId,
                        internalName,
                        title);
                }

                // Set the minimum size of the dockable window.
                System.Drawing.Size minimumSize = form.MinimumSize;
                if (!minimumSize.IsEmpty)
                {
                    dockableWindow.SetMinimumSize(minimumSize.Height, minimumSize.Width);
                }

                // Set the initial docking state of the DockableWindow if it is not remembered by Inventor.
                if (initialDockingState != default(Inventor.DockingStateEnum)) // && !dockableWindow.IsCustomized)
                {
                    dockableWindow.DockingState = initialDockingState;
                }

                // Set initial state to invisible.
                dockableWindow.Visible = false;

                // Listen for events.
                _form.HandleCreated  += new EventHandler(OnHandleCreated);
                _form.VisibleChanged += new EventHandler(OnVisibleChanged);

                _dockableWindowsEvents =
                    addInSite.Application.UserInterfaceManager.DockableWindows.Events;

                _dockableWindowsEvents.OnHide +=
                    new DockableWindowsEventsSink_OnHideEventHandler(DockableWindowsEvents_OnHide);
            }
        public ProfilerDockableWnd(
            Inventor.ApplicationAddInSite addInSite,
            Inventor.DockingStateEnum initialDockingState)
        {
            if (addInSite == null) // We can't build the dockable window without the add-in site object.
            {
                throw new ArgumentNullException("addInSite");
            }

            // Initialize the form with the designer code.
            InitializeComponent();

            // Make sure the components object is created. (The designer doesn't always create it.)
            if (components == null)
            {
                components = new Container();
            }

            // Create the DockableWindow using a managed wrapper and add it to the components collection.
            components.Add(
                new DockableWindowWrapper(addInSite, this, initialDockingState),
                typeof(DockableWindowWrapper).Name);
        }