private CommandEditorWindow(CommandModelBase existingCommand, IEnumerable <ActionModelBase> actions = null) : this() { commandId = existingCommand.ID; switch (existingCommand.Type) { case CommandTypeEnum.Chat: this.editorDetailsControl = new ChatCommandEditorDetailsControl(); this.viewModel = new ChatCommandEditorWindowViewModel((ChatCommandModel)existingCommand); break; case CommandTypeEnum.Event: this.editorDetailsControl = new EventCommandEditorDetailsControl(); this.viewModel = new EventCommandEditorWindowViewModel((EventCommandModel)existingCommand); break; case CommandTypeEnum.Timer: this.editorDetailsControl = new TimerCommandEditorDetailsControl(); this.viewModel = new TimerCommandEditorWindowViewModel((TimerCommandModel)existingCommand); break; case CommandTypeEnum.TwitchChannelPoints: this.editorDetailsControl = new TwitchChannelPointsCommandEditorDetailsControl(); this.viewModel = new TwitchChannelPointsCommandEditorWindowViewModel((TwitchChannelPointsCommandModel)existingCommand); break; case CommandTypeEnum.ActionGroup: this.editorDetailsControl = new ActionGroupCommandEditorDetailsControl(); this.viewModel = new ActionGroupCommandEditorWindowViewModel((ActionGroupCommandModel)existingCommand); break; case CommandTypeEnum.StreamlootsCard: this.editorDetailsControl = new StreamlootsCardCommandEditorDetailsControl(); this.viewModel = new StreamlootsCardCommandEditorWindowViewModel((StreamlootsCardCommandModel)existingCommand); break; case CommandTypeEnum.Webhook: this.editorDetailsControl = new WebhookCommandEditorDetailsControl(); this.viewModel = new WebhookCommandEditorWindowViewModel((WebhookCommandModel)existingCommand); break; case CommandTypeEnum.Custom: this.editorDetailsControl = new CustomCommandEditorDetailsControl(); this.viewModel = new CustomCommandEditorWindowViewModel((CustomCommandModel)existingCommand); break; case CommandTypeEnum.UserOnlyChat: this.editorDetailsControl = new ChatCommandEditorDetailsControl(); this.viewModel = new UserOnlyChatCommandEditorWindowViewModel((UserOnlyChatCommandModel)existingCommand); break; } this.importedActions = actions; this.DataContext = this.ViewModel = this.viewModel; this.ViewModel.StartLoadingOperationOccurred += (sender, eventArgs) => { this.StartLoadingOperation(); }; this.ViewModel.EndLoadingOperationOccurred += (sender, eventArgs) => { this.EndLoadingOperation(); }; }
public CommandEditorWindow(CommandTypeEnum commandType, string name = null) : this() { switch (commandType) { case CommandTypeEnum.Chat: this.editorDetailsControl = new ChatCommandEditorDetailsControl(); this.viewModel = new ChatCommandEditorWindowViewModel(); break; case CommandTypeEnum.Timer: this.editorDetailsControl = new TimerCommandEditorDetailsControl(); this.viewModel = new TimerCommandEditorWindowViewModel(); break; case CommandTypeEnum.TwitchChannelPoints: this.editorDetailsControl = new TwitchChannelPointsCommandEditorDetailsControl(); this.viewModel = new TwitchChannelPointsCommandEditorWindowViewModel(); break; case CommandTypeEnum.ActionGroup: this.editorDetailsControl = new ActionGroupCommandEditorDetailsControl(); this.viewModel = new ActionGroupCommandEditorWindowViewModel(); break; case CommandTypeEnum.Custom: this.editorDetailsControl = new CustomCommandEditorDetailsControl(); this.viewModel = (!string.IsNullOrEmpty(name)) ? new CustomCommandEditorWindowViewModel(name) : new CustomCommandEditorWindowViewModel(); break; } this.DataContext = this.ViewModel = this.viewModel; this.ViewModel.StartLoadingOperationOccurred += (sender, eventArgs) => { this.StartLoadingOperation(); }; this.ViewModel.EndLoadingOperationOccurred += (sender, eventArgs) => { this.EndLoadingOperation(); }; }
public CommandEditorWindow(EventTypeEnum eventType) : this() { this.editorDetailsControl = new EventCommandEditorDetailsControl(); this.DataContext = this.ViewModel = this.viewModel = new EventCommandEditorWindowViewModel(eventType); this.ViewModel.StartLoadingOperationOccurred += (sender, eventArgs) => { this.StartLoadingOperation(); }; this.ViewModel.EndLoadingOperationOccurred += (sender, eventArgs) => { this.EndLoadingOperation(); }; }
public CommandEditorWindow(Webhook webhook) : this() { this.editorDetailsControl = new WebhookCommandEditorDetailsControl(); this.DataContext = this.ViewModel = this.viewModel = new WebhookCommandEditorWindowViewModel(webhook); this.ViewModel.StartLoadingOperationOccurred += (sender, eventArgs) => { this.StartLoadingOperation(); }; this.ViewModel.EndLoadingOperationOccurred += (sender, eventArgs) => { this.EndLoadingOperation(); }; }
private async void PlayButton_Click(object sender, RoutedEventArgs e) { this.RaiseEvent(new RoutedEventArgs(CommandListingButtonsControl.PlayClickedEvent, this)); CommandModelBase command = this.GetCommandFromCommandButtons(); if (command != null) { await CommandEditorWindowViewModelBase.TestCommandWithTestSpecialIdentifiers(command); } }
protected override async Task OnLoadedInternal() { this.ImportActionsCommand = this.CreateCommand(async() => { try { await this.ImportActionsFromCommand(await CommandEditorWindowViewModelBase.ImportCommandFromFile(CommandEditorWindowViewModelBase.OpenCommandFileBrowser())); } catch (Exception ex) { Logger.Log(ex); await DialogHelper.ShowMessage(MixItUp.Base.Resources.FailedToImportCommand + ": " + ex.ToString()); } }); this.ExportActionsCommand = this.CreateCommand(async() => { try { IEnumerable <Result> results = await this.ActionEditorList.ValidateActions(); if (results.Any(r => !r.Success)) { await DialogHelper.ShowFailedResults(results.Where(r => !r.Success)); return; } CustomCommandModel command = new CustomCommandModel(this.Name); command.Actions.AddRange(await this.ActionEditorList.GetActions()); string fileName = ChannelSession.Services.FileService.ShowSaveFileDialog(this.Name + CommandEditorWindowViewModelBase.MixItUpCommandFileExtension); if (!string.IsNullOrEmpty(fileName)) { await FileSerializerHelper.SerializeToFile(fileName, command); } } catch (Exception ex) { Logger.Log(ex); await DialogHelper.ShowMessage(MixItUp.Base.Resources.FailedToExportCommand + ": " + ex.ToString()); } }); foreach (ActionModelBase subAction in subActions) { await this.ActionEditorList.AddAction(subAction); } subActions.Clear(); await base.OnLoadedInternal(); }
public CommandEditorWindow(CommandTypeEnum commandType, Guid id) : this() { switch (commandType) { case CommandTypeEnum.UserOnlyChat: this.editorDetailsControl = new ChatCommandEditorDetailsControl(); this.viewModel = new UserOnlyChatCommandEditorWindowViewModel(id); break; } this.DataContext = this.ViewModel = this.viewModel; this.ViewModel.StartLoadingOperationOccurred += (sender, eventArgs) => { this.StartLoadingOperation(); }; this.ViewModel.EndLoadingOperationOccurred += (sender, eventArgs) => { this.EndLoadingOperation(); }; }
public CommandEditorWindow(CommandTypeEnum commandType, string name = null, IEnumerable <ActionModelBase> actions = null) : this() { switch (commandType) { case CommandTypeEnum.Chat: this.editorDetailsControl = new ChatCommandEditorDetailsControl(); this.viewModel = new ChatCommandEditorWindowViewModel(); break; case CommandTypeEnum.Timer: this.editorDetailsControl = new TimerCommandEditorDetailsControl(); this.viewModel = new TimerCommandEditorWindowViewModel(); break; case CommandTypeEnum.TwitchChannelPoints: this.editorDetailsControl = new TwitchChannelPointsCommandEditorDetailsControl(); this.viewModel = new TwitchChannelPointsCommandEditorWindowViewModel(); break; case CommandTypeEnum.ActionGroup: this.editorDetailsControl = new ActionGroupCommandEditorDetailsControl(); this.viewModel = new ActionGroupCommandEditorWindowViewModel(); break; case CommandTypeEnum.StreamlootsCard: this.editorDetailsControl = new StreamlootsCardCommandEditorDetailsControl(); this.viewModel = new StreamlootsCardCommandEditorWindowViewModel(); break; case CommandTypeEnum.Custom: this.editorDetailsControl = new CustomCommandEditorDetailsControl(); this.viewModel = new CustomCommandEditorWindowViewModel(); break; } if (!string.IsNullOrEmpty(name)) { this.viewModel.Name = name; } this.importedActions = actions; this.DataContext = this.ViewModel = this.viewModel; this.ViewModel.StartLoadingOperationOccurred += (sender, eventArgs) => { this.StartLoadingOperation(); }; this.ViewModel.EndLoadingOperationOccurred += (sender, eventArgs) => { this.EndLoadingOperation(); }; }
public static void Initialize() { Task.Run(async() => { try { while (true) { using (NamedPipeServerStream pipeServer = new NamedPipeServerStream(PipeName, PipeDirection.In)) { pipeServer.WaitForConnection(); try { byte[] responseBytes = new byte[1000000]; int count = await pipeServer.ReadAsync(responseBytes, 0, responseBytes.Length); string response = Encoding.ASCII.GetString(responseBytes, 0, count); if (response.StartsWith(URIProtocolActivationCommunityCommand)) { if (Guid.TryParse(response.Replace(URIProtocolActivationCommunityCommand, ""), out Guid commandID)) { ActivationProtocolHandler.OnCommunityCommandActivation(null, commandID); } } else if (response.EndsWith(CommandEditorWindowViewModelBase.MixItUpCommandFileExtension)) { CommandModelBase command = await CommandEditorWindowViewModelBase.ImportCommandFromFile(response); if (command != null) { ActivationProtocolHandler.OnCommandFileActivation(null, command); } } } catch (IOException ex) { Logger.Log(LogLevel.Error, "Named Pipe Server Error: " + ex); } } } } catch (ThreadAbortException) { return; } catch (OperationCanceledException) { return; } catch (Exception ex) { Logger.Log(ex); } }, ActivationProtocolHandler.activationHandlerTaskCancellationTokenSource.Token); }
public CommandEditorWindow(CommandModelBase existingCommand) : this() { switch (existingCommand.Type) { case CommandTypeEnum.Chat: this.editorDetailsControl = new ChatCommandEditorDetailsControl(); this.viewModel = new ChatCommandEditorWindowViewModel((ChatCommandModel)existingCommand); break; case CommandTypeEnum.Event: this.editorDetailsControl = new EventCommandEditorDetailsControl(); this.viewModel = new EventCommandEditorWindowViewModel((EventCommandModel)existingCommand); break; case CommandTypeEnum.Timer: this.editorDetailsControl = new TimerCommandEditorDetailsControl(); this.viewModel = new TimerCommandEditorWindowViewModel((TimerCommandModel)existingCommand); break; case CommandTypeEnum.TwitchChannelPoints: this.editorDetailsControl = new TwitchChannelPointsCommandEditorDetailsControl(); this.viewModel = new TwitchChannelPointsCommandEditorWindowViewModel((TwitchChannelPointsCommandModel)existingCommand); break; case CommandTypeEnum.ActionGroup: this.editorDetailsControl = new ActionGroupCommandEditorDetailsControl(); this.viewModel = new ActionGroupCommandEditorWindowViewModel((ActionGroupCommandModel)existingCommand); break; case CommandTypeEnum.Custom: this.editorDetailsControl = new CustomCommandEditorDetailsControl(); this.viewModel = new CustomCommandEditorWindowViewModel((CustomCommandModel)existingCommand); break; case CommandTypeEnum.UserOnlyChat: this.editorDetailsControl = new ChatCommandEditorDetailsControl(); this.viewModel = new UserOnlyChatCommandEditorWindowViewModel((UserOnlyChatCommandModel)existingCommand); break; } this.DataContext = this.ViewModel = this.viewModel; this.ViewModel.StartLoadingOperationOccurred += (sender, eventArgs) => { this.StartLoadingOperation(); }; this.ViewModel.EndLoadingOperationOccurred += (sender, eventArgs) => { this.EndLoadingOperation(); }; }
protected override async Task OnLoadedInternal() { this.AddClauseCommand = this.CreateCommand((parameter) => { this.Clauses.Add(new ConditionalClauseViewModel(this)); return(Task.FromResult(0)); }); this.ImportActionsCommand = this.CreateCommand(async(parameter) => { await this.ImportActionsFromCommand(await CommandEditorWindowViewModelBase.ImportCommandFromFile()); }); foreach (ActionModelBase subAction in subActions) { await this.ActionEditorList.AddAction(subAction); } subActions.Clear(); await base.OnLoadedInternal(); }