Example #1
0
        public static void SaveList(ref ListViewEx List, int SelectedList, String SavePath)
        {
            UInt32 SFCount   = 1;
            String ToPrint   = "";
            String WhichList = (SelectedList == -1) ? SavePath : Program.ListsPath[SelectedList];

            ListViewItem[] Items = new ListViewItem[List.Items.Count];
            List.Items.CopyTo(Items, 0);

            StopCheck = true;
            ToPrint  += "// SoundFont list\n";
            ToPrint  += String.Format("// Last edit date: {0}\n\n", DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss.fffffff tt"));
            foreach (ListViewItem item in Items)
            {
                ToPrint += String.Format("// SoundFont n°{0}\n", SFCount);
                ToPrint += "sf.start\n";
                ToPrint += String.Format("sf.path = {0}\n", item.Text);
                ToPrint += String.Format("sf.enabled = {0}\n", item.Checked ? 1 : 0);
                ToPrint += String.Format("sf.preload = {0}\n", item.SubItems[7].Text.ToLowerInvariant().Equals("yes") ? 1 : 0);
                ToPrint += String.Format("sf.srcb = {0}\n", item.SubItems[1].Text);
                ToPrint += String.Format("sf.srcp = {0}\n", item.SubItems[2].Text);
                ToPrint += String.Format("sf.desb = {0}\n", item.SubItems[3].Text);
                ToPrint += String.Format("sf.desp = {0}\n", item.SubItems[4].Text);
                ToPrint += String.Format("sf.desblsb = {0}\n", item.SubItems[5].Text);
                ToPrint += String.Format("sf.xgdrums = {0}\n", item.SubItems[6].Text.ToLowerInvariant().Equals("yes") ? 1 : 0);
                ToPrint += "sf.end\n\n";
                SFCount++;
            }
            ToPrint += "// Generated by: OmniMIDI";

            CSFCS = ToPrint;
            File.WriteAllText(WhichList, ToPrint, Encoding.UTF8);
            StopCheck = false;

            if (SelectedList != -1)
            {
                int CurList = SelectedList + 1;

                if (Convert.ToInt32(Program.Watchdog.GetValue("currentsflist", 1)) == CurList)
                {
                    if (CurList == 1 | Properties.Settings.Default.AutoLoadList)
                    {
                        Program.Watchdog.SetValue(String.Format("rel{0}", CurList), 1, Microsoft.Win32.RegistryValueKind.DWord);
                    }
                }
            }
        }
Example #2
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);
            }
        }
Example #3
0
        public static void SaveList(ref ListViewEx List, int SelectedList, String SavePath)
        {
            String WhichList = (SelectedList == -1) ? SavePath : Program.ListsPath[SelectedList];

            ListViewItem[] Items = new ListViewItem[List.Items.Count];
            List.Items.CopyTo(Items, 0);

            StopCheck = true;
            using (StreamWriter sw = new StreamWriter(WhichList))
            {
                UInt32 SFCount = 1;
                sw.WriteLine("// Generated by OmniMIDI\n");
                foreach (ListViewItem item in Items)
                {
                    sw.WriteLine(String.Format("// SoundFont n°{0}", SFCount));
                    sw.WriteLine("sf.start");
                    sw.WriteLine(String.Format("sf.path = {0}", item.Text));
                    sw.WriteLine(String.Format("sf.enabled = {0}", (item.ForeColor == SFEnabled) ? "1" : "0"));
                    sw.WriteLine(String.Format("sf.srcb = {0}", item.SubItems[1].Text));
                    sw.WriteLine(String.Format("sf.srcp = {0}", item.SubItems[2].Text));
                    sw.WriteLine(String.Format("sf.desb = {0}", item.SubItems[3].Text));
                    sw.WriteLine(String.Format("sf.desp = {0}", item.SubItems[4].Text));
                    sw.WriteLine(String.Format("sf.xgdrums = {0}", (item.SubItems[5].Text.Equals("Yes")) ? "1" : "0"));
                    sw.WriteLine("sf.end\n");
                    SFCount++;
                }
                sw.WriteLine("// Generated by OmniMIDI");
            }
            StopCheck = false;

            if (SelectedList != -1)
            {
                int CurList = SelectedList + 1;

                if (Convert.ToInt32(Program.Watchdog.GetValue("currentsflist", 1)) == CurList)
                {
                    if (CurList == 1 | Properties.Settings.Default.AutoLoadList)
                    {
                        Program.Watchdog.SetValue(String.Format("rel{0}", CurList), 1, Microsoft.Win32.RegistryValueKind.DWord);
                    }
                }
            }
        }