private static async Task Version35Upgrade(int version, string filePath) { if (version < 35) { DesktopChannelSettings settings = await SerializerHelper.DeserializeFromFile <DesktopChannelSettings>(filePath); await ChannelSession.Services.Settings.Initialize(settings); foreach (CommandBase command in GetAllCommands(settings)) { StoreCommandUpgrader.RestructureNewerOverlayActions(command.Actions); } #pragma warning disable CS0612 // Type or member is obsolete foreach (OverlayWidget widget in settings.overlayWidgetsInternal) { OverlayItemModelBase newItem = StoreCommandUpgrader.ConvertOverlayItem(widget.Item); newItem.ID = widget.Item.ID; newItem.Position = new OverlayItemPositionModel((OverlayItemPositionType)widget.Position.PositionType, widget.Position.Horizontal, widget.Position.Vertical, 0); OverlayWidgetModel newWidget = new OverlayWidgetModel(widget.Name, widget.OverlayName, newItem, 0); settings.OverlayWidgets.Add(newWidget); if (newWidget.SupportsRefreshUpdating && !widget.DontRefresh) { newWidget.RefreshTime = settings.OverlayWidgetRefreshTime; } } settings.overlayWidgetsInternal.Clear(); #pragma warning restore CS0612 // Type or member is obsolete await ChannelSession.Services.Settings.Save(settings); } }
protected override async Task PerformInternal(UserViewModel user, IEnumerable <string> arguments) { if (this.WidgetID != Guid.Empty) { OverlayWidgetModel widget = ChannelSession.Settings.OverlayWidgets.FirstOrDefault(w => w.Item.ID.Equals(this.WidgetID)); if (widget != null) { if (this.ShowWidget) { await widget.Initialize(user, arguments, this.extraSpecialIdentifiers); } else { await widget.Disable(); } } } else { #pragma warning disable CS0612 // Type or member is obsolete if (this.Item != null) { StoreCommandUpgrader.RestructureNewerOverlayActions(new List <ActionBase>() { this }); } #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) { await overlay.ShowItem(this.OverlayItem, user, arguments, this.extraSpecialIdentifiers); } } }
public override Task OnLoaded() { if (ChannelSession.Settings.EnableOverlay) { if (ChannelSession.Services.OverlayServers.GetOverlayNames().Count() > 1) { this.OverlayNameComboBox.IsEnabled = true; this.OverlayNameComboBox.ItemsSource = ChannelSession.Services.OverlayServers.GetOverlayNames(); } else { this.OverlayNameComboBox.IsEnabled = false; this.OverlayNameComboBox.ItemsSource = new List <string>() { ChannelSession.Services.OverlayServers.DefaultOverlayName }; } this.OverlayNameComboBox.SelectedItem = ChannelSession.Services.OverlayServers.DefaultOverlayName; } else { this.OverlayNotEnabledWarningTextBlock.Visibility = Visibility.Visible; } List <string> typeOptions = new List <string>(EnumHelper.GetEnumNames <OverlayItemModelTypeEnum>(new List <OverlayItemModelTypeEnum>() { OverlayItemModelTypeEnum.Text, OverlayItemModelTypeEnum.Image, OverlayItemModelTypeEnum.Video, OverlayItemModelTypeEnum.YouTube, OverlayItemModelTypeEnum.WebPage, OverlayItemModelTypeEnum.HTML })); typeOptions.Add(ShowHideWidgetOption); this.TypeComboBox.ItemsSource = typeOptions; this.WidgetNameComboBox.ItemsSource = ChannelSession.Settings.OverlayWidgets.ToList(); this.EntranceAnimationComboBox.ItemsSource = EnumHelper.GetEnumNames <OverlayItemEffectEntranceAnimationTypeEnum>(); this.EntranceAnimationComboBox.SelectedIndex = 0; this.VisibleAnimationComboBox.ItemsSource = EnumHelper.GetEnumNames <OverlayItemEffectVisibleAnimationTypeEnum>(); this.VisibleAnimationComboBox.SelectedIndex = 0; this.ExitAnimationComboBox.ItemsSource = EnumHelper.GetEnumNames <OverlayItemEffectExitAnimationTypeEnum>(); this.ExitAnimationComboBox.SelectedIndex = 0; if (this.action != null) { if (!string.IsNullOrEmpty(this.action.OverlayName)) { this.OverlayNameComboBox.SelectedItem = this.action.OverlayName; } if (this.action.WidgetID != Guid.Empty) { this.TypeComboBox.SelectedItem = ShowHideWidgetOption; this.WidgetNameComboBox.SelectedItem = ChannelSession.Settings.OverlayWidgets.FirstOrDefault(w => w.Item.ID.Equals(this.action.WidgetID)); this.ShowHideWidgetCheckBox.IsChecked = this.action.ShowWidget; } else { #pragma warning disable CS0612 // Type or member is obsolete if (this.action.Item != null) { StoreCommandUpgrader.RestructureNewerOverlayActions(new List <ActionBase>() { this.action }); } #pragma warning restore CS0612 // Type or member is obsolete if (this.action.OverlayItem != null) { if (this.action.OverlayItem.Effects != null) { this.DurationTextBox.Text = this.action.OverlayItem.Effects.Duration.ToString(); this.EntranceAnimationComboBox.SelectedItem = EnumHelper.GetEnumName(this.action.OverlayItem.Effects.EntranceAnimation); this.VisibleAnimationComboBox.SelectedItem = EnumHelper.GetEnumName(this.action.OverlayItem.Effects.VisibleAnimation); this.ExitAnimationComboBox.SelectedItem = EnumHelper.GetEnumName(this.action.OverlayItem.Effects.ExitAnimation); } if (this.action.OverlayItem.Position != null) { this.ItemPosition.SetPosition(this.action.OverlayItem.Position); } if (this.action.OverlayItem is OverlayImageItemModel) { this.TypeComboBox.SelectedItem = EnumHelper.GetEnumName(OverlayItemModelTypeEnum.Image); this.ImageItem.SetItem(this.action.OverlayItem); } else if (this.action.OverlayItem is OverlayTextItemModel) { this.TypeComboBox.SelectedItem = EnumHelper.GetEnumName(OverlayItemModelTypeEnum.Text); this.TextItem.SetItem(this.action.OverlayItem); } else if (this.action.OverlayItem is OverlayYouTubeItemModel) { this.TypeComboBox.SelectedItem = EnumHelper.GetEnumName(OverlayItemModelTypeEnum.YouTube); this.YouTubeItem.SetItem(this.action.OverlayItem); } else if (this.action.OverlayItem is OverlayVideoItemModel) { this.TypeComboBox.SelectedItem = EnumHelper.GetEnumName(OverlayItemModelTypeEnum.Video); this.VideoItem.SetItem(this.action.OverlayItem); } else if (this.action.OverlayItem is OverlayWebPageItemModel) { this.TypeComboBox.SelectedItem = EnumHelper.GetEnumName(OverlayItemModelTypeEnum.WebPage); this.WebPageItem.SetItem(this.action.OverlayItem); } else if (this.action.OverlayItem is OverlayHTMLItemModel) { this.TypeComboBox.SelectedItem = EnumHelper.GetEnumName(OverlayItemModelTypeEnum.HTML); this.HTMLItem.SetItem(this.action.OverlayItem); } } } } return(Task.FromResult(0)); }