示例#1
0
        internal override bool Apply(TablatureContext context, ILogger logger)
        {
            Bar bar;

            if (!this.ToDocumentElement(context, logger, null, out bar))
            {
                return(false);
            }

            if (bar.Rhythm != null && bar.Lyrics != null)
            {
                var beats = bar.Rhythm.Segments.Sum(s => s.FirstVoice.Beats?.Count ?? 0);
                if (beats < bar.Lyrics.Segments.Count)
                {
                    logger.Report(LogLevel.Suggestion, bar.Lyrics.Range, Messages.Suggestion_LyricsTooLong);
                }
            }

            context.AddBar(bar);

            // check if this bar terminates an alternative ending, must be done AFTER adding this bar to context
            if ((bar.CloseLine == CloseBarLine.End || bar.CloseLine == CloseBarLine.EndRepeat) &&
                context.DocumentState.CurrentAlternation != null)
            {
                using (var state = context.AlterDocumentState())
                {
                    state.CurrentAlternation = null;
                }
            }

            return(true);
        }
        internal override bool Apply(TablatureContext context, ILogger logger)
        {
            Alternation alternation;

            if (!this.ToDocumentElement(context, logger, out alternation))
            {
                return(false);
            }

            if (context.DocumentState.AlternationTextExplicity != Explicity.NotSpecified &&
                alternation.Explicity != context.DocumentState.AlternationTextExplicity)
            {
                logger.Report(LogLevel.Warning, this.Range.To.AsRange(),
                              Messages.Warning_InconsistentAlternationTextExplicity);
            }

            using (var state = context.AlterDocumentState())
            {
                foreach (var index in alternation.Indices)
                {
                    state.DefinedAlternationIndices.Add(index);
                }

                state.CurrentAlternation       = alternation;
                state.AlternationTextType      = alternation.TextType;
                state.AlternationTextExplicity = alternation.Explicity;
            }

            return(true);
        }
示例#3
0
        internal override bool Apply(TablatureContext context, ILogger logger)
        {
            if (context.DocumentState.BarAppeared)
            {
                logger.Report(LogLevel.Error, this.Range, Messages.Error_TuningInstructionAfterBarAppeared);
                return(false);
            }

            if (context.DocumentState.TuningSignature != null)
            {
                logger.Report(LogLevel.Warning, this.Range, Messages.Warning_RedefiningTuningInstruction);
                return(false);
            }

            TuningSignature tuning;

            if (!this.ToDocumentElement(context, logger, out tuning))
            {
                return(false);
            }

            using (var state = context.AlterDocumentState())
            {
                state.TuningSignature = tuning;
            }

            return(true);
        }
示例#4
0
        internal override bool Apply(TablatureContext context, ILogger logger)
        {
            KeySignature key;

            if (!this.ToDocumentElement(context, logger, out key))
            {
                return(false);
            }

            using (var state = context.AlterDocumentState())
                state.KeySignature = key;

            return(true);
        }
示例#5
0
        internal override bool Apply(TablatureContext context, ILogger logger)
        {
            Capo capo;
            if (!this.ToDocumentElement(context, logger, out capo))
                return false;

            using (var state = context.AlterDocumentState())
            {
                state.Capos.Add(capo);
                state.CapoFretOffsets = capo.OffsetFrets(state.CapoFretOffsets);
            }

            return true;
        }
示例#6
0
        internal override bool Apply(TablatureContext context, ILogger logger)
        {
            TempoSignature tempo;

            if (!this.ToDocumentElement(context, logger, out tempo))
            {
                return(false);
            }

            using (var state = context.AlterDocumentState())
            {
                state.TempoSignature = tempo;
            }

            return(true);
        }
示例#7
0
        internal override bool Apply(TablatureContext context, ILogger logger)
        {
            ChordDefinition definition;

            if (!this.ToDocumentElement(context, logger, out definition))
            {
                return(false);
            }

            using (var state = context.AlterDocumentState())
            {
                state.DefinedChords.Add(definition);
            }

            return(true);
        }
        internal override bool Apply(TablatureContext context, ILogger logger)
        {
            Section section;

            if (!this.ToDocumentElement(context, logger, out section))
            {
                return(false);
            }

            using (var state = context.AlterDocumentState())
            {
                state.DefinedSections.Add(section);
                state.CurrentSection = section;
            }

            return(true);
        }
示例#9
0
        internal override bool Apply(TablatureContext context, ILogger logger)
        {
            if (context.DocumentState.RhythmTemplate != null && this.Equals(context.DocumentState.RhythmTemplate))
            {
                logger.Report(LogLevel.Suggestion, this.Range, Messages.Suggestion_UselessRhythmInstruction);
                return(true);
            }

            context.CurrentBar = null;  // todo: this is ugly, refactor it

            RhythmTemplate rhythmTemplate;

            if (!this.TemplateNode.ToDocumentElement(context, logger, out rhythmTemplate))
            {
                return(false);
            }

            using (var state = context.AlterDocumentState())
            {
                state.RhythmTemplate = rhythmTemplate;
            }

            return(true);
        }