Exemplo n.º 1
0
        private void SeasonsListBox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
        {
            Episodes.Clear();

            foreach (string season in SeasonsListBox.SelectedItems)
            {
                var episodesResult = Directory.EnumerateFiles(season);

                foreach (var filePath in episodesResult)
                {
                    Episodes.Add(filePath);
                }
            }

            if (SeasonsListBox.SelectedItems.Count == 0)
            {
                WriteOutput("Selections cleared.", OutputMessageLevel.Warning);
            }
            else if (SeasonsListBox.SelectedItems.Count == 1)
            {
                WriteOutput($"{System.IO.Path.GetFileName(openFolderDialog.FileName)} selected ({Episodes.Count} episodes).", OutputMessageLevel.Informational);
            }
            else
            {
                WriteOutput($"{SeasonsListBox.SelectedItems.Count} seasons selected ({Episodes.Count} total episodes).", OutputMessageLevel.Informational);
            }

            Analytics.TrackEvent("Season Selection", new Dictionary <string, string>
            {
                { "Selected Seasons", SeasonsListBox.SelectedItems.Count.ToString(CultureInfo.InvariantCulture) }
            });
        }
Exemplo n.º 2
0
 public override void Track(string eventName, Dictionary <string, string> parameters)
 {
     #if USE_ANALYTICS
     var bundle = bundleFromParameters(parameters);
     firebaseAnalytics.LogEvent(eventName, bundle);
     AppCenterAnalytics.TrackEvent(eventName, trimLongParameters(parameters));
     #endif
 }
Exemplo n.º 3
0
        protected override void NativeTrackEvent(string eventName, Dictionary <string, string> parameters)
        {
            AppCenterAnalytics.TrackEvent(eventName, trimLongParameters(parameters));

            var convertedDictionary = convertDictionary(parameters);

            FirebaseAnalytics.LogEvent(new NSString(eventName), convertedDictionary);
        }
Exemplo n.º 4
0
        protected override void NativeTrackEvent(string eventName, Dictionary <string, string> parameters)
        {
            AppCenterAnalytics.TrackEvent(eventName, trimLongParameters(parameters));

            FirebaseAnalytics.LogEvent(new NSString(eventName), NSDictionary <NSString, NSObject> .FromObjectsAndKeys(
                                           parameters.Values.ToArray(),
                                           parameters.Keys.ToArray()
                                           ));
        }
Exemplo n.º 5
0
        private void ResetButton_Click(object sender, RoutedEventArgs e)
        {
            Reset();
            WriteOutput("Reset complete! Open a folder to continue.", OutputMessageLevel.Success);

            Analytics.TrackEvent("User Reset", new Dictionary <string, string>
            {
                { "View Type", "Videos" }
            });
        }
Exemplo n.º 6
0
        public override void Track(string eventName, Dictionary <string, string> parameters = null)
        {
            parameters = parameters ?? new Dictionary <string, string>();

            AppCenterAnalytics.TrackEvent(eventName, trimLongParameters(parameters));

            var convertedDictionary = convertDictionary(parameters);

            FirebaseAnalytics.LogEvent(new NSString(eventName), convertedDictionary);
        }
Exemplo n.º 7
0
        private void CancelResultButton_Click(object sender, RoutedEventArgs e)
        {
            RenamedEpisodesPreviewList.Clear();

            EpisodesPane.IsSelected = true;

            ApproveResultButton.IsEnabled = false;
            CancelResultButton.IsEnabled  = false;

            Analytics.TrackEvent("Cancel Results Preview");
        }
Exemplo n.º 8
0
        static void trackEvent(string name, IDictionary <string, string> properties = null)
        {
            if (!string.IsNullOrEmpty(Constants.PrivateKeys.MobileCenter.AppSecret))
            {
                MobileAnalytics.TrackEvent(name, properties);
            }
            else
            {
                var props = (properties?.Count > 0) ? string.Join(" | ", properties.Select(p => $"{p.Key} = {p.Value}")) : "empty";

                log($"TrackEvent :: name: {name.PadRight (30)} properties: {props}");
            }
        }
