Binary plugin window won't show

Sep 5, 2014 at 5:30 PM
Edited Sep 5, 2014 at 6:31 PM
I am attempting to create a plugin binary that has a custom windows form open up. Right now it is just a form with no added items.

In the script class I create a new instance of that windows form and tell it to show and to be the highest focus, then for a popup to come up.

However, when I run the code, the windows form does not come up. I do get the pop
message that says "thanks"

Could anyone chime in to why my form is not showing?

Thank you in advance

namespace VMS.TPS
{
public class Script
{
public Script()
{
}

public void Execute(ScriptContext context /*, System.Windows.Window window*/)
{
  // TODO : Add here your code that is called when the script is launched from Eclipse
    SBRT_DOSE_CONSTRAINTS.MainForm1 mainForm = new     SBRT_DOSE_CONSTRAINTS.MainForm1();
    mainForm.Show();
    mainForm.TopMost.Equals(true);

    System.Windows.MessageBox.Show("thanks");
}
}
}
Coordinator
Sep 9, 2014 at 9:38 PM
Edited Sep 9, 2014 at 9:39 PM
Try uncommenting the passed window, then assign window.Content to your form;
Something like

public void Execute(ScriptContext context , System.Windows.Window window)
{
    SBRT_DOSE_CONSTRAINTS.MainForm1 mainForm = new     SBRT_DOSE_CONSTRAINTS.MainForm1();
    window.Content = mainForm;
}
See the example project "Example_DVH" for guidance. You can use the Eclipse Script Wizard to copy the example projects, "Example_DVH" is one of them.
Oct 3, 2014 at 6:49 PM
Solved, though I'm not sure it's the most efficent way
script cs file
...
public void Execute(ScriptContext context /, System.Windows.Window window/)
{
// i pass on the patient data to the window
       LoadAS.DisplayForm(context);
}
...


//i pass it on to the cs file that calls the window. I had to add the VMS.TPS.... references for it to handle the patient data
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using VMS.TPS.Common.Model.API;
using VMS.TPS.Common.Model.Types;


namespace MyLibrary
{
public class LoadAS
{

    public static void DisplayForm(ScriptContext context)
    {
        AssignStructures assignStructures = new AssignStructures(context);
        assignStructures.ShowDialog();
    }
}
}

//then in the windows form i bring in the patient data

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using VMS.TPS.Common.Model.API;
using VMS.TPS.Common.Model.Types;

namespace MyLibrary
{
public partial class AssignStructures : Form
{
    public ScriptContext currentPatient;
    public int numFractions;
    public AssignStructures(ScriptContext context)
    {
        InitializeComponent();
        currentPatient = context;
...