private void joinedChannelsChanged(object sender, NotifyCollectionChangedEventArgs args) { switch (args.Action) { case NotifyCollectionChangedAction.Add: IEnumerable <Channel> newChannels = args.NewItems.OfType <Channel>().Where(isChatChannel); foreach (var channel in newChannels) { channelList.AddChannel(channel); } break; case NotifyCollectionChangedAction.Remove: IEnumerable <Channel> leftChannels = args.OldItems.OfType <Channel>().Where(isChatChannel); foreach (var channel in leftChannels) { channelList.RemoveChannel(channel); if (loadedChannels.ContainsKey(channel)) { ChatOverlayDrawableChannel loaded = loadedChannels[channel]; loadedChannels.Remove(channel); // DrawableChannel removed from cache must be manually disposed loaded.Dispose(); } } break; } }
private void joinedChannelsChanged(object sender, NotifyCollectionChangedEventArgs args) { switch (args.Action) { case NotifyCollectionChangedAction.Add: IEnumerable <Channel> joinedChannels = filterChannels(args.NewItems); foreach (var channel in joinedChannels) { channelList.AddChannel(channel); } break; case NotifyCollectionChangedAction.Remove: IEnumerable <Channel> leftChannels = filterChannels(args.OldItems); foreach (var channel in leftChannels) { channelList.RemoveChannel(channel); } break; } }
public void SetUp() { Schedule(() => { Child = new GridContainer { Anchor = Anchor.Centre, Origin = Anchor.Centre, RelativeSizeAxes = Axes.Both, Height = 0.7f, RowDimensions = new[] { new Dimension(GridSizeMode.Absolute, 20), new Dimension(GridSizeMode.Absolute, 20), new Dimension(), }, Content = new[] { new Drawable[] { selectedText = new OsuSpriteText { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, }, }, new Drawable[] { leaveText = new OsuSpriteText { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, }, }, new Drawable[] { channelList = new ChannelList { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, RelativeSizeAxes = Axes.Y, Width = 190, }, }, }, }; channelList.OnRequestSelect += channel => { selected.Value = channel; }; channelList.OnRequestLeave += channel => { leaveText.Text = $"OnRequestLeave: {channel.Name}"; leaveText.FadeOutFromOne(1000, Easing.InQuint); selected.Value = channelList.ChannelListingChannel; channelList.RemoveChannel(channel); }; selected.BindValueChanged(change => { selectedText.Text = $"Selected Channel: {change.NewValue?.Name ?? "[null]"}"; }, true); }); }