Ejemplo n.º 1
0
        private void IEL_Click(object sender, EventArgs e)
        {
            OpenFileDialog OFD = new OpenFileDialog()
            {
                Multiselect      = true,
                InitialDirectory = Properties.Settings.Default.LastImportExportPath,
                Filter           = "Soundfont lists | *.sflist; *.omlist; *.txt;"
            };

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

                    foreach (string ListW in OFD.FileNames)
                    {
                        SoundFontListExtension.ChangeList(-1, ListW, true, false);
                    }

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

                    Program.ShowError(0, "Import finished", "The selected lists have been imported successfully to the currently selected list in the configurator.", null);
                }
            }
            catch (Exception ex)
            {
                ReloadListAfterError(ex);
            }

            OFD.Dispose();
        }
Ejemplo n.º 2
0
        private void Preload_Click(object sender, EventArgs e)
        {
            try
            {
                if (Lis.SelectedIndices.Count != -1 && Lis.SelectedIndices.Count > 0)
                {
                    for (int i = Lis.SelectedIndices.Count - 1; i >= 0; i--)
                    {
                        switch (Lis.SelectedItems[i].SubItems[7].Text.ToLowerInvariant())
                        {
                        default:
                        case "yes":
                            Lis.SelectedItems[i].SubItems[7].Text = "No";
                            break;

                        case "no":
                            Lis.SelectedItems[i].SubItems[7].Text = "Yes";
                            break;
                        }
                    }

                    SoundFontListExtension.SaveList(ref Lis, SelectedListBox.SelectedIndex, null);
                }
            }
            catch (Exception ex)
            {
                ReloadListAfterError(ex);
            }
        }
Ejemplo n.º 3
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);
                }
            }
        }
Ejemplo n.º 4
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);
            }
        }
Ejemplo n.º 5
0
        private void CLi_Click(object sender, EventArgs e)
        {
            DialogResult RES = Program.ShowError(1, String.Format("Clear {0}", SelectedListBox.Text), "Are you sure you want to clear this list?", null);

            if (RES == DialogResult.Yes)
            {
                try
                {
                    Lis.Items.Clear();
                    SoundFontListExtension.SaveList(ref Lis, SelectedListBox.SelectedIndex, null);
                    Program.ShowError(0, "Cleaning finished", "The list has been cleaned successfully.", null);
                }
                catch (Exception ex)
                {
                    ReloadListAfterError(ex);
                }
            }
        }
Ejemplo n.º 6
0
        private void MoveListViewItems(ListViewEx sender, MoveDirection direction)
        {
            try
            {
                int dir = (int)direction;
                int opp = dir * -1;

                bool valid = sender.SelectedItems.Count > 0 &&
                             ((direction == MoveDirection.Down && (sender.SelectedItems[sender.SelectedItems.Count - 1].Index < sender.Items.Count - 1)) ||
                              (direction == MoveDirection.Up && (sender.SelectedItems[0].Index > 0)));

                if (valid)
                {
                    List <int>     Is   = new List <int>();
                    ListViewItem[] iTBM = sender.SelectedItems.Cast <ListViewItem>().ToArray();

                    IEnumerable <ListViewItem> iTBMEnum;
                    iTBMEnum = (direction == MoveDirection.Down) ? iTBM.Reverse() : iTBM;

                    WinAPI.SendMessage(sender.Handle, WinAPI.WM_SETREDRAW, (IntPtr)0, IntPtr.Zero);
                    foreach (ListViewItem item in iTBMEnum)
                    {
                        int index = item.Index + dir;

                        sender.Items.RemoveAt(item.Index);
                        Is.Add(sender.Items.Insert(index, item).Index);
                    }

                    foreach (int I in Is)
                    {
                        sender.Items[I].Selected = true;
                    }

                    WinAPI.SendMessage(sender.Handle, WinAPI.WM_SETREDRAW, (IntPtr)1, IntPtr.Zero);
                    sender.Refresh();

                    SoundFontListExtension.SaveList(ref Lis, SelectedListBox.SelectedIndex, null);
                }
            }
            catch (Exception ex)
            {
                ReloadListAfterError(ex);
            }
        }
Ejemplo n.º 7
0
        private void RmvSF_Click(object sender, EventArgs e)
        {
            try
            {
                if (Lis.SelectedIndices.Count != -1 && Lis.SelectedIndices.Count > 0)
                {
                    foreach (int index in Lis.SelectedIndices.Cast <int>().Select(x => x).Reverse())
                    {
                        Lis.Items.RemoveAt(index);
                    }

                    SoundFontListExtension.SaveList(ref Lis, SelectedListBox.SelectedIndex, null);
                }
            }
            catch (Exception ex)
            {
                ReloadListAfterError(ex);
            }
        }
