Exemplo n.º 1
0
        private void PasteSoundFonts()
        {
            String FCB = Clipboard.GetText();

            if (!String.IsNullOrEmpty(FCB))
            {
                String   InvalidChars = new String(Path.GetInvalidPathChars());
                String[] Is           = FCB.Split('\t');

                for (int i = 0; i < Is.Count(); i++)
                {
                    foreach (char C in InvalidChars)
                    {
                        Is[i] = Is[i].Replace(C.ToString(), "");
                    }
                }

                ListViewItem[] iSFs = SoundFontListExtension.AddSFToList(Is, false, true);

                if (iSFs != null)
                {
                    foreach (ListViewItem iSF in iSFs)
                    {
                        Lis.Items.Add(iSF);
                    }

                    SoundFontListExtension.SaveList(ref Lis, SelectedListBox.SelectedIndex, null);
                }
            }
        }
Exemplo n.º 2
0
        private void Lis_DragDrop(object sender, DragEventArgs e)
        {
            string[] s = (string[])e.Data.GetData(DataFormats.FileDrop, false);

            ListViewItem[] iSFs = SoundFontListExtension.AddSFToList(s, BankPresetOverride.Checked, false);

            if (iSFs != null)
            {
                foreach (ListViewItem iSF in iSFs)
                {
                    Lis.Items.Add(iSF);
                }

                SoundFontListExtension.SaveList(ref Lis, SelectedListBox.SelectedIndex, null);
            }
        }
Exemplo n.º 3
0
        private void AddSF_Click(object sender, EventArgs e)
        {
            String F = "SoundFont files | ";

            foreach (String Fi in Properties.Settings.Default.SupportedFormats)
            {
                F += String.Format("*{0}; ", Fi);
            }

            OpenFileDialog OFD = new OpenFileDialog()
            {
                Multiselect      = true,
                InitialDirectory = Properties.Settings.Default.LastSoundFontPath,
                Filter           = F
            };

            try
            {
                if (OFD.ShowDialog(this) == DialogResult.OK)
                {
                    Properties.Settings.Default.LastSoundFontPath = Path.GetDirectoryName(OFD.FileNames[0]);
                    Properties.Settings.Default.Save();

                    ListViewItem[] iSFs = SoundFontListExtension.AddSFToList(OFD.FileNames, BankPresetOverride.Checked, false);

                    if (iSFs != null)
                    {
                        foreach (ListViewItem iSF in iSFs)
                        {
                            Lis.Items.Add(iSF);
                        }
                    }

                    SoundFontListExtension.SaveList(ref Lis, SelectedListBox.SelectedIndex, null);
                }
            }
            catch (Exception ex)
            {
                ReloadListAfterError(ex);
            }

            OFD.Dispose();
        }
Exemplo n.º 4
0
        public SoundFontListEditor(String[] SFs)
        {
            InitializeComponent();

            Delegate = this;

            try
            {
                for (int i = 0; i < Lis.Columns.Count; i++)
                {
                    if (Properties.Settings.Default.SFColumnsSize[i] != -1)
                    {
                        Lis.Columns[i].Width = Properties.Settings.Default.SFColumnsSize[i];
                    }
                    else
                    {
                        Properties.Settings.Default.SFColumnsSize[i] = Lis.Columns[i].Width;
                        Properties.Settings.Default.Save();
                    }
                }
            }
            catch { Functions.ResetSpecificSetting("SFColumnsSize"); }

            // Attach context menu
            Lis.ContextMenu = LisCM;

            // Prepare CSFWatcher
            SoundFontListExtension.OpenCSFWatcher(false, null);

            SFlg.BackgroundImage      = Properties.Resources.Question;
            CLi.BackgroundImage       = Properties.Resources.ClearIcon;
            AddSF.BackgroundImage     = Properties.Resources.AddSFIcon;
            RmvSF.BackgroundImage     = Properties.Resources.RmvSFIcon;
            MvU.BackgroundImage       = Properties.Resources.MvUpIcon;
            MvD.BackgroundImage       = Properties.Resources.MvDwIcon;
            LoadToApp.BackgroundImage = Properties.Resources.ReloadIcon;
            Preload.BackgroundImage   = Properties.Resources.PreloadIcon;
            IEL.BackgroundImage       = Properties.Resources.ImportIcon;
            EL.BackgroundImage        = Properties.Resources.ExportIcon;

            // Add the SoundFonts before activating the CSFWatcher
            if (SFs != null && SFs.Count() > 0)
            {
                foreach (String SF in SFs)
                {
                    if (SoundFontListExtension.CheckSupportedFormat(Path.GetExtension(SF)))
                    {
                        using (AddToWhichList TF = new AddToWhichList(SF))
                        {
                            if (TF.ShowDialog() == DialogResult.OK)
                            {
                                SelectedListBox.SelectedIndex = TF.Index;

                                String[]       TSF  = new String[] { SF };
                                ListViewItem[] iSFs = SoundFontListExtension.AddSFToList(TSF, false, true);

                                if (iSFs != null)
                                {
                                    foreach (ListViewItem iSF in iSFs)
                                    {
                                        Lis.Items.Add(iSF);
                                    }
                                }

                                SoundFontListExtension.SaveList(ref Lis, SelectedListBox.SelectedIndex, null);
                            }
                        }
                    }
                }
            }

            SelectedListBox.SelectedIndex = Properties.Settings.Default.LastListSelected;
        }
