/// <summary> /// Initialises a new <see cref="BuildLibrary"/> instance. /// </summary> /// <param name="settings">The settings for this <see cref="BuildLibrary"/> instance.</param> public BuildLibrary(BuildLibrarySettings settings) { Settings = settings; // Load the library Load(); }
/// <summary> /// Raises the System.Windows.Application.Startup event. /// </summary> /// <param name="e">A System.Windows.StartupEventArgs that contains the event data.</param> protected override void OnStartup(StartupEventArgs e) { BuildLibrarySettings settings = new BuildLibrarySettings(); string exportLocation = null, importLocation = null; options = new OptionSet() { // Overlay Mode { "o|overlay", "Overlay Mode", v => settings.OverlayMode = v != null }, // Full Screen Mode { "f|full-screen", "Full Screen Mode", v => settings.FullScreenMode = v != null }, // Quick Mode { "q|quick", "Quick Mode", v => settings.QuickMode = v != null }, // No Save Window State { "no-save-window-state", "No Save Window State", v => settings.SaveWindowState = v == null }, // Profession Filter { "profession=", "Profession Filter", v => settings.ProfessionFilter = ParseProfessionFilter(v) }, // Export Builds { "export=", "Export", v => exportLocation = v }, // Import Builds { "import=", "Import", v => importLocation = v }, // Help { "h|?|help", "Help", v => ShowHelp = v != null }, }; try { options.Parse(e.Args); } catch (OptionException ex) { MessageBox.Show($"Error: {ex.Message}", "Option Parsing Error", MessageBoxButton.OK, MessageBoxImage.Error); Shutdown(-1); return; } if (ShowHelp) { // Show the help message and exit ShowHelpMessage(); Shutdown(0); return; } BuildLibrary = new BuildLibrary(settings); bool shutdown = false; if (!string.IsNullOrEmpty(importLocation)) { // Load the additional templates BuildLibrary.Load(importLocation, loadWindowState: false); } if (!string.IsNullOrEmpty(exportLocation)) { // Save the library without window data to the specified location then shutdown the application BuildLibrary.Save(exportLocation, saveWindowState: false); shutdown = true; } if (shutdown) { Shutdown(0); } else { base.OnStartup(e); } }