Beispiel #1
0
        public void EventMoveIndexLocation(int number)
        {
            //TextBox1.SelectionStart=TextBox1.GetLineFromCharIndex(number);
            int caratIndex = TextBox1.GetFirstCharIndexFromLine(number);

            TextBox1.Select(caratIndex, 0);
            TextBox1.ScrollToCaret();
        }
Beispiel #2
0
 public void OutPut(string text, Color color, Font font)
 {
     TextBox1HP.OutPutSuper(TextBox1, text, color, font);
     TextBox1.Select(TextBox1.TextLength, 0);
     TextBox1.ScrollToCaret();
     if (Properties.Settings.Default.IsTXTOut)
     {
         TXTOutput(text);
     }
 }
Beispiel #3
0
 private void FindTextDefault()
 {
     if (IndexLocation == -1)
     {
         MessageBox.Show(string.Format("\"{0}\"을(를) 찾을 수 없습니다.", FindTextSave), "메모장");
     }
     else
     {
         TextBox1.Select(IndexLocation, FindTextSave.Length);
         TextBox1.ScrollToCaret();
     }
 }
Beispiel #4
0
 //private void TextBox1_TextChanged(object sender, EventArgs e)
 //{
 //    TextBox1.SelectionStart = TextBox1.Text.Length;
 //    TextBox1.ScrollToCaret();
 //}
 private void Logger_Onevent(object sender, string e)
 {
     if (startLoggin)
     {
         this.TextBox1.BeginInvoke(new Action(() =>
         {
             this.TextBox1.AppendText(e + Environment.NewLine);
             TextBox1.SelectionStart = TextBox1.Text.Length;
             TextBox1.ScrollToCaret();
         }));
     }
 }
Beispiel #5
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            //每? 0.1小时进行一次存档备份
            SaveGame();
            //清空文本//防止输出文本超过上限导致溢出
            if (TextBox1.TextLength >= 214748364)
            {
                TextBox1.Text = TextBox1.Text.Substring(214746364);
                TextBox1HP.SetRTF(TextBox1);
                TextBox1.Select(TextBox1.TextLength, 0);
                TextBox1.ScrollToCaret();
            }

            //判断有没有过一天
            if (timeRels != DateTime.Now.Day)
            {
                RelsUser();
            }
        }
Beispiel #6
0
        private void CaptureZpl(object port)
        {
            server = null;
            try
            {
                //string hostName = Dns.GetHostName();
                //IPAddress serverIP = Dns.Resolve(hostName).AddressList[0];

                server = new TcpListener(IPAddress.Any, (int)port);

                // Start listening for client requests.
                server.Start();

                // Buffer for reading data
                var    bytes = new byte[1024];
                string data;

                // Enter the listening loop.
                while (CaptureThread.ThreadState == ThreadState.Running)
                {
                    Console.WriteLine("Waiting for a connection... ");

                    // Perform a blocking call to accept requests.
                    // You could also user server.AcceptSocket() here.
                    TcpClient client = server.AcceptTcpClient();
                    Console.WriteLine("Connected!");

                    data = null;

                    // Get a stream object for reading and writing
                    NetworkStream stream = client.GetStream();

                    int i;

                    // Loop to receive all the data sent by the client.
                    i = stream.Read(bytes, 0, bytes.Length);
                    while (i != 0)
                    {
                        // Translate data bytes to a ASCII string.
                        string newData = System.Text.Encoding.ASCII.GetString(bytes, 0, i);
                        Console.Write(newData);
                        data += newData;



                        //(string.Format("<= RX ({0}) [ {1}]", inData.Length, ByteArrayToHexString(inData)) + Environment.NewLine); });

                        i = stream.Read(bytes, 0, bytes.Length);

                        if (!boolCapturing)
                        {
                            client.Close();
                            server.Stop();
                        }
                    }

                    ThreadSafeDelegate(delegate {
                        TextBox1.Text += data;
                        TextBox1.ScrollToCaret();
                    });


                    // Shutdown and end connection
                    client.Close();
                }

                server.Stop();
            } catch (SocketException e) {
                Console.WriteLine("SocketException: {0}", e.Message);
            } finally {
                Console.WriteLine("finally...");
            }
        }
