Пример #1
0
        public DialogResult ShowDialog(Form form)
        {
            // Now that we implemented IMsoComponent, calling IVsUIShell.EnableModeless
            // causes more problems than it solves (ASURT 41876).
            // uishell.EnableModeless(0);

            // Site the Form if possible, to give access to AmbientProperties.
            ShowDialogContainer container = null;

            if (form.Site == null)
            {
                AmbientProperties ambient = new AmbientProperties();
                ambient.Font = (Font)Styles["DialogFont"];
                container    = new ShowDialogContainer(ambient);
                container.Add(form);
            }

            DialogResult dlgResult = DialogResult.None;

            try {
                dlgResult = form.ShowDialog(GetDialogOwnerWindow());
            }
            finally {
                if (container != null)
                {
                    container.Remove(form);
                }
            }
            return(dlgResult);
        }
        /// <include file='doc\DialogContainerWithToolbar.uex' path='docs/doc[@for="DialogContainerWithToolbar.ShowDialog"]/*' />
        /// <devdoc>
        /// Show this window as modal dialog.
        /// </devdoc>
        public new DialogResult ShowDialog()
        {
            // if we don't have a service provider we can not show the dialog correctly
            if (null == provider)
            {
                throw new InvalidOperationException();
            }

            DialogResult   result;
            IMessageFilter filter = this as IMessageFilter;

            // Make sure that there is non visual containment for this form
            ShowDialogContainer dialogContainer = null;

            if (this.Site == null)
            {
                dialogContainer = new ShowDialogContainer((IServiceProvider)this);
                dialogContainer.Add(this);
            }

            try
            {
                // This form needs to install its message filter in order to
                // let the toolbar process the mouse events.
                Application.AddMessageFilter(filter);

                // Show the modal dialog
                result = base.ShowDialog();
            }
            finally
            {
                if (dialogContainer != null)
                {
                    dialogContainer.Remove(this);
                }
                Application.RemoveMessageFilter(filter);
            }

            return(result);
        }
        /// <include file='doc\DialogContainerWithToolbar.uex' path='docs/doc[@for="DialogContainerWithToolbar.ShowDialog"]/*' />
        /// <devdoc>
        /// Show this window as modal dialog.
        /// </devdoc>
        public new DialogResult ShowDialog()
        {
            // if we don't have a service provider we can not show the dialog correctly
            if (null == provider)
                throw new InvalidOperationException();

            DialogResult result;
            IMessageFilter filter = this as IMessageFilter;

            // Make sure that there is non visual containment for this form
            ShowDialogContainer dialogContainer = null;
            if (this.Site == null)
            {
                dialogContainer = new ShowDialogContainer((IServiceProvider)this);
                dialogContainer.Add(this);
            }

            try
            {
                // This form needs to install its message filter in order to
                // let the toolbar process the mouse events.
                Application.AddMessageFilter(filter);

                // Show the modal dialog
                result = base.ShowDialog();
            }
            finally
            {
                if (dialogContainer != null)
                    dialogContainer.Remove(this);
                Application.RemoveMessageFilter(filter);
            }

            return result;
        }
Пример #4
0
 internal ShowDialogSite(IComponent component, ShowDialogContainer container, String name)
 {
     this.component = component;
     this.container = container;
     this.name      = name;
 }