예제 #1
0
파일: Track.cs 프로젝트: Kasania/NoteEditor
        private static void ReadNote(ref NoteList notes, ref XmlReader reader)
        {
            Direction dir       = Direction.UP;
            Keys      key       = Keys.NotAKey;
            int       _Position = 0;

            try
            {
                if (reader.MoveToFirstAttribute())
                {
                    do
                    {
                        string attrbName = reader.Name;
                        if (attrbName.CompareTo(_XmlNoteKey) == 0)
                        {
                            Enum.TryParse <Keys>(reader.Value, out key);
                        }
                        else if (attrbName.CompareTo(_XmlNotePosition) == 0)
                        {
                            _Position = int.Parse(reader.Value);
                        }
                        else if (attrbName.CompareTo(_XmlNoteLocation) == 0)
                        {
                            if (reader.Value.Equals(_XmlNoteLocationUP))
                            {
                                dir = Direction.UP;
                            }
                            else
                            {
                                dir = Direction.DOWN;
                            }
                        }
                    } while (reader.MoveToNextAttribute());
                }
            }
            catch (System.Exception e)
            {
                Console.Write(e.Message);
                return;
            }


            Note note = new Note(key, dir)
            {
                Position = _Position,
                isActive = true
            };
            int _last = notes.GetNotes(key, dir).Count;

            if (_Position > _last)
            {
                int _resrvPos = _Position + (NoteList.DefaultNoteReserveLength -
                                             (_Position % NoteList.DefaultNoteReserveLength));
                NoteList.ReserveFrom(ref notes.GetNoteListRef(dir), _last, _resrvPos);
            }
            notes.GetNotesRef(note.Key, dir)[_Position] = note;
        }
예제 #2
0
파일: Track.cs 프로젝트: Kasania/NoteEditor
 public ObservableCollection <Note> GetNotes(Keys key, Direction dir)
 {
     return(NoteList.GetNotes(key, dir));
 }