Beispiel #7
0
        //監聽 Server 訊息 (Listening to the Server)
        private void Listen()
        {
            EndPoint ServerEP = (EndPoint)T.RemoteEndPoint; //Server 的 EndPoint

            byte[] B     = new byte[1023];                  //接收用的 Byte 陣列
            int    inLen = 0;                               //接收的位元組數目
            string Msg;                                     //接收到的完整訊息
            string St;                                      //命令碼
            string Str;                                     //訊息內容(不含命令碼)

            while (true)
            {
                try
                {
                    inLen = T.ReceiveFrom(B, ref ServerEP); //收聽資訊並取得位元組數
                }
                catch (Exception)                           //產生錯誤時
                {
                    //T.Close();//關閉通訊器
                    ListBox1.Items.Clear();                    //清除線上名單
                    MessageBox.Show("伺服器斷線了!");                //顯示斷線
                    Button1.Enabled = true;                    //連線按鍵恢復可用
                    Th.Abort();                                //刪除執行緒
                }
                Msg = Encoding.Default.GetString(B, 0, inLen); //解讀完整訊息
                St  = Msg.Substring(0, 1);                     //取出命令碼 (第一個字)
                Str = Msg.Substring(1);                        //取出命令碼之後的訊息
                switch (St)                                    //依命令碼執行功能
                {
                case "L":                                      //接收線上名單
                    ListBox1.Items.Clear();                    //清除名單
                    string[] M = Str.Split(',');               //拆解名單成陣列
                    for (int i = 0; i < M.Length; i++)
                    {
                        ListBox1.Items.Add(M[i]);     //逐一加入名單
                    }
                    break;

                case "1":                                            //接收廣播訊息
                    TextBox4.Text          += "(公開)" + Str + "\r\n"; //顯示訊息並換行
                    TextBox1.SelectionStart = TextBox1.Text.Length;  //游標移到最後
                    TextBox1.ScrollToCaret();                        //捲動到游標位置
                    break;

                case "2":                                            //接收私密訊息
                    TextBox4.Text          += "(私密)" + Str + "\r\n"; //顯示訊息並換行
                    TextBox1.SelectionStart = TextBox1.Text.Length;  //游標移到最後
                    TextBox1.ScrollToCaret();                        //捲動到游標位置
                    break;

                case "3":    //收到對戰邀請
                    string[]     C  = Str.Split('|');
                    DialogResult dr = MessageBox.Show("Accept a challenge from " + C[0] + " ?", "提示", MessageBoxButtons.OKCancel);
                    if (dr == DialogResult.OK)
                    {
                        //選擇確認
                        Send("4" + C[1] + "|" + C[0]);
                        //string opponentName = C[0];
                    }
                    else if (dr == DialogResult.Cancel)
                    {
                        //選擇拒絕
                        Send("2" + C[1] + " refuse to accept your challenge!" + "|" + C[0]);
                    }
                    break;

                case "4":    //對手同意對戰
                    string[] c            = Str.Split('|');
                    string   OpponentName = c[0];
                    Form1    f1;
                    if (OpponentName.Equals(User))
                    {
                        OpponentName = c[1];
                        f1           = new Form1(User, OpponentName, T, Th, 1);
                    }
                    else
                    {
                        f1 = new Form1(User, OpponentName, T, Th, 0);
                    }
                    //f1.getForm=this;
                    if (first)
                    {
                        this.Hide();
                    }
                    else
                    {
                        this.Close();
                    }
                    f1.ShowDialog();

                    break;

                case "M":
                    TextBox4.Text          += "Server: " + Str + "\r\n";
                    TextBox1.SelectionStart = TextBox1.Text.Length; //游標移到最後
                    TextBox1.ScrollToCaret();                       //捲動到游標位置
                    break;
                }
            }
        }