private ListViewItem AddSoundItem()
        {
            CreatorProperties.SoundDataItem newitem;
            newitem = new CreatorProperties.SoundDataItem("Sound" + BCBlockGameState.rgen.Next(0, 32768), "NONE", new byte[0]);

            ListViewItem newlitem = new ListViewItem(new string[] { newitem.Name, newitem.FileExtension, "0" });
            EditList.Add(newitem.Name, newitem);
            newlitem.Tag = (from h in EditList where h.Key == newitem.Name select h).First();

            lvwSoundEntries.Items.Add(newlitem);
            newlitem.Selected = true;
            return newlitem;
        }
        private void cmdBrowse_Click(object sender, EventArgs e)
        {
            const string Soundfilefilters = "All Supported Files(*.wav,*.ogg,*.mp3)|*.wav;*.ogg;*.mp3|" +
                "Wave Audio (*.wav)|*.wav|" +
                "Ogg Vorbis(*.ogg)|*.ogg|" +
                "MPEG Layer 3 (*.MP3)|*.MP3|" +
                "All Files(*.*)|*.*";

                //task: browse for and select a file, and populate the textboxes and LoadedSoundData arrays
                OpenFileDialog ofd = new OpenFileDialog();
                //filters? hmm. all the standard ones.

                ofd.Filter = Soundfilefilters;

                if (ofd.ShowDialog(this) == DialogResult.OK)
                {

                    //check that we have write access to the file.

                    var permission = new FileIOPermission(FileIOPermissionAccess.Read, ofd.FileName);
                    var permissionSet = new PermissionSet(PermissionState.None);
                    permissionSet.AddPermission(permission);
                    if (permissionSet.IsSubsetOf(AppDomain.CurrentDomain.PermissionSet))
                    {

                        if (lvwSoundEntries.Items.Count == 0) AddSoundItem();
                        //pressed OK.
                        String usefilename = ofd.FileName;
                        //cheat...
                        try
                        {
                            CreatorProperties.SoundDataItem sdi = new CreatorProperties.SoundDataItem(usefilename);

                            //txtProp_Key.Text = Path.GetFileNameWithoutExtension(usefilename);
                            //txtFileType.Text = Path.GetExtension(usefilename);
                            ignoreItemChanges = true;
                            txtProp_Key.Text = sdi.Name;
                            txtFileType.Text = sdi.FileExtension;
                            LoadedSoundData = sdi.SoundData;
                            lblDatainfo.Text = "Data Length:" + sdi.SoundData.Length.ToString() + " bytes";
                            ignoreItemChanges = false;
                            ApplyItem();
                        }
                        catch (IOException iox)
                        {
                            MessageBox.Show("Error Accessing \"" + usefilename + "\". " + iox.Message);

                        }

                    }

                }
        }