From bad680f65e9547216d20b391e2c242664b3152d6 Mon Sep 17 00:00:00 2001 From: s434678 Date: Wed, 10 Apr 2019 11:53:12 +0200 Subject: [PATCH 1/3] x --- Trunk/CzokoŚmieciarka.sln | 8 +- .../CzokoŚmieciarka.WPF/MainWindow.xaml.cs | 10 +- .../Models/GarbageCollectorWPF.cs | 12 +- .../CzokoŚmierciarka.WPF2.0/App.config | 6 + .../CzokoŚmierciarka.WPF2.0/App.xaml | 9 ++ .../CzokoŚmierciarka.WPF2.0/App.xaml.cs | 17 +++ .../CzokoŚmierciarka.WPF2.0.csproj | 98 +++++++++++++++ .../CzokoŚmierciarka.WPF2.0/MainWindow.xaml | 14 +++ .../MainWindow.xaml.cs | 36 ++++++ .../CzokoŚmierciarka.WPF2.0/Models/House.cs | 12 ++ .../Properties/AssemblyInfo.cs | 55 ++++++++ .../Properties/Resources.Designer.cs | 71 +++++++++++ .../Properties/Resources.resx | 117 ++++++++++++++++++ .../Properties/Settings.Designer.cs | 30 +++++ .../Properties/Settings.settings | 7 ++ 15 files changed, 492 insertions(+), 10 deletions(-) create mode 100644 Trunk/Interface/CzokoŚmierciarka.WPF2.0/App.config create mode 100644 Trunk/Interface/CzokoŚmierciarka.WPF2.0/App.xaml create mode 100644 Trunk/Interface/CzokoŚmierciarka.WPF2.0/App.xaml.cs create mode 100644 Trunk/Interface/CzokoŚmierciarka.WPF2.0/CzokoŚmierciarka.WPF2.0.csproj create mode 100644 Trunk/Interface/CzokoŚmierciarka.WPF2.0/MainWindow.xaml create mode 100644 Trunk/Interface/CzokoŚmierciarka.WPF2.0/MainWindow.xaml.cs create mode 100644 Trunk/Interface/CzokoŚmierciarka.WPF2.0/Models/House.cs create mode 100644 Trunk/Interface/CzokoŚmierciarka.WPF2.0/Properties/AssemblyInfo.cs create mode 100644 Trunk/Interface/CzokoŚmierciarka.WPF2.0/Properties/Resources.Designer.cs create mode 100644 Trunk/Interface/CzokoŚmierciarka.WPF2.0/Properties/Resources.resx create mode 100644 Trunk/Interface/CzokoŚmierciarka.WPF2.0/Properties/Settings.Designer.cs create mode 100644 Trunk/Interface/CzokoŚmierciarka.WPF2.0/Properties/Settings.settings diff --git a/Trunk/CzokoŚmieciarka.sln b/Trunk/CzokoŚmieciarka.sln index abbf3b7..1025652 100644 --- a/Trunk/CzokoŚmieciarka.sln +++ b/Trunk/CzokoŚmieciarka.sln @@ -9,7 +9,9 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CzokoŚmieciarka.DataModels EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CzokoŚmieciarka.WPF", "Interface\CzokoŚmieciarka.WPF\CzokoŚmieciarka.WPF.csproj", "{06937DFB-242D-46BD-9A4B-486D156B62A9}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Czoko_Smieciarka.AI_Naive", "Czoko_Smieciarka.AI_Naive\Czoko_Smieciarka.AI_Naive.csproj", "{A1F1D99A-4E5B-4389-B776-321D8A5976EE}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Czoko_Smieciarka.AI_Naive", "Czoko_Smieciarka.AI_Naive\Czoko_Smieciarka.AI_Naive.csproj", "{A1F1D99A-4E5B-4389-B776-321D8A5976EE}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CzokoŚmierciarka.WPF2.0", "Interface\CzokoŚmierciarka.WPF2.0\CzokoŚmierciarka.WPF2.0.csproj", "{6EE3CBC0-CD10-41D8-9282-FF91DCFB9D67}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -33,6 +35,10 @@ Global {A1F1D99A-4E5B-4389-B776-321D8A5976EE}.Debug|Any CPU.Build.0 = Debug|Any CPU {A1F1D99A-4E5B-4389-B776-321D8A5976EE}.Release|Any CPU.ActiveCfg = Release|Any CPU {A1F1D99A-4E5B-4389-B776-321D8A5976EE}.Release|Any CPU.Build.0 = Release|Any CPU + {6EE3CBC0-CD10-41D8-9282-FF91DCFB9D67}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6EE3CBC0-CD10-41D8-9282-FF91DCFB9D67}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6EE3CBC0-CD10-41D8-9282-FF91DCFB9D67}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6EE3CBC0-CD10-41D8-9282-FF91DCFB9D67}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Trunk/Interface/CzokoŚmieciarka.WPF/MainWindow.xaml.cs b/Trunk/Interface/CzokoŚmieciarka.WPF/MainWindow.xaml.cs index 0e867bc..06dba2c 100644 --- a/Trunk/Interface/CzokoŚmieciarka.WPF/MainWindow.xaml.cs +++ b/Trunk/Interface/CzokoŚmieciarka.WPF/MainWindow.xaml.cs @@ -32,7 +32,7 @@ namespace CzokoŚmieciarka.WPF //public Board board; private static int rows = 9; private static int columns = 9; - private GarbageCollectorWPF garbageCollector = new GarbageCollectorWPF(columns, new Coords(0, 0), AppDomain.CurrentDomain.BaseDirectory + @"..\..\Images\garbageCollector.png", new List()); + private GarbageCollectorWPF garbageCollector = new GarbageCollectorWPF(columns, rows, new Coords(0, 0), AppDomain.CurrentDomain.BaseDirectory + @"..\..\Images\garbageCollector.png", new List()); private List Objects = new List(); public MainWindow() { @@ -83,21 +83,21 @@ namespace CzokoŚmieciarka.WPF if (e.Key == Key.Up) { - garbageCollector.Move(columns, Direction.Up); + garbageCollector.Move(Direction.Up); } if (e.Key == Key.Down) { - garbageCollector.Move(columns, Direction.Down); + garbageCollector.Move(Direction.Down); } if (e.Key == Key.Left) { - garbageCollector.Move(columns, Direction.Left); + garbageCollector.Move(Direction.Left); } if (e.Key == Key.Right) { - garbageCollector.Move(columns, Direction.Right); + garbageCollector.Move(Direction.Right); } Board board = new Board(Objects, garbageCollector); board.BoardRefresh(Objects, garbageCollector); diff --git a/Trunk/Interface/CzokoŚmieciarka.WPF/Models/GarbageCollectorWPF.cs b/Trunk/Interface/CzokoŚmieciarka.WPF/Models/GarbageCollectorWPF.cs index 3e92782..3daf191 100644 --- a/Trunk/Interface/CzokoŚmieciarka.WPF/Models/GarbageCollectorWPF.cs +++ b/Trunk/Interface/CzokoŚmieciarka.WPF/Models/GarbageCollectorWPF.cs @@ -23,16 +23,18 @@ namespace CzokoŚmieciarka.WPF.Models public string ImagePath { get; set; } public string Data { get; set; } public ImageBrush Image { get; set; } - public void Move(int columns, Direction direction) + public int _columns { get; set; } + public int _rows { get; set; } + public void Move(Direction direction) { switch (direction) { case (Direction.Up): - Location.Y = Location.Y + (-1 * columns); + Location.Y = Location.Y + (-1 * _columns); Position = this.MoveUp(); break; case (Direction.Down): - Location.Y = Location.Y + (1 * columns); + Location.Y = Location.Y + (1 * _columns); Position = this.MoveDown(); break; case (Direction.Left): @@ -48,8 +50,10 @@ namespace CzokoŚmieciarka.WPF.Models } - public GarbageCollectorWPF(int columns, Coords location, string imagePath, IEnumerable trashContainers) : base(location, trashContainers) + public GarbageCollectorWPF(int columns, int rows, Coords location, string imagePath, IEnumerable trashContainers) : base(location, trashContainers) { + _columns = columns; + _rows = rows; Location = new Coords(location.X, location.Y * columns); ImagePath = imagePath; Image = new ImageBrush(new BitmapImage(new Uri(ImagePath))); diff --git a/Trunk/Interface/CzokoŚmierciarka.WPF2.0/App.config b/Trunk/Interface/CzokoŚmierciarka.WPF2.0/App.config new file mode 100644 index 0000000..731f6de --- /dev/null +++ b/Trunk/Interface/CzokoŚmierciarka.WPF2.0/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Trunk/Interface/CzokoŚmierciarka.WPF2.0/App.xaml b/Trunk/Interface/CzokoŚmierciarka.WPF2.0/App.xaml new file mode 100644 index 0000000..d4d1f6d --- /dev/null +++ b/Trunk/Interface/CzokoŚmierciarka.WPF2.0/App.xaml @@ -0,0 +1,9 @@ + + + + + diff --git a/Trunk/Interface/CzokoŚmierciarka.WPF2.0/App.xaml.cs b/Trunk/Interface/CzokoŚmierciarka.WPF2.0/App.xaml.cs new file mode 100644 index 0000000..a84f868 --- /dev/null +++ b/Trunk/Interface/CzokoŚmierciarka.WPF2.0/App.xaml.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Linq; +using System.Threading.Tasks; +using System.Windows; + +namespace CzokoŚmierciarka.WPF2._0 +{ + /// + /// Interaction logic for App.xaml + /// + public partial class App : Application + { + } +} diff --git a/Trunk/Interface/CzokoŚmierciarka.WPF2.0/CzokoŚmierciarka.WPF2.0.csproj b/Trunk/Interface/CzokoŚmierciarka.WPF2.0/CzokoŚmierciarka.WPF2.0.csproj new file mode 100644 index 0000000..74bae35 --- /dev/null +++ b/Trunk/Interface/CzokoŚmierciarka.WPF2.0/CzokoŚmierciarka.WPF2.0.csproj @@ -0,0 +1,98 @@ + + + + + Debug + AnyCPU + {6EE3CBC0-CD10-41D8-9282-FF91DCFB9D67} + WinExe + CzokoŚmierciarka.WPF2._0 + CzokoŚmierciarka.WPF2.0 + v4.6.1 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + true + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + 4.0 + + + + + + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + App.xaml + Code + + + MainWindow.xaml + Code + + + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + ResXFileCodeGenerator + Resources.Designer.cs + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + + + \ No newline at end of file diff --git a/Trunk/Interface/CzokoŚmierciarka.WPF2.0/MainWindow.xaml b/Trunk/Interface/CzokoŚmierciarka.WPF2.0/MainWindow.xaml new file mode 100644 index 0000000..449d76f --- /dev/null +++ b/Trunk/Interface/CzokoŚmierciarka.WPF2.0/MainWindow.xaml @@ -0,0 +1,14 @@ + + + + + + + diff --git a/Trunk/Interface/CzokoŚmierciarka.WPF2.0/MainWindow.xaml.cs b/Trunk/Interface/CzokoŚmierciarka.WPF2.0/MainWindow.xaml.cs new file mode 100644 index 0000000..d87befe --- /dev/null +++ b/Trunk/Interface/CzokoŚmierciarka.WPF2.0/MainWindow.xaml.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace CzokoŚmierciarka.WPF2._0 +{ + /// + /// Interaction logic for MainWindow.xaml + /// + public partial class MainWindow : Window + { + public MainWindow() + { + InitializeComponent(); + for(int i = 0; i < 10; i++) + { + ColumnDefinition column = new ColumnDefinition(); + RowDefinition row = new RowDefinition(); + Board.ColumnDefinitions.Add(column); + Board.RowDefinitions.Add(row); + } + Board.Set + } + } +} diff --git a/Trunk/Interface/CzokoŚmierciarka.WPF2.0/Models/House.cs b/Trunk/Interface/CzokoŚmierciarka.WPF2.0/Models/House.cs new file mode 100644 index 0000000..b0e0cab --- /dev/null +++ b/Trunk/Interface/CzokoŚmierciarka.WPF2.0/Models/House.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CzokoŚmierciarka.WPF2._0.Models +{ + class House + { + } +} diff --git a/Trunk/Interface/CzokoŚmierciarka.WPF2.0/Properties/AssemblyInfo.cs b/Trunk/Interface/CzokoŚmierciarka.WPF2.0/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..78e4e9b --- /dev/null +++ b/Trunk/Interface/CzokoŚmierciarka.WPF2.0/Properties/AssemblyInfo.cs @@ -0,0 +1,55 @@ +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Windows; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("CzokoŚmierciarka.WPF2.0")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("CzokoŚmierciarka.WPF2.0")] +[assembly: AssemblyCopyright("Copyright © 2019")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +//In order to begin building localizable applications, set +//CultureYouAreCodingWith in your .csproj file +//inside a . For example, if you are using US english +//in your source files, set the to en-US. Then uncomment +//the NeutralResourceLanguage attribute below. Update the "en-US" in +//the line below to match the UICulture setting in the project file. + +//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] + + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] + + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Trunk/Interface/CzokoŚmierciarka.WPF2.0/Properties/Resources.Designer.cs b/Trunk/Interface/CzokoŚmierciarka.WPF2.0/Properties/Resources.Designer.cs new file mode 100644 index 0000000..bee5fca --- /dev/null +++ b/Trunk/Interface/CzokoŚmierciarka.WPF2.0/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace CzokoŚmierciarka.WPF2._0.Properties +{ + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("CzokoŚmierciarka.WPF2._0.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/Trunk/Interface/CzokoŚmierciarka.WPF2.0/Properties/Resources.resx b/Trunk/Interface/CzokoŚmierciarka.WPF2.0/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Trunk/Interface/CzokoŚmierciarka.WPF2.0/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Trunk/Interface/CzokoŚmierciarka.WPF2.0/Properties/Settings.Designer.cs b/Trunk/Interface/CzokoŚmierciarka.WPF2.0/Properties/Settings.Designer.cs new file mode 100644 index 0000000..ebdd33d --- /dev/null +++ b/Trunk/Interface/CzokoŚmierciarka.WPF2.0/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace CzokoŚmierciarka.WPF2._0.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/Trunk/Interface/CzokoŚmierciarka.WPF2.0/Properties/Settings.settings b/Trunk/Interface/CzokoŚmierciarka.WPF2.0/Properties/Settings.settings new file mode 100644 index 0000000..033d7a5 --- /dev/null +++ b/Trunk/Interface/CzokoŚmierciarka.WPF2.0/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file From 57c53b9bdb9fcfcbabf8204730e99eeda38134af Mon Sep 17 00:00:00 2001 From: s434678 Date: Wed, 10 Apr 2019 12:32:32 +0200 Subject: [PATCH 2/3] Stefan --- .../Models/GarbageCollector.cs | 2 +- .../CzokoŚmieciarka.DataModels.csproj | 1 + .../Exceptions/OutOfGridException.cs | 24 ++++++++++ .../GarbageCollector/AGarbageCollector.cs | 44 ++++++++++++++----- .../GarbageCollector/IGarbageCollector.cs | 8 ++-- .../Interfaces/IWPFObject.cs | 4 +- .../CzokoŚmieciarka.WPFv2/MainWindow.xaml.cs | 37 +++++++++------- .../Models/GarbageCollector.cs | 23 ++++++---- .../CzokoŚmieciarka.WPFv2/Models/House.cs | 14 +++--- .../CzokoŚmieciarka.WPFv2/Models/Road.cs | 17 ++++--- 10 files changed, 116 insertions(+), 58 deletions(-) create mode 100644 Trunk/Components/CzokoŚmieciarka.DataModels/Exceptions/OutOfGridException.cs diff --git a/Trunk/Components/CzokoŚmieciarka.DataModels.GeneralModels/Models/GarbageCollector.cs b/Trunk/Components/CzokoŚmieciarka.DataModels.GeneralModels/Models/GarbageCollector.cs index f13df43..5a224df 100644 --- a/Trunk/Components/CzokoŚmieciarka.DataModels.GeneralModels/Models/GarbageCollector.cs +++ b/Trunk/Components/CzokoŚmieciarka.DataModels.GeneralModels/Models/GarbageCollector.cs @@ -7,7 +7,7 @@ namespace CzokoŚmieciarka.DataModels.GeneralModels.Models { public class GarbageCollector : AGarbageCollector { - public GarbageCollector(Coords startPosition, IEnumerable trashContainers) : base(startPosition, trashContainers) + public GarbageCollector(Coords startPosition, IEnumerable trashContainers, int columns, int rows) : base(startPosition, trashContainers, columns, rows) { } } diff --git a/Trunk/Components/CzokoŚmieciarka.DataModels/CzokoŚmieciarka.DataModels.csproj b/Trunk/Components/CzokoŚmieciarka.DataModels/CzokoŚmieciarka.DataModels.csproj index 010f889..1104398 100644 --- a/Trunk/Components/CzokoŚmieciarka.DataModels/CzokoŚmieciarka.DataModels.csproj +++ b/Trunk/Components/CzokoŚmieciarka.DataModels/CzokoŚmieciarka.DataModels.csproj @@ -45,6 +45,7 @@ + diff --git a/Trunk/Components/CzokoŚmieciarka.DataModels/Exceptions/OutOfGridException.cs b/Trunk/Components/CzokoŚmieciarka.DataModels/Exceptions/OutOfGridException.cs new file mode 100644 index 0000000..a0c69cc --- /dev/null +++ b/Trunk/Components/CzokoŚmieciarka.DataModels/Exceptions/OutOfGridException.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CzokoŚmieciarka.DataModels.Exceptions +{ + public class OutOfGridException : Exception + { + public OutOfGridException() + { + } + public OutOfGridException(string message) + : base(message) + { + } + + public OutOfGridException(string message, Exception inner) + : base(message, inner) + { + } + } +} diff --git a/Trunk/Components/CzokoŚmieciarka.DataModels/Interfaces/GarbageCollector/AGarbageCollector.cs b/Trunk/Components/CzokoŚmieciarka.DataModels/Interfaces/GarbageCollector/AGarbageCollector.cs index 3998ca2..414d5d6 100644 --- a/Trunk/Components/CzokoŚmieciarka.DataModels/Interfaces/GarbageCollector/AGarbageCollector.cs +++ b/Trunk/Components/CzokoŚmieciarka.DataModels/Interfaces/GarbageCollector/AGarbageCollector.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using CzokoŚmieciarka.DataModels.Exceptions; using CzokoŚmieciarka.DataModels.Interfaces.TrashCans; using CzokoŚmieciarka.DataModels.Models; @@ -10,31 +11,50 @@ namespace CzokoŚmieciarka.DataModels.Interfaces.GarbageCollector { public abstract class AGarbageCollector : IGarbageCollector { - public AGarbageCollector(Coords startPosition, IEnumerable trashContainers) - { + public AGarbageCollector(Coords startPosition, IEnumerable trashContainers, int columns, int rows) + { + this.columns = columns; + this.rows = rows; this.Coords = startPosition; this.TrashContainers = trashContainers; } - public Coords Coords { get; set; } - - public Coords MoveUp() + public Coords Coords { get; set; } + public int columns { get; set; } + public int rows { get; set; } + public void MoveUp() { - return new Coords(Coords.X,Coords.Y+1); + if(Coords.Y -1 < 0) + { + throw new OutOfGridException(); + } + Coords.Y -= 1; } - public Coords MoveDown() + public void MoveDown() { - return new Coords(Coords.X, Coords.Y - 1); + if (Coords.Y + 1 >= rows) + { + throw new OutOfGridException(); + } + Coords.Y +=1; } - public Coords MoveLeft() + public void MoveLeft() { - return new Coords(Coords.X-1, Coords.Y); + if (Coords.X - 1 < 0) + { + throw new OutOfGridException(); + } + Coords.X -= 1; } - public Coords MoveRight() + public void MoveRight() { - return new Coords(Coords.X+1, Coords.Y); + if (Coords.X + 1 >= columns) + { + throw new OutOfGridException(); + } + Coords.X += 1; } public object Clone() diff --git a/Trunk/Components/CzokoŚmieciarka.DataModels/Interfaces/GarbageCollector/IGarbageCollector.cs b/Trunk/Components/CzokoŚmieciarka.DataModels/Interfaces/GarbageCollector/IGarbageCollector.cs index 260a030..89bc30e 100644 --- a/Trunk/Components/CzokoŚmieciarka.DataModels/Interfaces/GarbageCollector/IGarbageCollector.cs +++ b/Trunk/Components/CzokoŚmieciarka.DataModels/Interfaces/GarbageCollector/IGarbageCollector.cs @@ -11,10 +11,10 @@ namespace CzokoŚmieciarka.DataModels.Interfaces public interface IGarbageCollector : ICloneable { Coords Coords { get; } - Coords MoveUp(); - Coords MoveDown(); - Coords MoveLeft(); - Coords MoveRight(); + void MoveUp(); + void MoveDown(); + void MoveLeft(); + void MoveRight(); IEnumerable TrashContainers { get; } } diff --git a/Trunk/Interface/CzokoŚmieciarka.WPFv2/Interfaces/IWPFObject.cs b/Trunk/Interface/CzokoŚmieciarka.WPFv2/Interfaces/IWPFObject.cs index 29b240a..6db260b 100644 --- a/Trunk/Interface/CzokoŚmieciarka.WPFv2/Interfaces/IWPFObject.cs +++ b/Trunk/Interface/CzokoŚmieciarka.WPFv2/Interfaces/IWPFObject.cs @@ -11,9 +11,7 @@ namespace CzokoŚmieciarka.WPFv2.Interfaces { public interface IWPFObject { - string ImagePath { get; set; } - Image Image { get; set; } + Image Image { get; } Coords Coords { get; set; } - } } diff --git a/Trunk/Interface/CzokoŚmieciarka.WPFv2/MainWindow.xaml.cs b/Trunk/Interface/CzokoŚmieciarka.WPFv2/MainWindow.xaml.cs index bf9c145..4523793 100644 --- a/Trunk/Interface/CzokoŚmieciarka.WPFv2/MainWindow.xaml.cs +++ b/Trunk/Interface/CzokoŚmieciarka.WPFv2/MainWindow.xaml.cs @@ -47,7 +47,8 @@ namespace CzokoŚmieciarka.WPFv2 if (e.Key == Key.Space) { - routePlanningEngine.PerformStep(); + garbageCollector.MoveLeft(); + //routePlanningEngine.PerformStep(); } CollectorBoard.Children.Clear(); @@ -55,12 +56,18 @@ namespace CzokoŚmieciarka.WPFv2 Grid.SetRow(garbageCollector.Image, garbageCollector.Coords.Y); CollectorBoard.Children.Add(garbageCollector.Image); Board.Children.Clear(); - foreach (var item in Objects) + for (int x=0;x trashContainers) : base(startPosition, trashContainers) + public Image Image { - ImagePath = AppDomain.CurrentDomain.BaseDirectory + @"..\..\Images\garbageCollector.png"; - Image = new Image + get { - Source = new BitmapImage(new Uri(AppDomain.CurrentDomain.BaseDirectory + - @"..\..\Images\garbageCollector.png")) - }; + return new Image + { + Source = new BitmapImage(new Uri(AppDomain.CurrentDomain.BaseDirectory + @"..\..\Images\garbageCollector.png")) + }; + } + } + + public WPFGarbageCollector(Coords startPosition, IEnumerable trashContainers, int columns, int rows) : base(startPosition, trashContainers, columns, rows) + { } public event PropertyChangedEventHandler PropertyChanged; @@ -38,5 +40,8 @@ namespace CzokoŚmieciarka.WPFv2.Models { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } + + + } } diff --git a/Trunk/Interface/CzokoŚmieciarka.WPFv2/Models/House.cs b/Trunk/Interface/CzokoŚmieciarka.WPFv2/Models/House.cs index 03cec39..4ad0f6d 100644 --- a/Trunk/Interface/CzokoŚmieciarka.WPFv2/Models/House.cs +++ b/Trunk/Interface/CzokoŚmieciarka.WPFv2/Models/House.cs @@ -17,17 +17,17 @@ namespace CzokoŚmieciarka.WPFv2.Models { public Coords Coords { get; set; } public IEnumerable TrashCans { get; set; } - public string ImagePath { get; set; } - public Image Image { get; set; } + public Image Image { get { + return new Image + { + Source = new BitmapImage(new Uri(AppDomain.CurrentDomain.BaseDirectory + @"..\..\Images\house.png")) + }; + } } public WPFHouse(Coords coords, IEnumerable trashCans) { - ImagePath = AppDomain.CurrentDomain.BaseDirectory + @"..\..\Images\house.png"; - Image = new Image - { - Source = new BitmapImage(new Uri(ImagePath)) - }; + TrashCans = trashCans; Coords = coords; } diff --git a/Trunk/Interface/CzokoŚmieciarka.WPFv2/Models/Road.cs b/Trunk/Interface/CzokoŚmieciarka.WPFv2/Models/Road.cs index 114149b..fd1542b 100644 --- a/Trunk/Interface/CzokoŚmieciarka.WPFv2/Models/Road.cs +++ b/Trunk/Interface/CzokoŚmieciarka.WPFv2/Models/Road.cs @@ -13,17 +13,20 @@ namespace CzokoŚmieciarka.WPFv2.Models { class Road : IWPFObject { - public string ImagePath { get; set; } - public Image Image { get; set; } + public Image Image + { + get + { + return new Image + { + Source = new BitmapImage(new Uri(AppDomain.CurrentDomain.BaseDirectory + @"..\..\Images\intersection.png")) + }; + } + } public Coords Coords { get; set; } public Road() { - ImagePath = AppDomain.CurrentDomain.BaseDirectory + @"..\..\Images\intersection.png"; - Image = new Image - { - Source = new BitmapImage(new Uri(ImagePath)) - }; } } } From 9aaa79a5c5258bc287f1041f4b31f5a40e5cf25f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Dulski?= Date: Thu, 18 Apr 2019 00:43:48 +0200 Subject: [PATCH 3/3] Zmiana pola Image w modelach --- .../Models/GarbageCollector.cs | 24 +++++++++------- .../CzokoŚmieciarka.WPFv2/Models/House.cs | 18 +++++++----- .../CzokoŚmieciarka.WPFv2/Models/Road.cs | 28 +++++++++++-------- 3 files changed, 42 insertions(+), 28 deletions(-) diff --git a/Trunk/Interface/CzokoŚmieciarka.WPFv2/Models/GarbageCollector.cs b/Trunk/Interface/CzokoŚmieciarka.WPFv2/Models/GarbageCollector.cs index 04f35a9..64e56d8 100644 --- a/Trunk/Interface/CzokoŚmieciarka.WPFv2/Models/GarbageCollector.cs +++ b/Trunk/Interface/CzokoŚmieciarka.WPFv2/Models/GarbageCollector.cs @@ -18,19 +18,23 @@ namespace CzokoŚmieciarka.WPFv2.Models { class WPFGarbageCollector : AGarbageCollector, IWPFObject, INotifyPropertyChanged { - public Image Image - { - get - { - return new Image - { - Source = new BitmapImage(new Uri(AppDomain.CurrentDomain.BaseDirectory + @"..\..\Images\garbageCollector.png")) - }; - } - } + public Image Image { get; set; } + //{ + // get + // { + // return new Image + // { + // Source = new BitmapImage(new Uri(AppDomain.CurrentDomain.BaseDirectory + @"..\..\Images\garbageCollector.png")) + // }; + // } + //} public WPFGarbageCollector(Coords startPosition, IEnumerable trashContainers, int columns, int rows) : base(startPosition, trashContainers, columns, rows) { + Image = new Image() + { + Source = new BitmapImage(new Uri(AppDomain.CurrentDomain.BaseDirectory + @"..\..\Images\garbageCollector.png")) + }; } public event PropertyChangedEventHandler PropertyChanged; diff --git a/Trunk/Interface/CzokoŚmieciarka.WPFv2/Models/House.cs b/Trunk/Interface/CzokoŚmieciarka.WPFv2/Models/House.cs index 4ad0f6d..eb7b999 100644 --- a/Trunk/Interface/CzokoŚmieciarka.WPFv2/Models/House.cs +++ b/Trunk/Interface/CzokoŚmieciarka.WPFv2/Models/House.cs @@ -17,17 +17,21 @@ namespace CzokoŚmieciarka.WPFv2.Models { public Coords Coords { get; set; } public IEnumerable TrashCans { get; set; } - public Image Image { get { - return new Image - { - Source = new BitmapImage(new Uri(AppDomain.CurrentDomain.BaseDirectory + @"..\..\Images\house.png")) - }; - } } + public Image Image { get; set; } + //{ get { + // return new Image + // { + // Source = new BitmapImage(new Uri(AppDomain.CurrentDomain.BaseDirectory + @"..\..\Images\house.png")) + // }; + // } } public WPFHouse(Coords coords, IEnumerable trashCans) { - + Image = new Image() + { + Source = new BitmapImage(new Uri(AppDomain.CurrentDomain.BaseDirectory + @"..\..\Images\house.png")) + }; TrashCans = trashCans; Coords = coords; } diff --git a/Trunk/Interface/CzokoŚmieciarka.WPFv2/Models/Road.cs b/Trunk/Interface/CzokoŚmieciarka.WPFv2/Models/Road.cs index fd1542b..8e4f5d7 100644 --- a/Trunk/Interface/CzokoŚmieciarka.WPFv2/Models/Road.cs +++ b/Trunk/Interface/CzokoŚmieciarka.WPFv2/Models/Road.cs @@ -13,20 +13,26 @@ namespace CzokoŚmieciarka.WPFv2.Models { class Road : IWPFObject { - public Image Image - { - get - { - return new Image - { - Source = new BitmapImage(new Uri(AppDomain.CurrentDomain.BaseDirectory + @"..\..\Images\intersection.png")) - }; - } - } - public Coords Coords { get; set; } + public Image Image { get; set; } + //{ + // get + // { + // return new Image + // { + // Source = new BitmapImage(new Uri(AppDomain.CurrentDomain.BaseDirectory + @"..\..\Images\intersection.png")) + // }; + // } + //} public Road() { + Image = new Image() + { + Source = + new BitmapImage(new Uri(AppDomain.CurrentDomain.BaseDirectory + @"..\..\Images\intersection.png")) + }; } + + public Coords Coords { get; set; } } }