Skip to content

Commit 1ff0d1c

Browse files
committed
WPF App now is a thing and displays a text grid.
1 parent 3f0e97d commit 1ff0d1c

8 files changed

+115
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<Application x:Class="MattEland.FSharpGeneticAlgorithm.WindowsClient.App"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:local="clr-namespace:MattEland.FSharpGeneticAlgorithm.WindowsClient"
5+
StartupUri="MainWindow.xaml">
6+
<Application.Resources>
7+
8+
</Application.Resources>
9+
</Application>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Configuration;
4+
using System.Data;
5+
using System.Linq;
6+
using System.Threading.Tasks;
7+
using System.Windows;
8+
9+
namespace MattEland.FSharpGeneticAlgorithm.WindowsClient
10+
{
11+
/// <summary>
12+
/// Interaction logic for App.xaml
13+
/// </summary>
14+
public partial class App : Application
15+
{
16+
}
17+
}
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using System.Text;
2+
using MattEland.FSharpGeneticAlgorithm.Logic;
3+
4+
namespace MattEland.FSharpGeneticAlgorithm.WindowsClient
5+
{
6+
internal class MainViewModel
7+
{
8+
private readonly World.World _world;
9+
10+
public MainViewModel()
11+
{
12+
_world = WorldGeneration.makeTestWorld(false);
13+
}
14+
15+
public string TextGrid => BuildAsciiGrid();
16+
17+
private string BuildAsciiGrid()
18+
{
19+
var sb = new StringBuilder();
20+
21+
for (int y = 1; y < _world.MaxY; y++)
22+
{
23+
for (int x = 1; x < _world.MaxX; x++)
24+
{
25+
sb.Append(World.getCharacterAtCell(x, y, _world));
26+
}
27+
28+
// Advance to the next line
29+
sb.AppendLine();
30+
}
31+
32+
return sb.ToString();
33+
}
34+
}
35+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<Window x:Class="MattEland.FSharpGeneticAlgorithm.WindowsClient.MainWindow"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
5+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
6+
xmlns:local="clr-namespace:MattEland.FSharpGeneticAlgorithm.WindowsClient"
7+
mc:Ignorable="d"
8+
Title="WPF Core C# talking to F# Tutorial by Matt Eland"
9+
Width="450" Height="325"
10+
Background="Black"
11+
Foreground="White"
12+
d:DataContext="{d:DesignInstance local:MainViewModel}">
13+
<Grid Margin="10">
14+
<TextBlock FontFamily="Courier New" Text="{Binding TextGrid}" FontSize="18"></TextBlock>
15+
</Grid>
16+
</Window>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System.Windows;
2+
3+
namespace MattEland.FSharpGeneticAlgorithm.WindowsClient
4+
{
5+
/// <summary>
6+
/// Interaction logic for MainWindow.xaml
7+
/// </summary>
8+
public partial class MainWindow : Window
9+
{
10+
public MainWindow()
11+
{
12+
InitializeComponent();
13+
14+
DataContext = new MainViewModel();
15+
}
16+
}
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
2+
3+
<PropertyGroup>
4+
<OutputType>WinExe</OutputType>
5+
<TargetFramework>netcoreapp3.0</TargetFramework>
6+
<UseWPF>true</UseWPF>
7+
<ApplicationIcon>KillAllDefectsSymbol.ico</ApplicationIcon>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<ProjectReference Include="..\MattEland.FSharpGeneticAlgorithm.Logic\MattEland.FSharpGeneticAlgorithm.Logic.fsproj" />
12+
</ItemGroup>
13+
14+
</Project>

MattEland.FSharpGeneticAlgorithm.sln

+7-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "MattEland.FSharpGeneticAlgo
77
EndProject
88
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "MattEland.FSharpGeneticAgorithm.ConsoleTestApp", "MattEland.FSharpGeneticAgorithm.ConsoleTestApp\MattEland.FSharpGeneticAgorithm.ConsoleTestApp.fsproj", "{B6D8C81B-288E-4B7D-BED2-B88888077390}"
99
EndProject
10-
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "MattEland.FSharpGeneticAlgorithm.Tests", "MattEland.FSharpGeneticAlgorithm.Tests\MattEland.FSharpGeneticAlgorithm.Tests.fsproj", "{4FBB57BA-F439-480D-81C7-3770D377EC28}"
10+
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "MattEland.FSharpGeneticAlgorithm.Tests", "MattEland.FSharpGeneticAlgorithm.Tests\MattEland.FSharpGeneticAlgorithm.Tests.fsproj", "{4FBB57BA-F439-480D-81C7-3770D377EC28}"
11+
EndProject
12+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MattEland.FSharpGeneticAlgorithm.WindowsClient", "MattEland.FSharpGeneticAlgorithm.WindowsClient\MattEland.FSharpGeneticAlgorithm.WindowsClient.csproj", "{A9D0C5F9-3197-48AB-977B-6B323664252B}"
1113
EndProject
1214
Global
1315
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -27,6 +29,10 @@ Global
2729
{4FBB57BA-F439-480D-81C7-3770D377EC28}.Debug|Any CPU.Build.0 = Debug|Any CPU
2830
{4FBB57BA-F439-480D-81C7-3770D377EC28}.Release|Any CPU.ActiveCfg = Release|Any CPU
2931
{4FBB57BA-F439-480D-81C7-3770D377EC28}.Release|Any CPU.Build.0 = Release|Any CPU
32+
{A9D0C5F9-3197-48AB-977B-6B323664252B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
33+
{A9D0C5F9-3197-48AB-977B-6B323664252B}.Debug|Any CPU.Build.0 = Debug|Any CPU
34+
{A9D0C5F9-3197-48AB-977B-6B323664252B}.Release|Any CPU.ActiveCfg = Release|Any CPU
35+
{A9D0C5F9-3197-48AB-977B-6B323664252B}.Release|Any CPU.Build.0 = Release|Any CPU
3036
EndGlobalSection
3137
GlobalSection(SolutionProperties) = preSolution
3238
HideSolutionNode = FALSE

0 commit comments

Comments
 (0)