private void CommandButtons_EditClicked(object sender, RoutedEventArgs e) { StreamlootsCardCommandModel command = ((CommandListingButtonsControl)sender).GetCommandFromCommandButtons <StreamlootsCardCommandModel>(); if (command != null) { CommandEditorWindow window = CommandEditorWindow.GetCommandEditorWindow(command); window.CommandSaved += Window_CommandSaved; window.ForceShow(); } }
private async void CommandButtons_DeleteClicked(object sender, RoutedEventArgs e) { await this.Window.RunAsyncOperation(async() => { StreamlootsCardCommandModel command = ((CommandListingButtonsControl)sender).GetCommandFromCommandButtons <StreamlootsCardCommandModel>(); if (command != null) { ChannelSession.Services.Command.StreamlootsCardCommands.Remove(command); ChannelSession.Settings.RemoveCommand(command); this.viewModel.RemoveCommand(command); await ChannelSession.SaveSettings(); } }); }
private async Task ProcessCardRedemption(JObject jobj) { string cardData = string.Empty; StreamlootsCardModel card = jobj["data"].ToObject <StreamlootsCardModel>(); if (card != null && !string.IsNullOrEmpty(card.data?.cardName)) { UserViewModel user = this.GetUser(card.data.Username); Dictionary <string, string> specialIdentifiers = new Dictionary <string, string>(); specialIdentifiers["streamlootscardname"] = card.data.cardName; specialIdentifiers["streamlootscarddescription"] = card.data.description; specialIdentifiers["streamlootscardimage"] = card.imageUrl; specialIdentifiers["streamlootscardhasvideo"] = (!string.IsNullOrEmpty(card.videoUrl)).ToString(); specialIdentifiers["streamlootscardvideo"] = card.videoUrl; specialIdentifiers["streamlootscardsound"] = card.soundUrl; specialIdentifiers["streamlootscardalertmessage"] = card.message; string message = card.data.Message; if (string.IsNullOrEmpty(message)) { message = card.data.LongMessage; } specialIdentifiers["streamlootsmessage"] = message; List <string> arguments = new List <string>(); if (!string.IsNullOrEmpty(message)) { arguments = new List <string>(message.Split(' ')); } await ChannelSession.Services.Events.PerformEvent(EventTypeEnum.StreamlootsCardRedeemed, new CommandParametersModel(user, arguments, specialIdentifiers)); StreamlootsCardCommandModel command = ChannelSession.Services.Command.StreamlootsCardCommands.FirstOrDefault(c => string.Equals(c.Name, card.data.cardName, StringComparison.CurrentCultureIgnoreCase)); if (command != null) { Dictionary <string, string> cardsCommandSpecialIdentifiers = new Dictionary <string, string>(specialIdentifiers); await ChannelSession.Services.Command.Queue(command, new CommandParametersModel(user, platform : user.Platform, arguments : arguments, specialIdentifiers : cardsCommandSpecialIdentifiers)); } await ChannelSession.Services.Alerts.AddAlert(new AlertChatMessageViewModel(user.Platform, user, string.Format("{0} Redeemed {1} Card", user.FullDisplayName, card.data.cardName), ChannelSession.Settings.AlertStreamlootsColor)); } }
public StreamlootsCardCommandEditorWindowViewModel(StreamlootsCardCommandModel existingCommand) : base(existingCommand) { }