コード例 #1
0
        public Form1()
        {
            _5pW   = _5pL = _5pD = 0;
            p5flag = drawflag = imgflag = whsflag = true;
            this.Hide();
            this.Location = new Point(150, 150);
            //this.ShowInTaskbar = true;
            InitializeComponent();


            //Gomoku a = new Gomoku();
            //a.ShowDialog();

            this.ShowInTaskbar = true;

            trackBar1.Hide();
            ColorBox.Hide();
            button2.Hide();

            Login log = new Login();

            log.ShowDialog();
            if (log.DialogResult == DialogResult.Cancel)
            {
                this.Close();
            }
            else
            {
                this.Show();
                //this.ShowInTaskbar = true;
                SetUpData init = log.Get();
                Username = init.UserName;


                MLabel.Hide();
                //Box.ForeColor = Bcolor;
                UserBox.DataSource = UserList;
                myGraphic          = DrawBox.CreateGraphics();
                DrawBox.BringToFront();

                c.Setup(init.IP, init.Port);


                //addMsg("2.成功連線");

                msgHandler = this.addMsg;
                dwHandler  = this.addDw;
                imgHandler = this.ShowPic;
                c.Recv(processMsgComeIn, processDwComeIn, processImgComeIn);

                //MessageBox.Show("歡迎加入~");
            }
        }
コード例 #2
0
 private void checkBox1_CheckedChanged(object sender, EventArgs e)
 {
     onDraw = !onDraw;
     if (onDraw == true)
     {
         DrawBox.BringToFront();
         DrawBox.Focus();
         //for (int i = 0; i < px.Count; i++)
         //{
         //  myGraphic.FillEllipse(myBrush, py[i], px[i], Bsize, Bsize);
         //}
     }
     else
     {
         DrawBox.Parent.Invalidate(new Rectangle(DrawBox.Location, DrawBox.Size), true);
     }
 }
コード例 #3
0
        public String addDw(String str)
        {
            DrawBox.BringToFront();
            myGraphic = DrawBox.CreateGraphics();

            String[]   Words  = str.Split('.');
            int        Nsize  = Int32.Parse(Words[1]);
            Color      Ncolor = System.Drawing.ColorTranslator.FromHtml(Words[2]);
            SolidBrush NBrush = new SolidBrush(Ncolor);
            int        i      = 0;

            try
            {
                for (i = 3; Words[i] != "!"; i += 2)
                {
                    if (i < Words.Length)
                    {
                        try
                        {
                            x = Int32.Parse(Words[i + 1]);
                            y = Int32.Parse(Words[i]);
                            px.Add(x);
                            py.Add(y);
                            if (onDraw == true)
                            {
                                myGraphic.FillEllipse(NBrush, y, x, Nsize, Nsize);
                            }
                        }
                        catch
                        {
                            MessageBox.Show(Words[i + 1]);
                        }
                    }
                }
            }
            catch
            {
                MessageBox.Show("畫太多了唷!");
            }
            return("OK");
        }
