示例#1
0
        private void ChatBox_Load(Control sender)
        {
            GameID = int.Parse(this.UserQuery["GameRoomID"]);

            if (((Variable)GetControlByID("theUsername")).Value == "") {

                if (Session.ContainsKey("LoggedInUser"))

                    ((Variable)GetControlByID("theUsername")).Value = ((myUser)Session["LoggedInUser"]).UserName;
                else
                    ((Variable)GetControlByID("theUsername")).Value = "Foobar" + DSTDControls.myHelper.RANDOM(0, 200);

            }

            if (!IsPostBack) {
                int lines = myChatLine.GetChatLinesByGameRoomID__Count(GameID);

                if (Session.ContainsKey("LineNumber"))
                    Session["LineNumber"] = lines;
                else
                    Session.Add("LineNumber",lines);

                getMessage(GetControlByID("theChat"));
            }
        }
示例#2
0
        public void buttonClick(Control sender)
        {
            ((Button)sender).label = ((Variable)GetControlByID("WhosTurn")).Value;

            Color color = Color.FromArgb(myHelper.RANDOM(0, 255), myHelper.RANDOM(0, 255), myHelper.RANDOM(0, 255));
            sender.GetPanel.Style = "float:left;background-color:#" + color.Name.Substring(0, 6) + ";";
            ((Button)sender).Enabled = false;
            handleSwitch();
            if (checkHandle()) {

                Button[][] b = new Button[3][];
                string[] str1 = new[] { "top", "middle", "bottom" };
                string[] str2 = new[] { "left", "middle", "right" };
                int i = 0;

                foreach (string s1 in str1) {
                    int a = 0;
                    b[i] = new Button[3];
                    foreach (string s2 in str2) {
                        b[i][a] = (Button)GetControlByID(s1 + s2);
                        a++;
                    }
                    i++;
                }

                for (int j = 0; j < 3; j++) {
                    for (int k = 0; k < 3; k++) {
                        b[j][k].label = "_";
                        b[j][k].Enabled = true;
                    }
                }
            }
        }
示例#3
0
        void LoginUser(Control sender)
        {
            string username = ((TextBox) this.GetControlByID("theUsername")).text;
            string password = ((TextBox) this.GetControlByID("thePassword")).text;

            myUser u = new myUser();

            if (u.GetUserByUserName(username))
            {
                if (u.Password != password)
                {
                    ((Label) this.GetControlByID("theError")).text = "The password was incorrect";
                    return;
                }
            }
            else
            {
                u.UserName = username;
                u.Password = password;
                u.InsertData();
            }
            setUsername(u);

            myGameRoom g = new myGameRoom();
            if (!g.GetGameRoomByGameRoomName("Home"))
            {
                g.GameRoomName = "Home";
                g.InsertData();
            }
            g.AddUser_(u);
            this.Page.Request.TransferToPage("Chat*GameRoomID="+g.GameRoomID);
        }
示例#4
0
        void t_OnFire(Control sender)
        {
            Children.Clear();
            foreach (GrabVariable foobar in foobars) {
                GrabVariableReturn v = foobar(this);
                Children.Add(new Label(v.Name + "&nbsp;"));
                Children.Add(new Label(v.Value.ToString()));
                Children.Add(new BR());
            }
            Children.Add(new BR());
            Children.Add(new BR());
            Children.Add(new BR());
            foreach (GrabVariableReturn v in vars) {
                Children.Add(new Label(v.Name + "&nbsp;"));
                Children.Add(new Label(v.Value.ToString()));
                Children.Add(new BR());
            }

            Timer t = new Timer();
            t.Time = 900;
            t.Where = "theDebugger";
            t.id = "debuggerTimer";
            t.OnFire += new TriggeredEvent(t_OnFire);
            this.Children.Add(t);
        }
示例#5
0
        public void getUsers(Control sender)
        {
            myGameRoom room = new myGameRoom(GameID);

            foreach (myUser s in room.Users)
            {
                sender.GetPanel.Children.Add(new Label(s.UserName));
                sender.GetPanel.Children.Add(new BR());
            }
        }
示例#6
0
        void b_OnClick(Control sender)
        {
            if (((Button)sender).label == "New") {
                ((Panel)GetControlByID("theNewGame")).Visible = true;
                return;
            }

            string s = ((Button)sender).label;
            myGameRoom g = moveGames(s);

            this.Page.Request.TransferToPage("Chat*GameRoomID=" + g.GameRoomID);
        }
