Optymalizacja ale nie śmiga
This commit is contained in:
parent
680b87e369
commit
5e132690da
@ -4,4 +4,8 @@
|
|||||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
<TargetFramework>netcoreapp2.1</TargetFramework>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Components\CzokoŚmieciarka.DataModels\CzokoŚmieciarka.DataModels.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -64,6 +64,7 @@
|
|||||||
<DependentUpon>App.xaml</DependentUpon>
|
<DependentUpon>App.xaml</DependentUpon>
|
||||||
<SubType>Code</SubType>
|
<SubType>Code</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="Interfaces\AObject.cs" />
|
||||||
<Compile Include="MainWindow.xaml.cs">
|
<Compile Include="MainWindow.xaml.cs">
|
||||||
<DependentUpon>MainWindow.xaml</DependentUpon>
|
<DependentUpon>MainWindow.xaml</DependentUpon>
|
||||||
<SubType>Code</SubType>
|
<SubType>Code</SubType>
|
||||||
|
BIN
Trunk/Interface/CzokoŚmieciarka.WPF/Images/dupa.jpg
Normal file
BIN
Trunk/Interface/CzokoŚmieciarka.WPF/Images/dupa.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.1 MiB |
26
Trunk/Interface/CzokoŚmieciarka.WPF/Interfaces/AObject.cs
Normal file
26
Trunk/Interface/CzokoŚmieciarka.WPF/Interfaces/AObject.cs
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Media.Imaging;
|
||||||
|
using CzokoŚmieciarka.DataModels.Models;
|
||||||
|
using CzokoŚmieciarka.WPF.Models;
|
||||||
|
|
||||||
|
namespace CzokoŚmieciarka.WPF.Interfaces
|
||||||
|
{
|
||||||
|
public abstract class AObject : IObject
|
||||||
|
{
|
||||||
|
public Coords Location { get; set; }
|
||||||
|
public string ImagePath { get; set; }
|
||||||
|
public string Data { get; set; }
|
||||||
|
public ImageBrush Image { get; set; }
|
||||||
|
|
||||||
|
public ImageBrush RefreshImage()
|
||||||
|
{
|
||||||
|
ImageBrush image = new ImageBrush(new BitmapImage(new Uri(ImagePath)));
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -18,6 +18,7 @@ using CzokoŚmieciarka.DataModels.GeneralModels.Models;
|
|||||||
using CzokoŚmieciarka.DataModels.Interfaces;
|
using CzokoŚmieciarka.DataModels.Interfaces;
|
||||||
using CzokoŚmieciarka.DataModels.Interfaces.TrashCans;
|
using CzokoŚmieciarka.DataModels.Interfaces.TrashCans;
|
||||||
using CzokoŚmieciarka.DataModels.Models;
|
using CzokoŚmieciarka.DataModels.Models;
|
||||||
|
using CzokoŚmieciarka.WPF.Interfaces;
|
||||||
using CzokoŚmieciarka.WPF.Models;
|
using CzokoŚmieciarka.WPF.Models;
|
||||||
|
|
||||||
namespace CzokoŚmieciarka.WPF
|
namespace CzokoŚmieciarka.WPF
|
||||||
@ -27,23 +28,39 @@ namespace CzokoŚmieciarka.WPF
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class MainWindow : Window
|
public partial class MainWindow : Window
|
||||||
{
|
{
|
||||||
public List<IObject> Objects = new List<IObject>();
|
|
||||||
public GarbageCollector garbageCollector = new GarbageCollector(new Coords(0,0), new List<AGarbageCollectorContainer>());
|
public GarbageCollector garbageCollector = new GarbageCollector(new Coords(0,0), new List<AGarbageCollectorContainer>());
|
||||||
public Board board;
|
public Board board;
|
||||||
private int rows = 9;
|
private int rows = 9;
|
||||||
private int columns = 9;
|
private int columns = 9;
|
||||||
|
private List<AObject> Objects = new List<AObject>();
|
||||||
public MainWindow()
|
public MainWindow()
|
||||||
{
|
{
|
||||||
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
Objects.Add(new House(columns, new Coords(3, 2)));
|
for (int y = 0; y < rows; y++)
|
||||||
Objects.Add(new House(columns, new Coords(5, 8)));
|
{
|
||||||
Objects.Add(new House(columns, new Coords(7, 5)));
|
for(int x = 0; x < columns; x++)
|
||||||
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)));
|
Road road = new Road(columns, new Coords(x, y), AppDomain.CurrentDomain.BaseDirectory + @"..\..\Images\intersection.png");
|
||||||
Objects.Add(new DumpWPF(columns, new Coords(3, 4), new TypeOfGarbage("organic", 0, 0)));
|
Objects.Add(road);
|
||||||
Objects.Add(new DumpWPF(columns, new Coords(3, 5), new TypeOfGarbage("paper", 0, 0)));
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
|
||||||
board = new Board(Objects, garbageCollector);
|
board = new Board(Objects, garbageCollector);
|
||||||
this.DataContext = board;
|
this.DataContext = board;
|
||||||
@ -69,8 +86,7 @@ namespace CzokoŚmieciarka.WPF
|
|||||||
{
|
{
|
||||||
garbageCollector.Position.X += 1;
|
garbageCollector.Position.X += 1;
|
||||||
}
|
}
|
||||||
//board = board.BoardRefresh(Objects, garbageCollector);
|
|
||||||
//this.DataContext = board;
|
|
||||||
this.DataContext = new Board(Objects, garbageCollector);
|
this.DataContext = new Board(Objects, garbageCollector);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ using System.Windows.Media;
|
|||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
using CzokoŚmieciarka.DataModels.GeneralModels.Models;
|
using CzokoŚmieciarka.DataModels.GeneralModels.Models;
|
||||||
using CzokoŚmieciarka.DataModels.Models;
|
using CzokoŚmieciarka.DataModels.Models;
|
||||||
|
using CzokoŚmieciarka.WPF.Interfaces;
|
||||||
|
|
||||||
namespace CzokoŚmieciarka.WPF.Models
|
namespace CzokoŚmieciarka.WPF.Models
|
||||||
{
|
{
|
||||||
@ -19,43 +20,36 @@ namespace CzokoŚmieciarka.WPF.Models
|
|||||||
List<Tile> _tiles = new List<Tile>();
|
List<Tile> _tiles = new List<Tile>();
|
||||||
private GarbageCollectorWPF garbageCollectorWPF = new GarbageCollectorWPF(_columns, 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(List<IObject> objects, GarbageCollector garbageCollector)
|
public Board(List<AObject> objects, GarbageCollector garbageCollector)
|
||||||
{
|
{
|
||||||
for (int r = 0; r < _rows; r++)
|
|
||||||
{
|
|
||||||
for (int c = 0; c < _columns; c++)
|
|
||||||
{
|
|
||||||
Road road = new Road(AppDomain.CurrentDomain.BaseDirectory + @"..\..\Images\intersection.png");
|
|
||||||
_tiles.Add(new Tile()
|
|
||||||
{
|
|
||||||
Data = string.Format(""),
|
|
||||||
Object = road
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach(var item in objects)
|
foreach(var item in objects)
|
||||||
{
|
{
|
||||||
_tiles[item.Location.X + item.Location.Y].Object = item;
|
Tile tile = new Tile()
|
||||||
|
{
|
||||||
|
Data = item.Data,
|
||||||
|
Object = item
|
||||||
|
};
|
||||||
|
_tiles.Add(tile);
|
||||||
}
|
}
|
||||||
garbageCollectorWPF.Move(_columns, garbageCollector);
|
|
||||||
_tiles[garbageCollectorWPF.Location.X + garbageCollectorWPF.Location.Y].Object.Image = MergedBitmaps(
|
_tiles[garbageCollectorWPF.Location.X + garbageCollectorWPF.Location.Y].Object.Image = MergedBitmaps(
|
||||||
new Bitmap(_tiles[garbageCollectorWPF.Location.X + garbageCollectorWPF.Location.Y].Object.ImagePath),
|
new Bitmap(_tiles[garbageCollectorWPF.Location.X + garbageCollectorWPF.Location.Y].Object.ImagePath),
|
||||||
new Bitmap(garbageCollectorWPF.ImagePath));
|
new Bitmap(garbageCollectorWPF.ImagePath));
|
||||||
}
|
}
|
||||||
|
|
||||||
//public void BoardRefresh(List<IObject> objects, GarbageCollector garbageCollector)
|
public void BoardRefresh(List<AObject> objects, GarbageCollector garbageCollector)
|
||||||
//{
|
{
|
||||||
// foreach (var item in objects)
|
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[item.Location.X + item.Location.Y].Object.Image = _tiles[item.Location.X + item.Location.Y].Object.RefreshImage();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// garbageCollectorWPF.Move(_columns, garbageCollector);
|
garbageCollectorWPF.Move(_columns, garbageCollector);
|
||||||
// _tiles[garbageCollectorWPF.Location.X + garbageCollectorWPF.Location.Y].Object.Image = MergedBitmaps(
|
_tiles[garbageCollectorWPF.Location.X + garbageCollectorWPF.Location.Y].Object.Image = MergedBitmaps(
|
||||||
// new Bitmap(_tiles[garbageCollectorWPF.Location.X + garbageCollectorWPF.Location.Y].Object.ImagePath),
|
new Bitmap(_tiles[garbageCollectorWPF.Location.X + garbageCollectorWPF.Location.Y].Object.ImagePath),
|
||||||
// new Bitmap(garbageCollectorWPF.ImagePath));
|
new Bitmap(garbageCollectorWPF.ImagePath));
|
||||||
//}
|
}
|
||||||
|
|
||||||
public int Rows
|
public int Rows
|
||||||
{
|
{
|
||||||
|
@ -8,15 +8,12 @@ using System.Windows.Media;
|
|||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
using CzokoŚmieciarka.DataModels.Interfaces;
|
using CzokoŚmieciarka.DataModels.Interfaces;
|
||||||
using CzokoŚmieciarka.DataModels.Models;
|
using CzokoŚmieciarka.DataModels.Models;
|
||||||
|
using CzokoŚmieciarka.WPF.Interfaces;
|
||||||
|
|
||||||
namespace CzokoŚmieciarka.WPF.Models
|
namespace CzokoŚmieciarka.WPF.Models
|
||||||
{
|
{
|
||||||
class DumpWPF : IObject, INotifyPropertyChanged
|
class DumpWPF : AObject, 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 ITypeOfGarbage TypeOfGarbage { get; set; }
|
||||||
public event PropertyChangedEventHandler PropertyChanged;
|
public event PropertyChangedEventHandler PropertyChanged;
|
||||||
|
|
||||||
|
@ -10,22 +10,18 @@ using System.Windows.Media.Imaging;
|
|||||||
using CzokoŚmieciarka.DataModels.GeneralModels.Models;
|
using CzokoŚmieciarka.DataModels.GeneralModels.Models;
|
||||||
using CzokoŚmieciarka.DataModels.Models;
|
using CzokoŚmieciarka.DataModels.Models;
|
||||||
using CzokoŚmieciarka.WPF.Annotations;
|
using CzokoŚmieciarka.WPF.Annotations;
|
||||||
|
using CzokoŚmieciarka.WPF.Interfaces;
|
||||||
|
|
||||||
namespace CzokoŚmieciarka.WPF.Models
|
namespace CzokoŚmieciarka.WPF.Models
|
||||||
{
|
{
|
||||||
public class GarbageCollectorWPF : IObject, INotifyPropertyChanged
|
public class GarbageCollectorWPF : AObject, INotifyPropertyChanged
|
||||||
{
|
{
|
||||||
public Coords Location { get; set; }
|
|
||||||
|
|
||||||
public void Move(int columns, GarbageCollector garbageCollector)
|
public void Move(int columns, GarbageCollector garbageCollector)
|
||||||
{
|
{
|
||||||
Location.X = garbageCollector.Position.X;
|
Location.X = garbageCollector.Position.X;
|
||||||
Location.Y = garbageCollector.Position.Y * columns;
|
Location.Y = garbageCollector.Position.Y * columns;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string ImagePath { get; set; }
|
|
||||||
public string Data { get; set; }
|
|
||||||
public ImageBrush Image { get; set; }
|
|
||||||
|
|
||||||
public GarbageCollectorWPF(int columns,Coords location, string imagePath)
|
public GarbageCollectorWPF(int columns,Coords location, string imagePath)
|
||||||
{
|
{
|
||||||
|
@ -6,16 +6,12 @@ using System.Threading.Tasks;
|
|||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
using CzokoŚmieciarka.DataModels.Models;
|
using CzokoŚmieciarka.DataModels.Models;
|
||||||
|
using CzokoŚmieciarka.WPF.Interfaces;
|
||||||
|
|
||||||
namespace CzokoŚmieciarka.WPF.Models
|
namespace CzokoŚmieciarka.WPF.Models
|
||||||
{
|
{
|
||||||
public class House : IObject
|
public class House : AObject
|
||||||
{
|
{
|
||||||
public Coords Location { get; set; }
|
|
||||||
public string ImagePath { get; set; }
|
|
||||||
public string Data { get; set; }
|
|
||||||
public ImageBrush Image { get; set; }
|
|
||||||
|
|
||||||
public House(int columns, Coords location)
|
public House(int columns, Coords location)
|
||||||
{
|
{
|
||||||
ImagePath = AppDomain.CurrentDomain.BaseDirectory + @"..\..\Images\house.png";
|
ImagePath = AppDomain.CurrentDomain.BaseDirectory + @"..\..\Images\house.png";
|
||||||
|
@ -6,18 +6,15 @@ using System.Threading.Tasks;
|
|||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
using CzokoŚmieciarka.DataModels.Models;
|
using CzokoŚmieciarka.DataModels.Models;
|
||||||
|
using CzokoŚmieciarka.WPF.Interfaces;
|
||||||
|
|
||||||
namespace CzokoŚmieciarka.WPF.Models
|
namespace CzokoŚmieciarka.WPF.Models
|
||||||
{
|
{
|
||||||
public class Road: IObject
|
public class Road: AObject
|
||||||
{
|
{
|
||||||
public Coords Location { get; set; }
|
public Road(int columns, Coords location, string imagePath)
|
||||||
public string ImagePath { get; set; }
|
|
||||||
public string Data { get; set; }
|
|
||||||
public ImageBrush Image { get; set; }
|
|
||||||
|
|
||||||
public Road(string imagePath)
|
|
||||||
{
|
{
|
||||||
|
Location = new Coords(location.X, location.Y * columns);
|
||||||
ImagePath = imagePath;
|
ImagePath = imagePath;
|
||||||
Image = new ImageBrush(new BitmapImage(new Uri(ImagePath)));
|
Image = new ImageBrush(new BitmapImage(new Uri(ImagePath)));
|
||||||
}
|
}
|
||||||
|
@ -4,12 +4,13 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
|
using CzokoŚmieciarka.WPF.Interfaces;
|
||||||
|
|
||||||
namespace CzokoŚmieciarka.WPF.Models
|
namespace CzokoŚmieciarka.WPF.Models
|
||||||
{
|
{
|
||||||
public class Tile
|
public class Tile
|
||||||
{
|
{
|
||||||
public string Data { get; set; }
|
public string Data { get; set; }
|
||||||
public IObject Object { get; set; }
|
public AObject Object { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user