private void StartButton_Click(object sender, EventArgs e) { var loggingDelegate = new LoggingDelegate(AppendText); var userConnectedDelegate = new UserConnectedDelegate(AppendUser); var userDisconnectedDelegate = new UserDisconnectedDelegate(RemoveUser); int.TryParse(portTextBox.Text, out var port); IPAddress.TryParse(ipAddressTextBox.Text, out var ip); if (port == default || ip == null) { var incorrectFields = $"{(port == default ? "port, " : string.Empty)}{(ip == null ? "ip address" : string.Empty)}"; MessageBox.Show($"Some fields are incorrect: {incorrectFields}"); } else { _backgroundWorker.Start(ip, port, loggingDelegate, userConnectedDelegate, userDisconnectedDelegate); var startMessage = $"Server started at {ip}:{port} ..."; _logger.Log(startMessage); AppendText(startMessage); portTextBox.Enabled = false; ipAddressTextBox.Enabled = false; comboBoxInterface.Enabled = false; startButton.Enabled = false; } }
private static void InvokeOnLog(LogMessage message) { LoggingDelegate handler = OnLog; if (handler != null) { handler(message); } }
public ValueFinder(char cordsToFind, double delta, NumberPrinter printer, double minValue, LoggingDelegate loggingDelegate = null) { Cords = cordsToFind; Delta = delta; Printer = printer; MinValue = minValue; Logger += loggingDelegate; if (Cords == 'Z') { IsUncheckedCoordinate = true; } }
private void AppendText(string message) { if (logTextBox.InvokeRequired) { var d = new LoggingDelegate(AppendText); logTextBox.Invoke(d, new object[] { message }); } else { logTextBox.AppendText($"{message}{Environment.NewLine}"); } }
public void Start( IPAddress address, int port, LoggingDelegate loggingDelegate, UserConnectedDelegate userConnectedDelegate, UserDisconnectedDelegate userDisconnectedDelegate) { _address = address; _port = port; _loggingDelegate = loggingDelegate; _userConnectedDelegate = userConnectedDelegate; _userDisconnectedDelegate = userDisconnectedDelegate; Task.Run(StartInternal); }
// Use this for initialization void Start() { move_ctrl = GetComponent <MovementController>(); LoggingDelegate logging_delegate = new LoggingDelegate(LoggingCallback); IntPtr fn_ptr = Marshal.GetFunctionPointerForDelegate(logging_delegate); set_logging_function(fn_ptr); int ret = load_robot(Path.Combine(Application.dataPath, "robot.py")); print("Loaded robot, retval = " + ret.ToString()); set_robot_mode("teleop", true); }
public void Report() { // Stop listening because we're going to blast back out to the logging system Ignore(); // Are we going to log as success, warnings, or errors? LoggingDelegate func = Logger.WriteSuccess; if (this.warnings.Count > 0) { func = Logger.WriteWarning; } if (this.errors.Count > 0) { func = Logger.WriteError; } // Write out the summary report string separator = new string('-', 80); Logger.WriteInfo(separator); func("{0} summary", this.name); // Add successes Logger.WriteInfo("Succeeded: {0}", this.successes.Count); foreach (var success in this.successes) { Logger.WriteSuccess(" {0}", success); } // Add warnings Logger.WriteInfo("Warnings: {0}", this.warnings.Count); foreach (var warn in this.warnings) { Logger.WriteWarning(" {0}", warn); } // Add errors Logger.WriteInfo("Errors: {0}", this.errors.Count); foreach (var error in this.errors) { Logger.WriteError(" {0}", error); } Logger.WriteInfo(separator); }
public ClientConnection( TcpClient tcpClient, Logger logger, LoggingDelegate loggingDelegate, UserConnectedDelegate userConnectedDelegate, UserDisconnectedDelegate userDisconnectedDelegate, ConcurrentDictionary <string, ConcurrentQueue <Message> > notSentMessages, ConcurrentDictionary <string, bool> users) { _client = tcpClient; _logger = logger; _loggingDelegate = loggingDelegate; _userConnectedDelegate = userConnectedDelegate; _userDisconnectedDelegate = userDisconnectedDelegate; _notSentMessages = notSentMessages; _users = users; }
public NumberPrinter GeneratePrinter(LoggingDelegate loggingDelegate = null) { Count = int.Parse(DisplayCount); return(new NumberPrinter(IsUseDot, Count, loggingDelegate)); }
private static extern void SetLoggingHandler(LoggingDelegate func);
/// <summary> /// Log a newline to the logging delegate /// </summary> private void LogLine(string s) { LoggingDelegate?.Invoke(s + Environment.NewLine); }
public void Report() { Ignore(); LoggingDelegate loggingDelegate = Logger.WriteSuccess; if (warnings.Count > 0) { loggingDelegate = Logger.WriteWarning; } if (errors.Count > 0) { loggingDelegate = Logger.WriteError; } string line = new string('-', 80); Logger.WriteInfo(line); loggingDelegate("{0} summary", name); Logger.WriteInfo("Succeeded: {0}", successes.Count); List <string> .Enumerator enumerator = successes.GetEnumerator(); try { while (enumerator.MoveNext()) { string current = enumerator.Current; Logger.WriteSuccess(" {0}", current); } } finally { ((IDisposable)enumerator).Dispose(); } Logger.WriteInfo("Warnings: {0}", warnings.Count); enumerator = warnings.GetEnumerator(); try { while (enumerator.MoveNext()) { string current2 = enumerator.Current; Logger.WriteWarning(" {0}", current2); } } finally { ((IDisposable)enumerator).Dispose(); } Logger.WriteInfo("Errors: {0}", errors.Count); enumerator = errors.GetEnumerator(); try { while (enumerator.MoveNext()) { string current3 = enumerator.Current; Logger.WriteError(" {0}", current3); } } finally { ((IDisposable)enumerator).Dispose(); } Logger.WriteInfo(line); }
public NumberPrinter(bool isNeedDot, int countAfterDot, LoggingDelegate loggingDelegate = null) { IsDotNeed = isNeedDot; DisplayAfterDot = countAfterDot; Logger += loggingDelegate; }
public static void SetLogger(LoggingDelegate loggingDelegate = null) { LoggingDelegate = loggingDelegate; }