Esempio n. 1
0
        public ServerForm()
        {
            InitializeComponent();
            shapeRows.ReadXml("panel_data.xml");

            foreach (var item in shapeRows)
            {
                Shape shape;
                if (item.Shape.Equals("Line"))
                {
                    MyLine myLine = new MyLine();
                    myLine.setPoint(new Point(item.x1, item.y1), new Point(item.x2, item.y2),
                                    new Pen(Color.FromArgb(item.Color), item.thick));
                    shape = myLine;
                }
                else if (item.Shape.Equals("Circle"))
                {
                    MyCircle myCircle = new MyCircle();
                    myCircle.setRectC(new Point(item.x1, item.y1),
                                      new Point(item.x1 + item.x2, item.y1 + item.y2),
                                      new Pen(Color.FromArgb(item.Color), item.thick),
                                      new SolidBrush(Color.FromArgb(item.Brush)));
                    shape = myCircle;
                }
                else// if (item.Shape.Equals("Rectangle"))
                {
                    MyRect myRect = new MyRect();
                    myRect.setRect(new Point(item.x1, item.y1),
                                   new Point(item.x1 + item.x2, item.y1 + item.y2),
                                   new Pen(Color.FromArgb(item.Color), item.thick),
                                   new SolidBrush(Color.FromArgb(item.Brush)));
                    shape = myRect;
                }
                shapes.Add(shape);
            }

            //shapeRows.Rows.Add(dr);
            //txt_Chat.AppendText(shapeRows.Last().Shape);
            //shapeRows.Rows.Add(dr);
            //txt_Chat.AppendText(shapeRows[0].Shape);
            //txt_Chat.AppendText(shapeRows[0].x1.ToString());

            ConnectModal connectModal = new ConnectModal();

            connectModal.ShowDialog();

            for (int i = 0; i < 10; i++)
            {
                serverThreads[i] = new ServerThread(this);
            }

            this.m_thServer = new Thread(new ThreadStart(ServerStart));
            this.m_thServer.Start();
        }
Esempio n. 2
0
        private void Panel_board_MouseMove(object sender, MouseEventArgs e)
        {
            if (!isholding)
            {
                return;
            }
            finish = e.Location;
            switch (drawTool)
            {
            case 0:
                break;

            case 1:         //Pencil
                m_Write.WriteLine("Line");
                m_Write.WriteLine(point.X);
                m_Write.WriteLine(point.Y);
                m_Write.WriteLine(finish.X);
                m_Write.WriteLine(finish.Y);
                m_Write.WriteLine(pen.Width);
                m_Write.WriteLine(pen.Color.ToArgb());
                m_Write.Flush();

                point = finish;
                break;

            case 2:     //Line
                myLine.setPoint(point, finish, pen);
                break;

            case 3:     //Circle
                myCircle.setRectC(point, finish, pen, brush);
                break;

            case 4:     //Rectangle
                myRect.setRect(point, finish, pen, brush);
                break;
            }
            panel_board.Invalidate(true);
            panel_board.Update();
        }
Esempio n. 3
0
        public void Receive()
        {
            string Request;

            while (m_bConnect)
            {
                Request = m_Read.ReadLine();
                if (Request.Equals("New Client"))
                {
                    connectedClient = m_Read.ReadLine();
                    serverForm.printChat(connectedClient + "이(가) 입장했습니다.");
                }
                else if (Request.Equals("Message"))
                {
                    serverForm.Receive_Message(m_Read.ReadLine());
                }
                else if (Request.Equals("Line"))
                {
                    int    x1     = int.Parse(m_Read.ReadLine());
                    int    y1     = int.Parse(m_Read.ReadLine());
                    int    x2     = int.Parse(m_Read.ReadLine());
                    int    y2     = int.Parse(m_Read.ReadLine());
                    int    thick  = int.Parse(m_Read.ReadLine());
                    int    Argb   = int.Parse(m_Read.ReadLine());
                    MyLine myLine = new MyLine();
                    myLine.setPoint(new Point(x1, y1), new Point(x2, y2), new Pen(Color.FromArgb(Argb), thick));
                    Shape shape = myLine;
                    serverForm.shapes.Add(shape);
                    serverForm.Draw();

                    serverForm.all_Send_Line(x1, y1, x2, y2, thick, Argb);
                }
                else if (Request.Equals("Circle"))
                {
                    int      x1       = int.Parse(m_Read.ReadLine());
                    int      y1       = int.Parse(m_Read.ReadLine());
                    int      wid      = int.Parse(m_Read.ReadLine());
                    int      hei      = int.Parse(m_Read.ReadLine());
                    int      thick    = int.Parse(m_Read.ReadLine());
                    int      Argb     = int.Parse(m_Read.ReadLine());
                    int      brush    = int.Parse(m_Read.ReadLine());
                    MyCircle myCircle = new MyCircle();
                    myCircle.setRectC(new Point(x1, y1), new Point(x1 + wid, y1 + hei), new Pen(Color.FromArgb(Argb), thick), new SolidBrush(Color.FromArgb(brush)));
                    Shape shape = myCircle;
                    serverForm.shapes.Add(shape);
                    serverForm.Draw();

                    serverForm.all_Send_Circle(x1, y1, wid, hei, thick, Argb, brush);
                }
                else if (Request.Equals("Rectangle"))
                {
                    int    x1     = int.Parse(m_Read.ReadLine());
                    int    y1     = int.Parse(m_Read.ReadLine());
                    int    wid    = int.Parse(m_Read.ReadLine());
                    int    hei    = int.Parse(m_Read.ReadLine());
                    int    thick  = int.Parse(m_Read.ReadLine());
                    int    Argb   = int.Parse(m_Read.ReadLine());
                    int    brush  = int.Parse(m_Read.ReadLine());
                    MyRect myRect = new MyRect();
                    myRect.setRect(new Point(x1, y1), new Point(x1 + wid, y1 + hei), new Pen(Color.FromArgb(Argb), thick), new SolidBrush(Color.FromArgb(brush)));
                    Shape shape = myRect;
                    serverForm.shapes.Add(shape);
                    serverForm.Draw();

                    serverForm.all_Send_Rectangle(x1, y1, wid, hei, thick, Argb, brush);
                }
                else if (Request.Equals("Disconnect"))
                {
                    serverForm.printChat(connectedClient + "이(가) 퇴장했습니다.");
                    m_bConnect = false;
                    return;
                }
            }
            serverForm.ServerThreadExit(this);
        }
