private void sendMessage()
        {
            try
            {
                // Sending message
                //<Client Quit> is the sign for end of data
                String theMessage;

                if (MessageTextbox.TextLength > 0)
                {
                    theMessage = MessageTextbox.Text;
                }
                else
                {
                    showWarningMessage("发送内容不能为空,请重新输入");
                    return;
                }

                byte[] msg = Encoding.Unicode.GetBytes(theMessage + "<Client Quit>");

                // Sends data to a connected Socket.
                String time = DateTime.Now.ToString();
                socketClient.SendTo(msg, this.ipEndPoint);
                historyTextBox.AppendText("clinet " + time + "\r\n  " + theMessage + "\r\n");
                MessageTextbox.Clear();
            }
            catch (Exception ex)
            {
            }
        }
Beispiel #2
0
        /// <summary>
        /// send message to all connected clients
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void sendButton_Click(object sender, EventArgs e)
        {
            String message;

            if (MessageTextbox.TextLength > 0)
            {
                message = MessageTextbox.Text;
            }
            else
            {
                this.showWarningMessage("发送内容不能为空,请重新输入");
                return;
            }

            byte[] msg = Encoding.Unicode.GetBytes(message + "<Server Quit>");

            // Sends data asynchronously to all connected Socket
            int i = 0;

            foreach (Socket socket in didCommunication.Values)
            {
                socket.BeginSend(msg, 0, msg.Length, 0,
                                 new AsyncCallback(SendCallback), socket);
                i++;
            }

            String time = DateTime.Now.ToString();

            //didCommunication[remoteEndPoint.ToString()].Send(msg);
            historyTextBox.AppendText("server " + time + "\r\n  " + message + "\r\n");
            historyTextBox.Focus();
            MessageTextbox.Clear();
        }
Beispiel #3
0
        private void GenerateCookbook(object sender, RoutedEventArgs e)
        {
            MessageTextbox.Clear();
            MessageTextbox.AppendText($"Generating cookbook version {ScottPlot.Tools.GetVersionString()}" + Environment.NewLine);

            BackgroundWorker worker = new BackgroundWorker();

            worker.WorkerReportsProgress = true;
            worker.DoWork             += CookbookWorker_DoWork;
            worker.ProgressChanged    += CookbookWorker_ProgressChanged;
            worker.RunWorkerCompleted += CookbookWorker_RunWorkerCompleted;;
            worker.RunWorkerAsync();
        }