I want to be able to also change the AudioEditorForm's SelectionPath from this script but its not working, provide entire fix.

using Microsoft.VisualBasic.ApplicationServices;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO; // Added for Directory and Path usage
using System.Linq;
using System.Reflection.Metadata;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static System.Windows.Forms.DataFormats;

namespace ByteBreath
{
    public partial class DataSetMaker : Form
    {
        public string SharedPath;
        private Form1 _form1;
        string DatasetHome = @"C:\AI\Datasets\Fish-Speech";
        string SelectedDataset;

        public DataSetMaker(Form1 form1)
        {
            InitializeComponent();
            _form1 = form1;  // Fixed assignment here
        }

        private void DataSetMaker_Load(object sender, EventArgs e)
        {
            OFFSCREEN?.Focus();
            OFFSCREEN?.Select();

            try
            {
                if (Directory.Exists(DatasetHome))
                {
                    Dataset_List.Items.Clear(); // Avoid duplicates if somehow loaded multiple times
                    foreach (var folder in Directory.GetDirectories(DatasetHome))
                    {
                        string MyFolderName = Path.GetFileName(folder);
                        Dataset_List.Items.Add(MyFolderName);
                    }
                }
                else
                {
                    MessageBox.Show($"Dataset home path does not exist: {DatasetHome}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Failed to load datasets: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        private void DataSetMaker_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (_form1 != null && !_form1.IsDisposed)  // Fixed: Show existing instance instead of creating new one
            {
                _form1.Show();
            }
        }

        private void Create_Base_Click(object sender, EventArgs e)
        {
            OFFSCREEN?.Focus();
            OFFSCREEN?.Select();

            string datasetName = Dataset_Name.Text.Trim();
            if (string.IsNullOrWhiteSpace(datasetName))
            {
                MessageBox.Show("Please enter a valid dataset name.", "Input Required", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            string BaseFolderPath = Path.Combine(DatasetHome, datasetName);

            try
            {
                if (Directory.Exists(BaseFolderPath))
                {
                    MessageBox.Show($"Dataset '{datasetName}' already exists.", "Duplicate Dataset", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                Directory.CreateDirectory(BaseFolderPath);
                Dataset_List.Items.Add(datasetName);
                Dataset_Name.Text = string.Empty;
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Failed to create dataset folder: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        private void Create_Speaker_Click(object sender, EventArgs e)
        {
            OFFSCREEN?.Focus();
            OFFSCREEN?.Select();

            if (Dataset_List.SelectedItem == null)
            {
                MessageBox.Show("Please select a dataset first.", "Selection Required", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            string speakerName = Speaker_Name.Text.Trim();
            if (string.IsNullOrWhiteSpace(speakerName))
            {
                MessageBox.Show("Please enter a valid speaker name.", "Input Required", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            string TruePath = Path.Combine(DatasetHome, Dataset_List.SelectedItem.ToString(), speakerName);

            try
            {
                if (Directory.Exists(TruePath))
                {
                    MessageBox.Show($"Speaker '{speakerName}' already exists in the dataset.", "Duplicate Speaker", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                Directory.CreateDirectory(TruePath);
                Speaker_List.Items.Add(speakerName);
                Speaker_Name.Text = string.Empty;
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Failed to create speaker folder: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        private void Delete_Dataset_Click(object sender, EventArgs e)
        {
            OFFSCREEN?.Focus();
            OFFSCREEN?.Select();

            if (Dataset_List.SelectedItem == null)
            {
                MessageBox.Show("Please select a dataset to delete.", "Selection Required", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            SelectedDataset = Path.Combine(DatasetHome, Dataset_List.SelectedItem.ToString());

            try
            {
                if (Directory.Exists(SelectedDataset))
                {
                    var confirmResult = MessageBox.Show($"Are you sure you want to delete the dataset '{Dataset_List.SelectedItem}' and all its contents?",
                        "Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

                    if (confirmResult != DialogResult.Yes)
                        return;

                    Directory.Delete(SelectedDataset, true);
                    Dataset_List.Items.Remove(Dataset_List.SelectedItem.ToString());

                    if (Dataset_List.Items.Count > 0)
                    {
                        Dataset_List.SelectedIndex = Math.Min(Dataset_List.SelectedIndex, Dataset_List.Items.Count - 1);
                    }
                    else
                    {
                        Speaker_List.Items.Clear();
                        Voice_List.Items.Clear();
                    }
                }
                else
                {
                    MessageBox.Show("Selected dataset does not exist.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Error deleting dataset folder: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        private void Rename_Dataset_Click(object sender, EventArgs e)
        {
            OFFSCREEN?.Focus();
            OFFSCREEN?.Select();

            if (Dataset_List.SelectedItem == null)
            {
                MessageBox.Show("Please select a dataset to rename.", "Selection Required", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            string oldName = Dataset_List.SelectedItem.ToString();
            string oldPath = Path.Combine(DatasetHome, oldName);

            // Prompt user for new name
            string newName = Prompt.ShowDialog("Enter new dataset name:", "Rename Dataset", oldName);
            if (string.IsNullOrWhiteSpace(newName))
            {
                MessageBox.Show("New dataset name cannot be empty.", "Invalid Input", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            string newPath = Path.Combine(DatasetHome, newName.Trim());

            if (string.Equals(oldName, newName, StringComparison.OrdinalIgnoreCase))
            {
                MessageBox.Show("New dataset name is the same as the current name.", "No Change", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            try
            {
                if (!Directory.Exists(oldPath))
                {
                    MessageBox.Show("Original dataset folder does not exist.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                if (Directory.Exists(newPath))
                {
                    MessageBox.Show($"Dataset with the name '{newName}' already exists.", "Duplicate Dataset", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                Directory.Move(oldPath, newPath);

                // Update the listbox item
                int selectedIndex = Dataset_List.SelectedIndex;
                Dataset_List.Items[selectedIndex] = newName;
                Dataset_List.SelectedIndex = selectedIndex;

                SelectedDataset = newPath;
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Failed to rename dataset folder: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        private void Upload_Voices_Click(object sender, EventArgs e)
        {
            OFFSCREEN?.Focus();
            OFFSCREEN?.Select();

            if (Dataset_List.SelectedItem == null)
            {
                MessageBox.Show("Please select a dataset first.", "Selection Required", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (Speaker_List.SelectedItem == null)
            {
                MessageBox.Show("Please select a speaker first.", "Selection Required", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            OpenAndCopyAudioFiles();
        }

        private void Post_Process_Click(object sender, EventArgs e)
        {
            OFFSCREEN?.Focus();
            OFFSCREEN?.Select();

            // Placeholder: Add actual post-processing code or message
            MessageBox.Show("Post-processing functionality is not implemented yet.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }

        private void Transcribe_Labs_Click(object sender, EventArgs e)
        {
            OFFSCREEN?.Focus();
            OFFSCREEN?.Select();

            // Placeholder: Add transcription logic or prompt
            MessageBox.Show("Transcription functionality is not implemented yet.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }

        private void Create_NPY_Click(object sender, EventArgs e)
        {
            OFFSCREEN?.Focus();
            OFFSCREEN?.Select();

            // Placeholder: Add .npy creation logic here
            MessageBox.Show(".NPY creation functionality is not implemented yet.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }

        private void Pack_Protos_Click(object sender, EventArgs e)
        {
            OFFSCREEN?.Focus();
            OFFSCREEN?.Select();

            // Placeholder: Add protobuf packing logic here
            MessageBox.Show("Packing protos functionality is not implemented yet.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }

        private void Preview_Voice_Click(object sender, EventArgs e)
        {
            OFFSCREEN?.Focus();
            OFFSCREEN?.Select();

            if (Voice_List.SelectedItem == null)
            {
                MessageBox.Show("Please select a voice file to preview.", "Selection Required", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            string voiceFilePath = Path.Combine(
                DatasetHome,
                Dataset_List.SelectedItem?.ToString() ?? string.Empty,
                Speaker_List.SelectedItem?.ToString() ?? string.Empty,
                Voice_List.SelectedItem.ToString());

            if (!File.Exists(voiceFilePath))
            {
                MessageBox.Show("Selected voice file does not exist.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            try
            {
                // Use an audio player or external process to preview file
                System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo()
                {
                    FileName = voiceFilePath,
                    UseShellExecute = true
                });
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Failed to preview voice file: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        private void Delete_Voice_Files_Click(object sender, EventArgs e)
        {
            OFFSCREEN?.Focus();
            OFFSCREEN?.Select();

            if (Dataset_List.SelectedItem == null || Speaker_List.SelectedItem == null || Voice_List.SelectedItem == null)
            {
                MessageBox.Show("Please select a dataset, speaker, and voice file to delete.", "Selection Required", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            string TotalPath = Path.Combine(
                DatasetHome,
                Dataset_List.SelectedItem.ToString(),
                Speaker_List.SelectedItem.ToString(),
                Voice_List.SelectedItem.ToString());

            if (!File.Exists(TotalPath))
            {
                MessageBox.Show("Selected voice file does not exist.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            var confirmResult = MessageBox.Show($"Are you sure you want to delete the voice file '{Voice_List.SelectedItem}'?",
                "Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (confirmResult != DialogResult.Yes)
                return;

            try
            {
                File.Delete(TotalPath);

                var itemBackup = Voice_List.SelectedItem;
                Voice_List.ClearSelected();
                Voice_List.Items.Remove(itemBackup);
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Failed to delete voice file: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        private void Train_Button_Click(object sender, EventArgs e)
        {
            OFFSCREEN?.Focus();
            OFFSCREEN?.Select();

            var confirmResult = MessageBox.Show("This action will stop all running servers before the training process starts. Continue?",
                "Confirm Training", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (confirmResult != DialogResult.Yes)
                return;

            // Insert training logic here or call training routine

            MessageBox.Show("Training process started.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }

        private void Dataset_List_Click(object sender, EventArgs e)
        {
            // If nothing is selected in the list box, make sure no items remain selected
            if (Dataset_List.SelectedIndex == -1)
            {
                Dataset_List.ClearSelected();
            }
        }

        private void Dataset_List_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (Dataset_List.SelectedItem == null)
            {
                Speaker_List.Items.Clear();
                Voice_List.Items.Clear();
                SelectedDataset = null;
                return;
            }

            // Clear the Speakers list before re-populating it
            Speaker_List.Items.Clear();
            Voice_List.Items.Clear();

            // Construct the selected dataset path safely
            SelectedDataset = Path.Combine(DatasetHome, Dataset_List.SelectedItem.ToString());

            try
            {
                if (Directory.Exists(SelectedDataset))
                {
                    foreach (var folder in Directory.GetDirectories(SelectedDataset))
                    {
                        string folderName = Path.GetFileName(folder);
                        Speaker_List.Items.Add(folderName);
                    }
                }
                else
                {
                    MessageBox.Show("Selected dataset directory does not exist.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Failed to load speakers: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (Voice_List.SelectedItem == null)
            {
                MessageBox.Show("Please select a voice file first.", "Selection Required", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            // Compose full path to selected voice file for usage in AudioEditorForm
            if (Dataset_List.SelectedItem == null || Speaker_List.SelectedItem == null)
            {
                MessageBox.Show("Please select a dataset and speaker first.", "Selection Required", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            SharedPath = Path.Combine(
                DatasetHome,
                Dataset_List.SelectedItem.ToString(),
                Speaker_List.SelectedItem.ToString(),
                Voice_List.SelectedItem.ToString());
            Clipboard.SetText(SharedPath);
            AudioEditorForm audioEditorForm = new AudioEditorForm();
            audioEditorForm.SelectionPath = SharedPath;
            audioEditorForm.Show();
        }

        private void Speaker_List_SelectedIndexChanged(object sender, EventArgs e)
        {
            // Clear existing voice list items
            Voice_List.Items.Clear();

            if (Dataset_List.SelectedItem == null || Speaker_List.SelectedItem == null)
                return;

            string totalPath = Path.Combine(
                DatasetHome,
                Dataset_List.SelectedItem.ToString(),
                Speaker_List.SelectedItem.ToString());

            try
            {
                if (Directory.Exists(totalPath))
                {
                    var files = Directory.GetFiles(totalPath)
                                         .Where(f => f.EndsWith(".mp3", StringComparison.OrdinalIgnoreCase) ||
                                                     f.EndsWith(".wav", StringComparison.OrdinalIgnoreCase) ||
                                                     f.EndsWith(".flac", StringComparison.OrdinalIgnoreCase));

                    foreach (var file in files)
                    {
                        Voice_List.Items.Add(Path.GetFileName(file));
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Failed to load voice files: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (Dataset_List.SelectedItem == null || Speaker_List.SelectedItem == null)
            {
                MessageBox.Show("Please select a dataset and speaker to delete.", "Selection Required", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            string TotalPath = Path.Combine(DatasetHome, Dataset_List.SelectedItem.ToString(), Speaker_List.SelectedItem.ToString());

            if (!Directory.Exists(TotalPath))
            {
                MessageBox.Show("Selected speaker folder does not exist.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            var confirmResult = MessageBox.Show($"Are you sure you want to delete the speaker folder '{Speaker_List.SelectedItem}' and all its contents?",
                "Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (confirmResult != DialogResult.Yes)
                return;

            try
            {
                Directory.Delete(TotalPath, true);

                var itemBackup = Speaker_List.SelectedItem;
                Speaker_List.ClearSelected();
                Speaker_List.Items.Remove(itemBackup);

                // Clear voice list and Speaker name input field
                Voice_List.Items.Clear();
                Speaker_Name.Clear();
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Failed to delete speaker folder: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        public void OpenAndCopyAudioFiles()
        {
            using (OpenFileDialog openFileDialog = new OpenFileDialog())
            {
                openFileDialog.Filter = "Audio Files (*.mp3;*.wav;*.flac)|*.mp3;*.wav;*.flac";
                openFileDialog.FilterIndex = 1;
                openFileDialog.Multiselect = true;  // Enable multi-selection
                openFileDialog.Title = "Select audio files to copy";

                if (openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    if (Dataset_List.SelectedItem == null || Speaker_List.SelectedItem == null)
                    {
                        MessageBox.Show("Please select a dataset and speaker before uploading files.", "Selection Required", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }

                    string TotalPath = Path.Combine(DatasetHome, Dataset_List.SelectedItem.ToString(), Speaker_List.SelectedItem.ToString());
                    // Ensure destination directory exists
                    if (!Directory.Exists(TotalPath))
                    {
                        Directory.CreateDirectory(TotalPath);
                    }

                    foreach (string sourceFilePath in openFileDialog.FileNames)
                    {
                        string fileName = Path.GetFileName(sourceFilePath);
                        string destFilePath = Path.Combine(TotalPath, fileName);

                        try
                        {
                            // Optionally overwrite existing files
                            File.Copy(sourceFilePath, destFilePath, overwrite: true);

                            // Avoid duplicating entries in Voice_List: add only if not already present
                            if (!Voice_List.Items.Contains(fileName))
                                Voice_List.Items.Add(fileName);
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show($"Failed to copy {fileName}: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
            }
        }
    }

    // Utility class for input dialogs (for renaming dataset)
    public static class Prompt
    {
        public static string ShowDialog(string text, string caption, string defaultValue = "")
        {
            Form prompt = new Form()
            {
                Width = 400,
                Height = 150,
                FormBorderStyle = FormBorderStyle.FixedDialog,
                Text = caption,
                StartPosition = FormStartPosition.CenterParent,
                MinimizeBox = false,
                MaximizeBox = false
            };

            Label textLabel = new Label() { Left = 20, Top = 20, Text = text, AutoSize = true };
            TextBox inputBox = new TextBox() { Left = 20, Top = 50, Width = 340 };
            inputBox.Text = defaultValue;

            Button confirmation = new Button() { Text = "OK", Left = 190, Width = 80, Top = 80, DialogResult = DialogResult.OK };
            Button cancel = new Button() { Text = "Cancel", Left = 280, Width = 80, Top = 80, DialogResult = DialogResult.Cancel };

            confirmation.Click += (sender, e) => { prompt.Close(); };
            cancel.Click += (sender, e) => { prompt.Close(); };

            prompt.Controls.Add(textLabel);
            prompt.Controls.Add(inputBox);
            prompt.Controls.Add(confirmation);
            prompt.Controls.Add(cancel);
            prompt.AcceptButton = confirmation;
            prompt.CancelButton = cancel;

            return prompt.ShowDialog() == DialogResult.OK ? inputBox.Text.Trim() : null;
        }
    }
}