Initial commit

This commit is contained in:
ReimarPB 2023-03-13 13:59:49 +01:00
commit 58849edeeb
9 changed files with 202 additions and 0 deletions

25
TicTacToe.sln Normal file
View File

@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.4.33103.184
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TicTacToe", "TicTacToe\TicTacToe.csproj", "{AB94BFE4-3BA9-4275-885A-BEA73ABEAFED}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{AB94BFE4-3BA9-4275-885A-BEA73ABEAFED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AB94BFE4-3BA9-4275-885A-BEA73ABEAFED}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AB94BFE4-3BA9-4275-885A-BEA73ABEAFED}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AB94BFE4-3BA9-4275-885A-BEA73ABEAFED}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {C7E0F3E0-6FB2-4B97-9BB6-F9E283C93D25}
EndGlobalSection
EndGlobal

16
tictactoe/App.xaml Normal file
View File

@ -0,0 +1,16 @@
<Application x:Class="TicTacToe.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:TicTacToe"
StartupUri="MainWindow.xaml">
<Application.Resources>
<Style TargetType="TextBlock" x:Key="Field">
<Setter Property="FontSize" Value="48" />
<!--<Setter Property="HorizontalAlignment" Value="Center" />-->
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="TextAlignment" Value="Center" />
</Style>
</Application.Resources>
</Application>

17
tictactoe/App.xaml.cs Normal file
View File

@ -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 TicTacToe
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}

10
tictactoe/AssemblyInfo.cs Normal file
View File

@ -0,0 +1,10 @@
using System.Windows;
[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)
)]

52
tictactoe/MainWindow.xaml Normal file
View File

@ -0,0 +1,52 @@
<Window x:Class="TicTacToe.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:TicTacToe"
xmlns:c="clr-namespace:TicTacToe"
mc:Ignorable="d"
Title="MainWindow" Height="200" Width="200" ResizeMode="NoResize">
<Window.Resources>
<c:TicTacToeViewModel x:Key="viewModel" />
</Window.Resources>
<Grid DataContext="{StaticResource viewModel}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Border BorderBrush="Black" BorderThickness="2" Grid.Row="0" Grid.Column="0">
<TextBlock Text="{ Binding Grid[0][0] }" Style="{ StaticResource Field }" />
</Border>
<Border BorderBrush="Black" BorderThickness="2" Grid.Row="1" Grid.Column="0">
<TextBlock Text="{ Binding Grid[0][1] }" Style="{ StaticResource Field }" />
</Border>
<Border BorderBrush="Black" BorderThickness="2" Grid.Row="2" Grid.Column="0">
<TextBlock Text="{ Binding Grid[0][2] }" Style="{ StaticResource Field }" />
</Border>
<Border BorderBrush="Black" BorderThickness="2" Grid.Row="0" Grid.Column="1">
<TextBlock Text="{ Binding Grid[1][0] }" Style="{ StaticResource Field }" />
</Border>
<Border BorderBrush="Black" BorderThickness="2" Grid.Row="1" Grid.Column="1">
<TextBlock Text="{ Binding Grid[1][1] }" Style="{ StaticResource Field }" />
</Border>
<Border BorderBrush="Black" BorderThickness="2" Grid.Row="2" Grid.Column="1">
<TextBlock Text="{ Binding Grid[1][2] }" Style="{ StaticResource Field }" />
</Border>
<Border BorderBrush="Black" BorderThickness="2" Grid.Row="0" Grid.Column="2">
<TextBlock Text="{ Binding Grid[2][0] }" Style="{ StaticResource Field }" />
</Border>
<Border BorderBrush="Black" BorderThickness="2" Grid.Row="1" Grid.Column="2">
<TextBlock Text="{ Binding Grid[2][1] }" Style="{ StaticResource Field }" />
</Border>
<Border BorderBrush="Black" BorderThickness="2" Grid.Row="2" Grid.Column="2">
<TextBlock Text="{ Binding Grid[2][2] }" Style="{ StaticResource Field }" />
</Border>
</Grid>
</Window>

View File

@ -0,0 +1,28 @@
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 TicTacToe
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
}
}

View File

@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net7.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.1.0" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
<ItemGroup>
<ApplicationDefinition Update="App.xaml">
<SubType>Designer</SubType>
</ApplicationDefinition>
</ItemGroup>
<ItemGroup>
<Page Update="MainWindow.xaml">
<SubType>Designer</SubType>
</Page>
</ItemGroup>
</Project>

View File

@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CommunityToolkit.Mvvm.ComponentModel;
namespace TicTacToe
{
partial class TicTacToeViewModel : ObservableObject
{
[ObservableProperty]
char[][] grid = new char[][] {
new char[] { ' ', ' ', ' ' },
new char[] { ' ', ' ', ' ' },
new char[] { ' ', ' ', ' ' },
};
char currentTurn = 'O';
public TicTacToeViewModel()
{
}
}
}