private async void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog()
            {
                Filter          = "Library Files|*.zip|All files (*.*)|*.*",
                CheckFileExists = true,
                CheckPathExists = true,
                Multiselect     = false,
                ValidateNames   = true
            };
            DialogResult result = dialog.ShowDialog();

            if ((result != DialogResult.OK) || (dialog.FileNames.Length != 1))
            {
                return;
            }

            var old  = this.Library;
            var path = Path.GetDirectoryName(dialog.FileName);
            var file = Path.GetFileName(dialog.FileName);

            this.Library = await AnotherCM.Library.Common.Library.OpenLibraryAsync(path, file);

            this.UpdateCounts();
            old.Flush();
        }
        private async void LibraryForm_Load(object sender, EventArgs e)
        {
            if (File.Exists(DockPanelLayoutPath))
            {
                // TODO: if any of our dock windows override GetPersistString, we'll need to reflect
                // that format here as well
                this.dockPanel.LoadFromXml(DockPanelLayoutPath, type => {
                    if (type == typeof(CombatantListWindow <Character>).ToString())
                    {
                        return(this.charactersWindow);
                    }
                    else if (type == typeof(CombatantListWindow <Monster>).ToString())
                    {
                        return(this.monstersWindow);
                    }
                    else if (type == typeof(EncountersWindow).ToString())
                    {
                        return(this.encountersWindow);
                    }
                    else if (type == typeof(EncounterDetailsWindow).ToString())
                    {
                        return(this.encounterDetailsWindow);
                    }
                    else if (type == typeof(PropertiesWindow).ToString())
                    {
                        return(this.propertiesWindow);
                    }
                    else if (type == typeof(StatBlockWindow).ToString())
                    {
                        return(this.statblockWindow);
                    }
                    else
                    {
                        System.Diagnostics.Debugger.Break(); return(null);
                    }
                });
            }
            else
            {
                // default initial layout
                this.charactersWindow.Show(this.dockPanel, DockState.DockLeft);
                this.monstersWindow.Show(this.dockPanel, DockState.DockLeft);
                this.encountersWindow.Show(this.dockPanel, DockState.DockLeft);
                this.propertiesWindow.Show(this.dockPanel, DockState.DockRightAutoHide);
                this.statblockWindow.Show(this.dockPanel, DockState.Document);
            }

            // the general idea is to get off the UI thread as soon as possible
            // while we load various parts of the library in the background
            if (this.Library == null)
            {
                this.Library = await AnotherCM.Library.Common.Library.OpenLibraryAsync();
            }
            this.UpdateCounts();

            await this.Library.LoadRulesAsync();

            this.importFromCBToolStripMenuItem.Enabled = true;
        }
        public LibraryForm(Library.Common.Library library)
        {
            AnotherCM.WinForms.Controls.StatBlockControl.SetBrowserRenderingRegistryKeys(addKeys: true);
            this.Library = library;
            InitializeComponent();

            this.charactersWindow.SelectionChanged       += charactersWindow_SelectionChanged;
            this.encounterDetailsWindow.SelectionChanged += encounterDetailsWindow_SelectionChanged;
            this.encountersWindow.SelectionChanged       += encountersWindow_SelectionChanged;
            this.monstersWindow.SelectionChanged         += monstersWindow_SelectionChanged;
        }