示例#1
0
        public FormEditDiscordWebhook(FormDiscordWebhooks discordPingLink, DiscordWebhookData data, int reservedId)
        {
            this.discordPingLink = discordPingLink;
            this.data            = data;
            this.reservedId      = reservedId;
            InitializeComponent();
            Icon             = Properties.Resources.AppIcon;
            Text             = (data == null) ? "Add a new webhook" : "Edit an existing webhook";
            textBoxName.Text = data?.Name ?? "";
            textBoxUrl.Text  = data?.URL ?? "";
            switch (data?.SuccessFailToggle ?? DiscordWebhookDataSuccessToggle.OnSuccessAndFailure)
            {
            case DiscordWebhookDataSuccessToggle.OnSuccessOnly:
                radioButtonOnlySuccess.Checked = true;
                break;

            case DiscordWebhookDataSuccessToggle.OnFailOnly:
                radioButtonOnlyFail.Checked = true;
                break;

            default:
                radioButtonOnlySuccessAndFail.Checked = true;
                break;
            }
            checkBoxPlayers.Checked = data?.ShowPlayers ?? false;
            Dictionary <int, BossData> bosses = Bosses.GetAllBosses();

            bosses = bosses
                     .OrderBy(x => x.Value.Type)
                     .ThenBy(x => x.Value.Name)
                     .ToDictionary(x => x.Key, x => x.Value);
            foreach (int bossNumber in bosses.Keys)
            {
                checkedListBoxBossesEnable.Items.Add(new BossesDisableHelperClass()
                {
                    BossID = bosses[bossNumber].BossId, Text = $"{bosses[bossNumber].Type}: {bosses[bossNumber].Name} ({bosses[bossNumber].BossId})"
                }, data?.IsBossEnabled(bosses[bossNumber].BossId) ?? true);
            }
        }