示例#7
0
        public void SendMessage(Control sender)
        {
            myChatLine c = new myChatLine();
            c.GameRoomID=GameID;
            c.TimePosted = DateTime.Now;
            c.ChatLineContent = ((Variable) GetControlByID("theUsername")).Value + ": " +((TextBox) GetControlByID("theChatText")).text + "\r\n";
            c.UserID = ((myUser) Session["LoggedInUser"]).UserID;
            c.InsertData();

            getMessage(this);
            ((TextBox) GetControlByID("theChatText")).text = "";
            SelectedControl = "theChatText";
        }
示例#8
0
        public void RandomClick(Control sender)
        {
            string[] str1 = new[] { "top", "middle", "bottom" };
            string[] str2 = new[] { "left", "middle", "right" };

            int i1 = myHelper.RANDOM(0, 3);
            int i2 = myHelper.RANDOM(0, 3);

            if (!((Button)sender.GetControlByID(str1[i1] + str2[i2])).Enabled) {
                RandomClick(sender);
                return;
            }
            ((Button)sender.GetControlByID(str1[i1] + str2[i2])).Click();
        }
示例#9
0
 public void getMessage(Control sender)
 {
     int c = myChatLine.GetChatLinesByGameRoomID__Count(GameID);
     if (c != (int) Session["LineNumber"])
     {
        // ((TextBox) GetControlByID("theChatContent")).text = "";
         int i = 0;
         foreach (myChatLine line in myChatLine.GetChatLineByGameRoomID(GameID))
         {
             if (i >= (int)Session["LineNumber"])
             {
                 ((TextBox) GetControlByID("theChatContent")).text += line.ChatLineContent;
             }
             i++;
         }
         Session["LineNumber"] = c;
     }
 }
示例#10
0
        void getGames(Control sender)
        {
            Panel that = ((Panel)GetControlByID("theGameList"));
            that.Children.Clear();
            Timer t = new Timer();
            t.Time = 1200;
            t.OnFire += getGames;
            t.Where = "theGameList";
            t.id = "time_2";
            that.Children.Add(t);

            if (isHome) {

                Button b = new Button();
                b.label = "New";
                b.Where = ID;
                b.id = "theGameClick0";
                int i = 1;
                b.OnClick += new TriggeredEvent(b_OnClick);
                that.Children.Add(b);
                that.Children.Add(new BR());
                foreach (myGameRoom gm in myGameRoom.GetAllGameRoom()) {
                    b = new Button();
                    if (gm.GameRoomName == "Home")
                        continue;
                    b.label = gm.GameRoomName;
                    b.id = "theGameClick" + i;
                    b.Where = ID;
                    b.OnClick += new TriggeredEvent(b_OnClick);
                    that.Children.Add(b);
                    that.Children.Add(new BR());
                    i++;
                }
            }
            else {
                Button b = new Button();
                b.label = "Leave";
                b.Where = ID;
                b.id = "theGameClick0";
                int i = 1;
                b.OnClick += new TriggeredEvent(b_OnClick);
                that.Children.Add(b);
            }
        }
示例#11
0
        void aTicTac_Init(Control sender)
        {
            Button[][] b = new Button[3][];
            string[] str1 = new[] { "top", "middle", "bottom" };
            string[] str2 = new[] { "left", "middle", "right" };
            int i = 0;

            foreach (string s1 in str1) {
                int a = 0;
                b[i] = new Button[3];
                foreach (string s2 in str2) {
                    b[i][a] = (Button)GetControlByID(s1 + s2);
                    b[i][a].Where = this.ID;
                    a++;
                }
                i++;
            }
            ((Timer)GetControlByID("someTimer")).Where = this.ID;
            ((Timer) GetControlByID("someTimer")).Time = myHelper.RANDOM(5,50);
        }
示例#12
0
        void Game_Load(Control sender)
        {
            myUser u;
            if (Session.ContainsKey("LoggedInUser"))
                u = ((myUser)Session["LoggedInUser"]);
            else
                return;

            int roomID = 0;

            if (this.UserQuery.ContainsKey("GameRoomID"))
            {
                roomID = int.Parse(this.UserQuery["GameRoomID"]);
            }

            myGameRoom r = new myGameRoom(roomID);
            foreach (myUser user in r.Users)
            {
                this.Children.Add(new Label(user.UserName));
                this.Children.Add(new BR());
            }
        }
示例#13
0
        private void Users_Load(Control sender)
        {
            GameID = int.Parse(this.UserQuery["GameRoomID"]);

            if (!IsPostBack || sender.PanelToUpdate.Split('_')[sender.PanelToUpdate.Split('_').Length-1] == "theChat")
             {
                getUsers(GetControlByID("theUsers"));
            }
        }
