using Hi.Disp; using Hi.Licenses; using Hi.MongoUtils; using Hi.Wpf.Disp; using System.Windows; namespace Sample.Disp { /// /// Provides utility functions for running HiAPI display examples in a WPF environment. /// Contains helper methods that simplify the setup and execution of WPF applications with HiAPI rendering. /// Handles common initialization and cleanup tasks for visualization examples. /// /// /// ### Source Code /// [!code-csharp[SampleCode](~/../Hi.Sample.Wpf/Disp/DemoUtil.cs)] /// public static class DemoUtil { /// /// Creates and runs a WPF application with a RenderingWindow to display 3D content. /// Handles proper initialization and cleanup of HiAPI resources including MongoDB server, /// display engine, and licensing. /// /// The title for the application window /// The object that implements IDisplayee to be rendered public static void RunApplication(string title, IDisplayee displayee) { Application app = new Application(); app.Exit += (o, e) => { if(MongoServer.IsDefaultInit) MongoServer.Default.Dispose(); DispEngine.FinishDisp(); License.LogOutAll(); }; app.Run(new RenderingWindow() { Title = title, Displayee = displayee }); } } }