initial commit

This commit is contained in:
timerix 2023-11-29 11:31:35 +06:00
commit 1dbe2e1bb6
11 changed files with 172 additions and 0 deletions

8
.gitignore vendored Normal file
View File

@ -0,0 +1,8 @@
bin/
obj/
.idea/
.vs/
tmp/
temp/
packages/
*.user

16
TicTacToe.sln Normal file
View File

@ -0,0 +1,16 @@

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TicTacToe", "TicTacToe\TicTacToe.csproj", "{05A4D578-6136-42EC-B279-26B2D970325E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{05A4D578-6136-42EC-B279-26B2D970325E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{05A4D578-6136-42EC-B279-26B2D970325E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{05A4D578-6136-42EC-B279-26B2D970325E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{05A4D578-6136-42EC-B279-26B2D970325E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal

10
TicTacToe/App.axaml Normal file
View File

@ -0,0 +1,10 @@
<Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="TicTacToe.App"
RequestedThemeVariant="Default">
<!-- "Default" ThemeVariant follows system theme variant. "Dark" or "Light" are other available options. -->
<Application.Styles>
<SimpleTheme />
</Application.Styles>
</Application>

23
TicTacToe/App.axaml.cs Normal file
View File

@ -0,0 +1,23 @@
using Avalonia;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml;
namespace TicTacToe;
public partial class App : Application
{
public override void Initialize()
{
AvaloniaXamlLoader.Load(this);
}
public override void OnFrameworkInitializationCompleted()
{
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
desktop.MainWindow = new MainWindow();
}
base.OnFrameworkInitializationCompleted();
}
}

10
TicTacToe/Cell.axaml Normal file
View File

@ -0,0 +1,10 @@
<UserControl xmlns="https://github.com/avaloniaui"
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"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="TicTacToe.Cell"
BorderThickness="2"
BorderBrush="White">
<TextBlock TextAlignment="Center" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="40">X</TextBlock>
</UserControl>

11
TicTacToe/Cell.axaml.cs Normal file
View File

@ -0,0 +1,11 @@
using Avalonia.Controls;
namespace TicTacToe;
public partial class Cell : UserControl
{
public Cell()
{
InitializeComponent();
}
}

View File

@ -0,0 +1,18 @@
<Window xmlns="https://github.com/avaloniaui"
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"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="TicTacToe.MainWindow"
Title="TicTacToe"
FontSize="20">
<Grid>
<Grid.RowDefinitions>40 *</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal" Spacing="20">
<Label Target="SizeTextBox" VerticalContentAlignment="Center">Size:</Label>
<TextBox Name="SizeTextBox"></TextBox>
<Button Click="RestartButton_OnClick">Restart</Button>
</StackPanel>
<Grid Grid.Row="1" Name="GameGrid"></Grid>
</Grid>
</Window>

View File

@ -0,0 +1,35 @@
using System;
using Avalonia.Controls;
using Avalonia.Interactivity;
namespace TicTacToe;
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void RestartButton_OnClick(object? sender, RoutedEventArgs e)
{
int size = Convert.ToInt32(SizeTextBox.Text);
GameGrid.Children.Clear();
GameGrid.RowDefinitions = new RowDefinitions();
for(int y=0; y<size; y++)
GameGrid.RowDefinitions.Add(new RowDefinition());
GameGrid.ColumnDefinitions = new ColumnDefinitions();
for(int x=0; x<size; x++)
GameGrid.ColumnDefinitions.Add(new ColumnDefinition());
for(int y=0; y<size; y++)
for (int x = 0; x < size; x++)
{
var c = new Cell();
c.SetValue(Grid.ColumnProperty, x);
c.SetValue(Grid.RowProperty, y);
GameGrid.Children.Add(c);
}
}
}

17
TicTacToe/Program.cs Normal file
View File

@ -0,0 +1,17 @@
using Avalonia;
using System;
namespace TicTacToe;
class Program
{
[STAThread]
public static void Main(string[] args) => BuildAvaloniaApp()
.StartWithClassicDesktopLifetime(args);
// Avalonia configuration, don't remove; also used by visual designer.
public static AppBuilder BuildAvaloniaApp()
=> AppBuilder.Configure<App>()
.UsePlatformDetect()
.LogToTrace();
}

View File

@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>disable</ImplicitUsings>
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Avalonia" Version="11.0.5"/>
<PackageReference Include="Avalonia.Desktop" Version="11.0.5"/>
<PackageReference Include="Avalonia.Themes.Simple" Version="11.0.5"/>
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.5"/>
</ItemGroup>
</Project>

6
nuget.config Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="local" value="./packages/" />
</packageSources>
</configuration>