public void Dispose() { View = null; m_ContentReloader?.Dispose(); m_ContentReloader = null; m_Game.Window.TextInput -= HandleWindowTextInput; m_Game.Window.ClientSizeChanged -= HandleWindowClientSizeChange; // TODO: How do we dispose just this Noesis UI view? Noesis.GUI.Shutdown(); }
/// <summary> /// Initializes a new instance of the <see cref="NoesisWrapper" /> class. /// </summary> /// <param name="game">The MonoGame game instance.</param> /// <param name="graphics">Graphics device manager of the game instance.</param> /// <param name="dataPath">(optional) Local path to the folder which will be used as root for other paths</param> /// <param name="rootXamlRelativePath">Local XAML file path - will be used as the UI root element</param> /// <param name="themeResourcesRelativePath"> /// (optional) Local XAML file path - will be used as global ResourceDictionary /// (UI style) /// </param> /// <param name="autoReloadFileFilter">Re-loads the UI when any data file that matches the filter changed</param> public NoesisWrapper( Game game, GraphicsDeviceManager graphics, string rootXamlRelativePath, string dataPath, string themeResourcesRelativePath, string autoReloadFileFilter = null) { m_Game = game; m_Graphics = graphics; m_GraphicsDevice = m_Graphics.GraphicsDevice; // Initialize DX11 renderer m_Dx11Device = (DX11.Device)m_GraphicsDevice.Handle; m_Game.Window.TextInput += HandleWindowTextInput; m_Game.Window.ClientSizeChanged += HandleWindowClientSizeChange; var fullDataPath = Path.GetFullPath(dataPath); if (!Directory.Exists(fullDataPath)) { throw new DirectoryNotFoundException(fullDataPath); } Noesis.GUI.Init(); Noesis.GUI.SetResourceProvider(fullDataPath); if (!string.IsNullOrWhiteSpace(autoReloadFileFilter)) { m_ContentReloader = new ContentReloader( fullDataPath, rootXamlRelativePath, themeResourcesRelativePath, autoReloadFileFilter); View = m_ContentReloader.View; } else { try { var theme = (Noesis.ResourceDictionary)Noesis.GUI.LoadXaml(themeResourcesRelativePath); Noesis.GUI.SetTheme(theme); var content = (Noesis.FrameworkElement)Noesis.GUI.LoadXaml(rootXamlRelativePath); View = Noesis.GUI.CreateView(content); } catch (Exception ex) { ReportError(ex); throw; } } // Use Noesis.View.AntialiasingMode.PPAA if you want less jagged edges. View.SetAntialiasingMode(Noesis.View.AntialiasingMode.MSAA); View.SetTessellationQuality(Noesis.View.TessellationQuality.Medium); m_InputManager = new InputManager(View); UpdateSize(); View.Renderer.InitD3D11(m_Dx11Device.ImmediateContext.NativePointer, new Noesis.VGOptions()); }