public OverlayImageItemViewModel(OverlayImageItemModel item) : this() { this.FilePath = item.FilePath; this.width = item.Width; this.height = item.Height; }
public VendingMachineGameEditorControlViewModel(UserCurrencyViewModel currency) : this() { this.Outcomes.Add(new VendingMachineOutcome("Nothing", this.CreateBasicChatCommand("@$username opened their capsule and found nothing..."), 40, 40, 40)); CustomCommand currencyCommand = this.CreateBasicChatCommand("@$username opened their capsule and found 50 " + currency.Name + "!"); currencyCommand.Actions.Add(new CurrencyAction(currency, CurrencyActionTypeEnum.AddToUser, 50.ToString())); this.Outcomes.Add(new VendingMachineOutcome("50", currencyCommand, 30, 30, 30)); CustomCommand overlayCommand = this.CreateBasicChatCommand("@$username opened their capsule and found a dancing Carlton!"); OverlayImageItemModel overlayImage = new OverlayImageItemModel("https://78.media.tumblr.com/1921bcd13e12643771410200a322cb0e/tumblr_ogs5bcHWUc1udh5n8o1_500.gif", 500, 500); overlayImage.Position = new OverlayItemPositionModel(OverlayItemPositionType.Percentage, 50, 50, 0); overlayImage.Effects = new OverlayItemEffectsModel(OverlayItemEffectEntranceAnimationTypeEnum.FadeIn, OverlayItemEffectVisibleAnimationTypeEnum.None, OverlayItemEffectExitAnimationTypeEnum.FadeOut, 3); overlayCommand.Actions.Add(new OverlayAction(ChannelSession.Services.OverlayServers.DefaultOverlayName, overlayImage)); this.Outcomes.Add(new VendingMachineOutcome("Dancing Carlton", overlayCommand, 30, 30, 30)); }
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.OverlayItem is OverlayImageItemModel) { OverlayImageItemModel overlayItem = (OverlayImageItemModel)oAction.OverlayItem; 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(); }); }
public OverlayImageItemControl(OverlayImageItemModel item) { InitializeComponent(); this.viewModel = new OverlayImageItemViewModel(item); }
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.OverlayItem is OverlayImageItemModel) { OverlayImageItemModel overlayItem = (OverlayImageItemModel)oAction.OverlayItem; 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); }); }