public Result OnStartup(UIControlledApplication application) { CreateRibbonPanel(application); ModelessWindowHandle.SetHandler(application.MainWindowHandle); ExternalExecutor.CreateExternalEvent(); return(Result.Succeeded); }
public static void Show(Form form, Document targetDocument = null, Form parentForm = null) { AddKeyEvents(form); if (parentForm is null) { form.StartPosition = FormStartPosition.CenterScreen; } else { parentForm.AddOwnedForm(form); form.StartPosition = FormStartPosition.Manual; form.Location = new Point(parentForm.Location.X + (parentForm.Width - form.Width) / 2, parentForm.Location.Y + (parentForm.Height - form.Height) / 2); } if (targetDocument is not null && form is IHaveCollector formWithCollector) { formWithCollector.Document = targetDocument; } form.Show(new ModelessWindowHandle()); form.FormClosed += (s, e) => { ModelessWindowHandle.BringRevitToFront(); FocusOwner((Form)s); }; }