private void AppendLog([NotNull] string logText, bool async) { var txt = this.TextBox; if (txt == null) { return; } //var richTextBox = txt as RichTextBox; //if (richTextBox != null) //{ // txt.Dispatcher.Invoke(new Action(() => richTextBox.Document.Blocks.Add(new Paragraph(new Run(logText) { Foreground = Brushes.Red })))); // return; //} this.RemoveExtraLines(async); Delegate dlg = new AppendTextDelegate(txt.AppendText); if (!async) { txt.Dispatcher.Invoke(dlg, logText); txt.Dispatcher.Invoke(new Action(txt.ScrollToEnd)); } else { txt.Dispatcher.BeginInvoke(dlg, DispatcherPriority.ContextIdle, logText); txt.Dispatcher.BeginInvoke(new Action(txt.ScrollToEnd), DispatcherPriority.ApplicationIdle); } }
/// <summary> /// Constructor for the form /// </summary> public BuildTools(Guid guid, Job job) { InitializeComponent(); _job = job; _googleAnalytics = new GoogleAnalytics(guid); _runner = new Runner(this, _job, _googleAnalytics); undoBT.Visible = false; progress.Visible = false; versionBox.SelectedIndex = 0; GetVersions(); // delegates _appendDelegate = AppendText; _appendRawDelegate = AppendRawText; _disableDelegate = Disable; _enableDelegate = Enable; _showProgressDelegate = ProgressShow; _hideProgressDelegate = ProgressHide; _indeterminateProgressDelegate = ProgressIndeterminate; _progressPercentDelegate = Progress; _updateVersionsDelegate = UpdateVersions; if (File.Exists(Program.CheckUpdate)) { string text = File.ReadAllText(Program.CheckUpdate); if (string.IsNullOrEmpty(text) || text.Trim().ToLower() == "false") { autoUpdateCB.Checked = false; } } Console.WriteLine(guid.ToString()); new Thread(delegate () { _googleAnalytics.SendEvent("Application", "Start"); }).Start(); }
private void Server_Load(object sender, EventArgs e) { serverSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP); textAppender = new AppendTextDelegate(AppendText); connectClientList = new List <Socket>(); //gets local ip address IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); foreach (IPAddress addr in hostEntry.AddressList) { if (addr.AddressFamily == AddressFamily.InterNetwork) { thisAddress = addr; break; } } //assigns local ip to the text box if (thisAddress == null) { thisAddress = IPAddress.Loopback; } tbIP.Text = thisAddress.ToString(); dgvUsernames.ReadOnly = true; }
/// <summary> /// Constructor for the form /// </summary> public BuildTools(Guid guid, Job job) { InitializeComponent(); _job = job; _runner = new Runner(this, _job); undoBT.Visible = false; progress.Visible = false; versionBox.SelectedIndex = 0; GetVersions(); // delegates _appendDelegate = AppendText; _appendRawDelegate = AppendRawText; _disableDelegate = Disable; _enableDelegate = Enable; _showProgressDelegate = ProgressShow; _hideProgressDelegate = ProgressHide; _indeterminateProgressDelegate = ProgressIndeterminate; _progressPercentDelegate = Progress; _updateVersionsDelegate = UpdateVersions; if (File.Exists(Program.CheckUpdate)) { string text = File.ReadAllText(Program.CheckUpdate); if (string.IsNullOrEmpty(text) || text.Trim().ToLower() == "false") { autoUpdateCB.Checked = false; } } Console.WriteLine(guid.ToString()); }
public chatroomForm() { InitializeComponent(); //연결 소켓 생성 mainSock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP); _textAppender = new AppendTextDelegate(AppendText); }
string key = "01234567891234560123456789123456";//암호화 키 값 public ServerForm() { InitializeComponent(); mainSock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP); _textAppender = new AppendTextDelegate(AppendText); connectedClients = new List <Socket>(); }
public ClientForm() { InitializeComponent(); mainSock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); textAppender = new AppendTextDelegate(AppendText); }
public TextBoxTraceListener(RichTextBox textBox) { _textBox = textBox; _notifyIcon = new NotificationManager(); _appendText = new AppendTextDelegate(AppendText); }
public Server() { InitializeComponent(); mainSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP); text = new AppendTextDelegate(AppendText); SetupVar(); }
// prime thread method private void calculatePrimes() { PerformStepDelegate performStep = new PerformStepDelegate(progressBar.PerformStep); //MethodInvoker performStep = delegate { progressBar.PerformStep(); }; AppendTextDelegate appendText = new AppendTextDelegate(txtBoxResults.AppendText); SetTxtBoxProgressText setTxtBoxProgressText = delegate(string s) { txtBoxProgress.Text = s; }; uint count = 0; uint stepValue = numberOfPrimes / 100; if (stepValue == 0) { stepValue = 1; } this.Invoke(appendText, new object[] { 2 + "\r\n" }); if (++count == numberOfPrimes) { goto end; } for (ulong n = 3; ; n += 2) { if (isPrime(n)) { this.Invoke(appendText, new object[] { n + "\r\n" }); if (++count == numberOfPrimes) { break; } if (count % stepValue == 0) { this.Invoke(performStep); //this.Invoke(setTxtBoxProgressText, new object[] { progressBar.Value + "%" }); this.Invoke((MethodInvoker) delegate { txtBoxProgress.Text = progressBar.Value + "%"; }); } } } end: this.Invoke((MethodInvoker) delegate { progressBar.Value = 100; }); this.Invoke((MethodInvoker) delegate { txtBoxProgress.Text = "100%"; }); this.Invoke((MethodInvoker) delegate { btnGo.Enabled = true; }); this.Invoke((MethodInvoker) delegate { btnStop.Enabled = false; }); this.Invoke((MethodInvoker) delegate { btnCancel.Enabled = false; }); this.Invoke((MethodInvoker) delegate { txtBoxInput.ReadOnly = false; }); stopWatch.Stop(); if (checkBoxSave.Checked) { File.WriteAllText(txtBoxSave.Text, txtBoxResults.Text, Encoding.Unicode); } CustomTimeSpan t = new CustomTimeSpan(stopWatch.ElapsedMilliseconds); this.Invoke(appendText, new object[] { "\r\nCompleted in " + t }); //this.Invoke(appendText, new object[] { "\r\nCompleted in " + (stopWatch.ElapsedMilliseconds / 1000.0) + " seconds." }); }
public Form1() { InitializeComponent(); easyIF = new ActEasyIF(); easyIF.ActLogicalStationNumber = 0; _textAppender = new AppendTextDelegate(AppendText); PLCOpen(); }
public ChatForm() { InitializeComponent(); mainSock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP); _textAppender = new AppendTextDelegate(AppendText); connectedClients = new Dictionary <string, Socket>(); clientNum = 0; //초기화 }
// 폼 관련 함수 public Form1() { InitializeComponent(); // 서버, 클라이언트 소켓과 대리자 할당 server_socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP); client_socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP); text_appender = new AppendTextDelegate(AppendText); }
public Form1() { InitializeComponent(); SetIp(); mainSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP); _textAppender = new AppendTextDelegate(AppendText); }
public ClientForm1() { InitializeComponent(); mainSock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP); _textAppender = new AppendTextDelegate(AppendText); _formGetter = new GetFormDelegate(GetChatForm); this.txtPort.Text = "8080"; }
public ChatForm() { InitializeComponent(); _mainSock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP); _textAppender = new AppendTextDelegate(AppendText); _byteList.Clear(); _packetQueue.Clear(); }
// MARK - 클라이언트 Initiate public client() { InitializeComponent(); clientSock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); _textAppender = new AppendTextDelegate(AppendText); sendMsgButton.Enabled = false; }
public MainForm() { InitializeComponent(); m_nPortNo = 0; m_bConnected = false; mainSock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); textAppender = new AppendTextDelegate(AppendText); }
int port = 15952; //고정 public ChatForm_Client() { InitializeComponent(); mainSock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP); _textAppender = new AppendTextDelegate(AppendText); udpSock = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); _textAppender = new AppendTextDelegate(AppendText); _notiAppender = new AppendTextDelegate(AppendText); }
public Form1() { InitializeComponent(); _textAppender = new AppendTextDelegate(AppendText); //LoadIFSP1(null, null); //LoadIFSP2(null, null); //LoadIFSP3(null, null); //LoadIFSP4(null, null); }
// Output line to the textarea public void WriteLine(string text) { if (richTextBox1.InvokeRequired) { // Handle cross-thread call AppendTextDelegate d = new AppendTextDelegate(WriteLine); this.Invoke(d, new object[] { text }); } else richTextBox1.Text += text + '\n'; }
public void AppendText(string text) { if (control.IsDisposed) return; if (control.InvokeRequired) { AppendTextDelegate del = new AppendTextDelegate(AppendText); control.Invoke(del, new object[] { text }); } else control.AppendText(text); }
private AppendTextDelegate WrapInvoke(AppendTextDelegate appendText) { return(text => { if (_asyncResult != null) { EndInvoke(_asyncResult); } _asyncResult = BeginInvoke(appendText, text); }); }
public ChatForm_S() { InitializeComponent(); pen.StartCap = System.Drawing.Drawing2D.LineCap.Round; //팬 시작 끝 둥글게 pen.EndCap = System.Drawing.Drawing2D.LineCap.Round; // 팬 끝 둥글게 mainSock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP); _textAppender = new AppendTextDelegate(AppendText); connectedClients = new Dictionary <string, Socket>(); clientNum = 0; //초기화 }
private void AppendText(RichTextBox richtextbox, string text) { if (richtextbox.InvokeRequired) { AppendTextDelegate d = AppendText; richtextbox.Invoke(d, new object[] { richtextbox, text }); } else { richtextbox.AppendText(text + "\n"); } }
public ChatForm_Server() { InitializeComponent(); mainSock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP); udpSock = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); _textAppender = new AppendTextDelegate(AppendText); connectedClients = new List <Socket>(); BeginStartServer(null, null); Thread th = new Thread(asyncConnectClient); th.IsBackground = true; th.Start(); }
//为控件的InvokeRequire的值为true时,说明一个不属于创建它的线程要访问它,此时需要采用异步的方式进行操作 private void MsgShow(string str) { if (txtReceive.InvokeRequired) { AppendTextDelegate appendText = new AppendTextDelegate(MsgShow); txtReceive.Invoke(appendText, new object[] { str }); } else { txtReceive.Text = ""; txtReceive.Text = str; } }
/// <summary> /// Appends text to the monitor /// </summary> /// <param name="tbox">Text Box</param> /// <param name="text">Text</param> public void AppendText(TextBox tbox, String text) { if (this.InvokeRequired) { AppendTextDelegate d = new AppendTextDelegate(this.AppendText); this.Invoke(d, new object[] { tbox, text }); } else { tbox.Text += text; tbox.SelectionStart = tbox.Text.Length - 1; tbox.ScrollToCaret(); } }
public Form1() { InitializeComponent(); atDelegate = new AppendTextDelegate(appendText); raspvDelegate = new ResetAndSetProgressValueDelegate(resetAndSetProgressValue); ppsDelegate = new PerformProgessStepDelegate(performProgressStep); smDelegate = new SetMessageDelegate(SetMessage); worker = new BackgroundWorker(); worker.DoWork += Worker_DoWork; worker.RunWorkerCompleted += Worker_RunWorkerCompleted; lib = new List <FileCompareInfo>(); }
public Server() { InitializeComponent(); eunSock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); arduSerialPort.PortName = "COM3"; //아두이노가 연결된 시리얼 포트 번호 지정 arduSerialPort.BaudRate = 9600; //시리얼 통신 속도 지정 // 포트 오픈 _textAppender = new AppendTextDelegate(AppendText); // Client의 ID와 Socket를 담는 Dictionary초기화 connectedClients = new Dictionary <string, Socket>(); //클라이언트 수 초기화 clientNum = 0; }
public void AppendText(string text) { if (control.IsDisposed) { return; } if (control.InvokeRequired) { AppendTextDelegate del = new AppendTextDelegate(AppendText); control.Invoke(del, new object[] { text }); } else { control.AppendText(text); } }
public void AppendText(string text) { if (!IsDisposed) { if (InvokeRequired) { AppendTextDelegate d = new AppendTextDelegate(AppendText); Invoke(d, new object[] { text }); } else { textBoxInputStream.AppendText(text); WindowHandleUtils.HideCaret(textBoxInputStream.Handle); } } }
public Form1() { InitializeComponent(); mainSock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); _textAppender = new AppendTextDelegate(AppendText); this.Text = "오목게임_정대윤- 클라이언트"; this.BackColor = Color.Orange; pen = new Pen(Color.Black); bBrush = new SolidBrush(Color.Black); wBrush = new SolidBrush(Color.White); this.ClientSize = new Size(2 * margin + 18 * 눈Size, 2 * margin + 18 * 눈Size + menuStrip1.Height); }
private void ReadOutputThread() { int num_read; char [] buffer = new char[4096]; TextReader stream = thread_output_stream; num_read = stream.Read(buffer, 0, 4096); while (num_read > 0) { string str; char [] text = new char[num_read]; Array.Copy(buffer, 0, text, 0, num_read); str = new string(text); object[] pList = { str }; // put the string in the edit box in a thread safe way AppendTextDelegate ap = new AppendTextDelegate(AppendText); output_richTextBox.Invoke(ap, pList); num_read = stream.Read(buffer, 0, 1024); } }
public TailThread(string filePath, AppendTextDelegate callback) { this.filePath = filePath; this.callback = callback; }
// prime thread method private void calculatePrimes() { PerformStepDelegate performStep = new PerformStepDelegate(progressBar.PerformStep); //MethodInvoker performStep = delegate { progressBar.PerformStep(); }; AppendTextDelegate appendText = new AppendTextDelegate(txtBoxResults.AppendText); SetTxtBoxProgressText setTxtBoxProgressText = delegate(string s) { txtBoxProgress.Text = s; }; uint count = 0; uint stepValue = numberOfPrimes / 100; if (stepValue == 0) stepValue = 1; this.Invoke(appendText, new object[] { 2 + "\r\n" }); if (++count == numberOfPrimes) goto end; for (ulong n = 3; ; n += 2) { if (isPrime(n)) { this.Invoke(appendText, new object[] { n + "\r\n" }); if (++count == numberOfPrimes) break; if (count % stepValue == 0) { this.Invoke(performStep); //this.Invoke(setTxtBoxProgressText, new object[] { progressBar.Value + "%" }); this.Invoke((MethodInvoker)delegate { txtBoxProgress.Text = progressBar.Value + "%"; }); } } } end: this.Invoke((MethodInvoker)delegate { progressBar.Value = 100; }); this.Invoke((MethodInvoker)delegate { txtBoxProgress.Text = "100%"; }); this.Invoke((MethodInvoker)delegate { btnGo.Enabled = true; }); this.Invoke((MethodInvoker)delegate { btnStop.Enabled = false; }); this.Invoke((MethodInvoker)delegate { btnCancel.Enabled = false; }); this.Invoke((MethodInvoker)delegate { txtBoxInput.ReadOnly = false; }); stopWatch.Stop(); if (checkBoxSave.Checked) File.WriteAllText(txtBoxSave.Text, txtBoxResults.Text, Encoding.Unicode); CustomTimeSpan t = new CustomTimeSpan(stopWatch.ElapsedMilliseconds); this.Invoke(appendText, new object[] { "\r\nCompleted in " + t }); //this.Invoke(appendText, new object[] { "\r\nCompleted in " + (stopWatch.ElapsedMilliseconds / 1000.0) + " seconds." }); }
public AsynchronousFileMonitor(string filePath, AppendTextDelegate appendTextDelegate) { appendText = appendTextDelegate; FindPathAndFile(filePath); }
public void AppendText(string text, Color color, Font font) { if (InvokeRequired) { AppendTextDelegate d = new AppendTextDelegate(AppendText); BeginInvoke(d, text, color, font); } else { SelectionStart = TextLength; SelectionLength = 0; SelectionColor = color; SelectionFont = font; AppendText(text); SelectionFont = Font; SelectionColor = ForeColor; } }