Czoko_Smieciarka/Trunk/Interface/CzokoŚmieciarka.WPFv2/MainWindow.xaml.cs

138 lines
5.8 KiB
C#
Raw Normal View History

2019-03-27 15:54:50 +01:00
using System;
2019-04-01 23:10:31 +02:00
using System.Collections;
2019-03-27 15:54:50 +01:00
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
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-04-08 15:47:01 +02:00
using CzokoŚmieciarka.DataModels.Enums;
2019-04-01 23:10:31 +02:00
using CzokoŚmieciarka.DataModels.GeneralModels.Models;
2019-04-08 16:43:52 +02:00
using CzokoŚmieciarka.DataModels.Interfaces;
using CzokoŚmieciarka.DataModels.Interfaces.TrashCans;
2019-04-01 23:10:31 +02:00
using CzokoŚmieciarka.DataModels.Models;
2019-04-01 21:53:06 +02:00
using CzokoŚmieciarka.WPFv2.Interfaces;
using CzokoŚmieciarka.WPFv2.Models;
2019-03-27 15:54:50 +01:00
namespace CzokoŚmieciarka.WPFv2
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
2019-04-01 21:53:06 +02:00
public static int Columns = 9;
public static int Rows = 9;
IWPFObject[,] Objects = new IWPFObject[Columns,Rows];
2019-04-02 16:14:33 +02:00
private IEnumerable<AGarbageCollectorContainer> GarbageCollectorContainers;
private WPFGarbageCollector garbageCollector;
2019-03-27 15:54:50 +01:00
public MainWindow()
2019-04-08 15:47:01 +02:00
{
InitializeComponent();
BoardInitialize();
}
private void MainWindow_OnKeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Space)
{
2019-04-10 12:32:32 +02:00
garbageCollector.MoveLeft();
//routePlanningEngine.PerformStep();
2019-04-08 15:47:01 +02:00
}
Board.Children.Clear();
2019-04-21 15:05:06 +02:00
Canvas.SetLeft(garbageCollector.Image, garbageCollector.Coords.X * 100);
Canvas.SetTop(garbageCollector.Image, garbageCollector.Coords.Y * 100);
Board.Children.Add(garbageCollector.Image);
for (int y=0;y<Rows;y++)
{
2019-04-21 15:05:06 +02:00
for (int x = 0; x < Columns; x++)
2019-04-10 12:32:32 +02:00
{
var item = Objects[x, y];
2019-04-21 15:05:06 +02:00
Canvas.SetLeft(Objects[x, y].Image, x * 100);
Canvas.SetTop(Objects[x, y].Image, y * 100);
2019-04-10 12:32:32 +02:00
Board.Children.Add(item.Image);
}
}
2019-04-10 12:32:32 +02:00
2019-04-08 15:47:01 +02:00
}
private void BoardInitialize()
2019-03-27 15:54:50 +01:00
{
2019-04-10 12:32:32 +02:00
for (int y = 0; y < Rows; y++)
2019-04-08 15:47:01 +02:00
{
2019-04-10 12:32:32 +02:00
for (int x = 0; x < Columns; x++)
2019-04-01 21:53:06 +02:00
{
2019-04-01 23:10:31 +02:00
Road road = new Road();
2019-04-10 12:32:32 +02:00
Objects[x, y] = road;
2019-04-21 15:05:06 +02:00
Canvas.SetLeft(Objects[x, y].Image, x * 100);
Canvas.SetTop(Objects[x, y].Image, y * 100);
2019-04-10 12:32:32 +02:00
Board.Children.Add(Objects[x, y].Image);
2019-04-01 21:53:06 +02:00
}
2019-04-01 23:10:31 +02:00
2019-03-27 15:54:50 +01:00
}
2019-04-21 15:05:06 +02:00
//Objects[2,7] = new WPFDump(new TypeOfGarbage(GarbageType.Glass,1,1), 10000,new Coords(2,7));
//Grid.SetColumn(Objects[2, 7].Image, 2);
//Grid.SetRow(Objects[2, 7].Image, 7);
//Board.Children.Add(Objects[2, 7].Image);
//Objects[3,7] = new WPFDump(new TypeOfGarbage(GarbageType.Organic,1,1),10000, new Coords(3,7));
//Grid.SetColumn(Objects[3, 7].Image, 3);
//Grid.SetRow(Objects[3, 7].Image, 7);
//Board.Children.Add(Objects[3, 7].Image);
//Objects[2,8] = new WPFDump(new TypeOfGarbage(GarbageType.Paper,1,1), 10000, new Coords(2,8));
//Grid.SetColumn(Objects[2, 8].Image, 2);
//Grid.SetRow(Objects[2, 8].Image, 8);
//Board.Children.Add(Objects[2, 8].Image);
//Objects[3,8] = new WPFDump(new TypeOfGarbage(GarbageType.PlasticMetal, 1,1), 10000, new Coords(3,8));
//Grid.SetColumn(Objects[3, 8].Image, 3);
//Grid.SetRow(Objects[3, 8].Image, 8);
//Board.Children.Add(Objects[3, 8].Image);
2019-04-08 15:47:01 +02:00
2019-03-27 15:54:50 +01:00
2019-04-08 15:47:01 +02:00
GarbageCollectorContainers = new List<AGarbageCollectorContainer>()
{
new GarbageCollectorContainer(new TypeOfGarbage(GarbageType.Glass,1,1), 500),
new GarbageCollectorContainer(new TypeOfGarbage(GarbageType.Organic,1,1), 500),
new GarbageCollectorContainer(new TypeOfGarbage(GarbageType.PlasticMetal, 1,1),500),
new GarbageCollectorContainer(new TypeOfGarbage(GarbageType.Paper, 1,1), 500)
};
2019-04-10 12:32:32 +02:00
garbageCollector = new WPFGarbageCollector(new Coords(2, 1), GarbageCollectorContainers, Columns, Rows);
2019-04-21 15:05:06 +02:00
Canvas.SetLeft(garbageCollector.Image, garbageCollector.Coords.X * 100);
Canvas.SetTop(garbageCollector.Image, garbageCollector.Coords.Y * 100);
Board.Children.Add(garbageCollector.Image);
2019-04-10 12:32:32 +02:00
//CollectorInfo.ItemsSource = garbageCollector;
//CollectorInfo.Items.Add(garbageCollector);
//CollectorInfo.Columns.Add(new DataGridTextColumn {Header="X", Binding = new Binding("Coords.X")});
//CollectorInfo.Columns.Add(new DataGridTextColumn { Header = "Y", Binding = new Binding("Coords.Y") });
2019-04-08 16:43:52 +02:00
IEnumerable<TrashCan> trashCans = new List<TrashCan>()
{
new TrashCan(new TypeOfGarbage(GarbageType.Glass,1,1), 500, new Garbage(new TypeOfGarbage(GarbageType.Glass,1,1), 100)),
new TrashCan(new TypeOfGarbage(GarbageType.Organic,1,1), 500, new Garbage(new TypeOfGarbage(GarbageType.Organic,1,1), 100)),
new TrashCan(new TypeOfGarbage(GarbageType.Paper,1,1), 500, new Garbage(new TypeOfGarbage(GarbageType.Paper,1,1), 100)),
new TrashCan(new TypeOfGarbage(GarbageType.PlasticMetal,1,1), 500, new Garbage(new TypeOfGarbage(GarbageType.PlasticMetal,1,1), 100))
};
WPFHouse house = new WPFHouse(new Coords(1, 3), trashCans);
Objects[1, 3] = house;
2019-04-21 15:05:06 +02:00
Canvas.SetLeft(Objects[1, 3].Image, 1 * 100);
Canvas.SetTop(Objects[1, 3].Image, 3 * 100);
2019-04-08 16:43:52 +02:00
Board.Children.Add(Objects[1, 3].Image);
2019-04-21 02:43:36 +02:00
2019-03-27 15:54:50 +01:00
}
}
}