How to close OMI client from script?

I want to make a buttom where the client can be closed. Is there a command for that?

Parents
  • There are some other ways, but I think the best way is this one:

    • Galaxy | Import | Script Library
      • C:\Program Files (x86)\ArchestrA\Framework\AcfSdk\Libs\ ArchestrA.Client.ViewApp.dll
      • This is the OMI toolkit
    • Now in the script use:
      • ArchestrA.Client.ViewApp.ViewApplication.Application.CloseViewApplication();
  • Are minimize, maximize and restore functions also available for making custom buttons?

  • All the SDK capabilities are documented here on an installed environment: https://localhost:28808/AVEVA%20OMI%20SDK/#OMISDK.html (we are working on getting it onto docs.aveva.com). As far as I can tell, Minimizem Maximise and Restore are not exposed, but you may be able to get at them directly via the .NET framework.

    WARNING: This is untested, so I'd appreciate if you can feed back here if it worked or not...

    First you need to reference the PresentationFramework like this:

    • In the IDE navigate to: Galaxy | Import | Script Library
    • Find the PresentationFramework.dll
      • Typically here: C:\Windows\Microsoft.NET\Framework\v4.0.30319\WPF\PresentationFramework.dll
      • Be sure to pick the right one with this exact name: PresentationFramework.dll
    • This will give you access to additional System Windows libraries.

    You should then be able to use statements like these in scripting:

    System.Windows.Application.Current.MainWindow.WindowState= System.Windows.WindowState.Normal;
    System.Windows.Application.Current.MainWindow.WindowState= System.Windows.WindowState.Minimized;
    System.Windows.Application.Current.MainWindow.WindowState= System.Windows.WindowState.Maximized;

  • I did not get this to work. There seems to be a threading/ownership issue:

    System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidOperationException: The calling thread cannot access this object because a different thread owns it.

  • Hi, I am sorry it took me a while to find a gap to look at this again, but I there is a solution using that same ViewApp.dll from the toolkit (C:\Program Files (x86)\ArchestrA\Framework\AcfSdk\Libs\ ArchestrA.Client.ViewApp.dll)

    It is a little more tricky, and maybe someone else can see an easier way — it will only work from a layout script so:

    • You need to trigger a layout script e.g., from a graphic by writing a condition script that looks at a public custom property of a graphic (typically something like MyContent.Graphic_0011.customProperty
    • It needs some OMI app to be present on the layout (I used the Titlebar).
    • It need access to Systems.Windows.WindowState, so you need to import C:\Windows\Microsoft.NET\Framework\v4.0.30319\WPF\PresentationFramework.dll
      • Remember to copy it out of this folder and into another folder before importing it

    Then use this:

    ArchestrA.Client.ViewApp.ViewApplication.Application.SetLayoutState(MyContent.TitleBarControl1.Parent, System.Windows.WindowState.Minimized);

Reply
  • Hi, I am sorry it took me a while to find a gap to look at this again, but I there is a solution using that same ViewApp.dll from the toolkit (C:\Program Files (x86)\ArchestrA\Framework\AcfSdk\Libs\ ArchestrA.Client.ViewApp.dll)

    It is a little more tricky, and maybe someone else can see an easier way — it will only work from a layout script so:

    • You need to trigger a layout script e.g., from a graphic by writing a condition script that looks at a public custom property of a graphic (typically something like MyContent.Graphic_0011.customProperty
    • It needs some OMI app to be present on the layout (I used the Titlebar).
    • It need access to Systems.Windows.WindowState, so you need to import C:\Windows\Microsoft.NET\Framework\v4.0.30319\WPF\PresentationFramework.dll
      • Remember to copy it out of this folder and into another folder before importing it

    Then use this:

    ArchestrA.Client.ViewApp.ViewApplication.Application.SetLayoutState(MyContent.TitleBarControl1.Parent, System.Windows.WindowState.Minimized);

Children
No Data