public AsyncServer(string ip, int port, AddLogDelegate addLog, Command[] cmds) { Ip = ip; Port = port; Commands = cmds; this.addLog = addLog; }
/// <summary> /// Add a log into textbox /// </summary> /// <param name="msg"></param> /// <param name="bInnerLog"></param> /// <param name="bAllowTracing"></param> public void AddLog(string msg, bool bInnerLog = false, bool bAllowTracing = true) { if (tbLogs.InvokeRequired) { //MessageBox.Show("Current Message Requires Invoke." + Environment.NewLine + msg, "Invoke Required"); //return; delegateAddLog = new AddLogDelegate(AddLog); tbLogs.Invoke(delegateAddLog, new object[] { msg, bInnerLog, bAllowTracing }); return; } string appendMsg = bInnerLog ? //(msg + Environment.NewLine) : "" : (Prefix.Trim() + "[" + DateTime.Now.ToString("HH:mm:ss") + "] " + msg + Environment.NewLine); tbLogs.AppendText(appendMsg); if (bAllowTracing) { tbLogs.SelectionStart = tbLogs.TextLength; tbLogs.ScrollToCaret(); } }
private void QuestionServer() { try { AddTextDelegate AddText = new AddTextDelegate(PrintToChatBox); AddLogDelegate AddLog = new AddLogDelegate(PrintLog); delAddNewClient addNewClient = new delAddNewClient(AddNewClient); IPAddress ip = new IPAddress(0); int port = defaultPort; stQuestion.Server = new TcpListener(ip, port); stQuestion.Server.Start(); Invoke(AddText, "서버가 켜졌어용!"); Invoke(AddLog, "server on"); while (true) { stQuestion.Client = stQuestion.Server.AcceptTcpClient(); Invoke(AddLog, "new client"); Invoke(addNewClient, lastID++, stQuestion.Client.GetStream()); } } catch (Exception e) { } }
public AIDebugWindow(string playerName, int playerIdx) { InitializeComponent(); this.Text = "Debug Window - " + playerName; this.myPlayerIdx = playerIdx; this.myPlayerName = playerName; this.addLogDel = new AddLogDelegate(this.AddLog); }
private void AddLog(string text) { if (richTextBox1.InvokeRequired) { var addLogDelegate = new AddLogDelegate(AddLog); Invoke(addLogDelegate, new object[] { text }); } else { richTextBox1.Text += text + Environment.NewLine; richTextBox1.Select(richTextBox1.Text.Length, 0); richTextBox1.ScrollToCaret(); } }
private void AddLog(string text) { if (_log.InvokeRequired) { var addLogDelegate = new AddLogDelegate(AddLog); Invoke(addLogDelegate, new object[] { text }); } else { _log.Text += text + Environment.NewLine; _log.Select(_log.Text.Length, 0); _log.ScrollToCaret(); } }
public void DeleteLoggerFunction(AddLogDelegate logFunction) { Delegate newDelegate = System.Delegate.Remove(addLog, logFunction); addLog = newDelegate as AddLogDelegate; }
public void AddLoggerFunction(AddLogDelegate logFunction) { addLog += logFunction; }
private void QuestionServer() { try { AddTextDelegate AddText = new AddTextDelegate(PrintToChatBox); AddLogDelegate AddLog = new AddLogDelegate(PrintLog); delAddNewClient addNewClient = new delAddNewClient(AddNewClient); IPAddress ip = new IPAddress(0); int port = defaultPort; stQuestion.Server = new TcpListener(ip, port); stQuestion.Server.Start(); Invoke(AddText, "서버가 켜졌어용!"); Invoke(AddLog, "server on"); while (true) { stQuestion.Client = stQuestion.Server.AcceptTcpClient(); Invoke(AddLog, "new client"); Invoke(addNewClient, lastID++, stQuestion.Client.GetStream()); } } catch (Exception e) { } }