Example #1
0
        private void SeparateNutFromFrets()
        {
            var nutLines = new List <FretLine>();

            for (int i = 0; i < Segments.Count; i++)
            {
                if (Segments[i].IsNut)
                {
                    var nutSegments = Segments.Skip(i).TakeWhile(s => s.IsNut).ToList();

                    if (i + nutSegments.Count < Segments.Count)
                    {
                        nutSegments.Add(Segments[i + nutSegments.Count].Clone());
                    }

                    if (i > 0)
                    {
                        nutSegments.Add(Segments[i - 1].Clone());
                    }

                    var newLine = new FretLine(nutSegments);
                    newLine.Layout = Layout;
                    Layout.VisualElements.Add(newLine);
                    nutLines.Add(newLine);
                    newLine.ComputeFretShape();
                    i += nutSegments.Count(s => !s.IsVirtual) - 1;
                }
            }

            Layout.VisualElements.Remove(this);

            for (int i = 0; i < Segments.Count; i++)
            {
                if (!Segments[i].IsVirtual && !Segments[i].IsNut)
                {
                    var fretSegments = Segments.Skip(i).TakeWhile(s => !s.IsNut && !s.IsVirtual).ToList();
                    int origSegCount = fretSegments.Count;
                    if (i + origSegCount < Segments.Count)
                    {
                        fretSegments.Add(Segments[i + origSegCount].Clone());
                    }

                    if (i > 0)
                    {
                        fretSegments.Add(Segments[i - 1].Clone());
                    }

                    var newLine = new FretLine(fretSegments);
                    newLine.Layout = Layout;
                    Layout.VisualElements.Add(newLine);
                    newLine.ComputeFretShape();
                    i += origSegCount - 1;
                }
            }
        }
Example #2
0
        private void SplitFret(int index)
        {
            var left = new FretLine(Segments.Take(index + 1))
            {
                Layout = Layout
            };

            Layout.VisualElements.Add(left);

            var right = new FretLine(Segments.Skip(index + 1))
            {
                Layout = Layout
            };

            Layout.VisualElements.Add(right);

            Layout.VisualElements.Remove(this);
            left.ComputeFretShape();
            right.ComputeFretShape();
        }