private static void ReadXml(ref NoteList notes, ref string Name, ref Time Time, ref int Level, ref int NPB, ref float BPM, string path) { XmlReader reader; try { reader = XmlReader.Create(path, new XmlReaderSettings { IgnoreComments = true, IgnoreWhitespace = true }); } catch (System.Exception e) { Console.WriteLine(e.Message); return; } while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element) { if (reader.Name.CompareTo(_XmlAttr) == 0) { ReadTrackAttribute(ref Name, ref Time, ref Level, ref NPB, ref BPM, ref reader); } else if (reader.Name.CompareTo(_xmlNote) == 0) { ReadNote(ref notes, ref reader); } } } }
public Track() { NoteList = new NoteList(); TrackName = defaultTrackName; TrackLength = new Time("0.0.0.0"); TrackLevel = 0; TrackBPM = 0.0f; }
private Track(ref NoteList notes, string name, Time length, int Level, int NPB, float BPM) { this.NoteList = notes; this.TrackName = name; this.TrackLength = length; this.TrackLevel = Level; this.TrackNPB = NPB; this.TrackBPM = BPM; }
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; }
public static Track CreateTrack(string path) { NoteList notes = new NoteList(); string TrackName = defaultTrackName; Time Time = new Time("0.0.0.0"); int Level = 0; int NPB = 0; float BPM = 0.0f; ReadXml(ref notes, ref TrackName, ref Time, ref Level, ref NPB, ref BPM, path); return(new Track(ref notes, TrackName, Time, Level, NPB, BPM)); }
private void UpScrollWheel(object sender, RoutedEventArgs e) { MouseWheelEventArgs m = (MouseWheelEventArgs)e; double offset = m.Delta * 2 / 3; double value = UpScroll.VerticalOffset; if (UPNoteCount > 0) { --UPNoteCount; return; } UPNoteCount = 8; if ((UpScroll.VerticalOffset <= UpScroll.ScrollableHeight * 0.1) && (offset > 0)) { NoteList.Reserve(ref CurrentTrack.GetNoteListRef(Direction.UP)); return; } UpScroll.ScrollToVerticalOffset(value - offset); }
private void DownScrollWheel(object sender, RoutedEventArgs e) { MouseWheelEventArgs m = (MouseWheelEventArgs)e; double offset = m.Delta * 2 / 3; double value = DownScroll.VerticalOffset; if (DownNoteCount > 0) { --DownNoteCount; return; } DownNoteCount = 8; if ((DownScroll.VerticalOffset >= DownScroll.ScrollableHeight * 0.9) && (offset < 0)) { NoteList.Reserve(ref CurrentTrack.GetNoteListRef(Direction.DOWN)); //increse notelist return; } DownScroll.ScrollToVerticalOffset(value - offset); }