コード例 #4
0
        public String addMsg(String str)
        {
            if (systemflag == true)
            {
                systemflag = false;
                c.Send("/t.系統公告: " + Username + "已成功連線");
            }
            //Box.AppendText(str + '\n');
            //DrawBox.Parent.Invalidate(new Rectangle(DrawBox.Location, DrawBox.Size), true);
            String[] Word = str.Split('.');

            if (Word[0] == "0" || Word[0] == "e")
            {
                if (Word[0] == "e")
                {
                    if (UserList.Contains(Word[2]))
                    {
                        UserList.Remove(Word[2]);
                        PTotal.Text = "總人數:" + UserList.Count + "人";
                    }
                }
                String temp = "";
                foreach (String x in Word)
                {
                    if (x != Word[0])
                    {
                        temp += x;
                    }
                }
                if (Word[0] == "e")
                {
                    Marquee = temp;
                    SetRunHorse();
                }
                else
                {
                    addSystemMsg(Word);
                }
            }
            else if (Word[0] == "/t")
            {
                Marquee = Word[1];
                //Box.AppendText(Marquee + '\n');
                SetRunHorse();
            }

            else if (Word[0] == "/nu")
            {
                AddUser(Word);
            }
            else if (Word[0] == "/r")
            {
                if (Word[2] != Username)
                {
                    if (Word[2] == "\reject")
                    {
                        Box.AppendText(Word[3] + "\n");
                    }
                    else
                    {
                        if (whsflag == true && !b.CheckList(Word[2]))
                        {
                            WhisperComeIn(Word[2], Word[3]);
                        }
                        else
                        {
                            c.Send("/r." + Word[2] + ".\reject." + Username + "拒絕你的密語");
                        }
                    }
                }
                else
                {
                }
            }
            else if (Word[0] == "2")
            {
                Color Ncolor = System.Drawing.ColorTranslator.FromHtml(Word[1]);
                Box.SelectionColor = Ncolor;
                String temp = "";
                string t    = Word[2].Substring(0, Word[2].Length - 2);
                if (!b.CheckList(t))
                {
                    for (int i = 2; i < Word.Length; i++)
                    {
                        temp += Word[i];
                    }
                    Box.AppendText(temp + '\n');
                }
            }
            else if (Word[0] == "3")
            {
                if (Word[1] == "Bear")
                {
                    for (int i = 2; i < Word.Length; i++)
                    {
                        Box.AppendText(Word[i] + '\n');
                    }
                }
            }
            else if (Word[0] == "/s")
            {
                if (pokeflag && !b.CheckList(Word[2]))
                {
                    if (Word[2] == Username)
                    {
                        Box.AppendText("戳了自己一下!" + '\n');
                    }
                    else
                    {
                        Box.AppendText(Word[2] + "戳了你一下!" + '\n');
                    }
                    Shake();
                }
            }
            else if (Word[0] == "5p")
            {
                if (Word[2] == "0")
                {
                    if (p5flag == true)
                    {
                        if (MessageBox.Show("玩家" + Word[3] + "向你提出五子棋挑戰!", "五子棋", MessageBoxButtons.OKCancel) == DialogResult.OK)
                        {
                            c.Send("5p." + Word[3] + ".y." + Username + "." + _5pW + "." + _5pL + "." + _5pD);
                            _5pGame       = new Gomoku(false);
                            _5pGame.Owner = this;
                            _5pGame.SetOwner();
                            _5pGame.SetInfo(2, _5pW, _5pL, _5pD, Username);
                            _5pGame.SetInfo(1, Int32.Parse(Word[4]), Int32.Parse(Word[5]), Int32.Parse(Word[6]), Word[3]);
                            _5pGame.SetName(Username, 2);
                            _5pGame.Show();

                            p5flag = false;
                        }
                        else
                        {
                            c.Send("5p." + Word[3] + ".r." + Username);
                        }
                    }
                    else
                    {
                        c.Send("5p." + Word[3] + ".r." + Username);
                    }
                }
                else if (Word[2] == "r")
                {
                    MessageBox.Show("玩家" + Word[3] + "拒絕你的五子棋挑戰!");
                }
                else if (Word[2] == "y")
                {
                    _5pGame       = new Gomoku(true);
                    _5pGame.Owner = this;
                    _5pGame.SetOwner();
                    _5pGame.Show();
                    _5pGame.SetName(Username, 1);
                    _5pGame.SetInfo(1, _5pW, _5pL, _5pD, Username);
                    _5pGame.SetInfo(2, Int32.Parse(Word[4]), Int32.Parse(Word[5]), Int32.Parse(Word[6]), Word[3]);
                    p5flag = false;
                }
                else if (Word[2] == "s")
                {
                    _5pGame.SetReady(Int32.Parse(Word[3]));
                }
                else if (Word[2] == "put")
                {
                    _5pGame.OnClickLabel(Int32.Parse(Word[3]));
                }
                else if (Word[2] == "w")
                {
                    String strtemp = "";
                    for (int i = 3; i < Word.Length; i++)
                    {
                        strtemp += Word[i];
                    }
                    _5pGame.PutStr(strtemp);
                }
                else if (Word[2] == "l")
                {
                    if (p5flag == false)
                    {
                        _5pGame.OppLeave();
                    }
                }
                else if (Word[2] == "al")
                {
                    if (p5flag == false)
                    {
                        _5pGame.OppAskLose();
                    }
                }

                else if (Word[2] == "ad")
                {
                    if (p5flag == false)
                    {
                        _5pGame.OppAskDraw();
                    }
                }
                else if (Word[2] == "adn")
                {
                    if (p5flag == false)
                    {
                        _5pGame.DrawReject();
                    }
                }
                else if (Word[2] == "ady")
                {
                    if (p5flag == false)
                    {
                        _5pGame.GameDraw();
                    }
                }
            }
            //DrawBox.Update();
            //if (systemflag==true)

            //if (flag == true)
            //{
            //   CheckName();
            //}

            textBox1.Focus();
            //for (int i = 0; i < px.Count; i++)
            //{
            //  myGraphic.FillEllipse(myBrush, py[i], px[i], Bsize, Bsize);
            //}
            DrawBox.BringToFront();
            return("ok");
        }