コード例 #1
0
        private void timeChanged(DateTime?time)
        {
            if (!time.HasValue)
            {
                return;
            }

            bool isEnabled = this.IsEnabled.Value;
            bool isRecord  = (getDateTimeJstNow() - time.Value).TotalMinutes > 3;

            if (this.lastIsEnabled == isEnabled && isRecord == this.lastIsRecord)
            {
                return; // 有効・無効、リアルタイム・録画、いずれも変化がなければ何もしない
            }
            this.lastIsEnabled = isEnabled;
            this.lastIsRecord  = isRecord;

            if (!isEnabled)
            {
                return; // 無効の場合は何もしない
            }
            if (isRecord)
            {
                //録画
                collectServiceModule.ClearServices();
                foreach (var serviceEntry in RecordChatCollectService)
                {
                    collectServiceModule.AddService(serviceEntry, null);
                }
            }
            else
            {
                //リアルタイム
                collectServiceModule.ClearServices();
                foreach (var serviceEntry in LiveChatCollectService)
                {
                    collectServiceModule.AddService(serviceEntry, null);
                }
            }
        }
コード例 #2
0
        public DefaultChatCollectServiceModule(
            TVTCommentSettings settings, ChannelInformationModule channelInformationModule,
            ChatCollectServiceModule collectServiceModule, IEnumerable <ChatCollectServiceEntry.IChatCollectServiceEntry> serviceEntryList
            )
        {
            this.settings = settings;
            this.channelInformationModule = channelInformationModule;
            this.collectServiceModule     = collectServiceModule;
            this.serviceEntryList         = serviceEntryList;

            loadSettings();
            disposables.Add(channelInformationModule.CurrentTime.Subscribe(timeChanged));
            disposables.Add(LiveChatCollectService.ObserveCollectionChanged(newServiceEntry =>
            {
                if (IsEnabled.Value && !lastIsRecord.GetValueOrDefault(true))
                {
                    if (collectServiceModule.RegisteredServices.All(x => x.ServiceEntry != newServiceEntry))
                    {
                        collectServiceModule.AddService(newServiceEntry, null);
                    }
                }
            }, oldServiceEntry =>
            {
                if (IsEnabled.Value && !lastIsRecord.GetValueOrDefault(true))
                {
                    foreach (var service in collectServiceModule.RegisteredServices.Where(x => x.ServiceEntry == oldServiceEntry))
                    {
                        collectServiceModule.RemoveService(service);
                    }
                }
            }, () =>
            {
                if (IsEnabled.Value && !lastIsRecord.GetValueOrDefault(true))
                {
                    collectServiceModule.ClearServices();
                }
            }));
            disposables.Add(RecordChatCollectService.ObserveCollectionChanged(newServiceEntry =>
            {
                if (IsEnabled.Value && lastIsRecord.GetValueOrDefault(false))
                {
                    if (collectServiceModule.RegisteredServices.All(x => x.ServiceEntry != newServiceEntry))
                    {
                        collectServiceModule.AddService(newServiceEntry, null);
                    }
                }
            }, oldServiceEntry =>
            {
                if (IsEnabled.Value && lastIsRecord.GetValueOrDefault(false))
                {
                    foreach (var service in collectServiceModule.RegisteredServices.Where(x => x.ServiceEntry == oldServiceEntry))
                    {
                        collectServiceModule.RemoveService(service);
                    }
                }
            }, () =>
            {
                if (IsEnabled.Value && lastIsRecord.GetValueOrDefault(false))
                {
                    collectServiceModule.ClearServices();
                }
            }));

            disposables.Add(channelInformationModule.CurrentTime.Subscribe(timeChanged));
        }