Commits

Robin Harper committed 367ad7a

Added a status ticker to the menu bar and cleaned up the 'open' menu button

  • Participants
  • Parent commits 2e06863

Comments (0)

Files changed (2)

PathTester/MainWindow.xaml

 <Window x:Class="PathTester.MainWindow"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
-        Title="MainWindow" SizeToContent="WidthAndHeight">
+        Title="A-Star Path Tester - Robin Harper" SizeToContent="WidthAndHeight">
     <Grid>
         <Grid.ColumnDefinitions>
             <ColumnDefinition Width="Auto"/>
             <RowDefinition Height="*"/>
             <RowDefinition Height="Auto"/>
         </Grid.RowDefinitions>
-        <Menu Name="PathTesterMenu" Grid.Row="0" Height="23" Grid.ColumnSpan="2">
-            <MenuItem Header="_Open" Click="MenuItem_Click" />
+        <Menu Name="PathTesterMenu" Grid.Row="0" Height="Auto" Grid.ColumnSpan="2">
+            <Button Content="Open" Click="MenuItem_Click" VerticalAlignment="Center" Width="75"/>
+            <WrapPanel>
+                <Label Content="Status:" VerticalAlignment="Center" FontWeight="Bold"/>
+                <Label Content="" Name="StatusLabel" VerticalAlignment="Center" FontWeight="Bold"/>
+            </WrapPanel>
         </Menu>
         <StackPanel Grid.Row="2" Margin="5" HorizontalAlignment="Stretch" Grid.Column="2">
             <Grid>
                     <ColumnDefinition Width="Auto"/>
                 </Grid.ColumnDefinitions>
                 <Label Content="Grid Size" Grid.Column="0"/>
-                <TextBox Name="GridSizeTextBox" Text="14" MinWidth="60" Margin="2" Grid.Column="1"/>
+                <TextBox Name="GridSizeTextBox" Text="6" MinWidth="60" Margin="2" Grid.Column="1"/>
                 <ComboBox Height="Auto" HorizontalAlignment="Stretch" Name="HeuristicComboBox" VerticalAlignment="Center" Width="Auto" Grid.Column="2" Margin="2"/>
                 <Button Content="Run" Height="23" Name="RunBtn" Width="75" Click="RunBtn_Click" Margin="2" HorizontalAlignment="Right" Grid.Column="3"/>
                 <Button Content="Draw Grid" Height="23" Name="DrawGridBtn" Width="75" Click="DrawGridBtn_Click" Margin="2" Grid.Column="4" HorizontalAlignment="Right"/>

PathTester/MainWindow.xaml.cs

         {
             if ((startSet && goalSet) || (!start.IsEmpty && !goal.IsEmpty))
             {
+                StatusLabel.Content = "";
                 startSet = false;
                 goalSet = false;
                 GetWorkingPath();
 
             var results = pathfinder.GridSearch(start, goal);
 
-            int i = 0; 
-            foreach (var ig in results)
+            if (results.Count > 1)
             {
-                if(i > 0)
+                int i = 0;
+                foreach (var ig in results)
                 {
-                    var l = new Line();
-                    l.X1 = results[i - 1].PixelX;
-                    l.Y1 = results[i - 1].PixelY;
-                    l.X2 = results[i].PixelX;
-                    l.Y2 = results[i].PixelY;
-                    l.StrokeThickness = 3.0;
-                    l.Stroke = new SolidColorBrush(System.Windows.Media.Color.FromRgb(0, 0, 0));
-                    LayoutCanvas.Children.Add(l);
+                    if (i > 0)
+                    {
+                        var l = new Line();
+                        l.X1 = results[i - 1].PixelX;
+                        l.Y1 = results[i - 1].PixelY;
+                        l.X2 = results[i].PixelX;
+                        l.Y2 = results[i].PixelY;
+                        l.StrokeThickness = 3.0;
+                        l.Stroke = new SolidColorBrush(System.Windows.Media.Color.FromRgb(255, 0, 0));
+                        LayoutCanvas.Children.Add(l);
+                        LayoutCanvas.UpdateLayout();
+                    }
+
+                    i++;
                 }
 
-                i++;
+                StatusLabel.Content = "Path found!";
+            }
+            else
+            {
+                StatusLabel.Content = "No path found!";
             }
         }