Esempio n. 1
0
 public void LoadLrc(string lrcstr)
 {
     Lrcs.Clear();
     c_lrc_items.Children.Clear();
     foucslrc = null;
     foreach (string str in lrcstr.Split("\r\n".ToCharArray()))
     {
         if (str.Length > 0 && str.IndexOf(":") != -1 && !str.StartsWith("[ti:") && !str.StartsWith("[ar:") && !str.StartsWith("[al:") && !str.StartsWith("[by:") && !str.StartsWith("[offset:"))
         {
             TimeSpan  time    = GetTime(str);
             string    lrc     = str.Split(']')[1];
             TextBlock c_lrcbk = new TextBlock();
             c_lrcbk.FontSize      = 18;
             c_lrcbk.Foreground    = NoramlLrcColor;
             c_lrcbk.TextWrapping  = TextWrapping.Wrap;
             c_lrcbk.TextAlignment = TextAlignment;
             c_lrcbk.Text          = lrc.Replace("^", "\n").Replace("//", "").Replace("null", "");
             if (c_lrc_items.Children.Count > 0)
             {
                 c_lrcbk.Margin = new Thickness(0, 15, 0, 15);
             }
             if (!Lrcs.ContainsKey(time.TotalMilliseconds))
             {
                 Lrcs.Add(time.TotalMilliseconds, new LrcModel()
                 {
                     c_LrcTb = c_lrcbk,
                     LrcText = lrc,
                     Time    = time.TotalMilliseconds
                 });
             }
             c_lrc_items.Children.Add(c_lrcbk);
         }
     }
 }
