diff --git a/ADIS_Csharp/RobotClientWpf/Assets/arrow-down-bold.png b/ADIS_Csharp/RobotClientWpf/Assets/arrow-down-bold.png new file mode 100644 index 0000000..e2c20c7 Binary files /dev/null and b/ADIS_Csharp/RobotClientWpf/Assets/arrow-down-bold.png differ diff --git a/ADIS_Csharp/RobotClientWpf/MainWindow.xaml b/ADIS_Csharp/RobotClientWpf/MainWindow.xaml index 16c7d40..3ba0a62 100644 --- a/ADIS_Csharp/RobotClientWpf/MainWindow.xaml +++ b/ADIS_Csharp/RobotClientWpf/MainWindow.xaml @@ -72,7 +72,7 @@ --> - + diff --git a/ADIS_Csharp/RobotClientWpf/RobotClientWpf.csproj b/ADIS_Csharp/RobotClientWpf/RobotClientWpf.csproj index 02c5250..b651ea2 100644 --- a/ADIS_Csharp/RobotClientWpf/RobotClientWpf.csproj +++ b/ADIS_Csharp/RobotClientWpf/RobotClientWpf.csproj @@ -8,6 +8,7 @@ + @@ -21,6 +22,9 @@ + + Always + Always diff --git a/ADIS_Csharp/RobotClientWpf/Views/MainView.xaml b/ADIS_Csharp/RobotClientWpf/Views/MainView.xaml index 8377738..d3c0402 100644 --- a/ADIS_Csharp/RobotClientWpf/Views/MainView.xaml +++ b/ADIS_Csharp/RobotClientWpf/Views/MainView.xaml @@ -5,20 +5,72 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:RobotClientWpf.Views" mc:Ignorable="d" - d:DesignHeight="450" d:DesignWidth="800"> + d:DesignHeight="450" d:DesignWidth="800" KeyDown="UserControl_KeyDown"> - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ADIS_Csharp/RobotClientWpf/Views/MainView.xaml.cs b/ADIS_Csharp/RobotClientWpf/Views/MainView.xaml.cs index e7d91f6..44f7ffd 100644 --- a/ADIS_Csharp/RobotClientWpf/Views/MainView.xaml.cs +++ b/ADIS_Csharp/RobotClientWpf/Views/MainView.xaml.cs @@ -1,5 +1,7 @@ using RobotClientWpf.Utilities; +using System.DirectoryServices.ActiveDirectory; using System.Windows.Controls; +using System.Windows.Input; namespace RobotClientWpf.Views { @@ -10,6 +12,8 @@ namespace RobotClientWpf.Views { private static readonly NLog.Logger log = NLog.LogManager.GetCurrentClassLogger(); private ChallengeFactory? challenge; + private const int AMOUNT_SPEED_ADDED_PER_CLICK = 10; + private const int TURN_ANGLE_PER_CLICK = 25; public MainView() { @@ -27,5 +31,63 @@ namespace RobotClientWpf.Views { UIAccessHelpers.SetTextboxText(this.tbSplitflapText, e.DisplayMessage); } + + private void btnModeAuto_Click(object sender, System.Windows.RoutedEventArgs e) + { + this.challenge?.RobotMobile.Movement.SetMobilityMode(true); + } + + private void btnModeManual_Click(object sender, System.Windows.RoutedEventArgs e) + { + this.challenge?.RobotMobile.Movement.SetMobilityMode(false); + } + + private void btnRoboFwd_Click(object sender, System.Windows.RoutedEventArgs e) + { + this.challenge?.RobotMobile.Movement.AddSpeed(AMOUNT_SPEED_ADDED_PER_CLICK); + } + private void btnRoboBwd_Click(object sender, System.Windows.RoutedEventArgs e) + { + this.challenge?.RobotMobile.Movement.AddSpeed(-AMOUNT_SPEED_ADDED_PER_CLICK); + } + + private void btnRoboRight_Click(object sender, System.Windows.RoutedEventArgs e) + { + this.challenge?.RobotMobile.Movement.Turn(TURN_ANGLE_PER_CLICK); + } + + private void btnRoboLeft_Click(object sender, System.Windows.RoutedEventArgs e) + { + this.challenge?.RobotMobile.Movement.Turn(-TURN_ANGLE_PER_CLICK); + } + + private void UserControl_KeyDown(object sender, System.Windows.Input.KeyEventArgs e) + { + if (e.Key == Key.Up) + { + this.challenge?.RobotMobile.Movement.AddSpeed(AMOUNT_SPEED_ADDED_PER_CLICK); + e.Handled = true; + } + else if (e.Key == Key.Down) + { + this.challenge?.RobotMobile.Movement.AddSpeed(-AMOUNT_SPEED_ADDED_PER_CLICK); + e.Handled = true; + } + else if (e.Key == Key.Left) + { + this.challenge?.RobotMobile.Movement.Turn(-TURN_ANGLE_PER_CLICK); + e.Handled = true; + } + else if (e.Key == Key.Right) + { + this.challenge?.RobotMobile.Movement.Turn(TURN_ANGLE_PER_CLICK); + e.Handled = true; + } + else if(e.Key == Key.End) + { + this.challenge?.RobotMobile.Movement.Stop(); + e.Handled = true; + } + } } } diff --git a/ADIS_Csharp/RobotConsoleClient/Program.cs b/ADIS_Csharp/RobotConsoleClient/Program.cs index d2d83d8..3720897 100644 --- a/ADIS_Csharp/RobotConsoleClient/Program.cs +++ b/ADIS_Csharp/RobotConsoleClient/Program.cs @@ -19,9 +19,9 @@ namespace RobotConsoleClient robotStationary.SplitFlap.InitializeAllSplitflaps(); Thread.Sleep(1000); - robotMobile.Movement.SetSpeed(1000); + robotMobile.Movement.AddSpeed(1000); robotMobile.Movement.Turn(-10); - robotMobile.Movement.SetSpeed(-500); + robotMobile.Movement.AddSpeed(-500); robotMobile.Movement.Stop(); robotMobile.Movement.SetMobilityMode(automatic: true); diff --git a/ADIS_Csharp/RobotLib/Movement/DevMovement.cs b/ADIS_Csharp/RobotLib/Movement/DevMovement.cs index f58638a..8648400 100644 --- a/ADIS_Csharp/RobotLib/Movement/DevMovement.cs +++ b/ADIS_Csharp/RobotLib/Movement/DevMovement.cs @@ -24,7 +24,7 @@ namespace RobotLib.Movement base.SendMessage(TOPIC_MOBILE_NAV_TURN, angle.ToString()); } - public void SetSpeed(int speed) + public void AddSpeed(int speed) { base.SendMessage(TOPIC_MOBILE_NAV_MOVE, speed.ToString()); }