private async void ActivationProtocolHandler_OnCommunityCommandActivation(object sender, Guid commandID) { await DispatcherHelper.Dispatcher.InvokeAsync(async() => { CommunityCommandDetailsModel commandDetails = await ChannelSession.Services.CommunityCommandsService.GetCommandDetails(commandID); if (commandDetails != null) { await CommunityCommandsControl.ProcessDownloadedCommunityCommand(new CommunityCommandDetailsViewModel(commandDetails)); } }); }
public CommunityCommandDetailsViewModel(CommunityCommandDetailsModel model) : base(model) { this.model = model; this.Commands = this.model.GetCommands(); foreach (CommunityCommandReviewModel review in this.model.Reviews.OrderByDescending(r => r.DateTime)) { if (!string.IsNullOrWhiteSpace(review.Review)) { this.Reviews.Add(new CommunityCommandReviewViewModel(review)); } } this.NotifyPropertyChanged("HasNoReviews"); }
public MyCommunityCommandDetailsViewModel(CommunityCommandDetailsModel model) : base(model) { this.model = model; }
protected override async Task OnLoaded() { await base.OnLoaded(); try { if (this.command != null) { this.uploadCommand = new CommunityCommandUploadModel() { ID = this.command.ID, Name = this.command.Name, }; this.uploadCommand.SetCommands(new List <CommandModelBase>() { this.command }); CommunityCommandDetailsModel existingCommand = await ChannelSession.Services.CommunityCommandsService.GetCommandDetails(command.ID); if (existingCommand != null) { this.uploadCommand.ID = existingCommand.ID; this.uploadCommand.Description = existingCommand.Description; } this.uploadCommand.Tags.Clear(); foreach (ActionModelBase action in this.command.Actions) { if (action is ConditionalActionModel) { foreach (ActionModelBase subAction in ((ConditionalActionModel)action).Actions) { this.uploadCommand.Tags.Add((CommunityCommandTagEnum)subAction.Type); } } this.uploadCommand.Tags.Add((CommunityCommandTagEnum)action.Type); } switch (this.command.Type) { case CommandTypeEnum.Chat: this.uploadCommand.Tags.Add(CommunityCommandTagEnum.ChatCommand); break; case CommandTypeEnum.Event: this.uploadCommand.Tags.Add(CommunityCommandTagEnum.EventCommand); break; case CommandTypeEnum.ActionGroup: this.uploadCommand.Tags.Add(CommunityCommandTagEnum.ActionGroupCommand); break; case CommandTypeEnum.Timer: this.uploadCommand.Tags.Add(CommunityCommandTagEnum.TimerCommand); break; case CommandTypeEnum.Game: this.uploadCommand.Tags.Add(CommunityCommandTagEnum.GameCommand); break; case CommandTypeEnum.StreamlootsCard: this.uploadCommand.Tags.Add(CommunityCommandTagEnum.StreamlootsCardCommand); break; case CommandTypeEnum.TwitchChannelPoints: this.uploadCommand.Tags.Add(CommunityCommandTagEnum.TwitchChannelPointsCommand); break; case CommandTypeEnum.Webhook: this.uploadCommand.Tags.Add(CommunityCommandTagEnum.Webhook); break; } } else { this.uploadCommand = new CommunityCommandUploadModel() { ID = this.ccCommand.ID, Name = this.ccCommand.Name, Description = this.ccCommand.Description, }; } this.NameTextBox.Text = this.uploadCommand.Name; this.DescriptionTextBox.Text = this.uploadCommand.Description; if (this.uploadCommand.Tags.Contains(CommunityCommandTagEnum.Sound) || this.uploadCommand.Tags.Contains(CommunityCommandTagEnum.Overlay) || this.uploadCommand.Tags.Contains(CommunityCommandTagEnum.File) || this.uploadCommand.Tags.Contains(CommunityCommandTagEnum.ExternalProgram)) { this.commandContainsMedia = true; } if (this.uploadCommand.Tags.Contains(CommunityCommandTagEnum.Command)) { this.commandReferencesOtherCommand = true; } } catch (Exception ex) { Logger.Log(ex); } }
public CommunityCommandsMainControlViewModel(MainWindowViewModel windowViewModel) : base(windowViewModel) { this.BackCommand = this.CreateCommand(async() => { if (this.ShowMyCommands) { await this.NavigateToCategories(); } else if (this.ShowUserCommands) { await this.NavigateToCategories(); } else if (this.ShowSearch) { await this.NavigateToCategories(); } else if (this.ShowCommandDetails) { if (this.MyCommands.Count > 0) { this.ClearAllShows(); this.ShowMyCommands = true; } else if (this.UserCommands.Count > 0) { this.ClearAllShows(); this.ShowUserCommands = true; } else if (this.SearchResults.Count > 0) { this.ClearAllShows(); this.ShowSearch = true; } else { await this.NavigateToCategories(); } } }); this.SearchCommand = this.CreateCommand(async() => { try { this.CurrentResultsPage = 0; await this.PerformSearch(); } catch (Exception ex) { Logger.Log(ex); } }); this.GetCommandDetailsCommand = this.CreateCommand(async(id) => { try { CommunityCommandDetailsModel commandDetails = await ChannelSession.Services.CommunityCommandsService.GetCommandDetails((Guid)id); if (commandDetails != null) { this.CommandDetails = new CommunityCommandDetailsViewModel(commandDetails); this.ClearAllShows(); this.ShowCommandDetails = true; } } catch (Exception ex) { Logger.Log(ex); } }); this.WebsiteLinkCommand = this.CreateCommand(() => { ProcessHelper.LaunchLink(this.CommandDetails?.WebsiteURL); }); this.GetUserCommandsCommand = this.CreateCommand(async() => { try { this.CurrentResultsPage = 0; await this.PerformUserCommands(); } catch (Exception ex) { Logger.Log(ex); } }); this.GetMyCommandsCommand = this.CreateCommand(async() => { try { this.CurrentResultsPage = 0; await this.PerformMyCommands(); } catch (Exception ex) { Logger.Log(ex); } }); this.EditMyCommandCommand = this.CreateCommand(async(id) => { try { CommunityCommandDetailsModel commandDetails = await ChannelSession.Services.CommunityCommandsService.GetCommandDetails((Guid)id); if (commandDetails != null) { this.CommandDetails = new MyCommunityCommandDetailsViewModel(commandDetails); this.ClearAllShows(); this.ShowCommandDetails = true; } } catch (Exception ex) { Logger.Log(ex); } }); this.DeleteMyCommandCommand = this.CreateCommand(async() => { try { if (this.CommandDetails.IsMyCommand && await DialogHelper.ShowConfirmation(MixItUp.Base.Resources.CommunityCommandsDeleteMyCommandConfirmation)) { await ChannelSession.Services.CommunityCommandsService.DeleteCommand(this.CommandDetails.ID); this.GetMyCommandsCommand.Execute(null); } } catch (Exception ex) { Logger.Log(ex); } }); this.PreviousResultsCommand = this.CreateCommand(async() => { this.CurrentResultsPage--; if (this.ShowMyCommands) { await this.PerformMyCommands(); } else if (this.ShowUserCommands) { await this.PerformUserCommands(); } else if (this.ShowSearch) { await this.PerformSearch(); } }); this.NextResultsCommand = this.CreateCommand(async() => { this.CurrentResultsPage++; if (this.ShowMyCommands) { await this.PerformMyCommands(); } else if (this.ShowUserCommands) { await this.PerformUserCommands(); } else if (this.ShowSearch) { await this.PerformSearch(); } }); }