internal static void RestructureNewOverlayActions(List <ActionBase> actions)
        {
            for (int i = 0; i < actions.Count; i++)
            {
                ActionBase action = actions[i];
                if (action is OverlayAction)
                {
                    OverlayAction oAction = (OverlayAction)action;
#pragma warning disable CS0612 // Type or member is obsolete
                    if (oAction.Effect != null)
                    {
                        if (oAction.Effect is OverlayTextEffect)
                        {
                            OverlayTextEffect effect = (OverlayTextEffect)oAction.Effect;
                            oAction.Item = new Model.Overlay.OverlayTextItem(effect.Text, effect.Color, effect.Size, string.Empty, true, false, false, string.Empty);
                        }
                        else if (oAction.Effect is OverlayImageEffect)
                        {
                            OverlayImageEffect effect = (OverlayImageEffect)oAction.Effect;
                            oAction.Item = new Model.Overlay.OverlayImageItem(effect.FilePath, effect.Width, effect.Height);
                        }
                        else if (oAction.Effect is OverlayVideoEffect)
                        {
                            OverlayVideoEffect effect = (OverlayVideoEffect)oAction.Effect;
                            oAction.Item = new Model.Overlay.OverlayVideoItem(effect.FilePath, effect.Width, effect.Height, 100);
                        }
                        else if (oAction.Effect is OverlayYoutubeEffect)
                        {
                            OverlayYoutubeEffect effect = (OverlayYoutubeEffect)oAction.Effect;
                            oAction.Item = new Model.Overlay.OverlayYouTubeItem(effect.ID, effect.StartTime, effect.Width, effect.Height, 100);
                        }
                        else if (oAction.Effect is OverlayWebPageEffect)
                        {
                            OverlayWebPageEffect effect = (OverlayWebPageEffect)oAction.Effect;
                            oAction.Item = new Model.Overlay.OverlayWebPageItem(effect.URL, effect.Width, effect.Height);
                        }
                        else if (oAction.Effect is OverlayHTMLEffect)
                        {
                            OverlayHTMLEffect effect = (OverlayHTMLEffect)oAction.Effect;
                            oAction.Item = new Model.Overlay.OverlayHTMLItem(effect.HTMLText);
                        }
                        oAction.Position = new Model.Overlay.OverlayItemPosition(Model.Overlay.OverlayEffectPositionType.Percentage, oAction.Effect.Horizontal, oAction.Effect.Vertical);
                        oAction.Effects  = new Model.Overlay.OverlayItemEffects((Model.Overlay.OverlayEffectEntranceAnimationTypeEnum)oAction.Effect.EntranceAnimation,
                                                                                (Model.Overlay.OverlayEffectVisibleAnimationTypeEnum)oAction.Effect.VisibleAnimation, (Model.Overlay.OverlayEffectExitAnimationTypeEnum)oAction.Effect.ExitAnimation,
                                                                                oAction.Effect.Duration);
                        oAction.Effect = null;
                    }
#pragma warning restore CS0612 // Type or member is obsolete
                }
            }
        }
        public override Task OnLoaded()
        {
            if (ChannelSession.Services.OverlayServer == null)
            {
                this.OverlayNotEnabledWarningTextBlock.Visibility = Visibility.Visible;
            }

            this.TypeComboBox.ItemsSource      = EnumHelper.GetEnumNames <OverlayEffectTypeEnum>();
            this.FontSizeComboBox.ItemsSource  = OverlayActionControl.sampleFontSize.Select(f => f.ToString());
            this.FontColorComboBox.ItemsSource = ColorSchemes.ColorSchemeDictionary.Keys;
            this.YoutubeStartTimeTextBox.Text  = "0";
            this.YoutubeWidthTextBox.Text      = this.VideoWidthTextBox.Text = OverlayVideoEffect.DefaultWidth.ToString();
            this.YoutubeHeightTextBox.Text     = this.VideoHeightTextBox.Text = OverlayVideoEffect.DefaultHeight.ToString();

            this.CenterPositionButton_Click(this, new RoutedEventArgs());

            this.EntranceAnimationComboBox.ItemsSource   = EnumHelper.GetEnumNames <OverlayEffectEntranceAnimationTypeEnum>();
            this.EntranceAnimationComboBox.SelectedIndex = 0;
            this.VisibleAnimationComboBox.ItemsSource    = EnumHelper.GetEnumNames <OverlayEffectVisibleAnimationTypeEnum>();
            this.VisibleAnimationComboBox.SelectedIndex  = 0;
            this.ExitAnimationComboBox.ItemsSource       = EnumHelper.GetEnumNames <OverlayEffectExitAnimationTypeEnum>();
            this.ExitAnimationComboBox.SelectedIndex     = 0;

            if (this.action != null)
            {
                if (this.action.Effect is OverlayImageEffect)
                {
                    OverlayImageEffect imageEffect = (OverlayImageEffect)this.action.Effect;
                    this.TypeComboBox.SelectedItem = EnumHelper.GetEnumName(OverlayEffectTypeEnum.Image);
                    this.ImageFilePathTextBox.Text = imageEffect.FilePath;
                    this.ImageWidthTextBox.Text    = imageEffect.Width.ToString();
                    this.ImageHeightTextBox.Text   = imageEffect.Height.ToString();
                }
                else if (this.action.Effect is OverlayTextEffect)
                {
                    OverlayTextEffect textEffect = (OverlayTextEffect)this.action.Effect;
                    this.TypeComboBox.SelectedItem = EnumHelper.GetEnumName(OverlayEffectTypeEnum.Text);
                    this.TextTextBox.Text          = textEffect.Text;
                    this.FontSizeComboBox.Text     = textEffect.Size.ToString();
                    string color = textEffect.Color;
                    if (ColorSchemes.ColorSchemeDictionary.ContainsValue(color))
                    {
                        color = ColorSchemes.ColorSchemeDictionary.FirstOrDefault(c => c.Value.Equals(color)).Key;
                    }
                    this.FontColorComboBox.Text = color;
                }
                else if (this.action.Effect is OverlayYoutubeEffect)
                {
                    OverlayYoutubeEffect youtubeEffect = (OverlayYoutubeEffect)this.action.Effect;
                    this.TypeComboBox.SelectedItem    = EnumHelper.GetEnumName(OverlayEffectTypeEnum.YouTube);
                    this.YoutubeVideoIDTextBox.Text   = youtubeEffect.ID;
                    this.YoutubeStartTimeTextBox.Text = youtubeEffect.StartTime.ToString();
                    this.YoutubeWidthTextBox.Text     = youtubeEffect.Width.ToString();
                    this.YoutubeHeightTextBox.Text    = youtubeEffect.Height.ToString();
                }
                else if (this.action.Effect is OverlayVideoEffect)
                {
                    OverlayVideoEffect videoEffect = (OverlayVideoEffect)this.action.Effect;
                    this.TypeComboBox.SelectedItem = EnumHelper.GetEnumName(OverlayEffectTypeEnum.Video);
                    this.VideoFilePathTextBox.Text = videoEffect.FilePath;
                    this.VideoWidthTextBox.Text    = videoEffect.Width.ToString();
                    this.VideoHeightTextBox.Text   = videoEffect.Height.ToString();
                }
                else if (this.action.Effect is OverlayWebPageEffect)
                {
                    OverlayWebPageEffect webPageEffect = (OverlayWebPageEffect)this.action.Effect;
                    this.TypeComboBox.SelectedItem   = EnumHelper.GetEnumName(OverlayEffectTypeEnum.WebPage);
                    this.WebPageFilePathTextBox.Text = webPageEffect.URL;
                    this.WebPageWidthTextBox.Text    = webPageEffect.Width.ToString();
                    this.WebPageHeightTextBox.Text   = webPageEffect.Height.ToString();
                }
                else if (this.action.Effect is OverlayHTMLEffect)
                {
                    OverlayHTMLEffect htmlEffect = (OverlayHTMLEffect)this.action.Effect;
                    this.TypeComboBox.SelectedItem = EnumHelper.GetEnumName(OverlayEffectTypeEnum.HTML);
                    this.HTMLTextBox.Text          = htmlEffect.HTMLText;
                }

                this.HorizontalSlider.Value = this.action.Effect.Horizontal;
                this.VerticalSlider.Value   = this.action.Effect.Vertical;

                if (this.action.Effect.Horizontal == 25 && this.action.Effect.Vertical == 25)
                {
                    this.TopLeftPositionButton_Click(this, new RoutedEventArgs());
                }
                else if (this.action.Effect.Horizontal == 50 && this.action.Effect.Vertical == 25)
                {
                    this.TopPositionButton_Click(this, new RoutedEventArgs());
                }
                else if (this.action.Effect.Horizontal == 75 && this.action.Effect.Vertical == 25)
                {
                    this.TopRightPositionButton_Click(this, new RoutedEventArgs());
                }
                else if (this.action.Effect.Horizontal == 25 && this.action.Effect.Vertical == 50)
                {
                    this.LeftPositionButton_Click(this, new RoutedEventArgs());
                }
                else if (this.action.Effect.Horizontal == 50 && this.action.Effect.Vertical == 50)
                {
                    this.CenterPositionButton_Click(this, new RoutedEventArgs());
                }
                else if (this.action.Effect.Horizontal == 75 && this.action.Effect.Vertical == 50)
                {
                    this.RightPositionButton_Click(this, new RoutedEventArgs());
                }
                else if (this.action.Effect.Horizontal == 25 && this.action.Effect.Vertical == 75)
                {
                    this.BottomLeftPositionButton_Click(this, new RoutedEventArgs());
                }
                else if (this.action.Effect.Horizontal == 50 && this.action.Effect.Vertical == 75)
                {
                    this.BottomPositionButton_Click(this, new RoutedEventArgs());
                }
                else if (this.action.Effect.Horizontal == 75 && this.action.Effect.Vertical == 75)
                {
                    this.BottomRightPositionButton_Click(this, new RoutedEventArgs());
                }
                else
                {
                    this.PositionSimpleAdvancedToggleButton.IsChecked = true;
                }

                this.DurationTextBox.Text = this.action.Effect.Duration.ToString();
                this.EntranceAnimationComboBox.SelectedItem = EnumHelper.GetEnumName(this.action.Effect.EntranceAnimation);
                this.VisibleAnimationComboBox.SelectedItem  = EnumHelper.GetEnumName(this.action.Effect.VisibleAnimation);
                this.ExitAnimationComboBox.SelectedItem     = EnumHelper.GetEnumName(this.action.Effect.ExitAnimation);
            }
            return(Task.FromResult(0));
        }
 public async Task SendText(OverlayTextEffect effect)
 {
     await this.SendPacket("text", effect);
 }