Beispiel #1
0
        private void PlusButton_Click(object sender, EventArgs e)
        {
            if (kujiKeyword.Text.Length == 0)
            {
                MessageBox.Show("キーワードが未入力です", "登録エラー", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (kujiItems.Text.Length == 0)
            {
                MessageBox.Show("くじ内容が未入力です", "登録エラー", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            string key     = kujiKeyword.Text;
            int    findIdx = KujiSettings.KujiDatas.FindIndex(o => {
                return(o.Keyword == key);
            });

            if (findIdx == -1)
            {
                KujiData data = new KujiData();
                data.Keyword  = kujiKeyword.Text;
                data.KujiList = kujiItems.Text.Trim().Replace("\r\n", "|");
                data.Enable   = "1";
                KujiSettings.KujiDatas.Add(data);
            }
            else
            {
                KujiSettings.KujiDatas[findIdx].KujiList = kujiItems.Text.Trim().Replace("\r\n", "|");
            }
            RenderList();
        }
Beispiel #2
0
        private void kujiListView_SelectedIndexChanged(object sender, EventArgs e)
        {
            SelectedIndexCollection idc = kujiListView.SelectedIndices;

            if (idc.Count > 0)
            {
                int      idx  = idc[0];
                KujiData data = KujiSettings.KujiDatas[idx];
                kujiKeyword.Text = data.Keyword;
                kujiItems.Text   = data.KujiList.Replace("|", "\r\n");
            }
        }
Beispiel #3
0
        private void DownButton_Click(object sender, EventArgs e)
        {
            SelectedIndexCollection idc = kujiListView.SelectedIndices;

            if (idc.Count > 0 && idc[0] < (kujiListView.Items.Count - 1))
            {
                int      idx  = idc[0];
                KujiData temp = KujiSettings.KujiDatas[idx + 1];
                KujiSettings.KujiDatas[idx + 1] = KujiSettings.KujiDatas[idx];
                KujiSettings.KujiDatas[idx]     = temp;
                RenderList();
                kujiListView.Items[idx + 1].Selected = true;
                kujiListView.Items[idx + 1].Focused  = true;
                kujiListView.Focus();
            }
        }
Beispiel #4
0
        private string KujiFind(string message)
        {
            string          result     = "";
            List <KujiData> data       = KujiSettings.KujiDatas;
            KujiData        resultData = data.Find(o => {
                return((message.IndexOf(o.Keyword) > -1) && (o.Enable == "1"));
            });

            if (resultData != null && resultData.KujiList != null && resultData.KujiList.Length > 0)
            {
                string[] kujiList = resultData.KujiList.Split(new char[] { '|' });
                Random   r        = new Random();
                int      idx      = r.Next(0, kujiList.Length);
                result = kujiList[idx];
            }
            return(result);
        }