Ejemplo n.º 8
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();
        }
Ejemplo n.º 9
0
        private void EL_Click(object sender, EventArgs e)
        {
            SaveFileDialog SFD = new SaveFileDialog()
            {
                OverwritePrompt  = true,
                InitialDirectory = Properties.Settings.Default.LastImportExportPath,
                Filter           = "Soundfont lists | *.sflist; *.omlist; *.txt;"
            };

            if (SFD.ShowDialog(this) == DialogResult.OK)
            {
                Properties.Settings.Default.LastImportExportPath = Path.GetDirectoryName(SFD.FileName);
                Properties.Settings.Default.Save();

                SoundFontListExtension.SaveList(ref Lis, -1, SFD.FileName);

                Program.ShowError(0, "Export finished", String.Format("The list has been exported successfully to \"{0}\".", SFD.FileName), null);
            }

            SFD.Dispose();
        }
Ejemplo n.º 10
0
        private void SFEDSwitch(bool status)
        {
            try
            {
                if (Lis.SelectedIndices.Count != -1 && Lis.SelectedIndices.Count > 0)
                {
                    for (int i = Lis.SelectedIndices.Count - 1; i >= 0; i--)
                    {
                        if (Lis.SelectedItems[i].ForeColor != (status ? SoundFontListExtension.SFEnabled : SoundFontListExtension.SFDisabled))
                        {
                            Lis.SelectedItems[i].ForeColor = (status ? SoundFontListExtension.SFEnabled : SoundFontListExtension.SFDisabled);
                        }
                    }

                    SoundFontListExtension.SaveList(ref Lis, SelectedListBox.SelectedIndex, null);
                }
            }
            catch (Exception ex)
            {
                ReloadListAfterError(ex);
            }
        }
Ejemplo n.º 11
0
 private void SaveList_Click(object sender, EventArgs e)
 {
     SoundFontListExtension.SaveList(ref Lis, SelectedListBox.SelectedIndex, null);
 }
Ejemplo n.º 12
0
        private void EBPV_Click(object sender, EventArgs e)
        {
            Boolean       ToReload = false;
            List <String> SFErr    = new List <String>();

            foreach (ListViewItem Item in Lis.SelectedItems)
            {
                try
                {
                    try
                    {
                        Int32[] OldValues =
                        {
                            Convert.ToInt32(Item.SubItems[1].Text),
                            Convert.ToInt32(Item.SubItems[2].Text),
                            Convert.ToInt32(Item.SubItems[3].Text),
                            Convert.ToInt32(Item.SubItems[4].Text),
                            Convert.ToInt32(Item.SubItems[5].Text),
                            Convert.ToInt32(Item.SubItems[6].Text.ToLowerInvariant().Equals("yes") ? 1 : 0)
                        };

                        using (var BPOW = new BankNPresetSel(Path.GetFileName(Item.Text), true, Path.GetExtension(Item.Text).ToLowerInvariant() != ".sfz", OldValues))
                        {
                            var RES = BPOW.ShowDialog();

                            if (RES == DialogResult.OK)
                            {
                                ToReload = true;
                                Item.SubItems[1].Text = BPOW.BankValueReturn.ToString();
                                Item.SubItems[2].Text = BPOW.PresetValueReturn.ToString();
                                Item.SubItems[3].Text = BPOW.DesBankValueReturn.ToString();
                                Item.SubItems[4].Text = BPOW.DesPresetValueReturn.ToString();
                                Item.SubItems[5].Text = BPOW.DesBankLSBValueReturn.ToString();
                                Item.SubItems[6].Text = BPOW.XGModeC ? "Yes" : "No";
                            }
                            else
                            {
                                continue;
                            }
                        }
                    }
                    catch { SFErr.Add(Item.Text); }

                    if (SFErr.Count > 0)
                    {
                        Program.ShowError(
                            2,
                            "Unable to edit SoundFont(s)",
                            String.Format(
                                "The configurator was unable to edit the following SoundFont(s).\n\n{0}\n\nPress OK to continue.",
                                String.Join(Environment.NewLine, SFErr.ToArray())),
                            null);
                    }

                    if (ToReload)
                    {
                        SoundFontListExtension.SaveList(ref Lis, SelectedListBox.SelectedIndex, null);
                    }
                }
                catch (Exception ex)
                {
                    ReloadListAfterError(ex);
                }
            }
        }
Ejemplo n.º 13
0
 private void Lis_ItemChecked(object sender, ItemCheckedEventArgs e)
 {
     SoundFontListExtension.SaveList(ref Lis, SelectedListBox.SelectedIndex, null);
 }
Ejemplo n.º 14
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;
        }
Ejemplo n.º 15
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));
        }