示例#1
0
        public Preferences()
        {
            string appData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);

            string moritzAppDataFolder = appData + @"\Moritz";

            // C:\Users\James\AppData\Roaming\Moritz
            M.CreateDirectoryIfItDoesNotExist(moritzAppDataFolder);

            LocalMoritzPreferencesPath = moritzAppDataFolder + @"\Preferences.mzpf";
            #region read prefs
            if (!File.Exists(LocalMoritzPreferencesPath))
            {
                LocalMoritzFolderLocation = "C://Documents";
                PreferredOutputDevice     = "";

                Save();

                string msg = "A preferences file could not be found at\n" +
                             "\t" + LocalMoritzPreferencesPath + ".\n\n" +
                             "A new one has been created with default values.";
                MessageBox.Show(msg, "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            try
            {
                using (XmlReader r = XmlReader.Create(LocalMoritzPreferencesPath))
                {
                    M.ReadToXmlElementTag(r, "moritzPreferences");                     // check that this is a moritz preferences file

                    M.ReadToXmlElementTag(r, "localMoritzFolderLocation");
                    LocalMoritzFolderLocation = r.ReadElementContentAsString();
                    M.ReadToXmlElementTag(r, "preferredOutputDevice");
                    PreferredOutputDevice = r.ReadElementContentAsString();
                }
            }
            catch
            {
                string msg = "Error reading preferences file";
                MessageBox.Show(msg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            #endregion

            if (CaptureOutputDevices())
            {
                if ((!String.IsNullOrEmpty(PreferredOutputDevice)) && MultimediaMidiOutputDevices.ContainsKey(PreferredOutputDevice) == false)
                {
                    string message = "Can't find the " + PreferredOutputDevice + ".\n\n" +
                                     "Check the preferences.";
                    MessageBox.Show(message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    CurrentOutputDeviceName = PreferredOutputDevice;
                }
            }
        }
示例#2
0
 public Multimedia.Midi.OutputDevice GetMidiOutputDevice(string deviceName)
 {
     Debug.Assert(MultimediaMidiOutputDevices.ContainsKey(deviceName));
     return(MultimediaMidiOutputDevices[deviceName]);
 }