Пример #1
0
        public void Init(Music music, ImageSource source)
        {
            //angle = 0;
            Lyric.Clear();
            LyricTextBlock.Inlines.Clear();
            if (source != null)
            {
                AlbumImage.ImageSource = source;
            }
            else
            {
                Image.DataContext = "logo.ico";
            }
            LyricBlock.ScrollToVerticalOffset(0);
            DesktopLyricWin.Lyric.Content = music.Title + music.Singer;
            timer.Stop();
            Thread thread = new Thread(new ThreadStart(() => GetLiric(music)));

            thread.IsBackground = true;
            thread.Start();
        }
Пример #2
0
 //private float angle = 0;
 private void TimerOnTick(object sender, EventArgs e)
 {
     //ChildWindows.DesktopLyricWindow.TopMostTool.SetTopMost(DesktopLyricWin);
     if (!haveLyric)
     {
         timer.Stop();
         return;
     }
     //RotateTransform rotateTransform = new RotateTransform((angle+=0.03f) * 180 / 3.142);
     //rotateTransform.CenterX = Image.ActualWidth / 2;
     //rotateTransform.CenterY = Image.ActualHeight / 2;
     //Image.RenderTransform = rotateTransform;
     if (CurrentLyricIndex < Lyric.Count && CurrentLyricIndex > LastLyricLineIndex && Lyric[CurrentLyricIndex].StartTime <= ParentWindow.bsp.CurrentTime)
     {
         LastLyricLineIndex = CurrentLyricIndex++;
         if (CurrentLyricIndex == Count)
         {
             CurrentLyricIndex  = -1;
             LastLyricLineIndex = -1;
         }
         else
         {
             var run = LyricTextBlock.Inlines.ElementAt(LastLyricLineIndex);
             if (LastLyricLineIndex > 0)
             {
                 var lastRun = LyricTextBlock.Inlines.ElementAt(LastLyricLineIndex - 1);
                 lastRun.Foreground = run.Foreground;
             }
             run.Foreground = Brushes.Red;
             LyricBlock.ScrollToVerticalOffset(LyricBlock.ScrollableHeight * LastLyricLineIndex * 1.0 / Count);
             if (!string.IsNullOrWhiteSpace(((Run)run).Text))
             {
                 DesktopLyricWin.Lyric.Content = ((Run)run).Text;
             }
         }
     }
 }