Example #1
0
 private void createKeySelector()
 {
     for (int i = 0; i < ChordBasic.toneCount; i++)
     {
         ComboBox_ChooseKey.Items.Add(ChordBasic.getTone(i).name);
     }
     ComboBox_ChooseKey.SelectionChanged += new SelectionChangedEventHandler(Callback_KeyChanged);
     ComboBox_ChooseKey.SelectedIndex     = 0;
 }
Example #2
0
        private void loadPadInfo()
        {
            XmlReader xml;

            xml = XmlReader.Create(new StreamReader("Resource/ChordPad.xml"));
            while (xml.Read())
            {
                if (xml.NodeType == XmlNodeType.Element && xml.Name == "pad")
                {
                    int    id;
                    string notation;
                    id       = int.Parse(xml.GetAttribute("id"));
                    notation = xml.GetAttribute("notation");
                    var res = Harmony.createHarmony(notation);
                    if (res != null)
                    {
                        harmonyToId.Add(res.uniqueId, harmonies.Count);
                        harmonies.Add(res);
                    }
                }
            }
            xml.Close();
            for (int x = 0; x < ChordBasic.toneCount; x++)
            {
                for (int y = 0; y < harmonies.Count; y++)
                {
                    chordPadList.Add(new ChordPad(x, y, new Chord(ChordBasic.getTone(x), harmonies[y])));
                }
            }
            xml = XmlReader.Create(new StreamReader("Resource/ChordRole.xml"));
            while (xml.Read())
            {
                if (xml.NodeType == XmlNodeType.Element && xml.Name == "role")
                {
                    string roleChordString = xml.GetAttribute("chord");
                    var    chordPad        = chordPadList.Find(m => m.chord.ToString() == roleChordString);
                    if (chordPad != null)
                    {
                        if (xml.GetAttribute("scale") == "M")
                        {
                            chordPad.roleInMajor = xml.GetAttribute("name");
                        }
                        else
                        {
                            chordPad.roleInMinor = xml.GetAttribute("name");
                        }
                    }
                }
            }
            xml.Close();
            isMajor = true;
        }