Пример #1
0
 public override void SetItem(OverlayItemBase item)
 {
     this.item = (OverlayImageItem)item;
     this.ImageFilePathTextBox.Text = this.item.FilePath;
     this.ImageWidthTextBox.Text    = this.item.Width.ToString();
     this.ImageHeightTextBox.Text   = this.item.Height.ToString();
 }
Пример #2
0
        public async Task SendItem(OverlayItemBase item, OverlayItemPosition position, OverlayItemEffects effects)
        {
            if (item is OverlayImageItem)
            {
                OverlayImageItem imageItem = (OverlayImageItem)item;
                this.httpListenerServer.SetLocalFile(imageItem.FileID, imageItem.FilePath);
            }
            else if (item is OverlayVideoItem)
            {
                OverlayVideoItem videoItem = (OverlayVideoItem)item;
                this.httpListenerServer.SetLocalFile(videoItem.FileID, videoItem.FilePath);
            }

            await this.SendEffectPacket(item.ItemType, item, position, effects);
        }
        private async void DownloadButton_Click(object sender, RoutedEventArgs e)
        {
            await this.window.RunAsyncOperation(async() =>
            {
                StoreDetailListingModel listingDetails = await ChannelSession.Services.MixItUpService.GetStoreListing(this.currentListing.ID);
                if (listingDetails == null)
                {
                    await MessageBoxHelper.ShowMessageDialog("Failed to download command, please try again");
                    return;
                }

                Version assemblyVersion = Assembly.GetExecutingAssembly().GetName().Version;

                Version commandVersion = new Version(listingDetails.AppVersion);
                if (assemblyVersion < commandVersion)
                {
                    await MessageBoxHelper.ShowMessageDialog(string.Format("You can not download this command as it was created on version ({0}) of Mix It Up ", commandVersion));
                    return;
                }

                await ChannelSession.Services.MixItUpService.AddStoreListingDownload(listingDetails);

                List <ActionBase> actions = listingDetails.GetActions();

                StoreCommandUpgrader.PerformUpgrades(actions, listingDetails.AppVersion);

                if (listingDetails.AssetsIncluded && listingDetails.AssetData != null && listingDetails.AssetData.Length > 0)
                {
                    if (await MessageBoxHelper.ShowConfirmationDialog("This command contains included assets." + Environment.NewLine + "Would you like to download them?"))
                    {
                        string folderLocation = ChannelSession.Services.FileService.ShowOpenFolderDialog();
                        if (!string.IsNullOrEmpty(folderLocation))
                        {
                            string zipFilePath = Path.Combine(ChannelSession.Services.FileService.GetTempFolder(), listingDetails.ID.ToString() + ".zip");
                            await ChannelSession.Services.FileService.SaveFileAsBytes(zipFilePath, listingDetails.AssetData);
                            await ChannelSession.Services.FileService.UnzipFiles(zipFilePath, folderLocation);

                            IEnumerable <string> assetFileNames = (await ChannelSession.Services.FileService.GetFilesInDirectory(folderLocation)).Select(s => Path.GetFileName(s));
                            foreach (ActionBase action in actions)
                            {
                                if (action.Type == ActionTypeEnum.Overlay)
                                {
                                    OverlayAction oAction = (OverlayAction)action;
                                    if (oAction.Item is OverlayImageItem)
                                    {
                                        OverlayImageItem overlayItem = (OverlayImageItem)oAction.Item;
                                        if (assetFileNames.Contains(Path.GetFileName(overlayItem.FilePath)))
                                        {
                                            overlayItem.FilePath = Path.Combine(folderLocation, Path.GetFileName(overlayItem.FilePath));
                                        }
                                    }
                                }
                                else if (action.Type == ActionTypeEnum.Sound)
                                {
                                    SoundAction sAction = (SoundAction)action;
                                    if (assetFileNames.Contains(Path.GetFileName(sAction.FilePath)))
                                    {
                                        sAction.FilePath = Path.Combine(folderLocation, Path.GetFileName(sAction.FilePath));
                                    }
                                }
                            }
                        }
                    }
                }

                this.window.DownloadCommandFromStore(listingDetails.ID, actions);
            });
        }
Пример #4
0
 public OverlayImageItemControl(OverlayImageItem item)
     : this()
 {
     this.item = item;
 }
