コード例 #1
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;
                    }
                }
            }
        }
コード例 #2
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);
            }
        }
コード例 #3
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);
        }
コード例 #4
0
        private bool 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++;
            }

            bool bc = false;
            string cur = "X";
            if (b[0][0].label == cur && b[1][0].label == cur && b[2][0].label == cur)
                bc = true;
            if (b[0][1].label == cur && b[1][1].label == cur && b[2][1].label == cur)
                bc = true;
            if (b[0][2].label == cur && b[1][2].label == cur && b[2][2].label == cur)
                bc = true;

            if (b[0][0].label == cur && b[0][1].label == cur && b[0][2].label == cur)
                bc = true;
            if (b[1][0].label == cur && b[1][1].label == cur && b[1][2].label == cur)
                bc = true;
            if (b[2][0].label == cur && b[2][1].label == cur && b[2][2].label == cur)
                bc = true;

            if (b[0][0].label == cur && b[1][1].label == cur && b[2][2].label == cur)
                bc = true;
            if (b[0][2].label == cur && b[1][1].label == cur && b[2][0].label == cur)
                bc = true;

            if (bc == true) {
                GetControlByID("theLabel").Value = cur + " Has Won it!";
                return true;
            }

            cur = "O";
            if (b[0][0].label == cur && b[1][0].label == cur && b[2][0].label == cur)
                bc = true;
            if (b[0][1].label == cur && b[1][1].label == cur && b[2][1].label == cur)
                bc = true;
            if (b[0][2].label == cur && b[1][2].label == cur && b[2][2].label == cur)
                bc = true;

            if (b[0][0].label == cur && b[0][1].label == cur && b[0][2].label == cur)
                bc = true;
            if (b[1][0].label == cur && b[1][1].label == cur && b[1][2].label == cur)
                bc = true;
            if (b[2][0].label == cur && b[2][1].label == cur && b[2][2].label == cur)
                bc = true;

            if (b[0][0].label == cur && b[1][1].label == cur && b[2][2].label == cur)
                bc = true;
            if (b[0][2].label == cur && b[1][1].label == cur && b[2][0].label == cur)
                bc = true;

            if (bc == true) {
                GetControlByID("theLabel").Value = cur + " Has Won it!";
                return true;
            }

            for (int j = 0; j < 3; j++) {
                for (int k = 0; k < 3; k++) {
                    if (b[j][k].label == "_") {
                        return false;
                    }
                }
            }

            GetControlByID("theLabel").Value = "Stale mate!";

            return true;
        }
