Skip to content

Commit aaab41e

Browse files
committed
First upload
0 parents  commit aaab41e

File tree

43 files changed

+1003
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1003
-0
lines changed

.vs/CsharpTicTacToe/v16/.suo

39.5 KB
Binary file not shown.

.vs/My_TIC_TAC_TOE/v16/.suo

62.5 KB
Binary file not shown.

.vs/My_TIC_TAC_TOE/v16/Server/sqlite3/db.lock

Whitespace-only changes.
Binary file not shown.

CsharpTicTacToe.sln

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.32407.337
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CsharpTicTacToe", "My_TIC_TAC_TOE\CsharpTicTacToe.csproj", "{D4570463-4567-48C5-AB51-1DF267F4035F}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{D4570463-4567-48C5-AB51-1DF267F4035F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{D4570463-4567-48C5-AB51-1DF267F4035F}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{D4570463-4567-48C5-AB51-1DF267F4035F}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{D4570463-4567-48C5-AB51-1DF267F4035F}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {C61E629A-39A4-4A0F-B863-2B84A62CBA27}
24+
EndGlobalSection
25+
EndGlobal

CsharpTicTacToe.v12.suo

28 KB
Binary file not shown.

My_TIC_TAC_TOE/App.config

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
5+
</startup>
6+
</configuration>

My_TIC_TAC_TOE/CsharpTicTacToe.Designer.cs

Lines changed: 271 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

My_TIC_TAC_TOE/CsharpTicTacToe.cs

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.ComponentModel;
4+
using System.Data;
5+
using System.Drawing;
6+
using System.Linq;
7+
using System.Text;
8+
using System.Threading.Tasks;
9+
using System.Windows.Forms;
10+
11+
namespace My_TIC_TAC_TOE
12+
{
13+
public partial class CsharpTicTacToe : Form
14+
{
15+
public CsharpTicTacToe()
16+
{
17+
InitializeComponent();
18+
}
19+
20+
private void Csharp_TIC_TAC_TOE_Load(object sender, EventArgs e)
21+
{
22+
// add action to all buttons inside panel2
23+
foreach (Control c in panel2.Controls)
24+
{
25+
if (c is Button)
26+
{
27+
c.Click += new System.EventHandler(btn_click);
28+
}
29+
}
30+
}
31+
32+
int XorO = 0;
33+
// create button action
34+
public void btn_click(object sender, EventArgs e)
35+
{
36+
Button btn = (Button)sender;
37+
if (btn.Text.Equals(""))// we will clear text from buttons later
38+
{
39+
if (XorO % 2 == 0)
40+
{
41+
btn.Text = "X";
42+
btn.ForeColor = Color.Blue;
43+
label1.Text = "O turn now";
44+
getTheWinner();
45+
}
46+
else
47+
{
48+
btn.Text = "O";
49+
btn.ForeColor = Color.Red;
50+
label1.Text = "X turn now";
51+
getTheWinner();
52+
}
53+
54+
XorO++;
55+
}
56+
}
57+
58+
bool win = false;
59+
public void getTheWinner()
60+
{
61+
if (!button1.Text.Equals("") && button1.Text.Equals(button2.Text) && button1.Text.Equals(button3.Text))
62+
{
63+
winEffect(button1, button2, button3);
64+
win = true;
65+
}
66+
if (!button4.Text.Equals("") && button4.Text.Equals(button5.Text) && button4.Text.Equals(button6.Text))
67+
{
68+
winEffect(button4, button5, button6);
69+
win = true;
70+
}
71+
if (!button7.Text.Equals("") && button7.Text.Equals(button8.Text) && button7.Text.Equals(button9.Text))
72+
{
73+
winEffect(button7, button8, button9);
74+
win = true;
75+
}
76+
if (!button1.Text.Equals("") && button1.Text.Equals(button4.Text) && button1.Text.Equals(button7.Text))
77+
{
78+
winEffect(button1, button4, button7);
79+
win = true;
80+
}
81+
if (!button2.Text.Equals("") && button2.Text.Equals(button5.Text) && button2.Text.Equals(button8.Text))
82+
{
83+
winEffect(button2, button5, button8);
84+
win = true;
85+
}
86+
if (!button3.Text.Equals("") && button3.Text.Equals(button6.Text) && button3.Text.Equals(button9.Text))
87+
{
88+
winEffect(button3, button6, button9);
89+
win = true;
90+
}
91+
if (!button1.Text.Equals("") && button1.Text.Equals(button5.Text) && button1.Text.Equals(button9.Text))
92+
{
93+
winEffect(button1, button5, button9);
94+
win = true;
95+
}
96+
if (!button3.Text.Equals("") && button3.Text.Equals(button5.Text) && button3.Text.Equals(button7.Text))
97+
{
98+
winEffect(button3, button5, button7);
99+
win = true;
100+
}
101+
102+
// if no one win
103+
// if all buttons are not empty
104+
// we can but 1 char in a button "X or O"
105+
// we have 9 buttons
106+
// mean 9 char in length
107+
if (AllBtnLength() == 9 && win == false)
108+
{
109+
label1.Text = "No Winner";
110+
}
111+
112+
}
113+
114+
public int AllBtnLength()
115+
{
116+
int allTextButtonsLength = 0;
117+
foreach (Control c in panel2.Controls)
118+
{
119+
if (c is Button)
120+
{
121+
allTextButtonsLength += c.Text.Length;
122+
}
123+
}
124+
return allTextButtonsLength;
125+
}
126+
127+
public void winEffect(Button b1, Button b2, Button b3)
128+
{
129+
b1.BackColor = Color.Green;
130+
b2.BackColor = Color.Green;
131+
b3.BackColor = Color.Green;
132+
133+
b1.ForeColor = Color.White;
134+
b2.ForeColor = Color.White;
135+
b3.ForeColor = Color.White;
136+
137+
label1.Text = b1.Text + " Win";
138+
}
139+
140+
private void buttonPartie_Click(object sender, EventArgs e)
141+
{
142+
XorO = 0;
143+
win = false;
144+
label1.Text = "Play";
145+
foreach (Control c in panel2.Controls)
146+
{
147+
if (c is Button)
148+
{
149+
c.Text = "";
150+
c.BackColor = Color.White;
151+
}
152+
}
153+
}
154+
155+
}
156+
}

My_TIC_TAC_TOE/CsharpTicTacToe.csproj

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{D4570463-4567-48C5-AB51-1DF267F4035F}</ProjectGuid>
8+
<OutputType>WinExe</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>My_TIC_TAC_TOE</RootNamespace>
11+
<AssemblyName>My_TIC_TAC_TOE</AssemblyName>
12+
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
</PropertyGroup>
15+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
16+
<PlatformTarget>AnyCPU</PlatformTarget>
17+
<DebugSymbols>true</DebugSymbols>
18+
<DebugType>full</DebugType>
19+
<Optimize>false</Optimize>
20+
<OutputPath>bin\Debug\</OutputPath>
21+
<DefineConstants>DEBUG;TRACE</DefineConstants>
22+
<ErrorReport>prompt</ErrorReport>
23+
<WarningLevel>4</WarningLevel>
24+
</PropertyGroup>
25+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
26+
<PlatformTarget>AnyCPU</PlatformTarget>
27+
<DebugType>pdbonly</DebugType>
28+
<Optimize>true</Optimize>
29+
<OutputPath>bin\Release\</OutputPath>
30+
<DefineConstants>TRACE</DefineConstants>
31+
<ErrorReport>prompt</ErrorReport>
32+
<WarningLevel>4</WarningLevel>
33+
</PropertyGroup>
34+
<ItemGroup>
35+
<Reference Include="System" />
36+
<Reference Include="System.Core" />
37+
<Reference Include="System.Xml.Linq" />
38+
<Reference Include="System.Data.DataSetExtensions" />
39+
<Reference Include="Microsoft.CSharp" />
40+
<Reference Include="System.Data" />
41+
<Reference Include="System.Deployment" />
42+
<Reference Include="System.Drawing" />
43+
<Reference Include="System.Windows.Forms" />
44+
<Reference Include="System.Xml" />
45+
</ItemGroup>
46+
<ItemGroup>
47+
<Compile Include="CsharpTicTacToe.cs">
48+
<SubType>Form</SubType>
49+
</Compile>
50+
<Compile Include="CsharpTicTacToe.Designer.cs">
51+
<DependentUpon>CsharpTicTacToe.cs</DependentUpon>
52+
</Compile>
53+
<Compile Include="Program.cs" />
54+
<Compile Include="Properties\AssemblyInfo.cs" />
55+
<EmbeddedResource Include="CsharpTicTacToe.resx">
56+
<DependentUpon>CsharpTicTacToe.cs</DependentUpon>
57+
</EmbeddedResource>
58+
<EmbeddedResource Include="Properties\Resources.resx">
59+
<Generator>ResXFileCodeGenerator</Generator>
60+
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
61+
<SubType>Designer</SubType>
62+
</EmbeddedResource>
63+
<Compile Include="Properties\Resources.Designer.cs">
64+
<AutoGen>True</AutoGen>
65+
<DependentUpon>Resources.resx</DependentUpon>
66+
</Compile>
67+
<None Include="Properties\Settings.settings">
68+
<Generator>SettingsSingleFileGenerator</Generator>
69+
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
70+
</None>
71+
<Compile Include="Properties\Settings.Designer.cs">
72+
<AutoGen>True</AutoGen>
73+
<DependentUpon>Settings.settings</DependentUpon>
74+
<DesignTimeSharedInput>True</DesignTimeSharedInput>
75+
</Compile>
76+
</ItemGroup>
77+
<ItemGroup>
78+
<None Include="App.config" />
79+
</ItemGroup>
80+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
81+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
82+
Other similar extension points exist, see Microsoft.Common.targets.
83+
<Target Name="BeforeBuild">
84+
</Target>
85+
<Target Name="AfterBuild">
86+
</Target>
87+
-->
88+
</Project>

0 commit comments

Comments
 (0)