当前位置: 首页>>代码示例>>C#>>正文


C# Song.FindPartByName方法代码示例

本文整理汇总了C#中Song.FindPartByName方法的典型用法代码示例。如果您正苦于以下问题:C# Song.FindPartByName方法的具体用法?C# Song.FindPartByName怎么用?C# Song.FindPartByName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Song的用法示例。


在下文中一共展示了Song.FindPartByName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FindUnusedPartName

 /// <summary>
 /// Helper function to generate an unused part name.
 /// </summary>
 /// <param name="song">The song to generate the name for.</param>
 /// <returns>A part name that is guaranteed to be unused in that song.</returns>
 private static string FindUnusedPartName(Song song)
 {
     int i = 1;
     while (song.FindPartByName(i.ToString()) != null)
     {
         i++;
     }
     return i.ToString();
 }
开发者ID:Boddlnagg,项目名称:WordsLive,代码行数:14,代码来源:SongBeamerSongReader.cs

示例2: Read

        public void Read(Song song, Stream stream)
        {
            if (song == null)
                throw new ArgumentNullException("song");

            if (stream == null)
                throw new ArgumentNullException("stream");

            using (StreamReader reader = new StreamReader(stream, Encoding.Default, true))
            {
                string line;
                bool inTab = false;
                SongPart chorusPart = null;
                string currentText = null;
                string nextPartName = null;
                string currentPartName = null;

                while ((line = reader.ReadLine()) != null)
                {
                    var trimmed = line.Trim();
                    if (trimmed.StartsWith("#"))
                    {
                        continue; // ignore comment line
                    }

                    if (trimmed.StartsWith("{") && trimmed.EndsWith("}"))
                    {
                        var tag = trimmed.Substring(1, trimmed.Length - 2);
                        if (tag.StartsWith("title:") || tag.StartsWith("t:"))
                        {
                            song.Title = tag.Substring(tag.IndexOf(':') + 1);
                            nextPartName = null;
                            continue;
                        }
                        else if (tag.StartsWith("subtitle:") || tag.StartsWith("st:"))
                        {
                            song.Copyright = tag.Substring(tag.IndexOf(':') + 1);
                            nextPartName = null;
                            continue;
                        }
                        else if (tag.StartsWith("comment:") || tag.StartsWith("c:") ||
                            tag.StartsWith("comment_italic:") || tag.StartsWith("ci:") ||
                            tag.StartsWith("comment_box:") || tag.StartsWith("cb:"))
                        {
                            if (tag.EndsWith(":") && chorusPart == null)
                            {
                                // we found a comment that might be a part name and we're not in the chorus
                                // -> remember it for later use
                                var name = tag.Substring(tag.IndexOf(':') + 1);
                                nextPartName = name.Substring(0, name.Length - 1);
                            }
                            continue;
                        }
                        else if (tag.StartsWith("start_of_tab") || tag.StartsWith("sot"))
                        {
                            inTab = true;
                            nextPartName = null;
                            continue;
                        }
                        else if (tag.StartsWith("end_of_tab") || tag.StartsWith("eot"))
                        {
                            inTab = false;
                            nextPartName = null;
                            continue;
                        }
                        else if (tag.StartsWith("start_of_chorus") || tag.StartsWith("soc"))
                        {
                            var chorusName = "Chorus";
                            if (song.FindPartByName(chorusName) != null)
                            {
                                int i = 2;
                                while (song.FindPartByName(chorusName + " " + i.ToString()) != null)
                                {
                                    i++;
                                }
                                chorusName = chorusName + " " + i.ToString();
                            }

                            chorusPart = new SongPart(song, chorusName);
                            nextPartName = null;
                            continue;
                        }
                        else if (tag.StartsWith("end_of_chorus") || tag.StartsWith("eoc"))
                        {
                            if (chorusPart != null)
                            {
                                // commit slide and part
                                if (currentText != null)
                                {
                                    chorusPart.AddSlide(new SongSlide(song) { Text = currentText });
                                    currentText = null;
                                }

                                song.AddPart(chorusPart);
                                chorusPart = null;
                            }
                            nextPartName = null;
                            continue;
                        }
                        else if (tag.StartsWith("define"))
//.........这里部分代码省略.........
开发者ID:Boddlnagg,项目名称:WordsLive,代码行数:101,代码来源:ChordProSongReader.cs


注:本文中的Song.FindPartByName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。