Beispiel #1
0
        private async void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
        {
            if (messageBox.Text == "" || nameBox.Text == "")
            {
                MessageDialog dialog = new MessageDialog("You must include a name and a command.", "Error");
                await dialog.ShowAsync();

                return;
            }
            else if (!messageBox.Text.Contains("#"))
            {
                MessageDialog dialog = new MessageDialog("You must include # where the user's name will be in the message.", "Error");
                await dialog.ShowAsync();

                return;
            }
            else if (messageBox.Text != "" && nameBox.Text != "" && messageBox.Text.Contains("#"))
            {
                DO = new DoormatOptions()
                {
                    Name    = nameBox.Text,
                    Message = messageBox.Text
                };
            }
        }
Beispiel #2
0
 public DoormatOptionsWindow(DoormatOptions options = null)
 {
     this.InitializeComponent();
     if (options != null)
     {
         AddOptions(options);
     }
 }
Beispiel #3
0
 public void AddOptions(DoormatOptions options)
 {
     if (DO == null)
     {
         DO              = options;
         nameBox.Text    = DO.Name;
         messageBox.Text = DO.Message;
     }
 }
Beispiel #4
0
        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;
            }
        }