Esempio n. 2
0
        public void LrcRoll(double nowtime, bool needScrol)
        {
            if (foucslrc == null)
            {
                foucslrc = Lrcs.Values.First();
                foucslrc.c_LrcTb.SetResourceReference(ForegroundProperty, "ThemeColor");
            }
            else
            {
                IEnumerable <KeyValuePair <double, LrcModel> > s = Lrcs.Where(m => nowtime >= m.Key);
                if (s.Count() > 0)
                {
                    LrcModel lm = s.Last().Value;
                    if (needScrol)
                    {
                        foucslrc.c_LrcTb.Foreground = NoramlLrcColor;
                    }

                    foucslrc = lm;
                    if (needScrol)
                    {
                        foucslrc.c_LrcTb.SetResourceReference(ForegroundProperty, "ThemeColor");
                        ResetLrcviewScroll();
                    }
                    string tx = foucslrc.LrcText.Replace("//", "");
                    if (tx.Substring(tx.Length - 1, 1) == "^")
                    {
                        tx = tx.Substring(0, tx.Length - 1);
                    }
                    tx = tx.Replace("^", "\r\n");
                    NextLyric(tx);
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 滚动歌词并定位焦点
        /// </summary>
        /// <param name="nowtime">当前时间</param>
        public void LrcRoll(double nowtime)
        {
            if (Lrcs.Count == 0)
            {
                return;
            }
            if (FoucsLrc == null)
            {
                FoucsLrc = Lrcs.Values.First();
            }
            else
            {
                int index = SortLrcs.FindIndex(m => m.Key >= nowtime);
                if (index <= 0 || index == LastIndex)
                {
                    return;
                }

                FoucsLrc.LrcTb.FontSize = 15;

                LastIndex = index;
                LrcModel lm = SortLrcs[index - 1].Value;

                FoucsLrc.LrcTb.Foreground = NoramlLrcColor;

                FoucsLrc = lm;
                FoucsLrc.LrcTb.Foreground = FoucsLrcColor;
                FoucsLrc.LrcTb.FontSize   = 20;
                ResetLrcviewScroll();
            }
        }
        /// <summary>
        /// 歌词滚动、定位焦点
        /// </summary>
        /// <param name="nowtime"></param>
        public void LrcRoll(double nowtime)
        {
            if (foucslrc == null)
            {
                foucslrc = Lrcs.Values.First();
                foucslrc.c_LrcTb.Foreground = FoucsLrcColor;
            }
            else
            {
                //查找焦点歌词
                IEnumerable <KeyValuePair <double, LrcModel> > s = Lrcs.Where(m => nowtime >= m.Key);
                if (s.Count() > 0)
                {
                    LrcModel lm = s.Last().Value;
                    foucslrc.c_LrcTb.Foreground = NoramlLrcColor;

                    foucslrc = lm;
                    foucslrc.c_LrcTb.Foreground = FoucsLrcColor;
                    //定位歌词在控件中间区域
                    ResetLrcviewScroll();
                }
            }

            //if (FoucsLrcLocation < 0)
            //{
            //    //音乐开始时歌词焦点到第一句
            //    FoucsLrcLocation = 0;
            //    Lrcs.Values.ToList()[FoucsLrcLocation].c_LrcTb.Foreground = FoucsLrcColor;
            //}
            //else
            //{
            //    //循环获取歌词
            //    for (int i = FoucsLrcLocation + 1; i < Lrcs.Values.Count; i++)
            //    {
            //        LrcModel lrc = Lrcs.Values.ToList()[i];



            //        //计算当前音乐播放时间与歌词时间的差值

            //        if ()
            //        {
            //            //取消当前焦点歌词
            //            Lrcs.Values.ToList()[FoucsLrcLocation].c_LrcTb.Foreground = NoramlLrcColor;
            //            //给歌词控件设置颜色突出显示
            //            lrc.c_LrcTb.Foreground = FoucsLrcColor;
            //            //重新设置当前歌词位置
            //            FoucsLrcLocation = i;
            //            ResetLrcviewScroll();
            //            //Debug.WriteLine("nowtime:" + nowtime + ",lrctime:" + lrctime + ",s:" + s);
            //            break;
            //        }

            //    }
            //}
        }
Esempio n. 5
0
        private void AddCommandBindings()
        {
            #region File

            CommandBindings.Add(new CommandBinding(
                                    UICommands.Export,
                                    Command_Export,
                                    (sender, args) =>
            {
                args.CanExecute = LrcModel.Current.IsModified;
                args.Handled    = true;
            }));

            CommandBindings.Add(new CommandBinding(
                                    UICommands.ExitApp,
                                    Command_ExitApp,
                                    CanExecute));

            #endregion

            #region Edit

            CommandBindings.Add(new CommandBinding(
                                    UICommands.EditSkipData,
                                    (sender, args) => Process.Start(LrcModel.UserSkipDataPath),
                                    CanExecute));

            CommandBindings.Add(new CommandBinding(
                                    UICommands.ReloadSkipData,
                                    (sender, args) => LrcModel.ReloadSkipData(),
                                    CanExecute));

            #endregion

            #region View

            CommandBindings.Add(new CommandBinding(
                                    UICommands.ShowLyricsEditorView,
                                    (sender, args) => LyricEditorView.Current.DockControl?.Show(),
                                    CanExecute));

            CommandBindings.Add(new CommandBinding(
                                    UICommands.ShowPlaybackView,
                                    (sender, args) => PlaybackView.Current.DockControl?.Show(),
                                    CanExecute));

            #endregion

            #region Other Window

            LyricEditorView.Current.AddCommandBindings();
            PlaybackView.Current.AddCommandBindings();

            #endregion
        }
Esempio n. 6
0
        public void LrcRoll(double nowtime)
        {
            if (foucslrc == null)
            {
                foucslrc = Lrcs.Values.First();
                foucslrc.c_LrcTb.Foreground = FoucsLrcColor;
            }
            else
            {
                IEnumerable <KeyValuePair <double, LrcModel> > s = Lrcs.Where(m => nowtime >= m.Key);
                if (s.Count() > 0)
                {
                    LrcModel lm = s.Last().Value;
                    foucslrc.c_LrcTb.Foreground = NoramlLrcColor;

                    foucslrc = lm;
                    foucslrc.c_LrcTb.Foreground = FoucsLrcColor;
                    ResetLrcviewScroll();
                }
            }
        }