コード例 #1
0
ファイル: Application.cs プロジェクト: yk35/RevitLookup
 public Result OnStartup(UIControlledApplication application)
 {
     CreateRibbonPanel(application);
     ModelessWindowHandle.SetHandler(application.MainWindowHandle);
     ExternalExecutor.CreateExternalEvent();
     return(Result.Succeeded);
 }
コード例 #2
0
    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);
        };
    }