XAML work for

Aug 15, 2014 at 10:33 PM
Edited Aug 15, 2014 at 10:35 PM
I have a general question about portal dosimetry scripting. In the example script, Example_DVH, the program calls a UserControl from the namespace of the project. Put in a simple format,
Using VMS.TPS.Common…
Using VMS.TPS.Com…
Namespace VMS.TPS
{
Class Script
{
Public Script()
{}
Public void Execute (scriptcontext context, window window)
{
//blah blah blah
*****Var mainControl = new Example_DVH.MainControl();
Window.content = mainControl;
mainControl.Function(input);
}
}
}
Then you can happily edit the MainControl XAML and Xaml.cs files to your hearts content and run the dll and all is good.

Now I’m trying to do the same thing with portal dosimetry scripting, but I have an issue. When I attempt it it looks like this.
Using vms.ca.scripting;
Namespace VMS.DV.PD.scripting;
<all save stuff>
String input = context.Patient.Id;
Var mainControl = new project_namespace.MainWindow(); //Here I’m just trying to make a window, starting simple.
Window.content = mainControl;
mainControl.Function(input);
In the XAML.cs file all I’m trying to do is put the patient id as the input.

The problem I’m having is that when I run this in PD it says that I’m missing an assembly or reference to the namespace “project_namespace”. If I make this project standalone it works fine ( I guess because visual studio knows that project_namespace is my namespace). Anyway, am I doing something wrong. Does PD scripting have the capabilities of using XAML to create GUIs?
If it would help I could have either of you view the screen on my workstattion and I can show you what’s going on. I’m really knew to WPF, so it may just be my lack of understanding. Feel free to forward this to anyone else that may be of help as well.
Coordinator
Aug 19, 2014 at 4:52 PM
You can use XAML in the PD scripting as well.

I just tried creating a PD plug-in script for the first time. By default, when I added a new item to the project, a WPF window, it created it to the same namespace as the first CS file was (VMS.DV.PD.Scripting). Then I did not have to worry about namespaces, I just say "Window myWindow = new Window1()" in my code file.

Does the first line of you XAML say:
<Window x:Class="project_namespace.MainWindow"

Is it in the same project as your main code file? If not, then you'll have to add a reference in the solution explorer.
Marked as answer by mcschmidt on 8/20/2014 at 10:09 AM
Aug 20, 2014 at 5:05 PM
Thanks for your help. I think my problem stems with my lack of understanding of what some of these components can do. I was able to create the window, but I was unable to modify the window using the XAML, the XAML.cs file or the program file itself. For instance, if I had a project with a script called test2.cs, and typed in the following:
string mystring = context.Patient.Id;
        //MessageBox.Show(mystring);
        Window mywindow = new Window1();
         
        window.Content = mywindow;
        window.Width = 400;
        window.Height = 100;
        window.Title = "Patient: " + mystring;
Then the program will create a new window, but will not hold any of these parameters. If I do the same thing to a User control:
string mystring = context.Patient.Id;
        //MessageBox.Show(mystring);
        var Usercontrol = new UserControl1();
        window.Content = Usercontrol;
        window.Width = 400;
        window.Height = 100;
        window.Title = "Patient: " + mystring;
then the box looks like I expect and has the title I expect. I can also directly edit the XAML file (for instance put in a textblock that is red so I can see it) using the User control, but it has no effect if I do it to a window. I was reading some other forums online and it seems that Windows have a difficult time performing some tasks as far as the modification. Should I be using a user control instead of a window if I want any edits from the context to take effect?

Thanks again.
Coordinator
Aug 20, 2014 at 5:20 PM
Yes, use the UserControl control to create content to the window.

The window that you get as the second parameter of the Execute function, is already created by Eclipse, and then you just create the content to the client area of it. You don't have to create a new window yourself.
Marked as answer by mcschmidt on 8/20/2014 at 10:09 AM