private void Window_Loaded(object sender, RoutedEventArgs e) { uiGameLog.Document = new FlowDocument(); uiGameLog.Document.FontSize = 14; uiGameLog.Document.FontFamily = new FontFamily("Times New Roman"); WindowState = Config.Settings.AnalysisWindowState; // show progress window/start parsing thread ProgressWindow progressWindow = new ProgressWindow() { Owner = this }; progressWindow.Thread = new Thread(new ThreadStart(Parse)) { Name = "Demo Parsing Thread" }; progressWindowInterface = (IProgressWindow)progressWindow; if (progressWindow.ShowDialog() == false) { Close(); } }
private void uiPlayButton_Click(object sender, RoutedEventArgs e) { Demo demo = uiDemoListView.GetSelectedDemo(); if (demo == null) { // shouldn't happen since the button should be disabled, but anyway... return; } // verify paths etc. launcher = LauncherFactory.CreateLauncher(demo); launcher.Owner = this; launcher.UseHlae = UseHlae(demo); launcher.Interface = (ILauncher)this; try { launcher.Verify(); } catch (Launcher.AbortLaunchException) { return; } catch (ApplicationException ex) { Common.Message(this, null, ex); return; } catch (Exception ex) { Common.Message(this, null, ex, MessageWindow.Flags.Error); return; } // make sure source and destination filenames don't match (dickhead insurance) if (String.Equals(demo.FileFullPath, launcher.GameFullPath + "\\" + Config.LaunchDemoFileName, StringComparison.CurrentCultureIgnoreCase)) { Common.Message(this, "Source and destination filenames are the same. Rename or move the source file and try again."); return; } // add the demo file path to the file operation manager FileOperationList.Add(new FileDeleteOperation(launcher.GameFullPath + "\\" + Config.LaunchDemoFileName)); // stop the user from being able to open a new demo now canOpenDemo = false; // write the demo ProgressWindow writeDemoProgressWindow = new ProgressWindow() { Owner = this }; writeDemoProgressWindow.Thread = demo.Write((IProgressWindow)writeDemoProgressWindow); writeDemoProgressWindow.ThreadParameter = launcher.GameFullPath + "\\" + Config.LaunchDemoFileName; if (writeDemoProgressWindow.ShowDialog() == false) { // user aborted writing FileOperationList.Execute(); canOpenDemo = true; return; } // go to tray MinimiseToTray(); // launch the game try { launcher.Run(); } catch (Exception ex) { RestoreFromTray(); FileOperationList.Execute(); canOpenDemo = true; Common.Message(this, "Error launching game.", ex, MessageWindow.Flags.Error); return; } SystemTrayIcon.Text = "Looking for " + (launcher.UseHlae ? "HLAE" : "game") + " process..."; // enable the tray context menu TrayContextMenuEnable(true); }