示例#1
0
        private void Create()
        {
            Gaming avatar = new Gaming(Avatar, "Post.aspx");
            Gaming parts = new Gaming(Parts, "Post.aspx");
            avatar.AddRow();
            avatar.AddCell("man_0", null, null, "border-width:1px", 
                "MXit.setStrip(['Bman.0'])",null, null);

            parts.AddRow();
            parts.AddCell("eyes_0", null, null, "border-width:1px",
                "MXit.setStrip(['eyes.0'])", "MXit.select(event,null,1,true)", null);
            parts.AddCell("eyes_1", null, null, "border-width:1px",
               "MXit.setStrip(['eyes.1'])", "MXit.select(event,null,1,true)", null);
            parts.AddRow();
            parts.AddCell("mouth_0", null, null, "border-width:1px",
                "MXit.setStrip(['mouth.0'])", "MXit.select(event,null,1,true)", null);
            parts.AddCell("mouth_1", null, null, "border-width:1px",
                "MXit.setStrip(['mouth.1'])", "MXit.select(event,null,1,true)", null);
            parts.AddRow();
            parts.AddCell("hair_0", null, null, "border-width:1px",
                "MXit.setStrip(['hair.0'])", "MXit.select(event,null,1,true)", null);
            parts.AddCell("hair_1", null, null, "border-width:1px",
                "MXit.setStrip(['hair.1'])", "MXit.select(event,null,1,true)", null);
            parts.AddRow();
            parts.AddCell("pants_0", null, null,"border-width:1px",
                "MXit.setStrip(['pants.0'])", "MXit.select(event,null,1,true)", null);
            parts.AddCell("pants_1", null, null, "border-width:1px",
                "MXit.setStrip(['pants.1'])", "MXit.select(event,null,1,true)", null);
            parts.AddRow();
            parts.AddCell("shirt_0", null, null, "border-width:1px",
                "MXit.setStrip(['shirt.0'])", "MXit.select(event,null,1,true)", null);
            parts.AddCell("shirt_1", null, null, "border-width:1px",
               "MXit.setStrip(['shirt.1'])", "MXit.select(event,null,1,true)", null);
            parts.AddRow();
            parts.AddCell("shoes_0", null, null, "border-width:1px",
                "MXit.setStrip(['shoes.0'])", "MXit.select(event,null,1,true)", null);
            parts.AddCell("shoes_1", null, null, "border-width:1px",
                "MXit.setStrip(['shoes.1'])", "MXit.select(event,null,1,true)", null);
            parts.AddRow();
            parts.AddCell("background_0", null, null, "border-width:1px",
                "MXit.setStrip(['background.0'])", "MXit.select(event,null,1,true)", null);
            parts.AddCell("background_1", null, null, "border-width:1px",
                "MXit.setStrip(['background.1'])", "MXit.select(event,null,1,true)", null);
            parts.AddRow();
            Session["partstable"] = Parts;
            Session["avatartable"] = Avatar;
            
        }
示例#2
0
文件: Post.aspx.cs 项目: Mxit/asp.net
        protected void Page_Load(object sender, EventArgs e)
        {
            Avatar.Attributes.Add("title", "mxit:table:update");
            Parts.Attributes.Add("title", "mxit:table:update");

            string postData = Request.Params[null];

            //Gaming gaming = new Gaming(parts, "Post.aspx"); 
            JavaScriptSerializer jss = new JavaScriptSerializer();
            TableReply reply = jss.Deserialize<TableReply>(postData);

            //parts.Visible = true;
            //parts.Attributes.Add("title", "mxit:table:update");

            if (reply.Selected.Count > 0)
            {
                CellCoord c = reply.Selected[0];
                Table prevParts = (Table)Session["partstable"];
                Table prevAvatar = (Table)Session["avatartable"];
                String id = prevParts.Rows[c.Row].Cells[c.Col].Attributes["data-mxit-init"];
                String prevav = prevAvatar.Rows[0].Cells[0].Attributes["data-mxit-init"];
                id = id.Substring(id.IndexOf("['")+2);
                id = id.Substring(0,id.IndexOf("']"));
                id = "B" + id;
                String tempid = id.Substring(0, id.IndexOf(".")+1);
                

                TableCell cell = prevAvatar.Rows[0].Cells[0];


                Gaming avatar = new Gaming(Avatar, "Post.aspx");
                avatar.AddRow();

                using (TableCell newTC = new TableCell())
                {
                    newTC.CopyBaseAttributes(cell);
                    newTC.ID = cell.ID;
                    newTC.Text = cell.Text;
                    foreach (string key in cell.Attributes.Keys)
                    {
                        newTC.Attributes.Add(key, cell.Attributes[key]);
                    }

                    foreach (string k in cell.Style.Keys)
                    {
                        newTC.Style.Add(k, cell.Style[k]);
                    }

                    avatar.CurrentRow.Cells.Add(newTC);
                }
                if (prevav.Contains(",'" + id + "'"))
                {
                    Avatar.Rows[0].Cells[0].Attributes["data-mxit-init"] = prevav.Replace(",'" + id + "'", "");
                }
                else if (prevav.Contains(",'" + tempid ))
                {
                    prevav = prevav.Remove(prevav.IndexOf(",'" + tempid),(",'" + tempid).Length+2);  //remove old item  and replace with new one
                    Avatar.Rows[0].Cells[0].Attributes["data-mxit-init"] = prevav.Insert(prevav.IndexOf(']'), ",'" + id + "'");                    
                }
                else
                {
                    Avatar.Rows[0].Cells[0].Attributes["data-mxit-init"] = prevav.Insert(prevav.IndexOf(']'), ",'" + id + "'");
                }
                Session["avatartable"] = Avatar;
                

                 
            }

        }