#if UNITY_5_3_OR_NEWER #define NOESIS using Noesis; using System; using System.Reflection; using UnityEngine; #else using System; using System.Windows; using System.Windows.Controls; #endif namespace Atome2 { /// /// Interaction logic for MainUserControl.xaml /// public partial class MainWindow : UserControl { public MainWindow() { InitializeComponent(); } #if NOESIS private void InitializeComponent() { //ResourceDictionary style = (ResourceDictionary)Noesis.GUI.LoadXaml("Assets/Code/XAML/AgileStyle.xaml"); //ResourceDictionary style = (ResourceDictionary)Noesis.GUI.LoadXaml("Assets/Code/XAML/WindowsStyle.xaml"); //ResourceDictionary style = (ResourceDictionary)Noesis.GUI.LoadXaml("Assets/Code/XAML/NocturnalStyle.xaml"); //ResourceDictionary style = (ResourceDictionary)Noesis.GUI.LoadXaml("Assets/Code/XAML/Atome2Style.xaml"); //ResourceDictionary style = (ResourceDictionary)LoadXaml("Atome2Style"); ResourceDictionary style = (ResourceDictionary)LoadXaml("NocturnalStyle"); Noesis.GUI.SetApplicationResources(style); Noesis.GUI.LoadComponent(this, "Assets/Code/XAML/MainWindow"); Button itButtonTest = (Button) this.FindName("itButtonTest"); // Convert.ChangeType(ItemToCast, Type.GetType(stringNameOfType))) itButtonTest.Click += itButtonTest_Click; } object LoadXaml(string xaml) { #if NOESIS NoesisXaml xamlUnity = (NoesisXaml)UnityEngine.Resources.Load(xaml, typeof(NoesisXaml)); return xamlUnity.Load(); #else string path = "/ControlGallery;component/Assets/NoesisGUI/Samples/ControlGallery/Resources/" + xaml + ".xaml"; return Application.LoadComponent(new Uri(path, UriKind.RelativeOrAbsolute)); #endif } private void itButtonTest_Click(object sender, RoutedEventArgs e) { System.Console.WriteLine("Button was clicked"); } // Event Declared in XAML // https://www.noesisengine.com/docs/Gui.Core._UIElement.html#events protected override bool ConnectEvent(object source, string eventName, string handlerName) { if (eventName == "Click" && handlerName == "itButtonTest") { ((Button)source).Click += this.itButtonTest_Click; return true; } return false; } #endif } }