Beispiel #1
0
        public void LoadTab(string path)
        {
            var lines = File.ReadAllLines(path).ToList();

            lines.RemoveAll(line => line.Length == 0 || !line.Contains('-'));

            if (lines.Count % 6 != 0)
            {
                OnTabLoaded?.Invoke(null);
                return;
            }
            var lines6 = new List <StringBuilder>();

            for (int i = 0; i < 6; i++)
            {
                lines6.Add(new StringBuilder());
            }
            for (int i = 0; i < lines.Count; i += 6)
            {
                for (int j = 0; j < 6; j++)
                {
                    lines6[j].Append(lines[i + j]);
                }
            }

            LoadTab(lines6.Select(sb => sb.ToString()).ToArray());
            CurrentPosition = -1;
        }
Beispiel #2
0
        public void LoadTab(string[] lines)
        {
            Tab.Clear();
            int minCharIndex = lines.Select(line => line.Length).Min();

            for (int charIndex = 0; charIndex < minCharIndex; charIndex++)
            {
                bool noFretsHit = true;
                StringRelatedChord tempChord = new StringRelatedChord(Tune);
                for (int lineIndex = 0; lineIndex < 6; lineIndex++)
                {
                    char c = lines[lineIndex][charIndex];
                    if (c >= '0' && c <= '9')
                    {
                        noFretsHit = false;
                        int fret = c - '0';
                        tempChord.Frets.Add(fret);
                    }
                    else
                    {
                        tempChord.Frets.Add(null);
                    }
                }

                if (!noFretsHit)
                {
                    Tab.Add(tempChord);
                }
            }

            TabWithBackground.Add(Tab[0]);
            for (int i = 1; i < Tab.Count; i++)
            {
                TabWithBackground.Add(TabWithBackground[i - 1].UpdateWith(Tab[i]));
            }

            if (Tab.Count == 0)
            {
                OnTabLoaded?.Invoke(null);
                return;
            }
            OnTabLoaded?.Invoke(Tab);
        }
Beispiel #3
0
 internal void TabLoaded(object obj, Control control)
 {
     OnTabLoaded?.Invoke(control, new EventTabLoaded(obj));
 }