Exemplo n.º 9
0
        private void ApproveResultButton_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(OriginalTextBox_Renumbering?.Text))
            {
                WriteOutput($"You must selected text that will be replaced by the season and episode number.", OutputMessageLevel.Error);
                return;
            }

            if (string.IsNullOrEmpty(SeasonNumberTextBox?.Text) || !int.TryParse(SeasonNumberTextBox?.Text, out int seasonNumber))
            {
                WriteOutput($"You must enter a valid two-digit number for the season.", OutputMessageLevel.Error);
                return;
            }

            if (string.IsNullOrEmpty(EpisodeStartTextBox?.Text) || string.IsNullOrEmpty(EpisodeEndTextBox?.Text))
            {
                WriteOutput($"You must enter a first and last episode number.", OutputMessageLevel.Error);
                return;
            }

            if (!int.TryParse(EpisodeStartTextBox?.Text, out int startingEpisodeNumber) || !int.TryParse(EpisodeEndTextBox?.Text, out int lastEpisodeNumber))
            {
                WriteOutput($"You must use a valid two-digit value for the start and end episode number.", OutputMessageLevel.Error);
                return;
            }

            // Make sure the user has entered the correct number of episodes
            if (lastEpisodeNumber - startingEpisodeNumber + 1 != EpisodesListBox.SelectedItems.Count)
            {
                WriteOutput($"The episode numbers do not match the total selected episodes, you need to have the same number of episode number as selected episodes.", OutputMessageLevel.Error);
                return;
            }

            Analytics.TrackEvent("Renumbering Preview Approved");

            busyIndicator.IsBusy          = true;
            busyIndicator.BusyContent     = "re-numbering and renaming files...";
            busyIndicator.IsIndeterminate = false;
            busyIndicator.ProgressValue   = 0;

            renumberWorker.RunWorkerAsync(new WorkerParameters
            {
                SelectedEpisodes   = EpisodesListBox.SelectedItems.Cast <string>().ToList(),
                SeasonNumber       = seasonNumber,
                EpisodeNumberStart = startingEpisodeNumber,
                EpisodeNumberEnd   = lastEpisodeNumber,
                SelectedTextLength = OriginalTextBox_Renumbering.Text.Length
            });
        }
Exemplo n.º 10
0
        private void SetTagsButton_Click(object sender, RoutedEventArgs e)
        {
            if (SetAlbumNameCheckBox.IsChecked == true && string.IsNullOrEmpty(AlbumNameTextBox.Text))
            {
                WriteOutput($"Album (book title) is empty.", OutputMessageLevel.Error);
                return;
            }

            if (SetArtistNameCheckBox.IsChecked == true && string.IsNullOrEmpty(ArtistTextBox.Text))
            {
                WriteOutput($"Artist (author name) is empty.", OutputMessageLevel.Error);
                return;
            }

            if (AudiobookFilesGridView.SelectedItems.Count == 0)
            {
                WriteOutput($"No files have been selected.", OutputMessageLevel.Error);
                return;
            }

            Analytics.TrackEvent("Set Tags started", new Dictionary <string, string>
            {
                { "Set Book Title Enabled", $"{SetAlbumNameCheckBox.IsChecked}" },
                { "Set Author Name Enabled", $"{SetArtistNameCheckBox.IsChecked}" },
                { "Selected Audiobook files", $"{AudiobookFilesGridView.SelectedItems.Count}" },
                { "Authors", $"{AudiobookTitles.Count}" }
            });

            busyIndicator.IsBusy          = true;
            busyIndicator.BusyContent     = "updating tags...";
            busyIndicator.IsIndeterminate = false;
            busyIndicator.ProgressValue   = 0;

            backgroundWorker.RunWorkerAsync(new TagWorkerParameters
            {
                AudiobookFiles   = AudiobookFilesGridView.SelectedItems.Cast <AudiobookFile>().ToList(),
                UpdateAlbumName  = SetAlbumNameCheckBox.IsChecked,
                UpdateTitle      = SetTitleCheckBox.IsChecked,
                UpdateArtistName = SetArtistNameCheckBox.IsChecked
            });
        }
Exemplo n.º 11
0
        private void RenumberWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (e.Result is WorkerResult resultParameter)
            {
                WriteOutput(resultParameter.FinalMessage, OutputMessageLevel.Success);

                Analytics.TrackEvent("Episode Renumbering Complete", new Dictionary <string, string>
                {
                    { "Total Episodes", Episodes.Count.ToString(CultureInfo.InvariantCulture) },
                    { "Episodes Renumbered", EpisodesListBox.SelectedItems.Count.ToString(CultureInfo.InvariantCulture) }
                });

                if (!resultParameter.IsPreview)
                {
                    RenamedEpisodesPreviewList.Clear();

                    RefreshEpisodesList();

                    EpisodesPane.IsSelected = true;

                    ApproveResultButton.IsEnabled = false;
                    CancelResultButton.IsEnabled  = false;
                }
                else
                {
                    ResultPreviewPane.IsSelected = true;

                    ApproveResultButton.IsEnabled = true;
                    CancelResultButton.IsEnabled  = true;
                }
            }

            busyIndicator.BusyContent   = "";
            busyIndicator.IsBusy        = false;
            busyIndicator.ProgressValue = 0;
        }
Exemplo n.º 12
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;
            }
        }
