Esempio n. 1
0
        private void LoadScore(string filePath)
        {
            {
                BinaryFormatter bf = new BinaryFormatter();
                using (Stream iStream = new FileStream
                                            (ofdScoreFile.FileName, FileMode.Open, FileAccess.Read))
                    score = (Score)bf.Deserialize(iStream);

                // Adjust old style note classes

                List <IMeasure> newMeasures = new List <IMeasure>();
                ScoreFactory    sf          = new ScoreFactory();

                foreach (IMeasure m in score.Measures)
                {
                    for (int i = 0; i < m.Notes.Count(); i++)
                    {
                        if (!(m.Notes[i] is ColouredNote))
                        {
                            m.Notes[i] = sf.CreateNote
                                             (m.Notes[i].Offset, m.Notes[i].Pitch, m.Notes[i].Duration);
                        }
                    }
                }
                filePath = ofdScoreFile.FileName;
                Properties.Settings.Default.FilePath = filePath;
                Properties.Settings.Default.Save();
                LoadImages();
            }
        }
Esempio n. 2
0
        public void CreateScoreWithFlats()
        {
            ScoreFactory sf    = new ScoreFactory();
            IScore       score = sf.CreateScore(true);

            score.Measures.Add(sf.CreateMeasure(4, false));
            score.Measures.Add(sf.CreateMeasure(3, false));
            score.Measures[0].Notes.Add(sf.CreateNote(0, 13, 4));
            score.Measures[0].Notes.Add(sf.CreateNote(2, 14, 4));
            score.Measures[0].Notes.Add(sf.CreateNote(4, 15, 4));
            score.Measures[0].Notes.Add(sf.CreateNote(14, 39, 4));
            score.Measures[0].Notes.Add(sf.CreateNote(14, 40, 4));
            score.Measures[1].Notes.Add(sf.CreateNote(0, 42, 4));
            ScoreWriter sw  = new ScoreWriter(score, 6);
            Image       img = sw.RenderPage(0);

            img.Save("c:\\tmp\\flatScore.bmp");
            Assert.IsNotNull(img);
        }