//this makes our beatmap from the json file void PrepareData(string name) { currentSong = SongSource.getSong(name); if (currentSong.tracks.Length > 0) { for (int i = 0; i < currentSong.tracks.Length; i++) { //go through each track first for (int j = 0; j < currentSong.tracks[i].notes.Length; j++) { //this will convert the note time from seconds to beats currentSong.tracks[i].notes[j].beatTime = currentSong.tracks[i].notes[j].time * currentSong.header.bpm / 60f; //assuming 4/4 time for now int measure = Mathf.FloorToInt(currentSong.tracks[i].notes[j].beatTime / 4f); int beat = Mathf.FloorToInt(currentSong.tracks[i].notes[j].beatTime - (measure * 4)); int tick = Mathf.FloorToInt((currentSong.tracks[i].notes[j].beatTime - (measure * 4) - beat) * 96); currentSong.tracks[i].notes[j].mbtValue = new MBT(measure, beat, tick); //assign this midi note to a beatmap event BeatMapEvent bmEvent = new BeatMapEvent(); bmEvent.eventMBT = currentSong.tracks[i].notes[j].mbtValue; bmEvent.eventMBT.Measure += 1; bmEvent.eventMBT.Beat += 1; bmEvent.eventMBT.Tick += 1; //depending on which note it is, assign the prefab accordingly if (!useFallingGemInputClass) { switch (currentSong.tracks[i].notes[j].name) { case "C1": bmEvent.inputKey = KeyCode.R; break; case "C#1": bmEvent.inputKey = KeyCode.G; break; case "D1": bmEvent.inputKey = KeyCode.B; break; } } else { foreach (BeatmapPair bmPair in beatmapParser.beatmapPairs) { if (bmPair.midiNote == currentSong.tracks[i].notes[j].name) { bmEvent.unityInput = bmPair.unityInput; } } } beatEvents.Add(bmEvent); } } } }
public void SourceSetUndoRedo() { song.SetSources(new SongSource[] { }); this.ClearUndoRedoStack(); Assert.Equal(1, song.Sources.Count); var sources = new SongSource[] { SongSource.Parse("Book / 1", song), SongSource.Parse("Book / 2", song), SongSource.Parse("Book / 3", song) }; Assert.Equal(0, UndoStackSize); song.SetSources(sources); Assert.Equal(1, UndoStackSize); Undo(); Assert.Equal(1, song.Sources.Count); Assert.Equal(String.Empty, song.FirstSource.ToString()); Redo(); Assert.Equal(3, song.Sources.Count); for (int i = 0; i < 3; i++) { Assert.Equal("Book", song.Sources[i].Songbook); Assert.Equal(i + 1, song.Sources[i].Number); } }
public void SourceMoveUp() { var sources = new SongSource[] { SongSource.Parse("Book / 1", song), SongSource.Parse("Book / 2", song), SongSource.Parse("Book / 3", song) }; song.SetSources(sources); ClearUndoRedoStack(); song.MoveSourceUp(sources[2]); Assert.Equal(3, song.Sources.Count); Assert.ReferenceEquals(sources[2], song.FirstSource); Assert.Equal(1, UndoStackSize); Undo(); for (int i = 0; i < 3; i++) { Assert.Equal("Book", song.Sources[i].Songbook); Assert.Equal(i + 1, song.Sources[i].Number); } Redo(); Assert.Equal(3, song.Sources.Count); Assert.ReferenceEquals(sources[2], song.FirstSource); }
//Return all open tabs of the Specified Browser, as a String array. public static String[] getTabNames(SongSource source) { //Check which Browser is selected. switch (source) { //When Browser is InternetExplorer. case SongSource.IE: List <string> tabs = new List <string>(); foreach (InternetExplorer ie in new ShellWindows()) { //When task executable is iexplore. string filename = Path.GetFileNameWithoutExtension(ie.FullName).ToLower(); if (filename.Equals("iexplore")) { //Get the page Document, and get put the Title in the tab List. IHTMLDocument2 doc = ie.Document; tabs.Add(doc.title); } } //Return all tabs. return(tabs.ToArray()); default: //Return Empty Array if a wrong Source is Selected. return(new String[0]); } }
private void ListView_SelectionChanged(object sender, SelectionChangedEventArgs e) { SongSource source = ListView1.SelectedItem as SongSource; string url = string.Format(Constants.URLs.SongSourceFile, source.Source); Player.Source = new Uri(url); Player.Play(); }
public Settings(string prefix, string suffix, SongSource source, int refreshSpeed, string invalidSongMessage) { this.prefix = prefix; this.suffix = suffix; this.source = source; this.refreshSpeed = refreshSpeed; this.invalidSongMessage = invalidSongMessage; }
public void SongSourceRemoveClean() { var weakRef = new WeakReference(song.FirstSource); song.IsUndoEnabled = false; song.SetSources(new SongSource[] { SongSource.Parse("Book / 1", song) }); GC.Collect(); Assert.False(weakRef.IsAlive); }
public void SourceParse() { var source = SongSource.Parse("Book / 1", song); Assert.Equal("Book", source.Songbook); Assert.Equal(1, source.Number); // parsing a source should not influence the undo stack Assert.Equal(0, UndoStackSize); Assert.Equal(0, RedoStackSize); }
public void SourceSetSingle() { song.SetSources(new SongSource[] { }); Assert.Equal(1, song.Sources.Count); Assert.NotNull(song.FirstSource); var source = SongSource.Parse("Book / 1", song); song.SetSources(new SongSource[] { source }); Assert.Equal(1, song.Sources.Count); Assert.Equal("Book", song.Sources[0].Songbook); Assert.Equal(1, song.Sources[0].Number); Assert.ReferenceEquals(song.Sources[0], song.FirstSource); }
public static List <SongSource> ParseSources(string html) { try { List <SongSource> sources = new List <SongSource>(); HtmlDocument doc = new HtmlDocument(); doc.LoadHtml(html); HtmlNode node = doc.DocumentNode; IEnumerable <HtmlNode> col = node.ChildNodes.Descendants("li"); foreach (var item in col) { if (!string.IsNullOrEmpty(item.InnerText.ToString().Replace("\r", "").Replace("\n", "").Replace("\t", ""))) { try { SongSource source = new SongSource(); IEnumerable <HtmlNode> nodem = item.ChildNodes.Where(x => x.Name == "div"); IEnumerable <HtmlNode> nodesm; if (nodem.First().Elements("div").Where(x => x.Attributes["class"].Value.Contains("newPlayer")).Count() != 0) { source.Source = string.Format(Constants.URLs.SongSourceFile, nodem.First().Elements("div").Where(x => x.Attributes["class"].Value.Contains("newPlayer")).First().Attributes["fcode"].Value.ToString()); } if (nodem.First().Elements("a").Where(x => x.Attributes["class"].Value.Contains("nhsTrackTitle")).Count() != 0) { nodesm = nodem.First().Elements("a").Where(x => x.Attributes["class"].Value.Contains("nhsTrackTitle")); source.Name = nodesm.First().InnerText; sources.Add(source); } else if (nodem.First().Elements("div").Where(x => x.Attributes["class"].Value.Contains("nhsTrunTrackedTitle")).Count() != 0) { nodesm = nodem.First().Elements("div").Where(x => x.Attributes["class"].Value.Contains("nhsTrunTrackedTitle")); source.Name = nodesm.First().InnerText; sources.Add(source); } } catch (Exception) { } } } return(sources); } catch (Exception) { return(null); } }
public void SourceSetMultiple() { song.SetSources(new SongSource[] { }); Assert.Equal(1, song.Sources.Count); var sources = new SongSource[] { SongSource.Parse("Book / 1", song), SongSource.Parse("Book / 2", song), SongSource.Parse("Book / 3", song) }; song.SetSources(sources); Assert.Equal(3, song.Sources.Count); for (int i = 0; i < 3; i++) { Assert.Equal("Book", song.Sources[i].Songbook); Assert.Equal(i + 1, song.Sources[i].Number); } }
public void SourceRemoveUndoRedo() { var sources = new SongSource[] { SongSource.Parse("Book / 1", song), SongSource.Parse("Book / 2", song), SongSource.Parse("Book / 3", song) }; song.SetSources(sources); ClearUndoRedoStack(); song.RemoveSource(song.FirstSource); song.RemoveSource(song.FirstSource); Assert.Equal(1, song.Sources.Count); Undo(); Undo(); for (int i = 0; i < 3; i++) { Assert.Equal("Book", song.Sources[i].Songbook); Assert.Equal(i + 1, song.Sources[i].Number); } Redo(); Redo(); Assert.Equal(1, song.Sources.Count); }
public void SetSource(SongSource source) { control.ExecuteJavascript("presentation.setSource(" + JsonConvert.SerializeObject(source.ToString()) + ")"); }