示例#14
0
 private void Chat_UnLoad(Control sender)
 {
     myGameRoom g = new myGameRoom(GameID);
     ((myUser)Session["LoggedInUser"]).DeleteGameRoom(g.GameRoomID);
 }
示例#15
0
 void Chat_Load(Control sender)
 {
 }
示例#16
0
 public void Compute(Control sender)
 {
     Session["CurrentClick"] = int.Parse(int.Parse(((Button)sender).label)+(((int)Session["CurrentClick"]) == 0 ? "" : Session["CurrentClick"].ToString()));
     ((TextBox)GetControlByID("result")).text = Session["CurrentClick"].ToString();
 }
示例#17
0
        private void theGameList_Init(Control sender)
        {
            GameID = int.Parse(this.Page.UserQuery["GameRoomID"]);

            myGameRoom g = new myGameRoom();
            g.GetGameRoomByGameRoomName("Home");
            if (g.GameRoomID == GameID)

                isHome = true;

            //if (!Page.IsPostBack)
            getGames(sender);
        }
示例#18
0
 private GrabVariableReturn getUserName(Control sender)
 {
     return new GrabVariableReturn("Username", ((TextBox)this.GetControlByID("theUsername")).text);
 }
示例#19
0
 public static string GetIDFromid(Control p, string where)
 {
     Control n = p.GetControlByID(where);
     if (n != null) {
         if (n.id == where) {
             return n.ID;
         }
     }
     return where;
 }
示例#20
0
 void Game_Init(Control sender)
 {
 }
示例#21
0
        public void Calc(Control sender)
        {
            int val = (int)Session["CurrentValue"];
            int val2 = (int)Session["CurrentClick"];

            sign s;

            if (((Button)sender).label == "+")
                s = sign.plus;
            else if (((Button)sender).label == "-")
                s = sign.minus;
            else if (((Button)sender).label == "*")
                s = sign.multipy;
            else if (((Button)sender).label == "=")
                s = sign.equal;
            else
                return;

            if (s!=sign.equal)
                Session["LastSign"] = s;
            switch (s) {
                case sign.plus:
                    val += val2;
                    break;
                case sign.minus:
                    val -= val2;
                    break;
                case sign.multipy:
                    if (((int)Session["CurrentValue"])==0)
                        val2 = 1;
                    val *= val2;

                    break;
                case sign.equal:
                    val2 = int.Parse(((TextBox)GetControlByID("result")).text);
                    if (Session["LastSign"]==null)
                        return;
                    switch ((sign)Session["LastSign"]) {
                        case sign.plus:
                            val += val2;
                            break;
                        case sign.minus:
                            val -= val2;
                            break;
                        case sign.multipy:
                            val *= val2;
                            break;
                        default:
                            throw new ArgumentOutOfRangeException();
                    }

                    Session["CurrentClick"] = val;
                    Session["LastSign"] = null;
                    break;
                default:
                    throw new ArgumentOutOfRangeException();
            }
            Session["CurrentValue"] = val;
            Session["CurrentClick"] = 0;

            ((TextBox)GetControlByID("result")).text = val.ToString();

            if (val==5)
            {
                Request.TransferToPage("Home2");

            }
        }
示例#22
0
 void Calculator_Load(Control sender)
 {
     if (!Session.ContainsKey("CurrentValue"))
         Session.Add("CurrentValue", 0);
     if (!Session.ContainsKey("CurrentClick"))
         Session.Add("CurrentClick", 0);
     if (!Session.ContainsKey("LastSign"))
         Session.Add("LastSign", null);
 }
示例#23
0
 void Calculator_Init(Control sender)
 {
 }
示例#24
0
 void GamesOpen_Load(Control sender)
 {
 }
示例#25
0
 void GamesOpen_Init(Control sender)
 {
 }
示例#26
0
 void Home_Load(Control sender)
 {
     bugger.PushVariable(new GrabVariableReturn("Something", "Init"));
 }
示例#27
0
 void Chat_Init(Control sender)
 {
     ((TextBox)GetControlByID("theChatContent")).Enabled = false;
 }
示例#28
0
 public void Clear(Control sender)
 {
     Session["CurrentClick"] = 0;
     Session["CurrentValue"] = 0;
     ((TextBox)GetControlByID("result")).text = Session["CurrentClick"].ToString();
 }
示例#29
0
 void aTicTac_Load(Control sender)
 {
 }
示例#30
0
 private GrabVariableReturn getPassword(Control sender)
 {
     return new GrabVariableReturn("Password", ((TextBox)this.GetControlByID("thePassword")).text);
 }