Exemplo n.º 13
0
        protected override void TrackEventInternal(string eventName, IDictionary <string, object> properties)
        {
            var propertiesToSend = this.MergePropertiesToAppCenterFormat(properties);

            AppCenterAnalytics.TrackEvent(eventName, propertiesToSend);
        }
 public static void Track(string eventName)
 {
     Analytics.TrackEvent(eventName, new Dictionary <string, string> {
         { "Person", GetPerson() }
     });
 }
Exemplo n.º 15
0
        private async void UpdateFileNameButton_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(OriginalTextBox_Renaming.Text))
            {
                WriteOutput("No text selected, aborting file name update.", OutputMessageLevel.Error);
                return;
            }
            else
            {
                WriteOutput("Renaming operation starting...", OutputMessageLevel.Warning);
            }

            // variables for background thread access
            var selectedItems   = EpisodesListBox.SelectedItems.Cast <string>().ToList();
            var selectedText    = OriginalTextBox_Renaming.Text;
            var replacementText = ReplacementTextBox.Text;

            busyIndicator.IsBusy          = true;
            busyIndicator.BusyContent     = "updating file names...";
            busyIndicator.IsIndeterminate = false;
            busyIndicator.ProgressValue   = 0;

            await Task.Run(() =>
            {
                try
                {
                    for (int i = 0; i < selectedItems.Count; i++)
                    {
                        var episodeFilePath = selectedItems[i];

                        // Need to separate name and path in order to prefix the file name
                        string curDir = Path.GetDirectoryName(episodeFilePath);

                        if (string.IsNullOrEmpty(curDir))
                        {
                            WriteOutput($"Could not find directory, skipping.", OutputMessageLevel.Error);
                            continue;
                        }

                        string curName = Path.GetFileName(episodeFilePath);

                        if (string.IsNullOrEmpty(curName))
                        {
                            WriteOutput($"Could not find file, skipping.", OutputMessageLevel.Error);
                            continue;
                        }

                        // Replace the selected text with the new text (support empty replacement to remove text)
                        string newName = curName.Replace(selectedText, replacementText, StringComparison.InvariantCulture);

                        // Rename the file
                        File.Move(episodeFilePath, Path.Combine(curDir, newName));

                        // Need to dispatch back to UI thread, variables to avoid access to modified closure problem
                        var progressComplete = i / selectedItems.Count * 100;
                        var progressText     = $"Renaming - '{selectedText}' to '{replacementText}'...";

                        Dispatcher.Invoke(() =>
                        {
                            busyIndicator.ProgressValue = progressComplete;
                            busyIndicator.BusyContent   = $"Completed {progressText}...";
                        });
                    }

                    WriteOutput($"Renaming operation complete!", OutputMessageLevel.Success);
                }
                catch (Exception ex)
                {
                    WriteOutput(ex.Message, OutputMessageLevel.Error);

                    Crashes.TrackError(ex, new Dictionary <string, string>
                    {
                        { "Rename Episode", "TV Show" }
                    });
                }
            }).ConfigureAwait(true);

            RefreshEpisodesList();

            Analytics.TrackEvent("Episode Renaming Complete", new Dictionary <string, string>
            {
                { "Total Episodes", Episodes.Count.ToString(CultureInfo.InvariantCulture) },
                { "Episodes Renamed", EpisodesListBox.SelectedItems.Count.ToString(CultureInfo.InvariantCulture) }
            });

            busyIndicator.BusyContent   = "";
            busyIndicator.IsBusy        = false;
            busyIndicator.ProgressValue = 0;
        }
Exemplo n.º 16
0
 public void TrackEvent(string eventName, IDictionary <string, string> properties = null)
 {
     AppAnalytics.TrackEvent(eventName, properties);
 }
Exemplo n.º 17
0
        private void SelectFolderButton_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 seasons...";

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

                Seasons.Clear();

                foreach (var season in seasonsResult)
                {
                    Seasons.Add(season);

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

                if (Seasons.Count == 0)
                {
                    WriteOutput("No seasons detected, make sure there are subfolders with season number.", OutputMessageLevel.Warning);
                }
                else if (Seasons.Count == 1)
                {
                    WriteOutput($"Opened '{System.IO.Path.GetFileName(openFolderDialog.FileName)}' ({Seasons.Count} season).", OutputMessageLevel.Success);
                }
                else
                {
                    WriteOutput($"Opened '{System.IO.Path.GetFileName(openFolderDialog.FileName)}' ({Seasons.Count} seasons).", OutputMessageLevel.Success);
                }

                Analytics.TrackEvent("Video Folder Opened", new Dictionary <string, string>
                {
                    { "Seasons", Seasons.Count.ToString(CultureInfo.InvariantCulture) }
                });
            }
            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", "TV Show" }
                });
            }
            finally
            {
                busyIndicator.BusyContent     = "";
                busyIndicator.IsBusy          = false;
                busyIndicator.IsIndeterminate = false;
            }
        }