/// <summary> /// Creates the window and switches to the correct page /// </summary> public MainWindow() { Preexecution(); InitializeComponent(); try { if (MessageBox.Show("Show Graph?", "Debug", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.No) { throw new InvalidOperationException(); } var lbr = LibraryHandler.TryLoadLib("Aufgabe9.dll"); //Environment.Exit(0); new SceneGraph(lbr as Renderer.TransformableRenderer).ShowDialog(); } catch { if (LibraryHandler.IsLoaded) { OpenPage2(prefetchRenderer); } else { pageViewer.Content = new DND(OpenPage2); } } App.MakeMeDark(this); }
//string FlattenArray(string[] arr) { // var ret = "("; // foreach(var e in arr) ret += e + ", "; // return ret.TrimEnd(new[] { ',', ' ' }) + ")"; //} /// <summary> /// Handles Drag and drop events /// <para> /// if a proper file is given it will switch to the next page /// </para> /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Grid_Drop(object sender, DragEventArgs e) { var a = e.Data.GetData("FileNameW") as string[]; if (a.Length != 1) { MessageBox.Show("This Application requires ONE .dll"); return; } var path = a[0]; var ext = Path.GetExtension(path).ToLower(); if (ext != ".dll") { MessageBox.Show("Please Drag&Drop the Renderer dll", "Error"); return; } var rend = LibraryHandler.TryLoadLib(path); if (rend != null) { openNext(rend); } else { MessageBox.Show("Could not load dll"); } }
/// <summary> /// Shows filepicker Modal Dialog and opens library /// </summary> private void Button_Click(object sender, RoutedEventArgs e) { var dlg = new Microsoft.Win32.OpenFileDialog { DefaultExt = "*.dll;", CheckFileExists = true, CheckPathExists = true, Multiselect = false, RestoreDirectory = true, DereferenceLinks = true, Title = "Please select the renderer file", Filter = "Renderer *.dll|*.dll" }; if (dlg.ShowDialog() == true) { var rend = LibraryHandler.TryLoadLib(dlg.FileName); if (rend != null) { openNext(rend); } } }
/// <summary> /// Detects if this should immediatly open the <see cref="CompilationSettings"/> page based on the command line parameters /// <para> /// <see cref="LibraryHandler"/> will relaunch the Application if required. When is does so, it will pass the name of the target DLL as a parameter. /// But depending on the execution environment the path to our executable might be the first parameter. To ignore this we check for such options. /// After checking all this this function will cause <see cref="LibraryHandler"/> to load the passed DLL. /// Since <see cref="LibraryHandler"/> remembers this, the <see cref="MainWindow()"/> constructor will detect that a library has been loaded and trigger the <see cref="CompilationSettings"/> /// Page instead of the <see cref="DND"/> page /// </para> /// </summary> void Preexecution() { var para = Environment.GetCommandLineArgs(); if (para[0] != Assembly.GetExecutingAssembly().Location) { ////For debugging purposes: List all command line parameters //var s = ""; //foreach(var p in para) s += p + "\n"; //MessageBox.Show(s); } if (para.Length == 1) { if (para[0] == Assembly.GetExecutingAssembly().Location) { return; } prefetchRenderer = LibraryHandler.TryLoadLib(para[0]); } else if (para.Length > 1 && para[0] == Assembly.GetExecutingAssembly().Location) { prefetchRenderer = LibraryHandler.TryLoadLib(para[1]); } }