예제 #1
0
        public void ChangeSelectedFileName()
        {
            audioPlaybackService.Stop();
            audioPlaybackService.KillAudio();

            CustomMessageBox tempDialog = new CustomMessageBox(
                caption: "Rename the selected file",
                icon: CustomMessageBoxIcon.Question,
                buttons: CustomMessageBoxButtons.OkAndCancel,
                messageRows: new List <string>(),
                prompt: Path.GetFileNameWithoutExtension(selectedFileService.SelectedFile.Name),
                controlFocus: CustomMessageBoxFocus.Prompt,
                promptValidationMode: CustomMessageBoxPromptValidation.EraseIllegalPathCharacters);

            tempDialog.TrySetViewablePositionFromOwner(OwnerControl);

            if (tempDialog.ShowDialog().HasValue&& tempDialog.Ok)
            {
                if (!selectedFileService.RenameSelectedFileWithoutExtension(tempDialog.PromptContent))
                {
                    _notificationManager.ShowAsync(
                        content: new NotificationContent()
                    {
                        Title   = "Something went wrong",
                        Message = "An unknown error occurred trying to rename the selected file",
                        Type    = NotificationType.Error
                    },
                        expirationTime: TimeSpan.FromSeconds(10));
                }
            }
        }
예제 #2
0
        public void ExportSelectedFile()
        {
            audioPlaybackService.Stop();
            audioPlaybackService.KillAudio();

            string preferredFileName = string.Empty;

            if (appSettingService.PromptForExportFileName)
            {
                CustomMessageBox tempDialog = new CustomMessageBox(
                    caption: "Select a filename for the exported file",
                    icon: CustomMessageBoxIcon.Question,
                    buttons: CustomMessageBoxButtons.OkAndCancel,
                    messageRows: new List <string>(),
                    prompt: Path.GetFileNameWithoutExtension(selectedFileService.SelectedFile.Name),
                    controlFocus: CustomMessageBoxFocus.Prompt,
                    promptValidationMode: CustomMessageBoxPromptValidation.EraseIllegalPathCharacters);

                tempDialog.TrySetViewablePositionFromOwner(OwnerControl);

                if (!tempDialog.ShowDialog().HasValue || !tempDialog.Ok)
                {
                    return;
                }

                preferredFileName = tempDialog.PromptContent;
            }

            var exportedFileName = selectedFileService.ExportFile(preferredFileName);

            if (string.IsNullOrEmpty(exportedFileName))
            {
                _notificationManager.ShowAsync(
                    content: new NotificationContent()
                {
                    Title   = "Something went wrong",
                    Message = "An unknown error occurred trying to export the selected file",
                    Type    = NotificationType.Error
                },
                    expirationTime: TimeSpan.FromSeconds(10));
                return;
            }


            _notificationManager.ShowAsync(
                content: new NotificationContent()
            {
                Type    = NotificationType.Success,
                Title   = $"{selectedFileService.SelectedFile.Name} exported to MP3!",
                Message = $"Export was successful, file has been exported to {exportedFileName}."
            },
                onClick: () =>
            {
                string argument = "/select, \"" + exportedFileName + "\"";
                System.Diagnostics.Process.Start("explorer.exe", argument);
            });
        }
예제 #3
0
        private void AudioRecordingService_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            switch (e.PropertyName)
            {
            case nameof(AudioRecordingService.CurrentlyRecording):
            {
                if (AudioRecordingService.CurrentlyRecording)
                {
                    if (SettingService.PlayAudioFeedBackMarkingStartAndStopRecording)
                    {
                        audioPlaybackService.KillAudio(reset: true);

                        audioPlaybackService.QueueFile(audioPlaybackService.RecordStartAudioFeedbackPath);
                        audioPlaybackService.Play();

                        while (audioPlaybackService.PlaybackState != PlaybackState.Stopped)
                        {
                        }

                        audioPlaybackService.KillAudio(reset: true);
                    }

                    if (SettingService.ShowBalloonTipsForRecording)
                    {
                        _notificationManager.ShowAsync(
                            new NotificationContent()
                            {
                                Type    = NotificationType.Information,
                                Title   = "Recording started!",
                                Message = "RecNForget now recording..."
                            });
                    }

                    AudioPlaybackService.KillAudio(reset: true);
                    TaskBar_ProgressState = "Error";
                }
                else
                {
                    if (SettingService.PlayAudioFeedBackMarkingStartAndStopRecording || SettingService.AutoReplayAudioAfterRecording)
                    {
                        if (SettingService.PlayAudioFeedBackMarkingStartAndStopRecording)
                        {
                            actionService.QueueAudioPlayback(fileName: audioPlaybackService.RecordStopAudioFeedbackPath);
                        }

                        if (SettingService.AutoReplayAudioAfterRecording)
                        {
                            actionService.QueueAudioPlayback(
                                fileName: AudioRecordingService.LastFileName,
                                startIndicatorFileName: SettingService.PlayAudioFeedBackMarkingStartAndStopReplaying ? audioPlaybackService.ReplayStartAudioFeedbackPath : null,
                                endIndicatorFileName: SettingService.PlayAudioFeedBackMarkingStartAndStopReplaying ? audioPlaybackService.ReplayStopAudioFeedbackPath : null);
                        }

                        actionService.TogglePlayPauseAudio();
                    }

                    TaskBar_ProgressState = "None";

                    if (SettingService.ShowBalloonTipsForRecording)
                    {
                        _notificationManager.ShowAsync(
                            content: new NotificationContent()
                            {
                                Type    = NotificationType.Success,
                                Title   = "Recording saved!",
                                Message = AudioRecordingService.LastFileName
                            },
                            onClick: () =>
                            {
                                if (AudioRecordingService.LastFileName == string.Empty || !File.Exists(AudioRecordingService.LastFileName))
                                {
                                    return;
                                }

                                string argument = "/select, \"" + AudioRecordingService.LastFileName + "\"";
                                System.Diagnostics.Process.Start("explorer.exe", argument);
                            });
                    }

                    if (SettingService.AutoSelectLastRecording)
                    {
                        SelectedFileService.SelectFile(new FileInfo(AudioRecordingService.LastFileName));
                    }
                }

                break;
            }
            }
        }