Exemplo n.º 5
0
        public SoundFontListEditor(String[] SFs)
        {
            InitializeComponent();

            Delegate = this;

            for (int i = 0; i < Lis.Columns.Count; i++)
            {
                if (Properties.Settings.Default.SFColumnsSize[i] != -1)
                {
                    Lis.Columns[i].Width = Properties.Settings.Default.SFColumnsSize[i];
                }
                else
                {
                    Properties.Settings.Default.SFColumnsSize[i] = Lis.Columns[i].Width;
                    Properties.Settings.Default.Save();
                }
            }

            // Attach context menu
            Lis.ContextMenu = LisCM;

            // Prepare CSFWatcher
            SoundFontListExtension.OpenCSFWatcher(false, null);

            SFlg.BackgroundImage      = Properties.Resources.Question;
            CLi.BackgroundImage       = Properties.Resources.ClearIcon;
            AddSF.BackgroundImage     = Properties.Resources.AddSFIcon;
            RmvSF.BackgroundImage     = Properties.Resources.RmvSFIcon;
            MvU.BackgroundImage       = Properties.Resources.MvUpIcon;
            MvD.BackgroundImage       = Properties.Resources.MvDwIcon;
            LoadToApp.BackgroundImage = Properties.Resources.ReloadIcon;
            EnableSF.BackgroundImage  = Properties.Resources.EnableIcon;
            DisableSF.BackgroundImage = Properties.Resources.DisableIcon;
            IEL.BackgroundImage       = Properties.Resources.ImportIcon;
            EL.BackgroundImage        = Properties.Resources.ExportIcon;

            // Add the SoundFonts before activating the CSFWatcher
            if (SFs != null && SFs.Count() > 0)
            {
                foreach (String SF in SFs)
                {
                    if (Path.GetExtension(SF).ToLowerInvariant() == ".sf1" |
                        Path.GetExtension(SF).ToLowerInvariant() == ".sf2" |
                        Path.GetExtension(SF).ToLowerInvariant() == ".sfz" |
                        Path.GetExtension(SF).ToLowerInvariant() == ".sfark" |
                        Path.GetExtension(SF).ToLowerInvariant() == ".sfpack")
                    {
                        using (AddToWhichList TF = new AddToWhichList(SF))
                        {
                            if (TF.ShowDialog() == DialogResult.OK)
                            {
                                SelectedListBox.SelectedIndex = TF.Index;

                                String[]       TSF  = new String[] { SF };
                                ListViewItem[] iSFs = SoundFontListExtension.AddSFToList(TSF, false, true);

                                if (iSFs != null)
                                {
                                    foreach (ListViewItem iSF in iSFs)
                                    {
                                        Lis.Items.Add(iSF);
                                    }
                                }

                                SoundFontListExtension.SaveList(ref Lis, SelectedListBox.SelectedIndex, null);
                            }
                        }
                    }
                }
            }

            SelectedListBox.SelectedIndex = Properties.Settings.Default.LastListSelected;
            if (SelectedListBox.SelectedIndex == 0)
            {
                SoundFontListExtension.StartCSFWatcher();
            }

            // Activate the CSFWatcher now by assigning the events, to avoid a race condition
            SoundFontListExtension.OpenCSFWatcher(true, new FileSystemEventHandler(CSFHandler));
        }