Example #1
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;
        }
Example #2
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));
        }