Czoko_Smieciarka/Trunk/Interface/CzokoŚmieciarka.WPF/Models/GarbageCollectorWPF.cs

70 lines
2.4 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using CzokoŚmieciarka.DataModels.Enums;
using CzokoŚmieciarka.DataModels.GeneralModels.Models;
using CzokoŚmieciarka.DataModels.Interfaces.GarbageCollector;
using CzokoŚmieciarka.DataModels.Interfaces.TrashCans;
using CzokoŚmieciarka.DataModels.Models;
using CzokoŚmieciarka.WPF.Annotations;
using CzokoŚmieciarka.WPF.Interfaces;
namespace CzokoŚmieciarka.WPF.Models
{
public class GarbageCollectorWPF : AGarbageCollector, IObject, INotifyPropertyChanged
{
public Coords Location { get; set; }
public string ImagePath { get; set; }
public string Data { get; set; }
public ImageBrush Image { get; set; }
public void Move(int columns, Direction direction)
{
switch (direction)
{
case (Direction.Up):
Location.Y = Location.Y + (-1 * columns);
Position = this.MoveUp();
break;
case (Direction.Down):
Location.Y = Location.Y + (1 * columns);
Position = this.MoveDown();
break;
case (Direction.Left):
Location.X = Location.X + (-1);
Position = this.MoveLeft();
break;
case (Direction.Right):
Location.X = Location.X + (1);
Position = this.MoveRight();
break;
}
}
public GarbageCollectorWPF(int columns, Coords location, string imagePath, IEnumerable<AGarbageCollectorContainer> trashContainers) : base(location, trashContainers)
{
Location = new Coords(location.X, location.Y * columns);
ImagePath = imagePath;
Image = new ImageBrush(new BitmapImage(new Uri(ImagePath)));
}
public event PropertyChangedEventHandler PropertyChanged;
[NotifyPropertyChangedInvocator]
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
}