/// <summary> /// Open an AnkiImporterWdw instance. /// </summary> /// <param name="trees"></param> private void OpenAnkiImporterWdw(DeckTreeDictionary trees) { if (trees == null || trees.Count == 0) { LogTo.Error("Attempted to OpenAnkiImporterWdw with a null or empty DeckTreeDictionary object"); return; } if (CurrentInstance != null) { return; } Application.Current.Dispatcher.Invoke(() => { var wdw = new ImporterWdw(trees); CurrentInstance = wdw; wdw.ShowAndActivate(); }); }
/// <summary> /// Get Decks from the database and launch the importer window. /// </summary> private async void OpenAnkiImporter() { var database = Config.AnkiCollectionDB; if (!File.Exists(database)) { Popups.ShowAlert($"Anki database \"{database}\" does not exist", "Failed to open AnkiImporter window"); return; } var decks = await GetDecksAsync(database); if (decks == null || decks.Count == 0) { Popups.ShowAlert($"Attempt to get decks from database \"{database}\"returned null or empty.", "Failed to open AnkiImporter window"); return; } var trees = new DeckTreeDictionary(decks); OpenAnkiImporterWdw(trees); }