Dodano wysypisko i drobne poprawki
This commit is contained in:
parent
b14fd9f43f
commit
31a9e9109c
@ -72,6 +72,7 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="Models\Board.cs" />
|
||||
<Compile Include="Interfaces\IObject.cs" />
|
||||
<Compile Include="Models\DumpWPF.cs" />
|
||||
<Compile Include="Models\GarbageCollectorWPF.cs" />
|
||||
<Compile Include="Models\House.cs" />
|
||||
<Compile Include="Models\Road.cs" />
|
||||
|
BIN
Trunk/Interface/CzokoŚmieciarka.WPF/Images/Dumps/glass.png
Normal file
BIN
Trunk/Interface/CzokoŚmieciarka.WPF/Images/Dumps/glass.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 83 KiB |
BIN
Trunk/Interface/CzokoŚmieciarka.WPF/Images/Dumps/organic.png
Normal file
BIN
Trunk/Interface/CzokoŚmieciarka.WPF/Images/Dumps/organic.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 100 KiB |
BIN
Trunk/Interface/CzokoŚmieciarka.WPF/Images/Dumps/paper.png
Normal file
BIN
Trunk/Interface/CzokoŚmieciarka.WPF/Images/Dumps/paper.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 85 KiB |
Binary file not shown.
After Width: | Height: | Size: 52 KiB |
@ -30,33 +30,23 @@ namespace CzokoŚmieciarka.WPF
|
||||
public List<IObject> Objects = new List<IObject>();
|
||||
public GarbageCollector garbageCollector = new GarbageCollector(new Coords(0,0), new List<AGarbageCollectorContainer>());
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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<Tile> _tiles = new List<Tile>();
|
||||
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<IObject> objects, GarbageCollector garbageCollector)
|
||||
public Board(List<IObject> 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<IObject> objects, GarbageCollector garbageCollector)
|
||||
{
|
||||
foreach (var item in objects)
|
||||
{
|
||||
_tiles[item.Location.X + item.Location.Y * _columns].Object = item;
|
||||
}
|
||||
//public void BoardRefresh(List<IObject> 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
|
||||
{
|
||||
|
52
Trunk/Interface/CzokoŚmieciarka.WPF/Models/DumpWPF.cs
Normal file
52
Trunk/Interface/CzokoŚmieciarka.WPF/Models/DumpWPF.cs
Normal file
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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)));
|
||||
}
|
||||
|
@ -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";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user