void remote_Error(object sender, NAORemote.NAORemote.ErrorArgs e) { string message = e.Message + System.Environment.NewLine; Console.WriteLine("Command execution exception: "+message); if (e.Message.Contains("Kill") || e.Message.Contains("kill")) return; //MessageBox.Show(message, "Command execution exception", MessageBoxButton.OK, MessageBoxImage.Error); Dispatcher.BeginInvoke((Action)(() => { txtLogs.Text = txtLogs.Text+ System.Environment.NewLine + "REMOTE COMMAND ERROR: "+message; })); }
private async Task<SshCommand> ExecuteCommandAsync(string command) { if (selectedNao == null) { System.Windows.MessageBox.Show("No address selected for NAO", "No address", MessageBoxButton.OK, MessageBoxImage.Exclamation); } else { NAORemote.NAORemote remote = new NAORemote.NAORemote(selectedNao.IP, txtUsername.Text, txtPassword.Text, "/home/nao"); remote.Error += remote_Error; bool connected = await remote.ConnectAsync(); if (connected) { var remoteCommand = await remote.ExecuteCommandAsync(command); remote.Disconnect(); return remoteCommand; } } return null; }