Dodano poruszanie się śmieciarki przy pomocy strzałek
This commit is contained in:
parent
22814fc944
commit
b14fd9f43f
2
Trunk/CzokoŚmieciarka.sln.DotSettings
Normal file
2
Trunk/CzokoŚmieciarka.sln.DotSettings
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||||
|
<s:Boolean x:Key="/Default/CodeInspection/CodeAnnotations/NamespacesWithAnnotations/=Czoko_015Amieciarka_002EWPF_002EAnnotations/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
@ -76,6 +76,7 @@
|
|||||||
<Compile Include="Models\House.cs" />
|
<Compile Include="Models\House.cs" />
|
||||||
<Compile Include="Models\Road.cs" />
|
<Compile Include="Models\Road.cs" />
|
||||||
<Compile Include="Models\Tile.cs" />
|
<Compile Include="Models\Tile.cs" />
|
||||||
|
<Compile Include="Properties\Annotations.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs">
|
<Compile Include="Properties\AssemblyInfo.cs">
|
||||||
<SubType>Code</SubType>
|
<SubType>Code</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
@ -6,7 +6,8 @@
|
|||||||
xmlns:local="clr-namespace:CzokoŚmieciarka.WPF"
|
xmlns:local="clr-namespace:CzokoŚmieciarka.WPF"
|
||||||
xmlns:models="clr-namespace:CzokoŚmieciarka.WPF.Models"
|
xmlns:models="clr-namespace:CzokoŚmieciarka.WPF.Models"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
Title="MainWindow" Height="800" Width="800">
|
Title="MainWindow" Height="800" Width="800"
|
||||||
|
KeyDown="MainWindow_OnKeyDown">
|
||||||
<ItemsControl ItemsSource="{Binding Tiles}">
|
<ItemsControl ItemsSource="{Binding Tiles}">
|
||||||
<ItemsControl.Resources>
|
<ItemsControl.Resources>
|
||||||
<DataTemplate DataType="{x:Type models:Tile}">
|
<DataTemplate DataType="{x:Type models:Tile}">
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
@ -28,7 +29,7 @@ namespace CzokoŚmieciarka.WPF
|
|||||||
{
|
{
|
||||||
public List<IObject> Objects = new List<IObject>();
|
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 MainWindow()
|
public MainWindow()
|
||||||
{
|
{
|
||||||
@ -55,10 +56,30 @@ namespace CzokoŚmieciarka.WPF
|
|||||||
Location = new Coords(7, 5),
|
Location = new Coords(7, 5),
|
||||||
Data = "House"
|
Data = "House"
|
||||||
});
|
});
|
||||||
garbageCollector.Position.X += 1;
|
|
||||||
this.DataContext = new Board(9, 9, Objects, garbageCollector);
|
this.DataContext = new Board(9, 9, Objects, garbageCollector);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void MainWindow_OnKeyDown(object sender, KeyEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.Key == Key.Up)
|
||||||
|
{
|
||||||
|
garbageCollector.Position.Y -= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (e.Key == Key.Down)
|
||||||
|
{
|
||||||
|
garbageCollector.Position.Y += 1;
|
||||||
|
}
|
||||||
|
if (e.Key == Key.Left)
|
||||||
|
{
|
||||||
|
garbageCollector.Position.X -= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (e.Key == Key.Right)
|
||||||
|
{
|
||||||
|
garbageCollector.Position.X += 1;
|
||||||
|
}
|
||||||
|
this.DataContext = new Board(9, 9, Objects, garbageCollector);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,17 +38,29 @@ namespace CzokoŚmieciarka.WPF.Models
|
|||||||
|
|
||||||
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 * _columns].Object = item;
|
||||||
_tiles[item.Location.X + item.Location.Y * columns].Object.Image = item.Image;
|
|
||||||
_tiles[item.Location.X + item.Location.Y * columns].Object.Data = item.Data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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 Board 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;
|
||||||
|
}
|
||||||
|
|
||||||
public int Rows
|
public int Rows
|
||||||
{
|
{
|
||||||
get { return _rows; }
|
get { return _rows; }
|
||||||
|
@ -1,16 +1,19 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
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.GeneralModels.Models;
|
using CzokoŚmieciarka.DataModels.GeneralModels.Models;
|
||||||
using CzokoŚmieciarka.DataModels.Models;
|
using CzokoŚmieciarka.DataModels.Models;
|
||||||
|
using CzokoŚmieciarka.WPF.Annotations;
|
||||||
|
|
||||||
namespace CzokoŚmieciarka.WPF.Models
|
namespace CzokoŚmieciarka.WPF.Models
|
||||||
{
|
{
|
||||||
public class GarbageCollectorWPF : IObject
|
public class GarbageCollectorWPF : IObject, INotifyPropertyChanged
|
||||||
{
|
{
|
||||||
public Coords Location { get; set; }
|
public Coords Location { get; set; }
|
||||||
|
|
||||||
@ -31,5 +34,12 @@ namespace CzokoŚmieciarka.WPF.Models
|
|||||||
Image = new ImageBrush(new BitmapImage(new Uri(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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
1065
Trunk/Interface/CzokoŚmieciarka.WPF/Properties/Annotations.cs
Normal file
1065
Trunk/Interface/CzokoŚmieciarka.WPF/Properties/Annotations.cs
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user