Example #1
0
        private void Reset()
        {
            AlbumNameTextBox.Text = string.Empty;
            ArtistTextBox.Text    = string.Empty;

            SetAlbumNameCheckBox.IsChecked  = true;
            SetTitleCheckBox.IsChecked      = true;
            SetArtistNameCheckBox.IsChecked = true;

            AudiobookTitles.Clear();
            AudiobookFiles.Clear();
            StatusMessages.Clear();
        }
Example #2
0
        private void SelectAuthorFolderButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                WriteOutput($"Opening folder picker...", OutputMessageLevel.Normal);

                busyIndicator.IsBusy          = true;
                busyIndicator.BusyContent     = "opening folder...";
                busyIndicator.IsIndeterminate = true;

                if (!string.IsNullOrEmpty(Properties.Settings.Default.LastFolder))
                {
                    // Need to bump up one level from the last folder location
                    var topDirectoryInfo = Directory.GetParent(Properties.Settings.Default.LastFolder);

                    openFolderDialog.InitialDirectory = topDirectoryInfo.FullName;

                    WriteOutput($"Starting at saved folder.", OutputMessageLevel.Normal);
                }
                else
                {
                    WriteOutput($"No saved folder, starting at root.", OutputMessageLevel.Warning);
                }

                openFolderDialog.ShowDialog();

                if (openFolderDialog.DialogResult != true)
                {
                    WriteOutput($"Canceled folder selection.", OutputMessageLevel.Normal);
                    return;
                }
                else
                {
                    Properties.Settings.Default.LastFolder = openFolderDialog.FileName;
                    Properties.Settings.Default.Save();
                }

                Reset();

                busyIndicator.BusyContent = $"searching for albums...";

                var folders = Directory.EnumerateDirectories(openFolderDialog.FileName).ToList();

                AudiobookTitles.Clear();

                foreach (var folder in folders)
                {
                    AudiobookTitles.Add(folder);

                    busyIndicator.BusyContent = $"added {folder}";
                }

                if (AudiobookTitles.Count == 0)
                {
                    WriteOutput("No titles detected.", OutputMessageLevel.Error);

                    MessageBox.Show("The selected Author's folder should have subfolders, each subfolder should be named with the audiobook's title.", "No Titles Available.");
                }
                else if (AudiobookTitles.Count == 1)
                {
                    WriteOutput($"Opened {Path.GetFileName(openFolderDialog.FileName)}' ({AudiobookTitles.Count} title).", OutputMessageLevel.Success);
                }
                else
                {
                    WriteOutput($"Opened {Path.GetFileName(openFolderDialog.FileName)} ({AudiobookTitles.Count} titles).", OutputMessageLevel.Success);
                }

                Analytics.TrackEvent("Audiobook Folder Opened", new Dictionary <string, string>
                {
                    { "Audiobook Titles Loaded", $"{AudiobookTitles.Count}" }
                });
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);

                WriteOutput(ex.Message, OutputMessageLevel.Error);

                Crashes.TrackError(ex, new Dictionary <string, string>
                {
                    { "Folder Open", "Audiobook Author" }
                });
            }
            finally
            {
                busyIndicator.BusyContent     = "";
                busyIndicator.IsBusy          = false;
                busyIndicator.IsIndeterminate = false;
            }
        }