Пример #5
0
        private async void UploadButton_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            await this.RunAsyncOperation(async() =>
            {
                if (string.IsNullOrEmpty(this.NameTextBox.Text))
                {
                    await MessageBoxHelper.ShowMessageDialog("A name must be specified");
                    return;
                }

                if (this.NameTextBox.Text.Length >= 50)
                {
                    await MessageBoxHelper.ShowMessageDialog("A name must be 50 characters or less");
                    return;
                }

                if (string.IsNullOrEmpty(this.DescriptionTextBox.Text))
                {
                    await MessageBoxHelper.ShowMessageDialog("A description must be specified");
                    return;
                }

                if (!string.IsNullOrEmpty(this.DisplayImagePathTextBox.Text))
                {
                    if (!File.Exists(this.DisplayImagePathTextBox.Text))
                    {
                        await MessageBoxHelper.ShowMessageDialog("The specified display image does not exist");
                        return;
                    }

                    FileInfo info = new FileInfo(this.DisplayImagePathTextBox.Text);
                    if (info.Length >= 1000000)
                    {
                        await MessageBoxHelper.ShowMessageDialog("Display image must be smaller than 1 MB");
                        return;
                    }
                }

                HashSet <string> tags = new HashSet <string>();
                if (this.Tag1ComboBox.SelectedIndex > 0)
                {
                    tags.Add(this.Tag1ComboBox.Text);
                }
                if (this.Tag2ComboBox.SelectedIndex > 0)
                {
                    tags.Add(this.Tag2ComboBox.Text);
                }
                if (this.Tag3ComboBox.SelectedIndex > 0)
                {
                    tags.Add(this.Tag3ComboBox.Text);
                }
                if (this.Tag4ComboBox.SelectedIndex > 0)
                {
                    tags.Add(this.Tag4ComboBox.Text);
                }
                if (this.Tag5ComboBox.SelectedIndex > 0)
                {
                    tags.Add(this.Tag5ComboBox.Text);
                }
                if (this.Tag6ComboBox.SelectedIndex > 0)
                {
                    tags.Add(this.Tag6ComboBox.Text);
                }

                if (tags.Count == 0)
                {
                    await MessageBoxHelper.ShowMessageDialog("At least 1 tag must be selected");
                    return;
                }

                JObject metadata = new JObject();

                byte[] displayImageData = null;
                if (!string.IsNullOrEmpty(this.DisplayImagePathTextBox.Text))
                {
                    displayImageData = await ChannelSession.Services.FileService.ReadFileAsBytes(this.DisplayImagePathTextBox.Text);
                }

                byte[] assetData = null;
                if (this.IncludeAssetsToggleButton.IsChecked.GetValueOrDefault())
                {
                    List <string> assetFiles = new List <string>();
                    foreach (ActionBase action in this.command.Actions)
                    {
                        if (action.Type == ActionTypeEnum.Overlay)
                        {
                            OverlayAction oAction = (OverlayAction)action;
                            if (oAction.Item is OverlayImageItem)
                            {
                                OverlayImageItem overlayItem = (OverlayImageItem)oAction.Item;
                                if (File.Exists(overlayItem.FilePath))
                                {
                                    assetFiles.Add(overlayItem.FilePath);
                                }
                            }
                        }
                        else if (action.Type == ActionTypeEnum.Sound)
                        {
                            SoundAction sAction = (SoundAction)action;
                            if (File.Exists(sAction.FilePath))
                            {
                                assetFiles.Add(sAction.FilePath);
                            }
                        }
                    }

                    if (assetFiles.Count > 0)
                    {
                        foreach (string assetFile in assetFiles)
                        {
                            FileInfo info = new FileInfo(assetFile);
                            if (info.Length >= 1000000)
                            {
                                await MessageBoxHelper.ShowMessageDialog("All asset files must be smaller than 1 MB");
                                return;
                            }
                        }

                        string zipFilePath = Path.Combine(ChannelSession.Services.FileService.GetTempFolder(), this.command.ID.ToString() + ".zip");
                        if (File.Exists(zipFilePath))
                        {
                            File.Delete(zipFilePath);
                        }
                        await ChannelSession.Services.FileService.ZipFiles(zipFilePath, assetFiles);
                        assetData = await ChannelSession.Services.FileService.ReadFileAsBytes(zipFilePath);
                    }
                }

                await ChannelSession.Services.MixItUpService.AddStoreListing(new StoreDetailListingModel(this.command, this.NameTextBox.Text, this.DescriptionTextBox.Text, tags,
                                                                                                         this.DisplayImagePathTextBox.Text, displayImageData, assetData, metadata));

                this.command.StoreID = this.command.ID;

                this.Close();
            });
        }
