diff --git a/Trunk/Interface/CzokoŚmieciarka.WPF/CzokoŚmieciarka.WPF.csproj b/Trunk/Interface/CzokoŚmieciarka.WPF/CzokoŚmieciarka.WPF.csproj index a55ebe1..bc43ff0 100644 --- a/Trunk/Interface/CzokoŚmieciarka.WPF/CzokoŚmieciarka.WPF.csproj +++ b/Trunk/Interface/CzokoŚmieciarka.WPF/CzokoŚmieciarka.WPF.csproj @@ -72,6 +72,7 @@ + diff --git a/Trunk/Interface/CzokoŚmieciarka.WPF/Images/Dumps/glass.png b/Trunk/Interface/CzokoŚmieciarka.WPF/Images/Dumps/glass.png new file mode 100644 index 0000000..60a475e Binary files /dev/null and b/Trunk/Interface/CzokoŚmieciarka.WPF/Images/Dumps/glass.png differ diff --git a/Trunk/Interface/CzokoŚmieciarka.WPF/Images/Dumps/organic.png b/Trunk/Interface/CzokoŚmieciarka.WPF/Images/Dumps/organic.png new file mode 100644 index 0000000..fec2e9e Binary files /dev/null and b/Trunk/Interface/CzokoŚmieciarka.WPF/Images/Dumps/organic.png differ diff --git a/Trunk/Interface/CzokoŚmieciarka.WPF/Images/Dumps/paper.png b/Trunk/Interface/CzokoŚmieciarka.WPF/Images/Dumps/paper.png new file mode 100644 index 0000000..548493e Binary files /dev/null and b/Trunk/Interface/CzokoŚmieciarka.WPF/Images/Dumps/paper.png differ diff --git a/Trunk/Interface/CzokoŚmieciarka.WPF/Images/Dumps/plasticmetal.png b/Trunk/Interface/CzokoŚmieciarka.WPF/Images/Dumps/plasticmetal.png new file mode 100644 index 0000000..cbf47a7 Binary files /dev/null and b/Trunk/Interface/CzokoŚmieciarka.WPF/Images/Dumps/plasticmetal.png differ diff --git a/Trunk/Interface/CzokoŚmieciarka.WPF/MainWindow.xaml.cs b/Trunk/Interface/CzokoŚmieciarka.WPF/MainWindow.xaml.cs index 936b4d0..d5aff6d 100644 --- a/Trunk/Interface/CzokoŚmieciarka.WPF/MainWindow.xaml.cs +++ b/Trunk/Interface/CzokoŚmieciarka.WPF/MainWindow.xaml.cs @@ -30,33 +30,23 @@ namespace CzokoŚmieciarka.WPF public List Objects = new List(); public GarbageCollector garbageCollector = new GarbageCollector(new Coords(0,0), new List()); public Board board; + private int rows = 9; + private int columns = 9; public MainWindow() { InitializeComponent(); - Objects.Add(new House() - { - ImagePath = AppDomain.CurrentDomain.BaseDirectory + @"..\..\Images\house.png", - Image = new ImageBrush(new BitmapImage(new Uri(AppDomain.CurrentDomain.BaseDirectory + @"..\..\Images\house.png"))), - Location = new Coords(3, 2), - Data = "House" - }); - Objects.Add(new House() - { - ImagePath = AppDomain.CurrentDomain.BaseDirectory + @"..\..\Images\house.png", - Image = new ImageBrush(new BitmapImage(new Uri(AppDomain.CurrentDomain.BaseDirectory + @"..\..\Images\house.png"))), - Location = new Coords(5, 8), - Data = "House" - }); - Objects.Add(new House() - { - ImagePath = AppDomain.CurrentDomain.BaseDirectory + @"..\..\Images\house.png", - Image = new ImageBrush(new BitmapImage(new Uri(AppDomain.CurrentDomain.BaseDirectory + @"..\..\Images\house.png"))), - Location = new Coords(7, 5), - Data = "House" - }); - this.DataContext = new Board(9, 9, Objects, garbageCollector); + Objects.Add(new House(columns, new Coords(3, 2))); + Objects.Add(new House(columns, new Coords(5, 8))); + Objects.Add(new House(columns, new Coords(7, 5))); + Objects.Add(new DumpWPF(columns, new Coords(2, 4), new TypeOfGarbage("glass",0,0))); + Objects.Add(new DumpWPF(columns, new Coords(2, 5), new TypeOfGarbage("plasticmetal", 0, 0))); + Objects.Add(new DumpWPF(columns, new Coords(3, 4), new TypeOfGarbage("organic", 0, 0))); + Objects.Add(new DumpWPF(columns, new Coords(3, 5), new TypeOfGarbage("paper", 0, 0))); + + board = new Board(Objects, garbageCollector); + this.DataContext = board; } private void MainWindow_OnKeyDown(object sender, KeyEventArgs e) @@ -79,7 +69,9 @@ namespace CzokoŚmieciarka.WPF { garbageCollector.Position.X += 1; } - this.DataContext = new Board(9, 9, Objects, garbageCollector); + //board = board.BoardRefresh(Objects, garbageCollector); + //this.DataContext = board; + this.DataContext = new Board(Objects, garbageCollector); } } } diff --git a/Trunk/Interface/CzokoŚmieciarka.WPF/Models/Board.cs b/Trunk/Interface/CzokoŚmieciarka.WPF/Models/Board.cs index 817ea4c..62693ae 100644 --- a/Trunk/Interface/CzokoŚmieciarka.WPF/Models/Board.cs +++ b/Trunk/Interface/CzokoŚmieciarka.WPF/Models/Board.cs @@ -14,18 +14,16 @@ namespace CzokoŚmieciarka.WPF.Models { public class Board { - int _rows; - int _columns; + static int _rows = 9; + static int _columns = 9; List _tiles = new List(); - private GarbageCollectorWPF garbageCollectorWPF = new GarbageCollectorWPF(new Coords(0,0), AppDomain.CurrentDomain.BaseDirectory + @"..\..\Images\garbageCollector.png"); + private GarbageCollectorWPF garbageCollectorWPF = new GarbageCollectorWPF(_columns, new Coords(0,0), AppDomain.CurrentDomain.BaseDirectory + @"..\..\Images\garbageCollector.png"); - public Board(int rows, int columns, List objects, GarbageCollector garbageCollector) + public Board(List objects, GarbageCollector garbageCollector) { - _rows = rows; - _columns = columns; - for (int r = 0; r < rows; r++) + for (int r = 0; r < _rows; r++) { - for (int c = 0; c < columns; c++) + for (int c = 0; c < _columns; c++) { Road road = new Road(AppDomain.CurrentDomain.BaseDirectory + @"..\..\Images\intersection.png"); _tiles.Add(new Tile() @@ -38,28 +36,27 @@ namespace CzokoŚmieciarka.WPF.Models foreach(var item in objects) { - _tiles[item.Location.X + item.Location.Y * _columns].Object = item; + _tiles[item.Location.X + item.Location.Y].Object = item; } - + _tiles[garbageCollectorWPF.Location.X + garbageCollectorWPF.Location.Y].Object.Image = new ImageBrush(new BitmapImage(new Uri(_tiles[garbageCollectorWPF.Location.X + garbageCollectorWPF.Location.Y].Object.ImagePath))); garbageCollectorWPF.Move(_columns, garbageCollector); _tiles[garbageCollectorWPF.Location.X + garbageCollectorWPF.Location.Y].Object.Image = MergedBitmaps( new Bitmap(_tiles[garbageCollectorWPF.Location.X + garbageCollectorWPF.Location.Y].Object.ImagePath), new Bitmap(garbageCollectorWPF.ImagePath)); } - public Board BoardRefresh(List objects, GarbageCollector garbageCollector) - { - foreach (var item in objects) - { - _tiles[item.Location.X + item.Location.Y * _columns].Object = item; - } + //public void BoardRefresh(List objects, GarbageCollector garbageCollector) + //{ + // foreach (var item in objects) + // { + // _tiles[item.Location.X + item.Location.Y * _columns].Object = item; + // } - garbageCollectorWPF.Move(_columns, garbageCollector); - _tiles[garbageCollectorWPF.Location.X + garbageCollectorWPF.Location.Y].Object.Image = MergedBitmaps( - new Bitmap(_tiles[garbageCollectorWPF.Location.X + garbageCollectorWPF.Location.Y].Object.ImagePath), - new Bitmap(garbageCollectorWPF.ImagePath)); - return this; - } + // garbageCollectorWPF.Move(_columns, garbageCollector); + // _tiles[garbageCollectorWPF.Location.X + garbageCollectorWPF.Location.Y].Object.Image = MergedBitmaps( + // new Bitmap(_tiles[garbageCollectorWPF.Location.X + garbageCollectorWPF.Location.Y].Object.ImagePath), + // new Bitmap(garbageCollectorWPF.ImagePath)); + //} public int Rows { diff --git a/Trunk/Interface/CzokoŚmieciarka.WPF/Models/DumpWPF.cs b/Trunk/Interface/CzokoŚmieciarka.WPF/Models/DumpWPF.cs new file mode 100644 index 0000000..7fb9b1f --- /dev/null +++ b/Trunk/Interface/CzokoŚmieciarka.WPF/Models/DumpWPF.cs @@ -0,0 +1,52 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using CzokoŚmieciarka.DataModels.Interfaces; +using CzokoŚmieciarka.DataModels.Models; + +namespace CzokoŚmieciarka.WPF.Models +{ + class DumpWPF : IObject, INotifyPropertyChanged + { + public Coords Location { get; set; } + public string ImagePath { get; set; } + public string Data { get; set; } + public ImageBrush Image { get; set; } + public ITypeOfGarbage TypeOfGarbage { get; set; } + public event PropertyChangedEventHandler PropertyChanged; + + public DumpWPF(int columns, Coords location, ITypeOfGarbage typeOfGarbage) + { + Location = new Coords(location.X, location.Y * columns); + TypeOfGarbage = typeOfGarbage; + switch (TypeOfGarbage.GarbageType) + { + case "glass": + ImagePath = AppDomain.CurrentDomain.BaseDirectory + @"..\..\Images\Dumps\glass.png"; + Image = new ImageBrush(new BitmapImage(new Uri(ImagePath))); + Data = "Szkło"; + break; + case "plasticmetal": + ImagePath = AppDomain.CurrentDomain.BaseDirectory + @"..\..\Images\Dumps\plasticmetal.png"; + Image = new ImageBrush(new BitmapImage(new Uri(ImagePath))); + Data = "Plastiki i metale"; + break; + case "organic": + ImagePath = AppDomain.CurrentDomain.BaseDirectory + @"..\..\Images\Dumps\organic.png"; + Image = new ImageBrush(new BitmapImage(new Uri(ImagePath))); + Data = "Organiczne"; + break; + case "paper": + ImagePath = AppDomain.CurrentDomain.BaseDirectory + @"..\..\Images\Dumps\paper.png"; + Image = new ImageBrush(new BitmapImage(new Uri(ImagePath))); + Data = "Papier"; + break; + } + } + } +} diff --git a/Trunk/Interface/CzokoŚmieciarka.WPF/Models/GarbageCollectorWPF.cs b/Trunk/Interface/CzokoŚmieciarka.WPF/Models/GarbageCollectorWPF.cs index 924ca93..900f56e 100644 --- a/Trunk/Interface/CzokoŚmieciarka.WPF/Models/GarbageCollectorWPF.cs +++ b/Trunk/Interface/CzokoŚmieciarka.WPF/Models/GarbageCollectorWPF.cs @@ -27,9 +27,9 @@ namespace CzokoŚmieciarka.WPF.Models public string Data { get; set; } public ImageBrush Image { get; set; } - public GarbageCollectorWPF(Coords location, string imagePath) + public GarbageCollectorWPF(int columns,Coords location, string imagePath) { - Location = location; + Location = new Coords(location.X, location.Y * columns); ImagePath = imagePath; Image = new ImageBrush(new BitmapImage(new Uri(ImagePath))); } diff --git a/Trunk/Interface/CzokoŚmieciarka.WPF/Models/House.cs b/Trunk/Interface/CzokoŚmieciarka.WPF/Models/House.cs index f622b88..5370edb 100644 --- a/Trunk/Interface/CzokoŚmieciarka.WPF/Models/House.cs +++ b/Trunk/Interface/CzokoŚmieciarka.WPF/Models/House.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Media; +using System.Windows.Media.Imaging; using CzokoŚmieciarka.DataModels.Models; namespace CzokoŚmieciarka.WPF.Models @@ -14,5 +15,13 @@ namespace CzokoŚmieciarka.WPF.Models public string ImagePath { get; set; } public string Data { get; set; } public ImageBrush Image { get; set; } + + public House(int columns, Coords location) + { + ImagePath = AppDomain.CurrentDomain.BaseDirectory + @"..\..\Images\house.png"; + Image = new ImageBrush(new BitmapImage(new Uri(ImagePath))); + Location = new Coords(location.X, location.Y*columns); + Data = "House"; + } } }