Skip to content
This repository has been archived by the owner on Mar 27, 2022. It is now read-only.

Commit

Permalink
Finished open file
Browse files Browse the repository at this point in the history
  • Loading branch information
tommyhosewol committed Oct 28, 2021
1 parent 396ca7f commit 38b1c4b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
10 changes: 5 additions & 5 deletions src/Avans.FlatGalaxy.Presentation/Commands/ShortcutList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@ public ShortcutList()
Description = "Remove asteroid from simulation",
Key = Key.I,
});
Add(new Shortcut

Add(new()
{
Command = new RemoveAsteroidCommand(),
Description = "Remove asteroid from simulation",
Key = Key.I,
Command = new OpenFileCommand(),
Description = "Stop simulation and start with new file",
Key = Key.Q,
});
}

Expand Down
4 changes: 2 additions & 2 deletions src/Avans.FlatGalaxy.Presentation/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ private void SubmitFile(object sender, RoutedEventArgs e)
var fileContents = _fileLoader.GetContent(fileUri);
var galaxy = _configurationParser.Parse(fileContents);

_simulationWindow.Show(galaxy);
Close();
_simulationWindow.Show(galaxy, this);
Hide();
}
else
{
Expand Down
9 changes: 5 additions & 4 deletions src/Avans.FlatGalaxy.Presentation/SimulationWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@ namespace Avans.FlatGalaxy.Presentation
{
public partial class SimulationWindow : Window, IObserver<ISimulator>
{
private readonly MainWindow _mainWindow;
private MainWindow _mainWindow;
private ISimulator? _simulator;
private readonly ShortcutList _shortcutList;

public SimulationWindow(MainWindow mainWindow, ShortcutList shortcutList)
public SimulationWindow(ShortcutList shortcutList)
{
_mainWindow = mainWindow;
_shortcutList = shortcutList;

InitializeComponent();
Expand Down Expand Up @@ -61,8 +60,10 @@ private void OnRender(object? sender, EventArgs e)
if (_simulator.CollisionVisible && _simulator.QuadTree != null) { Draw(_simulator.QuadTree); }
}

public void Show(Galaxy galaxy)
public void Show(Galaxy galaxy, MainWindow mainWindow)
{
_mainWindow = mainWindow;

Show();

_simulator = new Simulator(galaxy);
Expand Down
2 changes: 2 additions & 0 deletions src/Avans.FlatGalaxy.Simulation/Simulator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public Simulator(Galaxy galaxy)
_collisionHandler = new();
_pathHandler = new();
_caretaker = new SimulatorCaretaker(this);

_observers = new List<IObserver<ISimulator>>();
}

public Galaxy Galaxy { get; set; }
Expand Down

0 comments on commit 38b1c4b

Please sign in to comment.