Dodano board i wyświetlanie obrazu w gridzie

This commit is contained in:
Michał Dulski 2019-03-14 16:24:37 +01:00
parent 58ba4a5b1c
commit c165a3f07a
9 changed files with 56 additions and 36 deletions

View File

@ -56,6 +56,7 @@
<Compile Include="Interfaces\TrashCans\ATrashCan.cs" />
<Compile Include="Interfaces\TrashCans\IStep.cs" />
<Compile Include="Models\Coords.cs" />
<Compile Include="Models\Map.cs" />
<Compile Include="Models\Steps\CollectStep.cs" />
<Compile Include="Models\Steps\MoveStep.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />

View File

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Shapes;
using CzokoŚmieciarka.DataModels.Interfaces;
namespace CzokoŚmieciarka.DataModels.Models
{
public class Map
{
public Map(Rectangle mapRectangle, IEnumerable<IGarbageLocalization> garbageLocalizations = null)
{
this.MapRectangle = mapRectangle;
this.GarbageLocalizations = garbageLocalizations;
}
Rectangle MapRectangle { get; }
IEnumerable<IGarbageLocalization> GarbageLocalizations { get; }
}
}

View File

@ -4,7 +4,7 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{AFCA9593-EF6B-4860-95F5-4F56F2AF221B}</ProjectGuid>
<ProjectGuid>{06937DFB-242D-46BD-9A4B-486D156B62A9}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>CzokoŚmieciarka.WPF</RootNamespace>
<AssemblyName>CzokoŚmieciarka.WPF</AssemblyName>
@ -37,7 +37,6 @@
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
@ -71,6 +70,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Models\Board.cs" />
<Compile Include="Models\Tile.cs" />
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
@ -96,16 +96,5 @@
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Components\CzokoŚmieciarka.DataModels\CzokoŚmieciarka.DataModels.csproj">
<Project>{f2e11fee-c5ac-47d2-ba9c-819909b6dff7}</Project>
<Name>CzokoŚmieciarka.DataModels</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Resource Include="Images\dirt.jpg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.8 KiB

After

Width:  |  Height:  |  Size: 27 KiB

View File

@ -6,8 +6,8 @@
xmlns:local="clr-namespace:CzokoŚmieciarka.WPF"
xmlns:models="clr-namespace:CzokoŚmieciarka.WPF.Models"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<ItemsControl ItemsSource="{Binding Tiles}" BorderBrush="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}">
Title="MainWindow" Height="800" Width="800">
<ItemsControl ItemsSource="{Binding Tiles}">
<ItemsControl.Resources>
<DataTemplate DataType="{x:Type models:Tile}">
<Grid Background="{Binding Background}">
@ -17,7 +17,7 @@
</ItemsControl.Resources>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid Rows="{Binding Rows}" Columns="{Binding Columns}" Margin="10" Background="{DynamicResource {x:Static SystemColors.ActiveBorderBrushKey}}"/>
<UniformGrid Rows="{Binding Rows}" Columns="{Binding Columns}"></UniformGrid>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>

View File

@ -5,6 +5,7 @@ using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
@ -27,5 +28,6 @@ namespace CzokoŚmieciarka.WPF
this.DataContext = new Board(10, 10);
}
}
}

View File

@ -1,13 +1,10 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using System.Windows.Media;
using CzokoŚmieciarka.DataModels.Interfaces;
using System.Windows.Media.Imaging;
namespace CzokoŚmieciarka.WPF.Models
{
@ -21,17 +18,15 @@ namespace CzokoŚmieciarka.WPF.Models
{
_rows = rows;
_columns = columns;
ImageBrush imgBrush = new ImageBrush(new BitmapImage(new Uri(@"F:\Projects\In-progress\CzokoSmieciarka\Trunk\CzokoŚmieciarka.WPF\Images\dirt.jpg")));
for (int r = 0; r < rows; r++)
{
for (int c = 0; c < columns; c++)
{
string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Images\dirt.jpg");
var Bitmap = new Bitmap(path);
_tiles.Add(new Tile()
{
Data = string.Format("Tile {0}", r*10+c),
Img = Bitmap
Data = string.Format("Dirt {0}", r * 10 + c),
Background = imgBrush
});
}
}
@ -55,10 +50,4 @@ namespace CzokoŚmieciarka.WPF.Models
set { _tiles = value; }
}
}
public class Tile
{
public string Data { get; set; }
public Bitmap Img { get; set; }
}
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
namespace CzokoŚmieciarka.WPF.Models
{
public class Tile
{
public string Data { get; set; }
public ImageBrush Background { get; set; }
}
}

View File

@ -5,7 +5,7 @@ VisualStudioVersion = 15.0.28307.136
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CzokoŚmieciarka.DataModels", "Components\CzokoŚmieciarka.DataModels\CzokoŚmieciarka.DataModels.csproj", "{F2E11FEE-C5AC-47D2-BA9C-819909B6DFF7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CzokoŚmieciarka.WPF", "CzokoŚmieciarka.WPF\CzokoŚmieciarka.WPF.csproj", "{AFCA9593-EF6B-4860-95F5-4F56F2AF221B}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CzokoŚmieciarka.WPF", "CzokoŚmieciarka.WPF\CzokoŚmieciarka.WPF.csproj", "{06937DFB-242D-46BD-9A4B-486D156B62A9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -17,10 +17,10 @@ Global
{F2E11FEE-C5AC-47D2-BA9C-819909B6DFF7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F2E11FEE-C5AC-47D2-BA9C-819909B6DFF7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F2E11FEE-C5AC-47D2-BA9C-819909B6DFF7}.Release|Any CPU.Build.0 = Release|Any CPU
{AFCA9593-EF6B-4860-95F5-4F56F2AF221B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AFCA9593-EF6B-4860-95F5-4F56F2AF221B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AFCA9593-EF6B-4860-95F5-4F56F2AF221B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AFCA9593-EF6B-4860-95F5-4F56F2AF221B}.Release|Any CPU.Build.0 = Release|Any CPU
{06937DFB-242D-46BD-9A4B-486D156B62A9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{06937DFB-242D-46BD-9A4B-486D156B62A9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{06937DFB-242D-46BD-9A4B-486D156B62A9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{06937DFB-242D-46BD-9A4B-486D156B62A9}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE