private async Task HideWidget(OverlayWidget widget)
        {
            IOverlayService overlay = ChannelSession.Services.OverlayServers.GetOverlay(widget.OverlayName);

            if (overlay != null)
            {
                await overlay.RemoveItem(widget.Item);
            }
        }
Beispiel #2
0
        protected override async Task PerformInternal(UserViewModel user, IEnumerable <string> arguments)
        {
            if (this.WidgetID != Guid.Empty)
            {
                OverlayWidget widget = ChannelSession.Settings.OverlayWidgets.FirstOrDefault(w => w.Item.ID.Equals(this.WidgetID));
                if (widget != null)
                {
                    widget.IsEnabled = this.ShowWidget;
                    if (!widget.IsEnabled)
                    {
                        IOverlayService overlay = ChannelSession.Services.OverlayServers.GetOverlay(widget.OverlayName);
                        if (overlay != null)
                        {
                            await overlay.RemoveItem(widget.Item);
                        }
                    }
                }
            }
            else
            {
#pragma warning disable CS0612 // Type or member is obsolete
                if (this.Position == null && this.Effect != null)
                {
                    this.Position = new OverlayItemPosition(OverlayEffectPositionType.Percentage, this.Effect.Horizontal, this.Effect.Vertical);
                }
                if (this.Effects == null && this.Effect != null)
                {
                    this.Effects = new OverlayItemEffects((OverlayEffectEntranceAnimationTypeEnum)this.Effect.EntranceAnimation,
                                                          (OverlayEffectVisibleAnimationTypeEnum)this.Effect.VisibleAnimation, (OverlayEffectExitAnimationTypeEnum)this.Effect.ExitAnimation, this.Effect.Duration);
                }
                this.Effect = null;
#pragma warning restore CS0612 // Type or member is obsolete

                string          overlayName = (string.IsNullOrEmpty(this.OverlayName)) ? ChannelSession.Services.OverlayServers.DefaultOverlayName : this.OverlayName;
                IOverlayService overlay     = ChannelSession.Services.OverlayServers.GetOverlay(overlayName);
                if (overlay != null)
                {
                    OverlayItemBase processedItem = await this.Item.GetProcessedItem(user, arguments, this.extraSpecialIdentifiers);

                    await overlay.SendItem(processedItem, this.Position, this.Effects);
                }
            }
        }