Ejemplo n.º 1
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);
            }
Ejemplo n.º 2
0
            /// <summary>
            /// Releases unmanaged resources used by the <see cref="Component"/> and optionally
            /// releases the Inventor.DockableWindow.
            /// </summary>
            /// <param name="disposing">true to release the Dockable Window.</param>
            protected override void Dispose(bool disposing)
            {
                // Let the base do its clean-up.
                base.Dispose(disposing);

                if (disposing)
                {
                    // If disposing, we should release the dockable window.
                    Inventor.DockableWindow wnd = dockableWindow;
                    dockableWindow = null; // Clear the field so we can't release it twice.
                    if (wnd != null)
                    {
                        wnd.Visible = false;
                        System.Runtime.InteropServices.Marshal.ReleaseComObject(wnd);
                    }
                }
            }
Ejemplo n.º 3
0
            /// <summary>
            /// Releases unmanaged resources used by the <see cref="Component"/> and optionally
            /// releases the Inventor.DockableWindow.
            /// </summary>
            /// <param name="disposing">true to release the Dockable Window.</param>
            protected override void Dispose(bool disposing)
            {
                // Let the base do its clean-up.
                base.Dispose(disposing);

                if (disposing)
                {
                    // If disposing, we should release the dockable window.
                    Inventor.DockableWindow wnd = dockableWindow;
                    dockableWindow = null; // Clear the field so we can't release it twice.
                    if (wnd != null)
                    {
                        wnd.Visible = false;
                        System.Runtime.InteropServices.Marshal.ReleaseComObject(wnd);
                    }
                }
            }
Ejemplo n.º 4
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);
            }