2019-03-13 16:45:38 +01:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
2019-03-20 16:51:35 +01:00
|
|
|
|
using System.Threading;
|
2019-03-13 16:45:38 +01:00
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows;
|
|
|
|
|
using System.Windows.Controls;
|
2019-03-14 16:24:37 +01:00
|
|
|
|
using System.Windows.Controls.Primitives;
|
2019-03-13 16:45:38 +01:00
|
|
|
|
using System.Windows.Data;
|
|
|
|
|
using System.Windows.Documents;
|
|
|
|
|
using System.Windows.Input;
|
|
|
|
|
using System.Windows.Media;
|
|
|
|
|
using System.Windows.Media.Imaging;
|
|
|
|
|
using System.Windows.Navigation;
|
|
|
|
|
using System.Windows.Shapes;
|
2019-03-27 00:49:55 +01:00
|
|
|
|
using CzokoŚmieciarka.DataModels.Enums;
|
2019-03-20 16:02:05 +01:00
|
|
|
|
using CzokoŚmieciarka.DataModels.GeneralModels.Models;
|
|
|
|
|
using CzokoŚmieciarka.DataModels.Interfaces;
|
|
|
|
|
using CzokoŚmieciarka.DataModels.Interfaces.TrashCans;
|
2019-03-20 12:34:03 +01:00
|
|
|
|
using CzokoŚmieciarka.DataModels.Models;
|
2019-03-26 22:47:45 +01:00
|
|
|
|
using CzokoŚmieciarka.WPF.Interfaces;
|
2019-03-13 16:45:38 +01:00
|
|
|
|
using CzokoŚmieciarka.WPF.Models;
|
|
|
|
|
|
|
|
|
|
namespace CzokoŚmieciarka.WPF
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Interaction logic for MainWindow.xaml
|
|
|
|
|
/// </summary>
|
|
|
|
|
public partial class MainWindow : Window
|
|
|
|
|
{
|
2019-03-26 23:20:41 +01:00
|
|
|
|
//public Board board;
|
2019-03-27 00:49:55 +01:00
|
|
|
|
private static int rows = 9;
|
|
|
|
|
private static int columns = 9;
|
|
|
|
|
private GarbageCollectorWPF garbageCollector = new GarbageCollectorWPF(columns, new Coords(0, 0), AppDomain.CurrentDomain.BaseDirectory + @"..\..\Images\garbageCollector.png");
|
2019-03-26 22:47:45 +01:00
|
|
|
|
private List<AObject> Objects = new List<AObject>();
|
2019-03-13 16:45:38 +01:00
|
|
|
|
public MainWindow()
|
|
|
|
|
{
|
|
|
|
|
|
2019-03-20 12:34:03 +01:00
|
|
|
|
InitializeComponent();
|
2019-03-26 23:20:41 +01:00
|
|
|
|
|
2019-03-26 22:47:45 +01:00
|
|
|
|
for (int y = 0; y < rows; y++)
|
|
|
|
|
{
|
|
|
|
|
for(int x = 0; x < columns; x++)
|
|
|
|
|
{
|
|
|
|
|
Road road = new Road(columns, new Coords(x, y), AppDomain.CurrentDomain.BaseDirectory + @"..\..\Images\intersection.png");
|
|
|
|
|
Objects.Add(road);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
House house = new House(columns, new Coords(0, 0));
|
|
|
|
|
Objects[house.Location.X + house.Location.Y] = house;
|
|
|
|
|
house = new House(columns, new Coords(1, 0));
|
|
|
|
|
Objects[house.Location.X + house.Location.Y] = house;
|
|
|
|
|
house = new House(columns, new Coords(2, 0));
|
|
|
|
|
Objects[house.Location.X + house.Location.Y] = house;
|
|
|
|
|
DumpWPF dump = new DumpWPF(columns, new Coords(2, 4), new TypeOfGarbage("glass", 0, 0));
|
|
|
|
|
Objects[dump.Location.X + dump.Location.Y] = dump;
|
|
|
|
|
dump = new DumpWPF(columns, new Coords(2, 5), new TypeOfGarbage("plasticmetal", 0, 0));
|
|
|
|
|
Objects[dump.Location.X + dump.Location.Y] = dump;
|
|
|
|
|
dump = new DumpWPF(columns, new Coords(3, 4), new TypeOfGarbage("organic", 0, 0));
|
|
|
|
|
Objects[dump.Location.X + dump.Location.Y] = dump;
|
|
|
|
|
dump = new DumpWPF(columns, new Coords(3, 5), new TypeOfGarbage("paper", 0, 0));
|
|
|
|
|
Objects[dump.Location.X + dump.Location.Y] = dump;
|
|
|
|
|
|
2019-03-20 18:27:11 +01:00
|
|
|
|
|
2019-03-26 23:20:41 +01:00
|
|
|
|
Board board = new Board(Objects, garbageCollector);
|
2019-03-20 18:27:11 +01:00
|
|
|
|
this.DataContext = board;
|
2019-03-13 16:45:38 +01:00
|
|
|
|
}
|
2019-03-20 16:02:05 +01:00
|
|
|
|
|
2019-03-20 16:51:35 +01:00
|
|
|
|
private void MainWindow_OnKeyDown(object sender, KeyEventArgs e)
|
|
|
|
|
{
|
2019-03-27 00:49:55 +01:00
|
|
|
|
|
2019-03-20 16:51:35 +01:00
|
|
|
|
if (e.Key == Key.Up)
|
|
|
|
|
{
|
2019-03-27 00:49:55 +01:00
|
|
|
|
garbageCollector.Move(columns, Direction.Up);
|
2019-03-20 16:51:35 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (e.Key == Key.Down)
|
|
|
|
|
{
|
2019-03-27 00:49:55 +01:00
|
|
|
|
garbageCollector.Move(columns, Direction.Down);
|
2019-03-20 16:51:35 +01:00
|
|
|
|
}
|
|
|
|
|
if (e.Key == Key.Left)
|
|
|
|
|
{
|
2019-03-27 00:49:55 +01:00
|
|
|
|
garbageCollector.Move(columns, Direction.Left);
|
2019-03-20 16:51:35 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (e.Key == Key.Right)
|
|
|
|
|
{
|
2019-03-27 00:49:55 +01:00
|
|
|
|
garbageCollector.Move(columns,Direction.Right);
|
2019-03-20 16:51:35 +01:00
|
|
|
|
}
|
2019-03-26 23:20:41 +01:00
|
|
|
|
Board board = new Board(Objects, garbageCollector);
|
|
|
|
|
board.BoardRefresh(Objects, garbageCollector);
|
|
|
|
|
this.DataContext = board;
|
2019-03-20 16:51:35 +01:00
|
|
|
|
}
|
2019-03-13 16:45:38 +01:00
|
|
|
|
}
|
|
|
|
|
}
|