public void TestBindCollectionChangedNotRunIfBoundToSequenceEqualDictionary() { var dict = new BindableDictionary <string, byte> { { "a", 1 }, { "b", 3 }, { "c", 5 }, { "d", 7 } }; var otherDict = new BindableDictionary <string, byte> { { "a", 1 }, { "b", 3 }, { "c", 5 }, { "d", 7 } }; NotifyDictionaryChangedEventArgs <string, byte> triggeredArgs = null; dict.BindCollectionChanged((_, args) => triggeredArgs = args); dict.BindTo(otherDict); Assert.That(triggeredArgs, Is.Null); }
public void TestBindCollectionChangedNotRunIfParsingSequenceEqualEnumerable() { var dict = new BindableDictionary <string, byte> { { "a", 1 }, { "b", 3 }, { "c", 5 }, { "d", 7 } }; var enumerable = new[] { new KeyValuePair <string, byte>("a", 1), new KeyValuePair <string, byte>("b", 3), new KeyValuePair <string, byte>("c", 5), new KeyValuePair <string, byte>("d", 7) }; NotifyDictionaryChangedEventArgs <string, byte> triggeredArgs = null; dict.BindCollectionChanged((_, args) => triggeredArgs = args); dict.Parse(enumerable); Assert.That(triggeredArgs, Is.Null); }
public void TestBindCollectionChangedWithRunImmediately() { var dictionary = new BindableDictionary <int, string>(); NotifyCollectionChangedEventArgs triggeredArgs = null; dictionary.BindCollectionChanged((_, args) => triggeredArgs = args, true); Assert.That(triggeredArgs.Action, Is.EqualTo(NotifyCollectionChangedAction.Add)); Assert.That(triggeredArgs.NewItems, Is.EquivalentTo(dictionary)); }
public void TestBindCollectionChangedWithoutRunningImmediately() { var dict = new BindableDictionary <string, byte> { { "a", 1 } }; NotifyDictionaryChangedEventArgs <string, byte> triggeredArgs = null; dict.BindCollectionChanged((_, args) => triggeredArgs = args); Assert.That(triggeredArgs, Is.Null); }
public void TestBindCollectionChangedWithoutRunningImmediately() { var dictionary = new BindableDictionary <int, string> { { 1, "One" } }; NotifyCollectionChangedEventArgs triggeredArgs = null; dictionary.BindCollectionChanged((_, args) => triggeredArgs = args); Assert.That(triggeredArgs, Is.Null); }
public void TestBindCollectionChangedWithRunImmediately() { var dict = new BindableDictionary <string, byte> { { "a", 1 } }; NotifyDictionaryChangedEventArgs <string, byte> triggeredArgs = null; dict.BindCollectionChanged((_, args) => triggeredArgs = args, true); Assert.That(triggeredArgs.Action, Is.EqualTo(NotifyDictionaryChangedAction.Add)); Assert.That(triggeredArgs.NewItems, Is.EquivalentTo(dict)); }
private void load(OsuColour colour, LyricCheckerManager lyricCheckerManager) { Children = new[] { // todo : should all invalid tag number table = new TimeTagIssueTable(), }; bindableReports = lyricCheckerManager.BindableReports.GetBoundCopy(); bindableReports.BindCollectionChanged((a, b) => { // todo : might have filter in here. var issues = bindableReports.Values.SelectMany(x => x); table.Issues = issues.OfType <TimeTagIssue>(); }, true); }
private void load() { Scale = new Vector2((float)(config?.Get <double>(KaraokeRulesetSetting.LyricScale) ?? 2)); AutoSizeAxes = Axes.Both; AddInternal(lyricPieces = new Container <DefaultLyricPiece> { AutoSizeAxes = Axes.Both, }); AddInternal(translateText = new OsuSpriteText { Anchor = Anchor.BottomLeft, Origin = Anchor.TopLeft, }); SingersBindable.BindValueChanged(index => { ApplySkin(CurrentSkin, false); }); LayoutIndexBindable.BindValueChanged(index => { ApplySkin(CurrentSkin, false); }); TranslateTextBindable.BindCollectionChanged((_, args) => { ApplyTranslate(); }); }
private void load() { Scale = new Vector2(2f); AutoSizeAxes = Axes.Both; AddInternal(KaraokeText = new KaraokeSpriteText()); AddInternal(translateText = new OsuSpriteText { Anchor = Anchor.BottomLeft, Origin = Anchor.TopLeft, }); TextBindable.BindValueChanged(text => { KaraokeText.Text = text.NewValue; }); TimeTagsBindable.BindValueChanged(timeTags => { KaraokeText.TimeTags = TimeTagsUtils.ToDictionary(timeTags.NewValue); }); RubyTagsBindable.BindValueChanged(rubyTags => { ApplyRuby(); }); RomajiTagsBindable.BindValueChanged(romajiTags => { ApplyRomaji(); }); SingersBindable.BindValueChanged(index => { ApplySkin(CurrentSkin, false); }); LayoutIndexBindable.BindValueChanged(index => { ApplySkin(CurrentSkin, false); }); TranslateTextBindable.BindCollectionChanged((_, args) => { ApplyTranslate(); }); }
public void TestBindCollectionChangedEventsRanIfBoundToDifferentDictionary() { var firstDictContents = new[] { new KeyValuePair <string, byte>("a", 1), new KeyValuePair <string, byte>("b", 3), new KeyValuePair <string, byte>("c", 5), new KeyValuePair <string, byte>("d", 7), }; var otherDictContents = new[] { new KeyValuePair <string, byte>("a", 2), new KeyValuePair <string, byte>("b", 4), new KeyValuePair <string, byte>("c", 6), new KeyValuePair <string, byte>("d", 8), new KeyValuePair <string, byte>("e", 10), }; var dict = new BindableDictionary <string, byte>(firstDictContents); var otherDict = new BindableDictionary <string, byte>(otherDictContents); var triggeredArgs = new List <NotifyDictionaryChangedEventArgs <string, byte> >(); dict.BindCollectionChanged((_, args) => triggeredArgs.Add(args)); dict.BindTo(otherDict); Assert.That(triggeredArgs, Has.Count.EqualTo(2)); var removeEvent = triggeredArgs.SingleOrDefault(ev => ev.Action == NotifyDictionaryChangedAction.Remove); Assert.That(removeEvent, Is.Not.Null); Assert.That(removeEvent.OldItems, Is.EquivalentTo(firstDictContents)); var addEvent = triggeredArgs.SingleOrDefault(ev => ev.Action == NotifyDictionaryChangedAction.Add); Assert.That(addEvent, Is.Not.Null); Assert.That(addEvent.NewItems, Is.EquivalentTo(otherDict)); }
private void load(LyricCheckerManager lyricCheckerManager, NoteManager noteManager) { bindableReports = lyricCheckerManager.BindableReports.GetBoundCopy(); bindableReports.BindCollectionChanged((a, b) => { var hasTimeTagIssue = bindableReports.Values.SelectMany(x => x) .OfType <TimeTagIssue>().Any(); if (hasTimeTagIssue) { Children = new[] { new OsuSpriteText { Text = "Seems there's some time-tag issue in lyric. \nGo to time-tag edit mode then clear those issues." } }; } else { Children = new[] { new AutoGenerateButton { Text = "Generate", Action = () => { // todo : should be able to apply only selected lyric. var lyrics = beatmap.HitObjects.OfType <Lyric>().ToArray(); noteManager.AutoGenerateNotes(lyrics); } }, }; } }, true); }