コード例 #5
0
ファイル: CompileDTSD.cs プロジェクト: dested/DSTD-Web-Server
        private Control getControlFromNode(XmlNode node)
        {
            string id = "";
            if (node.Attributes["id"] != null)
                id = node.Attributes["id"].Value;

            string value = "";
            bool visible = true;
            if (node.Attributes["value"] != null)
                value = node.Attributes["value"].Value;
            if (node.Attributes["label"] != null)
                value = node.Attributes["label"].Value;
            if (node.Attributes["text"] != null)
                value = node.Attributes["text"].Value;
            if (node.Attributes["visible"] != null)
                visible = bool.Parse(node.Attributes["visible"].Value);

            string style = "";
            if (node.Attributes["style"] != null)
                style = node.Attributes["style"].Value;
            bool enabled = true;
            if (node.Attributes["enabled"] != null)
                enabled = bool.Parse(node.Attributes["enabled"].Value);
            string onclick = "";
            if (node.Attributes["onclick"] != null)
                onclick = node.Attributes["onclick"].Value;

            switch (node.Name.ToLower()) {
                case "panel":
                    Panel panel = new Panel();
                    panel.id = id;
                    panel.Value = value;
                    panel.Visible = visible;
                    panel.Style = style;
                    return panel;
                    break;
                case "page":
                    Page page = new Page();
                    page.id = id;
                    return page;
                    break;
                case "textbox":
                    TextBox text = new TextBox();
                    text.id = id;
                    text.Enabled = enabled;
                    if (node.Attributes["onkeypressenter"] != null) {
                        onclick = node.Attributes["onkeypressenter"].Value;
                        if (onclick != "") {
                            text.GetType().GetEvent("OnKeyPressEnter").AddEventHandler(text, Delegate.CreateDelegate(typeof(Control.TriggeredEvent), (Control)this.page ?? (Control)this.panel, onclick.Split('|')[0]));
                            if (onclick.Split('|').Length == 2) {
                                text.Where = onclick.Split('|')[1];
                            }
                        }
                    }

                    text.text = value;
                    text.Style = style;
                    if (node.Attributes["multiline"] != null) {
                        text.Multiline = bool.Parse(node.Attributes["multiline"].Value);
                        if (node.Attributes["rows"] != null)
                            text.Rows = int.Parse(node.Attributes["rows"].Value);
                        if (node.Attributes["cols"] != null)
                            text.Cols = int.Parse(node.Attributes["cols"].Value);
                    }
                    return text;
                    break;
                case "label":
                    Label label = new Label();
                    label.id = id;
                    label.text = value;
                    label.Style = style;
                    return label;
                    break;
                case "button":
                    Button button = new Button();
                    button.id = id;
                    button.Enabled = enabled;
                    button.label = value;
                    if (node.Attributes["enabled"] != null)
                        button.Enabled = bool.Parse(node.Attributes["enabled"].Value);

                    if (onclick != "") {
                        button.GetType().GetEvent("OnClick").AddEventHandler(button, Delegate.CreateDelegate(typeof(Control.TriggeredEvent), (Control)this.page ?? (Control)this.panel, onclick.Split('|')[0]));
                        if (onclick.Split('|').Length == 2) {
                            button.Where = onclick.Split('|')[1];
                        }
                    }
                    button.Style = style;
                    return button;
                    break;
                case "table":
                    Table table = new Table();
                    table.id = id;
                    table.Style = style;
                    return table;
                    break;
                case "tr":
                    TableRow row = new TableRow();

                    if (node.Attributes["colspan"] != null)
                        row.ColSpan = int.Parse(node.Attributes["colspan"].Value);

                    if (node.Attributes["rowspan"] != null)
                        row.RowSpan = int.Parse(node.Attributes["rowspan"].Value);

                    row.id = id;
                    row.Style = style;
                    return row;
                    break;
                case "td":
                    TableCell cell = new TableCell();
                    if (node.Attributes["colspan"] != null)
                        cell.ColSpan = int.Parse(node.Attributes["colspan"].Value);

                    if (node.Attributes["rowspan"] != null)
                        cell.RowSpan = int.Parse(node.Attributes["rowspan"].Value);
                    cell.id = id;
                    cell.Style = style;
                    return cell;
                    break;
                case "br":
                    BR br = new BR();
                    br.Style = style;
                    return br;
                    break;
                case "variable":
                    Variable variable = new Variable();
                    variable.id = id;
                    variable.Value = value;
                    variable.Style = style;
                    return variable;
                    break;
                case "timer":
                    Timer timer = new Timer();
                    timer.id = id;
                    if (node.Attributes["time"] != null)
                        timer.Time = int.Parse(node.Attributes["time"].Value);
                    if (node.Attributes["before"] != null)
                        timer.Before = (node.Attributes["before"].Value);

                    if (node.Attributes["onfire"] != null) {
                        onclick = node.Attributes["onfire"].Value;
                        timer.GetType().GetEvent("OnFire").AddEventHandler(timer, Delegate.CreateDelegate(typeof(Control.TriggeredEvent), (Control)this.page ?? (Control)this.panel, onclick.Split('|')[0]));
                        if (onclick.Split('|').Length == 2) {
                            timer.Where = onclick.Split('|')[1];
                        }
                    }
                    timer.Value = value;
                    return timer;
                    break;
                default:
                    Panel pa = Panel.LoadControl(Context, Location + node.Name, node.Name, id);
                    if (Panel.LoadControl(Context,Location+ node.Name, node.Name, id) != null) {
                        return pa;
                    }
                    throw new Exception("Control doesnt exists:" + node.Name.ToLower());
            }
        }