예제 #1
0
        private void exportMappingsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            PickDialog pickDlg = new PickDialog();

            pickDlg.Prompt = "Pick the mappings to export";
            string[] existingMappings = DB.GetSavedMappings();
            if (existingMappings.Length <= 0)
            {
                MessageBox.Show("You can only export saved mappings,\nYou must save your current mapping before it can be exported", "Unable To Export", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            pickDlg.ExistingMappings = existingMappings;
            if (pickDlg.ShowDialog() == DialogResult.OK)
            {
                SaveFileDialog dlg = new SaveFileDialog();
                dlg.FileName = "";
                dlg.Filter   = "Midi2Cat Files | *.m2c";
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    DB.ExportMappings(dlg.FileName, pickDlg.Mappings);
                }
            }
        }
예제 #2
0
        private void importMappingsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.FileName    = "";
            dlg.Filter      = "Midi2Cat Files | *.m2c";
            dlg.Multiselect = false;
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                if (DB.ImportMappings(dlg.FileName) == false)
                {
                    MessageBox.Show("The import file is invalid or corrupt", "Import Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                PickDialog pickDlg = new PickDialog();
                pickDlg.Prompt           = "Pick the mappings to import from the file.";
                pickDlg.ExistingMappings = DB.GetImportedMappings();
                if (pickDlg.ShowDialog() == DialogResult.OK)
                {
                    DB.AddFromImport(pickDlg.Mappings);
                }
            }
        }