Пример #1
0
        private void EmoMessage_Changed(object sender, EventArgs e)
        {
            TextBox tb = (TextBox)sender;

            String[]   ids        = tb.ID.Split(',');
            EmoMessage emoMessage = WechatNotifier.EmoMessages.Find(emo => emo.Id == ids[0]);

            emoMessage.Message = tb.Text;
            DataAccess.Save(Manager);
        }
Пример #2
0
        private void EmoMessageDDL_Changed(object sender, EventArgs e)
        {
            DropDownList ddl = (DropDownList)sender;

            String[]   ids        = ddl.ID.Split(',');
            EmoMessage emoMessage = WechatNotifier.EmoMessages.Find(emo => emo.Id == ids[0]);

            if (ids[1] == MIN)
            {
                emoMessage.Min = int.Parse(ddl.Text);
            }
            else if (ids[1] == MAX)
            {
                emoMessage.Max = int.Parse(ddl.Text);
            }
            else if (ids[1] == TYPE)
            {
                emoMessage.Type = int.Parse(ddl.SelectedValue);
            }
            DataAccess.Save(Manager);
        }
Пример #3
0
        private void ActionEmoMessage_Click(object sender, EventArgs e)
        {
            Button tb = (Button)sender;

            String[] ids = tb.ID.Split(',');
            if (ids[1] == ADD)
            {
                int        min        = int.Parse(((DropDownList)this.Master.FindControl("MainContent").FindControl("," + MIN)).Text);
                int        max        = int.Parse(((DropDownList)this.Master.FindControl("MainContent").FindControl("," + MAX)).Text);
                String     typeString = ((DropDownList)this.Master.FindControl("MainContent").FindControl("," + TYPE)).SelectedValue;
                int        type       = int.Parse(typeString);
                String     message    = ((TextBox)this.Master.FindControl("MainContent").FindControl(",message")).Text;
                EmoMessage emoMessage = new EmoMessage(type, min, max, message);
                WechatNotifier.EmoMessages.Add(emoMessage);
            }
            else if (ids[1] == DELETE)
            {
                EmoMessage emoMessage = WechatNotifier.EmoMessages.Find(emo => emo.Id == ids[0]);
                WechatNotifier.EmoMessages.Remove(emoMessage);
            }
            DataAccess.Save(Manager);
            Response.Redirect(Request.RawUrl);
        }
Пример #4
0
        private void CreateEmoTableRow(EmoMessage emoMessage)
        {
            TableRow tableRow = new TableRow();
            //
            TableCell    typeCell = new TableCell();
            DropDownList typeDDL  = new DropDownList();

            typeDDL.ID = emoMessage.Id + "," + TYPE;
            BindEmoTypeDropdownList(typeDDL);
            typeDDL.DataBind();
            typeDDL.SelectedValue = emoMessage.Type.ToString();
            typeCell.Controls.Add(typeDDL);
            tableRow.Cells.Add(typeCell);
            //min
            TableCell    minCell = new TableCell();
            DropDownList minDDL  = new DropDownList();

            minDDL.ID         = emoMessage.Id + "," + MIN;
            minDDL.DataSource = playerNumbers;
            minDDL.DataBind();
            minDDL.SelectedValue = emoMessage.Min.ToString();
            minCell.Controls.Add(minDDL);
            tableRow.Cells.Add(minCell);
            //max
            TableCell    maxCell = new TableCell();
            DropDownList maxDDL  = new DropDownList();

            maxDDL.ID         = emoMessage.Id + "," + MAX;
            maxDDL.DataSource = playerNumbers;
            maxDDL.DataBind();
            maxDDL.SelectedValue = emoMessage.Max.ToString();
            maxCell.Controls.Add(maxDDL);
            tableRow.Cells.Add(maxCell);
            //
            TableCell messageCell = new TableCell();
            TextBox   messageTb   = new TextBox();

            messageTb.ID    = emoMessage.Id + ",message";
            messageTb.Width = 800;
            messageTb.Text  = emoMessage.Message;
            messageCell.Controls.Add(messageTb);
            tableRow.Cells.Add(messageCell);
            TableCell actionCell = new TableCell();
            Button    actionBtn  = new Button();

            actionBtn.ID            = emoMessage.Id + "," + (String.IsNullOrEmpty(emoMessage.Message) ? ADD : DELETE);
            actionBtn.Text          = String.IsNullOrEmpty(emoMessage.Message) ? ADD : DELETE;
            actionBtn.Click        += new EventHandler(ActionEmoMessage_Click);
            actionBtn.OnClientClick = "if ( !confirm('Are you sure?')) return false;";
            actionCell.Controls.Add(actionBtn);
            tableRow.Cells.Add(actionCell);
            if (!String.IsNullOrEmpty(emoMessage.Message))
            {
                minDDL.AutoPostBack           = true;
                minDDL.SelectedIndexChanged  += new EventHandler(EmoMessageDDL_Changed);
                maxDDL.AutoPostBack           = true;
                maxDDL.SelectedIndexChanged  += new EventHandler(EmoMessageDDL_Changed);
                typeDDL.AutoPostBack          = true;
                typeDDL.SelectedIndexChanged += new EventHandler(EmoMessageDDL_Changed);
                messageTb.AutoPostBack        = true;
                messageTb.TextChanged        += new EventHandler(EmoMessage_Changed);
                tableRow.BackColor            = System.Drawing.Color.CadetBlue;
            }
            this.EmoTable.Rows.Add(tableRow);
        }