Пример #6
0
#pragma warning disable CS0612 // Type or member is obsolete
        public static OverlayItemModelBase ConvertOverlayItem(OverlayItemBase item)
        {
            if (item is OverlayTextItem)
            {
                OverlayTextItem oItem = (OverlayTextItem)item;
                return(new OverlayTextItemModel(oItem.Text, oItem.Color, oItem.Size, oItem.Font, oItem.Bold, oItem.Italic, oItem.Underline, oItem.ShadowColor));
            }
            else if (item is OverlayImageItem)
            {
                OverlayImageItem oItem = (OverlayImageItem)item;
                return(new OverlayImageItemModel(oItem.FilePath, oItem.Width, oItem.Height));
            }
            else if (item is OverlayVideoItem)
            {
                OverlayVideoItem oItem = (OverlayVideoItem)item;
                return(new OverlayVideoItemModel(oItem.FilePath, oItem.Width, oItem.Height, oItem.Volume));
            }
            else if (item is OverlayYouTubeItem)
            {
                OverlayYouTubeItem oItem = (OverlayYouTubeItem)item;
                return(new OverlayYouTubeItemModel(oItem.VideoID, oItem.Width, oItem.Height, oItem.StartTime, oItem.Volume));
            }
            else if (item is OverlayWebPageItem)
            {
                OverlayWebPageItem oItem = (OverlayWebPageItem)item;
                return(new OverlayWebPageItemModel(oItem.URL, oItem.Width, oItem.Height));
            }
            else if (item is OverlayHTMLItem)
            {
                OverlayHTMLItem oItem = (OverlayHTMLItem)item;
                return(new OverlayHTMLItemModel(oItem.HTMLText));
            }
            else if (item is OverlayChatMessages)
            {
                OverlayChatMessages oItem = (OverlayChatMessages)item;
                return(new OverlayChatMessagesListItemModel(oItem.HTMLText, oItem.TotalToShow, 0, oItem.TextFont, oItem.Width, oItem.TextSize, oItem.BorderColor, oItem.BackgroundColor,
                                                            oItem.TextColor, OverlayListItemAlignmentTypeEnum.Top, (OverlayItemEffectEntranceAnimationTypeEnum)oItem.AddEventAnimation, OverlayItemEffectExitAnimationTypeEnum.None));
            }
            else if (item is OverlayEventList)
            {
                OverlayEventList oItem = (OverlayEventList)item;
                List <OverlayEventListItemTypeEnum> types = new List <OverlayEventListItemTypeEnum>();
                foreach (EventListItemTypeEnum type in oItem.ItemTypes)
                {
                    types.Add((OverlayEventListItemTypeEnum)type);
                }
                return(new OverlayEventListItemModel(oItem.HTMLText, types, oItem.TotalToShow, 0, oItem.TextFont, oItem.Width, oItem.Height, oItem.BorderColor, oItem.BackgroundColor,
                                                     oItem.TextColor, OverlayListItemAlignmentTypeEnum.Top, (OverlayItemEffectEntranceAnimationTypeEnum)oItem.AddEventAnimation, (OverlayItemEffectExitAnimationTypeEnum)oItem.RemoveEventAnimation));
            }
            else if (item is OverlayGameQueue)
            {
                OverlayGameQueue oItem = (OverlayGameQueue)item;
                return(new OverlayGameQueueListItemModel(oItem.HTMLText, oItem.TotalToShow, oItem.TextFont, oItem.Width, oItem.Height, oItem.BorderColor, oItem.BackgroundColor,
                                                         oItem.TextColor, OverlayListItemAlignmentTypeEnum.Top, (OverlayItemEffectEntranceAnimationTypeEnum)oItem.AddEventAnimation, (OverlayItemEffectExitAnimationTypeEnum)oItem.RemoveEventAnimation));
            }
            else if (item is OverlayLeaderboard)
            {
                OverlayLeaderboard oItem = (OverlayLeaderboard)item;
                OverlayLeaderboardListItemModel result = new OverlayLeaderboardListItemModel(oItem.HTMLText, (OverlayLeaderboardListItemTypeEnum)oItem.LeaderboardType, oItem.TotalToShow,
                                                                                             oItem.TextFont, oItem.Width, oItem.Height, oItem.BorderColor, oItem.BackgroundColor, oItem.TextColor, OverlayListItemAlignmentTypeEnum.Top,
                                                                                             (OverlayItemEffectEntranceAnimationTypeEnum)oItem.AddEventAnimation, (OverlayItemEffectExitAnimationTypeEnum)oItem.RemoveEventAnimation, null);
                result.CurrencyID           = oItem.CurrencyID;
                result.LeaderboardDateRange = (OverlayLeaderboardListItemDateRangeEnum)oItem.DateRange;
                return(result);
            }
            else if (item is OverlayProgressBar)
            {
                OverlayProgressBar          oItem  = (OverlayProgressBar)item;
                OverlayProgressBarItemModel result = new OverlayProgressBarItemModel(oItem.HTMLText, (OverlayProgressBarItemTypeEnum)oItem.ProgressBarType, oItem.ResetAfterDays,
                                                                                     oItem.ProgressColor, oItem.BackgroundColor, oItem.TextColor, oItem.TextFont, oItem.Width, oItem.Height, oItem.GoalReachedCommand);
                result.StartAmount         = result.CurrentAmount = oItem.CurrentAmountNumber;
                result.GoalAmount          = oItem.GoalAmountNumber;
                result.CurrentAmountCustom = oItem.CurrentAmountCustom;
                result.GoalAmountCustom    = oItem.GoalAmountCustom;
                return(result);
            }
            else if (item is OverlaySongRequests)
            {
                OverlaySongRequests oItem = (OverlaySongRequests)item;
                return(new OverlaySongRequestsListItemModel(oItem.HTMLText, oItem.TotalToShow, oItem.TextFont, oItem.Width, oItem.Height, oItem.BorderColor, oItem.BackgroundColor,
                                                            oItem.TextColor, true, OverlayListItemAlignmentTypeEnum.Top, (OverlayItemEffectEntranceAnimationTypeEnum)oItem.AddEventAnimation, (OverlayItemEffectExitAnimationTypeEnum)oItem.RemoveEventAnimation));
            }
            else if (item is OverlayStreamBoss)
            {
                OverlayStreamBoss oItem = (OverlayStreamBoss)item;
                return(new OverlayStreamBossItemModel(oItem.HTMLText, oItem.StartingHealth, oItem.Width, oItem.Height, oItem.TextColor, oItem.TextFont, oItem.BorderColor, oItem.BackgroundColor,
                                                      oItem.ProgressColor, oItem.FollowBonus, oItem.HostBonus, oItem.SubscriberBonus, oItem.DonationBonus, oItem.SparkBonus, oItem.EmberBonus, 1.0, 1.0,
                                                      (OverlayItemEffectVisibleAnimationTypeEnum)oItem.DamageAnimation, (OverlayItemEffectVisibleAnimationTypeEnum)oItem.NewBossAnimation, oItem.NewStreamBossCommand));
            }
            else if (item is OverlayMixerClip)
            {
                OverlayMixerClip oItem = (OverlayMixerClip)item;
                return(new OverlayStreamClipItemModel(oItem.Width, oItem.Height, oItem.Volume, (OverlayItemEffectEntranceAnimationTypeEnum)oItem.EntranceAnimation, (OverlayItemEffectExitAnimationTypeEnum)oItem.ExitAnimation));
            }
            else if (item is OverlayTimer)
            {
                OverlayTimer oItem = (OverlayTimer)item;
                return(new OverlayTimerItemModel(oItem.HTMLText, oItem.TotalLength, oItem.TextColor, oItem.TextFont, oItem.TextSize, oItem.TimerCompleteCommand));
            }
            else if (item is OverlayTimerTrain)
            {
                OverlayTimerTrain oItem = (OverlayTimerTrain)item;
                return(new OverlayTimerTrainItemModel(oItem.HTMLText, oItem.MinimumSecondsToShow, oItem.TextColor, oItem.TextFont, oItem.TextSize, oItem.FollowBonus, oItem.HostBonus, oItem.SubscriberBonus, oItem.DonationBonus, oItem.SparkBonus, oItem.EmberBonus));
            }
            return(null);
        }