protected TextTagEditSection() { // create list of text-tag text-box if bindable changed. TextTags.BindValueChanged(e => { Content.RemoveAll(x => x is LabelledTextTagTextBox); Content.AddRange(e.NewValue?.Select(x => { var relativeToLyricText = TextTagUtils.GetTextFromLyric(x, Lyric?.Text); var range = TextTagUtils.PositionFormattedString(x); return(new LabelledTextTagTextBox(x) { Label = relativeToLyricText, Description = range, OnDeleteButtonClick = () => { LyricUtils.RemoveTextTag(Lyric, x); }, TabbableContentContainer = this }); })); }); // add create button. AddCreateButton(); }
public void TestRemoveTextTag(string[] textTags, string removeTextTag, bool actual) { var lyric = new Lyric { Text = "からおけ", RubyTags = TestCaseTagHelper.ParseRubyTags(textTags), RomajiTags = TestCaseTagHelper.ParseRomajiTags(textTags) }; var fromIndex = textTags?.IndexOf(removeTextTag) ?? -1; // test ruby and romaji at the same test. var removeRubyTag = fromIndex >= 0 ? lyric.RubyTags[fromIndex] : TestCaseTagHelper.ParseRubyTag(removeTextTag); var removeRomajiTag = fromIndex >= 0 ? lyric.RomajiTags[fromIndex] : TestCaseTagHelper.ParseRomajiTag(removeTextTag); Assert.AreEqual(LyricUtils.RemoveTextTag(lyric, removeRubyTag), actual); Assert.AreEqual(LyricUtils.RemoveTextTag(lyric, removeRomajiTag), actual); }