public void AddOptions(ChatCommandAPI options) { if (CCAPI == null) { CCAPI = options; apiBox.Text = CCAPI.APIKey; } }
public ChatCommandAPIWindow(ChatCommandAPI options = null) { this.InitializeComponent(); if (options != null) { AddOptions(options); } }
private async void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args) { if (apiBox.Text == "") { MessageDialog dialog = new MessageDialog("You must include an API key.", "Error"); await dialog.ShowAsync(); } else { CCAPI = new ChatCommandAPI() { APIKey = apiBox.Text }; } }
private async void addButton_Click(object sender, RoutedEventArgs e) { string selected = ""; TriggerType type; try { selected = ((ListBoxItem)triggersListBox.SelectedValue).Name; } catch (Exception) { return; } ChatCommand cc = new ChatCommand(); ChatCommandAPI cca = new ChatCommandAPI(); ChatReply cr = new ChatReply(); DoormatOptions _do = new DoormatOptions(); TriggerOptionsBase tob = new TriggerOptionsBase(); switch (selected) { case "kickTrigger": case "banTrigger": case "isUpTrigger": case "playGameTrigger": case "chooseTrigger": case "helpTrigger": { ChatCommandWindow window = new ChatCommandWindow(); ContentDialogResult result = await window.ShowAsync(); if (result == ContentDialogResult.Primary && window.CC != null) { MainOptionsWindow mow = new MainOptionsWindow(); ContentDialogResult r1 = await mow.ShowAsync(); if (r1 == ContentDialogResult.Primary && mow.MO != null) { cc = window.CC; type = (TriggerType)Enum.Parse(typeof(TriggerType), char.ToUpper(selected[0]) + selected.Substring(1)); addedTriggersListBox.Items.Add(string.Format("{0} - {1}", cc.Name, type.ToString())); tob.ChatCommand = cc; tob.Name = cc.Name; tob.Type = type; tob.MainOptions = mow.MO; BaseTrigger trigger = (BaseTrigger)Activator.CreateInstance(Type.GetType("Chaos.Triggers." + type.ToString()), type, cc.Name, tob); Bot.Triggers.Add(trigger); } } } break; case "chatReplyTrigger": { ChatReplyWindow window = new ChatReplyWindow(); ContentDialogResult result = await window.ShowAsync(); if (result == ContentDialogResult.Primary && window.CR != null) { MainOptionsWindow mow = new MainOptionsWindow(); ContentDialogResult r1 = await mow.ShowAsync(); if (r1 == ContentDialogResult.Primary && mow.MO != null) { cr = window.CR; type = (TriggerType)Enum.Parse(typeof(TriggerType), char.ToUpper(selected[0]) + selected.Substring(1)); tob.ChatReply = cr; tob.Name = cr.Name; tob.Type = type; tob.MainOptions = mow.MO; addedTriggersListBox.Items.Add(string.Format("{0} - {1}", cr.Name, type.ToString())); BaseTrigger trigger = (BaseTrigger)Activator.CreateInstance(Type.GetType("Chaos.Triggers." + type.ToString()), type, cr.Name, tob); Bot.Triggers.Add(trigger); } } } break; case "doormatTrigger": { DoormatOptionsWindow window = new DoormatOptionsWindow(); ContentDialogResult result = await window.ShowAsync(); if (result == ContentDialogResult.Primary && window.DO != null) { MainOptionsWindow mow = new MainOptionsWindow(); ContentDialogResult r1 = await mow.ShowAsync(); if (r1 == ContentDialogResult.Primary && mow.MO != null) { _do = window.DO; type = (TriggerType)Enum.Parse(typeof(TriggerType), char.ToUpper(selected[0]) + selected.Substring(1)); addedTriggersListBox.Items.Add(string.Format("{0} - {1}", _do.Name, type.ToString())); tob.DoormatOptions = _do; tob.Name = _do.Name; tob.Type = type; tob.MainOptions = mow.MO; BaseTrigger trigger = (BaseTrigger)Activator.CreateInstance(Type.GetType("Chaos.Triggers." + type.ToString()), type, _do.Name, tob); Bot.Triggers.Add(trigger); } } } break; case "cSGOStatTrigger": { ChatCommandAPIWindow window = new ChatCommandAPIWindow(); ContentDialogResult result = await window.ShowAsync(); if (result == ContentDialogResult.Primary && window.CCAPI != null) { ChatCommandWindow ccw = new ChatCommandWindow(); ContentDialogResult r2 = await ccw.ShowAsync(); if (r2 == ContentDialogResult.Primary && ccw.CC != null) { MainOptionsWindow mow = new MainOptionsWindow(); ContentDialogResult r1 = await mow.ShowAsync(); if (r1 == ContentDialogResult.Primary && mow.MO != null) { cca = window.CCAPI; cca.ChatCommand = ccw.CC; type = (TriggerType)Enum.Parse(typeof(TriggerType), char.ToUpper(selected[0]) + selected.Substring(1)); addedTriggersListBox.Items.Add(string.Format("{0} - {1}", cca.ChatCommand.Name, type.ToString())); tob.ChatCommandAPI = cca; tob.ChatCommandAPI.ChatCommand = cca.ChatCommand; tob.Name = cca.ChatCommand.Name; tob.Type = type; tob.MainOptions = mow.MO; BaseTrigger trigger = (BaseTrigger)Activator.CreateInstance(Type.GetType("Chaos.Triggers." + type.ToString()), type, _do.Name, tob); Bot.Triggers.Add(trigger); } } } } break; } }