public static void ConvertTranslation(string LyricAllText, List <SongLyric> Lyrics) { if (string.IsNullOrEmpty(LyricAllText)) { return; } string[] LyricsArr = LyricAllText.Replace("\r\n", "\n").Replace("\r", "\n").Split("\n"); TimeSpan offset = TimeSpan.Zero; foreach (string sL in LyricsArr) { string LyricTextLine = sL.Trim(); if (LyricTextLine.IndexOf('[') == -1 || LyricTextLine.IndexOf(']') == -1) { continue; //此行不为Lrc } string prefix = LyricTextLine.Substring(1, LyricTextLine.IndexOf(']') - 1); if (prefix.StartsWith("al") || prefix.StartsWith("ar") || prefix.StartsWith("au") || prefix.StartsWith("by") || prefix.StartsWith("re") || prefix.StartsWith("ti") || prefix.StartsWith("ve")) {//这种废标签不想解析 continue; } if (prefix.StartsWith("offset")) { if (!int.TryParse(prefix.Substring(6), out int offsetint)) { continue; } offset = new TimeSpan(0, 0, 0, 0, offsetint); } if (!TimeSpan.TryParse("00:" + prefix, out TimeSpan time)) { continue; } string lrctxt = LyricTextLine.Substring(LyricTextLine.IndexOf(']') + 1); while (lrctxt.Trim().StartsWith('[')) { //一句双时间 ConvertTranslation(lrctxt, Lyrics); } for (int i = 0; i < Lyrics.Count; i++) { SongLyric songLyric = Lyrics[i]; if (songLyric.LyricTime == time) { songLyric.Translation = lrctxt; songLyric.HaveTranslation = true; Lyrics[i] = songLyric; } } } }
private void RefreshLyricTime(SongLyric LRC) { LyricItem item = LyricList.Find(t => t.Lrc.LyricTime == LRC.LyricTime); item.OnShow(); if (sclock > 0) { sclock--; return; } GeneralTransform transform = item?.TransformToVisual((UIElement)LyricBoxContainer.Content); Point? position = transform?.TransformPoint(new Point(0, 0)); LyricBoxContainer.ChangeView(null, position?.Y - (LyricBoxContainer.ViewportHeight / 3), null, false);; LyricList.FindAll(t => t.Lrc.LyricTime != LRC.LyricTime).ForEach(t => t.OnHind()); }
public LyricItem(SongLyric lrc) { this.InitializeComponent(); originBrush = TextBoxPureLyric.Foreground; TextBoxPureLyric.FontSize = actualsize; TextBoxTranslation.FontSize = actualsize; Lrc = lrc; TextBoxPureLyric.Text = Lrc.PureLyric; if (Lrc.HaveTranslation) { TextBoxTranslation.Text = Lrc.Translation; } else { TextBoxTranslation.Visibility = Visibility.Collapsed; } OnHind(); }
public LyricItem(SongLyric lrc) { InitializeComponent(); TextBoxPureLyric.FontSize = actualsize; TextBoxTranslation.FontSize = actualsize; Lrc = lrc; TextBoxPureLyric.Text = Lrc.PureLyric; if (Lrc.HaveTranslation && Common.ShowLyricTrans) { TextBoxTranslation.Text = Lrc.Translation; } else { TextBoxTranslation.Visibility = Visibility.Collapsed; } if (Common.KawazuConv != null && Common.ShowLyricSound) { Task.Run(() => { Invoke((async() => { if (Kawazu.Utilities.HasKana(Lrc.PureLyric)) { TextBoxSound.Text = await Common.KawazuConv.Convert(Lrc.PureLyric, To.Romaji, Mode.Separated); } else { TextBoxSound.Visibility = Visibility.Collapsed; } })); }); } else { TextBoxSound.Visibility = Visibility.Collapsed; } OnHind(); }
private void HyPlayList_OnLyricChange(SongLyric lrc) { //throw new NotImplementedException(); }
private static void LoadLyricChange() { SongLyric songLyric = Lyrics.LastOrDefault((t => t.LyricTime < Player.PlaybackSession.Position)); Invoke(() => OnLyricChange?.Invoke(songLyric)); }