Esempio n. 4
0
        private void Receive()
        {
            m_Write.WriteLine("New Client");
            m_Write.WriteLine(id);
            m_Write.Flush();
            string receive;

            while (m_bConnect)
            {
                //this.Invoke(new Action(delegate ()
                //{
                //    txt_Chat.AppendText("dddddddd\r\n");
                //}));
                receive = m_Read.ReadLine();
                if (receive.Equals("Message"))
                {
                    string message = m_Read.ReadLine();
                    this.Invoke(new Action(delegate()
                    {
                        txt_Chat.AppendText(message + "\r\n");
                    }));
                }
                else if (receive.Equals("Line"))
                {
                    int    x1    = int.Parse(m_Read.ReadLine());
                    int    y1    = int.Parse(m_Read.ReadLine());
                    int    x2    = int.Parse(m_Read.ReadLine());
                    int    y2    = int.Parse(m_Read.ReadLine());
                    int    thick = int.Parse(m_Read.ReadLine());
                    int    Argb  = int.Parse(m_Read.ReadLine());
                    MyLine ml    = new MyLine();
                    ml.setPoint(new Point(x1, y1), new Point(x2, y2), new Pen(Color.FromArgb(Argb), thick));
                    shape = ml;
                    shapes.Add(shape);
                }
                else if (receive.Equals("Circle"))
                {
                    int      x1    = int.Parse(m_Read.ReadLine());
                    int      y1    = int.Parse(m_Read.ReadLine());
                    int      wid   = int.Parse(m_Read.ReadLine());
                    int      hei   = int.Parse(m_Read.ReadLine());
                    int      thick = int.Parse(m_Read.ReadLine());
                    int      Argb  = int.Parse(m_Read.ReadLine());
                    int      brush = int.Parse(m_Read.ReadLine());
                    MyCircle mc    = new MyCircle();
                    mc.setRectC(new Point(x1, y1), new Point(x1 + wid, y1 + hei), new Pen(Color.FromArgb(Argb), thick), new SolidBrush(Color.FromArgb(brush)));
                    shape = mc;
                    shapes.Add(shape);
                }
                else if (receive.Equals("Rectangle"))
                {
                    int    x1    = int.Parse(m_Read.ReadLine());
                    int    y1    = int.Parse(m_Read.ReadLine());
                    int    wid   = int.Parse(m_Read.ReadLine());
                    int    hei   = int.Parse(m_Read.ReadLine());
                    int    thick = int.Parse(m_Read.ReadLine());
                    int    Argb  = int.Parse(m_Read.ReadLine());
                    int    brush = int.Parse(m_Read.ReadLine());
                    MyRect mr    = new MyRect();
                    mr.setRect(new Point(x1, y1), new Point(x1 + wid, y1 + hei), new Pen(Color.FromArgb(Argb), thick), new SolidBrush(Color.FromArgb(brush)));
                    shape = mr;
                    shapes.Add(shape);
                }
                else if (receive.Equals("Bitmap"))
                {
                    int    length = int.Parse(m_Read.ReadLine());
                    byte[] buf    = m_bRead.ReadBytes(length);
                    txt_Chat.AppendText(length + "\r\n");
                    ms     = new MemoryStream(buf);
                    bitmap = new Bitmap(ms);
                    //bitmap.Save("C:/Users/junhwa/source/repos/Application_Software_3rdPractice/Client/bin/Debug/abc.bmp");
                }
                Draw();
            }
        }