Added asynchrony samples and more samples about events for .NET Core 2.2

ci
Marc CHEVALDONNE 5 years ago
parent 8089f61190
commit 77201ca2d0

@ -2,5 +2,6 @@
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<NameOfLastUsedPublishProfile>AlertWebAPI20180205014115 - Web Deploy</NameOfLastUsedPublishProfile>
<ActiveDebugProfile>IIS Express</ActiveDebugProfile>
</PropertyGroup>
</Project>

@ -0,0 +1,449 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29102.190
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "2. event asynchone et wrapping d'event", "2. event asynchone et wrapping d'event", "{9C04D9DA-5D6F-48BB-9D4C-B8D4A328A19F}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "1. Morpion", "1. Morpion", "{3C95AB92-B731-4D0A-854F-850203047E55}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "v1_contexte", "v1_contexte", "{43A5D94B-71F9-44A0-B5CA-B8BA2061B220}"
ProjectSection(SolutionItems) = preProject
Morpion\MorpionV1\event_v1_UML.png = Morpion\MorpionV1\event_v1_UML.png
Morpion\MorpionV1\event_v1_UML_seq.png = Morpion\MorpionV1\event_v1_UML_seq.png
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "giMorpionCore", "Morpion\MorpionV1\giMorpionCore\giMorpionCore.csproj", "{100BBE7D-CD80-4DE5-94F3-666D5911537A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MorpionGame", "Morpion\MorpionV1\MorpionGame\MorpionGame.csproj", "{9010B8A4-CB52-4EB8-BBD0-855A784D5579}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "v2_solutionAvecInterfaces", "v2_solutionAvecInterfaces", "{2CA02339-41F8-45BA-BC76-4F5EC23F7C49}"
ProjectSection(SolutionItems) = preProject
Morpion\MorpionV2\event_v2_UML.png = Morpion\MorpionV2\event_v2_UML.png
Morpion\MorpionV2\event_v2_UML_seq.png = Morpion\MorpionV2\event_v2_UML_seq.png
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "giMorpionCore", "Morpion\MorpionV2\giMorpionCore\giMorpionCore.csproj", "{6BC7A7C5-F550-4B6F-9366-386EE7F84AE4}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MorpionGame", "Morpion\MorpionV2\MorpionGame\MorpionGame.csproj", "{2C8D6879-BAC3-437E-B209-CB693E00F8A9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MorpionGameWpf", "Morpion\MorpionV2\MorpionGameWpf\MorpionGameWpf.csproj", "{45690090-D045-43D4-8F51-EA845DA5F95E}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "v3_solutionAvecDélégués", "v3_solutionAvecDélégués", "{6C0FA782-4DDF-4E0D-A80B-E9E84D8041AD}"
ProjectSection(SolutionItems) = preProject
Morpion\MorpionV3\event_v3_UML.png = Morpion\MorpionV3\event_v3_UML.png
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "giMorpionCore", "Morpion\MorpionV3\giMorpionCore\giMorpionCore.csproj", "{19F22A39-2E54-40C1-8F5D-FB1AE39DD78B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MorpionGame", "Morpion\MorpionV3\MorpionGame\MorpionGame.csproj", "{62838905-DF8B-41AE-B7B4-17A9E6E51647}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "v4_solutionAvecEvent", "v4_solutionAvecEvent", "{60A0817C-D6CD-4C86-A5DF-1E4D18F97E25}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "giMorpionCore", "Morpion\MorpionV4\giMorpionCore\giMorpionCore.csproj", "{4C5197D3-9080-4F04-9413-C353D5B03640}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MorpionGame", "Morpion\MorpionV4\MorpionGame\MorpionGame.csproj", "{33F89AD2-A00E-4F33-B1E1-3DB45E674B24}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "v5_solutionAvecPatternStandardDesEvénements", "v5_solutionAvecPatternStandardDesEvénements", "{DB20E493-39DD-4B90-A709-40A93E10C8CD}"
ProjectSection(SolutionItems) = preProject
Morpion\MorpionV5\event_v5_UML.png = Morpion\MorpionV5\event_v5_UML.png
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "giMorpionCore", "Morpion\MorpionV5\giMorpionCore\giMorpionCore.csproj", "{38830DB6-08C8-4F3D-889E-EE59F6BE63D8}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MorpionGame", "Morpion\MorpionV5\MorpionGame\MorpionGame.csproj", "{1417753A-BB2A-42C4-A38A-53B0C50591B4}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MusiqueEnConsole", "MusiqueEnConsole\MusiqueEnConsole.csproj", "{433AA439-DC1D-47DC-BEE8-7090FAEEAA87}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MorpionGameWpf", "Morpion\MorpionV3\MorpionGameWpf\MorpionGameWpf.csproj", "{602B0ECB-3E91-4B17-961A-0EBA5C922DA1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MorpionGameWpf", "Morpion\MorpionV4\MorpionGameWpf\MorpionGameWpf.csproj", "{3200F3AF-5D50-40FD-BB47-92EDB2DD85B9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MorpionGameWpf", "Morpion\MorpionV5\MorpionGameWpf\MorpionGameWpf.csproj", "{C3AAF4F7-2939-438B-B5E4-9D7B547C1E5E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|ARM = Debug|ARM
Debug|ARM64 = Debug|ARM64
Debug|Mixed Platforms = Debug|Mixed Platforms
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|ARM = Release|ARM
Release|ARM64 = Release|ARM64
Release|Mixed Platforms = Release|Mixed Platforms
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Debug|ARM.ActiveCfg = Debug|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Debug|ARM.Build.0 = Debug|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Debug|ARM64.Build.0 = Debug|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Debug|x64.ActiveCfg = Debug|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Debug|x64.Build.0 = Debug|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Debug|x86.ActiveCfg = Debug|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Release|Any CPU.Build.0 = Release|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Release|ARM.ActiveCfg = Release|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Release|ARM.Build.0 = Release|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Release|ARM64.ActiveCfg = Release|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Release|ARM64.Build.0 = Release|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Release|x64.ActiveCfg = Release|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Release|x64.Build.0 = Release|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Release|x86.ActiveCfg = Release|Any CPU
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Debug|ARM.ActiveCfg = Debug|Any CPU
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Debug|ARM.Build.0 = Debug|Any CPU
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Debug|ARM64.Build.0 = Debug|Any CPU
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Debug|x64.ActiveCfg = Debug|Any CPU
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Debug|x64.Build.0 = Debug|Any CPU
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Debug|x86.ActiveCfg = Debug|Any CPU
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Debug|x86.Build.0 = Debug|Any CPU
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Release|Any CPU.Build.0 = Release|Any CPU
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Release|ARM.ActiveCfg = Release|Any CPU
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Release|ARM.Build.0 = Release|Any CPU
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Release|ARM64.ActiveCfg = Release|Any CPU
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Release|ARM64.Build.0 = Release|Any CPU
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Release|x64.ActiveCfg = Release|Any CPU
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Release|x64.Build.0 = Release|Any CPU
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Release|x86.ActiveCfg = Release|Any CPU
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Release|x86.Build.0 = Release|Any CPU
{6BC7A7C5-F550-4B6F-9366-386EE7F84AE4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6BC7A7C5-F550-4B6F-9366-386EE7F84AE4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6BC7A7C5-F550-4B6F-9366-386EE7F84AE4}.Debug|ARM.ActiveCfg = Debug|Any CPU
{6BC7A7C5-F550-4B6F-9366-386EE7F84AE4}.Debug|ARM.Build.0 = Debug|Any CPU
{6BC7A7C5-F550-4B6F-9366-386EE7F84AE4}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{6BC7A7C5-F550-4B6F-9366-386EE7F84AE4}.Debug|ARM64.Build.0 = Debug|Any CPU
{6BC7A7C5-F550-4B6F-9366-386EE7F84AE4}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{6BC7A7C5-F550-4B6F-9366-386EE7F84AE4}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{6BC7A7C5-F550-4B6F-9366-386EE7F84AE4}.Debug|x64.ActiveCfg = Debug|Any CPU
{6BC7A7C5-F550-4B6F-9366-386EE7F84AE4}.Debug|x64.Build.0 = Debug|Any CPU
{6BC7A7C5-F550-4B6F-9366-386EE7F84AE4}.Debug|x86.ActiveCfg = Debug|Any CPU
{6BC7A7C5-F550-4B6F-9366-386EE7F84AE4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6BC7A7C5-F550-4B6F-9366-386EE7F84AE4}.Release|Any CPU.Build.0 = Release|Any CPU
{6BC7A7C5-F550-4B6F-9366-386EE7F84AE4}.Release|ARM.ActiveCfg = Release|Any CPU
{6BC7A7C5-F550-4B6F-9366-386EE7F84AE4}.Release|ARM.Build.0 = Release|Any CPU
{6BC7A7C5-F550-4B6F-9366-386EE7F84AE4}.Release|ARM64.ActiveCfg = Release|Any CPU
{6BC7A7C5-F550-4B6F-9366-386EE7F84AE4}.Release|ARM64.Build.0 = Release|Any CPU
{6BC7A7C5-F550-4B6F-9366-386EE7F84AE4}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{6BC7A7C5-F550-4B6F-9366-386EE7F84AE4}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{6BC7A7C5-F550-4B6F-9366-386EE7F84AE4}.Release|x64.ActiveCfg = Release|Any CPU
{6BC7A7C5-F550-4B6F-9366-386EE7F84AE4}.Release|x64.Build.0 = Release|Any CPU
{6BC7A7C5-F550-4B6F-9366-386EE7F84AE4}.Release|x86.ActiveCfg = Release|Any CPU
{2C8D6879-BAC3-437E-B209-CB693E00F8A9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2C8D6879-BAC3-437E-B209-CB693E00F8A9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2C8D6879-BAC3-437E-B209-CB693E00F8A9}.Debug|ARM.ActiveCfg = Debug|Any CPU
{2C8D6879-BAC3-437E-B209-CB693E00F8A9}.Debug|ARM.Build.0 = Debug|Any CPU
{2C8D6879-BAC3-437E-B209-CB693E00F8A9}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{2C8D6879-BAC3-437E-B209-CB693E00F8A9}.Debug|ARM64.Build.0 = Debug|Any CPU
{2C8D6879-BAC3-437E-B209-CB693E00F8A9}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{2C8D6879-BAC3-437E-B209-CB693E00F8A9}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{2C8D6879-BAC3-437E-B209-CB693E00F8A9}.Debug|x64.ActiveCfg = Debug|Any CPU
{2C8D6879-BAC3-437E-B209-CB693E00F8A9}.Debug|x64.Build.0 = Debug|Any CPU
{2C8D6879-BAC3-437E-B209-CB693E00F8A9}.Debug|x86.ActiveCfg = Debug|Any CPU
{2C8D6879-BAC3-437E-B209-CB693E00F8A9}.Debug|x86.Build.0 = Debug|Any CPU
{2C8D6879-BAC3-437E-B209-CB693E00F8A9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2C8D6879-BAC3-437E-B209-CB693E00F8A9}.Release|Any CPU.Build.0 = Release|Any CPU
{2C8D6879-BAC3-437E-B209-CB693E00F8A9}.Release|ARM.ActiveCfg = Release|Any CPU
{2C8D6879-BAC3-437E-B209-CB693E00F8A9}.Release|ARM.Build.0 = Release|Any CPU
{2C8D6879-BAC3-437E-B209-CB693E00F8A9}.Release|ARM64.ActiveCfg = Release|Any CPU
{2C8D6879-BAC3-437E-B209-CB693E00F8A9}.Release|ARM64.Build.0 = Release|Any CPU
{2C8D6879-BAC3-437E-B209-CB693E00F8A9}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{2C8D6879-BAC3-437E-B209-CB693E00F8A9}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{2C8D6879-BAC3-437E-B209-CB693E00F8A9}.Release|x64.ActiveCfg = Release|Any CPU
{2C8D6879-BAC3-437E-B209-CB693E00F8A9}.Release|x64.Build.0 = Release|Any CPU
{2C8D6879-BAC3-437E-B209-CB693E00F8A9}.Release|x86.ActiveCfg = Release|Any CPU
{2C8D6879-BAC3-437E-B209-CB693E00F8A9}.Release|x86.Build.0 = Release|Any CPU
{45690090-D045-43D4-8F51-EA845DA5F95E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{45690090-D045-43D4-8F51-EA845DA5F95E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{45690090-D045-43D4-8F51-EA845DA5F95E}.Debug|ARM.ActiveCfg = Debug|Any CPU
{45690090-D045-43D4-8F51-EA845DA5F95E}.Debug|ARM.Build.0 = Debug|Any CPU
{45690090-D045-43D4-8F51-EA845DA5F95E}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{45690090-D045-43D4-8F51-EA845DA5F95E}.Debug|ARM64.Build.0 = Debug|Any CPU
{45690090-D045-43D4-8F51-EA845DA5F95E}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{45690090-D045-43D4-8F51-EA845DA5F95E}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{45690090-D045-43D4-8F51-EA845DA5F95E}.Debug|x64.ActiveCfg = Debug|Any CPU
{45690090-D045-43D4-8F51-EA845DA5F95E}.Debug|x64.Build.0 = Debug|Any CPU
{45690090-D045-43D4-8F51-EA845DA5F95E}.Debug|x86.ActiveCfg = Debug|Any CPU
{45690090-D045-43D4-8F51-EA845DA5F95E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{45690090-D045-43D4-8F51-EA845DA5F95E}.Release|Any CPU.Build.0 = Release|Any CPU
{45690090-D045-43D4-8F51-EA845DA5F95E}.Release|ARM.ActiveCfg = Release|Any CPU
{45690090-D045-43D4-8F51-EA845DA5F95E}.Release|ARM.Build.0 = Release|Any CPU
{45690090-D045-43D4-8F51-EA845DA5F95E}.Release|ARM64.ActiveCfg = Release|Any CPU
{45690090-D045-43D4-8F51-EA845DA5F95E}.Release|ARM64.Build.0 = Release|Any CPU
{45690090-D045-43D4-8F51-EA845DA5F95E}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{45690090-D045-43D4-8F51-EA845DA5F95E}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{45690090-D045-43D4-8F51-EA845DA5F95E}.Release|x64.ActiveCfg = Release|Any CPU
{45690090-D045-43D4-8F51-EA845DA5F95E}.Release|x64.Build.0 = Release|Any CPU
{45690090-D045-43D4-8F51-EA845DA5F95E}.Release|x86.ActiveCfg = Release|Any CPU
{19F22A39-2E54-40C1-8F5D-FB1AE39DD78B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{19F22A39-2E54-40C1-8F5D-FB1AE39DD78B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{19F22A39-2E54-40C1-8F5D-FB1AE39DD78B}.Debug|ARM.ActiveCfg = Debug|Any CPU
{19F22A39-2E54-40C1-8F5D-FB1AE39DD78B}.Debug|ARM.Build.0 = Debug|Any CPU
{19F22A39-2E54-40C1-8F5D-FB1AE39DD78B}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{19F22A39-2E54-40C1-8F5D-FB1AE39DD78B}.Debug|ARM64.Build.0 = Debug|Any CPU
{19F22A39-2E54-40C1-8F5D-FB1AE39DD78B}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{19F22A39-2E54-40C1-8F5D-FB1AE39DD78B}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{19F22A39-2E54-40C1-8F5D-FB1AE39DD78B}.Debug|x64.ActiveCfg = Debug|Any CPU
{19F22A39-2E54-40C1-8F5D-FB1AE39DD78B}.Debug|x64.Build.0 = Debug|Any CPU
{19F22A39-2E54-40C1-8F5D-FB1AE39DD78B}.Debug|x86.ActiveCfg = Debug|Any CPU
{19F22A39-2E54-40C1-8F5D-FB1AE39DD78B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{19F22A39-2E54-40C1-8F5D-FB1AE39DD78B}.Release|Any CPU.Build.0 = Release|Any CPU
{19F22A39-2E54-40C1-8F5D-FB1AE39DD78B}.Release|ARM.ActiveCfg = Release|Any CPU
{19F22A39-2E54-40C1-8F5D-FB1AE39DD78B}.Release|ARM.Build.0 = Release|Any CPU
{19F22A39-2E54-40C1-8F5D-FB1AE39DD78B}.Release|ARM64.ActiveCfg = Release|Any CPU
{19F22A39-2E54-40C1-8F5D-FB1AE39DD78B}.Release|ARM64.Build.0 = Release|Any CPU
{19F22A39-2E54-40C1-8F5D-FB1AE39DD78B}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{19F22A39-2E54-40C1-8F5D-FB1AE39DD78B}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{19F22A39-2E54-40C1-8F5D-FB1AE39DD78B}.Release|x64.ActiveCfg = Release|Any CPU
{19F22A39-2E54-40C1-8F5D-FB1AE39DD78B}.Release|x64.Build.0 = Release|Any CPU
{19F22A39-2E54-40C1-8F5D-FB1AE39DD78B}.Release|x86.ActiveCfg = Release|Any CPU
{62838905-DF8B-41AE-B7B4-17A9E6E51647}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{62838905-DF8B-41AE-B7B4-17A9E6E51647}.Debug|Any CPU.Build.0 = Debug|Any CPU
{62838905-DF8B-41AE-B7B4-17A9E6E51647}.Debug|ARM.ActiveCfg = Debug|Any CPU
{62838905-DF8B-41AE-B7B4-17A9E6E51647}.Debug|ARM.Build.0 = Debug|Any CPU
{62838905-DF8B-41AE-B7B4-17A9E6E51647}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{62838905-DF8B-41AE-B7B4-17A9E6E51647}.Debug|ARM64.Build.0 = Debug|Any CPU
{62838905-DF8B-41AE-B7B4-17A9E6E51647}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{62838905-DF8B-41AE-B7B4-17A9E6E51647}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{62838905-DF8B-41AE-B7B4-17A9E6E51647}.Debug|x64.ActiveCfg = Debug|Any CPU
{62838905-DF8B-41AE-B7B4-17A9E6E51647}.Debug|x64.Build.0 = Debug|Any CPU
{62838905-DF8B-41AE-B7B4-17A9E6E51647}.Debug|x86.ActiveCfg = Debug|Any CPU
{62838905-DF8B-41AE-B7B4-17A9E6E51647}.Debug|x86.Build.0 = Debug|Any CPU
{62838905-DF8B-41AE-B7B4-17A9E6E51647}.Release|Any CPU.ActiveCfg = Release|Any CPU
{62838905-DF8B-41AE-B7B4-17A9E6E51647}.Release|Any CPU.Build.0 = Release|Any CPU
{62838905-DF8B-41AE-B7B4-17A9E6E51647}.Release|ARM.ActiveCfg = Release|Any CPU
{62838905-DF8B-41AE-B7B4-17A9E6E51647}.Release|ARM.Build.0 = Release|Any CPU
{62838905-DF8B-41AE-B7B4-17A9E6E51647}.Release|ARM64.ActiveCfg = Release|Any CPU
{62838905-DF8B-41AE-B7B4-17A9E6E51647}.Release|ARM64.Build.0 = Release|Any CPU
{62838905-DF8B-41AE-B7B4-17A9E6E51647}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{62838905-DF8B-41AE-B7B4-17A9E6E51647}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{62838905-DF8B-41AE-B7B4-17A9E6E51647}.Release|x64.ActiveCfg = Release|Any CPU
{62838905-DF8B-41AE-B7B4-17A9E6E51647}.Release|x64.Build.0 = Release|Any CPU
{62838905-DF8B-41AE-B7B4-17A9E6E51647}.Release|x86.ActiveCfg = Release|Any CPU
{62838905-DF8B-41AE-B7B4-17A9E6E51647}.Release|x86.Build.0 = Release|Any CPU
{4C5197D3-9080-4F04-9413-C353D5B03640}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4C5197D3-9080-4F04-9413-C353D5B03640}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4C5197D3-9080-4F04-9413-C353D5B03640}.Debug|ARM.ActiveCfg = Debug|Any CPU
{4C5197D3-9080-4F04-9413-C353D5B03640}.Debug|ARM.Build.0 = Debug|Any CPU
{4C5197D3-9080-4F04-9413-C353D5B03640}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{4C5197D3-9080-4F04-9413-C353D5B03640}.Debug|ARM64.Build.0 = Debug|Any CPU
{4C5197D3-9080-4F04-9413-C353D5B03640}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{4C5197D3-9080-4F04-9413-C353D5B03640}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{4C5197D3-9080-4F04-9413-C353D5B03640}.Debug|x64.ActiveCfg = Debug|Any CPU
{4C5197D3-9080-4F04-9413-C353D5B03640}.Debug|x64.Build.0 = Debug|Any CPU
{4C5197D3-9080-4F04-9413-C353D5B03640}.Debug|x86.ActiveCfg = Debug|Any CPU
{4C5197D3-9080-4F04-9413-C353D5B03640}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4C5197D3-9080-4F04-9413-C353D5B03640}.Release|Any CPU.Build.0 = Release|Any CPU
{4C5197D3-9080-4F04-9413-C353D5B03640}.Release|ARM.ActiveCfg = Release|Any CPU
{4C5197D3-9080-4F04-9413-C353D5B03640}.Release|ARM.Build.0 = Release|Any CPU
{4C5197D3-9080-4F04-9413-C353D5B03640}.Release|ARM64.ActiveCfg = Release|Any CPU
{4C5197D3-9080-4F04-9413-C353D5B03640}.Release|ARM64.Build.0 = Release|Any CPU
{4C5197D3-9080-4F04-9413-C353D5B03640}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{4C5197D3-9080-4F04-9413-C353D5B03640}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{4C5197D3-9080-4F04-9413-C353D5B03640}.Release|x64.ActiveCfg = Release|Any CPU
{4C5197D3-9080-4F04-9413-C353D5B03640}.Release|x64.Build.0 = Release|Any CPU
{4C5197D3-9080-4F04-9413-C353D5B03640}.Release|x86.ActiveCfg = Release|Any CPU
{33F89AD2-A00E-4F33-B1E1-3DB45E674B24}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{33F89AD2-A00E-4F33-B1E1-3DB45E674B24}.Debug|Any CPU.Build.0 = Debug|Any CPU
{33F89AD2-A00E-4F33-B1E1-3DB45E674B24}.Debug|ARM.ActiveCfg = Debug|Any CPU
{33F89AD2-A00E-4F33-B1E1-3DB45E674B24}.Debug|ARM.Build.0 = Debug|Any CPU
{33F89AD2-A00E-4F33-B1E1-3DB45E674B24}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{33F89AD2-A00E-4F33-B1E1-3DB45E674B24}.Debug|ARM64.Build.0 = Debug|Any CPU
{33F89AD2-A00E-4F33-B1E1-3DB45E674B24}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{33F89AD2-A00E-4F33-B1E1-3DB45E674B24}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{33F89AD2-A00E-4F33-B1E1-3DB45E674B24}.Debug|x64.ActiveCfg = Debug|Any CPU
{33F89AD2-A00E-4F33-B1E1-3DB45E674B24}.Debug|x64.Build.0 = Debug|Any CPU
{33F89AD2-A00E-4F33-B1E1-3DB45E674B24}.Debug|x86.ActiveCfg = Debug|Any CPU
{33F89AD2-A00E-4F33-B1E1-3DB45E674B24}.Debug|x86.Build.0 = Debug|Any CPU
{33F89AD2-A00E-4F33-B1E1-3DB45E674B24}.Release|Any CPU.ActiveCfg = Release|Any CPU
{33F89AD2-A00E-4F33-B1E1-3DB45E674B24}.Release|Any CPU.Build.0 = Release|Any CPU
{33F89AD2-A00E-4F33-B1E1-3DB45E674B24}.Release|ARM.ActiveCfg = Release|Any CPU
{33F89AD2-A00E-4F33-B1E1-3DB45E674B24}.Release|ARM.Build.0 = Release|Any CPU
{33F89AD2-A00E-4F33-B1E1-3DB45E674B24}.Release|ARM64.ActiveCfg = Release|Any CPU
{33F89AD2-A00E-4F33-B1E1-3DB45E674B24}.Release|ARM64.Build.0 = Release|Any CPU
{33F89AD2-A00E-4F33-B1E1-3DB45E674B24}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{33F89AD2-A00E-4F33-B1E1-3DB45E674B24}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{33F89AD2-A00E-4F33-B1E1-3DB45E674B24}.Release|x64.ActiveCfg = Release|Any CPU
{33F89AD2-A00E-4F33-B1E1-3DB45E674B24}.Release|x64.Build.0 = Release|Any CPU
{33F89AD2-A00E-4F33-B1E1-3DB45E674B24}.Release|x86.ActiveCfg = Release|Any CPU
{33F89AD2-A00E-4F33-B1E1-3DB45E674B24}.Release|x86.Build.0 = Release|Any CPU
{38830DB6-08C8-4F3D-889E-EE59F6BE63D8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{38830DB6-08C8-4F3D-889E-EE59F6BE63D8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{38830DB6-08C8-4F3D-889E-EE59F6BE63D8}.Debug|ARM.ActiveCfg = Debug|Any CPU
{38830DB6-08C8-4F3D-889E-EE59F6BE63D8}.Debug|ARM.Build.0 = Debug|Any CPU
{38830DB6-08C8-4F3D-889E-EE59F6BE63D8}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{38830DB6-08C8-4F3D-889E-EE59F6BE63D8}.Debug|ARM64.Build.0 = Debug|Any CPU
{38830DB6-08C8-4F3D-889E-EE59F6BE63D8}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{38830DB6-08C8-4F3D-889E-EE59F6BE63D8}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{38830DB6-08C8-4F3D-889E-EE59F6BE63D8}.Debug|x64.ActiveCfg = Debug|Any CPU
{38830DB6-08C8-4F3D-889E-EE59F6BE63D8}.Debug|x64.Build.0 = Debug|Any CPU
{38830DB6-08C8-4F3D-889E-EE59F6BE63D8}.Debug|x86.ActiveCfg = Debug|Any CPU
{38830DB6-08C8-4F3D-889E-EE59F6BE63D8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{38830DB6-08C8-4F3D-889E-EE59F6BE63D8}.Release|Any CPU.Build.0 = Release|Any CPU
{38830DB6-08C8-4F3D-889E-EE59F6BE63D8}.Release|ARM.ActiveCfg = Release|Any CPU
{38830DB6-08C8-4F3D-889E-EE59F6BE63D8}.Release|ARM.Build.0 = Release|Any CPU
{38830DB6-08C8-4F3D-889E-EE59F6BE63D8}.Release|ARM64.ActiveCfg = Release|Any CPU
{38830DB6-08C8-4F3D-889E-EE59F6BE63D8}.Release|ARM64.Build.0 = Release|Any CPU
{38830DB6-08C8-4F3D-889E-EE59F6BE63D8}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{38830DB6-08C8-4F3D-889E-EE59F6BE63D8}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{38830DB6-08C8-4F3D-889E-EE59F6BE63D8}.Release|x64.ActiveCfg = Release|Any CPU
{38830DB6-08C8-4F3D-889E-EE59F6BE63D8}.Release|x64.Build.0 = Release|Any CPU
{38830DB6-08C8-4F3D-889E-EE59F6BE63D8}.Release|x86.ActiveCfg = Release|Any CPU
{1417753A-BB2A-42C4-A38A-53B0C50591B4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1417753A-BB2A-42C4-A38A-53B0C50591B4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1417753A-BB2A-42C4-A38A-53B0C50591B4}.Debug|ARM.ActiveCfg = Debug|Any CPU
{1417753A-BB2A-42C4-A38A-53B0C50591B4}.Debug|ARM.Build.0 = Debug|Any CPU
{1417753A-BB2A-42C4-A38A-53B0C50591B4}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{1417753A-BB2A-42C4-A38A-53B0C50591B4}.Debug|ARM64.Build.0 = Debug|Any CPU
{1417753A-BB2A-42C4-A38A-53B0C50591B4}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{1417753A-BB2A-42C4-A38A-53B0C50591B4}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{1417753A-BB2A-42C4-A38A-53B0C50591B4}.Debug|x64.ActiveCfg = Debug|Any CPU
{1417753A-BB2A-42C4-A38A-53B0C50591B4}.Debug|x64.Build.0 = Debug|Any CPU
{1417753A-BB2A-42C4-A38A-53B0C50591B4}.Debug|x86.ActiveCfg = Debug|Any CPU
{1417753A-BB2A-42C4-A38A-53B0C50591B4}.Debug|x86.Build.0 = Debug|Any CPU
{1417753A-BB2A-42C4-A38A-53B0C50591B4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1417753A-BB2A-42C4-A38A-53B0C50591B4}.Release|Any CPU.Build.0 = Release|Any CPU
{1417753A-BB2A-42C4-A38A-53B0C50591B4}.Release|ARM.ActiveCfg = Release|Any CPU
{1417753A-BB2A-42C4-A38A-53B0C50591B4}.Release|ARM.Build.0 = Release|Any CPU
{1417753A-BB2A-42C4-A38A-53B0C50591B4}.Release|ARM64.ActiveCfg = Release|Any CPU
{1417753A-BB2A-42C4-A38A-53B0C50591B4}.Release|ARM64.Build.0 = Release|Any CPU
{1417753A-BB2A-42C4-A38A-53B0C50591B4}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{1417753A-BB2A-42C4-A38A-53B0C50591B4}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{1417753A-BB2A-42C4-A38A-53B0C50591B4}.Release|x64.ActiveCfg = Release|Any CPU
{1417753A-BB2A-42C4-A38A-53B0C50591B4}.Release|x64.Build.0 = Release|Any CPU
{1417753A-BB2A-42C4-A38A-53B0C50591B4}.Release|x86.ActiveCfg = Release|Any CPU
{1417753A-BB2A-42C4-A38A-53B0C50591B4}.Release|x86.Build.0 = Release|Any CPU
{433AA439-DC1D-47DC-BEE8-7090FAEEAA87}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{433AA439-DC1D-47DC-BEE8-7090FAEEAA87}.Debug|Any CPU.Build.0 = Debug|Any CPU
{433AA439-DC1D-47DC-BEE8-7090FAEEAA87}.Debug|ARM.ActiveCfg = Debug|Any CPU
{433AA439-DC1D-47DC-BEE8-7090FAEEAA87}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{433AA439-DC1D-47DC-BEE8-7090FAEEAA87}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{433AA439-DC1D-47DC-BEE8-7090FAEEAA87}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{433AA439-DC1D-47DC-BEE8-7090FAEEAA87}.Debug|x64.ActiveCfg = Debug|Any CPU
{433AA439-DC1D-47DC-BEE8-7090FAEEAA87}.Debug|x86.ActiveCfg = Debug|Any CPU
{433AA439-DC1D-47DC-BEE8-7090FAEEAA87}.Release|Any CPU.ActiveCfg = Release|Any CPU
{433AA439-DC1D-47DC-BEE8-7090FAEEAA87}.Release|Any CPU.Build.0 = Release|Any CPU
{433AA439-DC1D-47DC-BEE8-7090FAEEAA87}.Release|ARM.ActiveCfg = Release|Any CPU
{433AA439-DC1D-47DC-BEE8-7090FAEEAA87}.Release|ARM64.ActiveCfg = Release|Any CPU
{433AA439-DC1D-47DC-BEE8-7090FAEEAA87}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{433AA439-DC1D-47DC-BEE8-7090FAEEAA87}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{433AA439-DC1D-47DC-BEE8-7090FAEEAA87}.Release|x64.ActiveCfg = Release|Any CPU
{433AA439-DC1D-47DC-BEE8-7090FAEEAA87}.Release|x86.ActiveCfg = Release|Any CPU
{602B0ECB-3E91-4B17-961A-0EBA5C922DA1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{602B0ECB-3E91-4B17-961A-0EBA5C922DA1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{602B0ECB-3E91-4B17-961A-0EBA5C922DA1}.Debug|ARM.ActiveCfg = Debug|Any CPU
{602B0ECB-3E91-4B17-961A-0EBA5C922DA1}.Debug|ARM.Build.0 = Debug|Any CPU
{602B0ECB-3E91-4B17-961A-0EBA5C922DA1}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{602B0ECB-3E91-4B17-961A-0EBA5C922DA1}.Debug|ARM64.Build.0 = Debug|Any CPU
{602B0ECB-3E91-4B17-961A-0EBA5C922DA1}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{602B0ECB-3E91-4B17-961A-0EBA5C922DA1}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{602B0ECB-3E91-4B17-961A-0EBA5C922DA1}.Debug|x64.ActiveCfg = Debug|Any CPU
{602B0ECB-3E91-4B17-961A-0EBA5C922DA1}.Debug|x64.Build.0 = Debug|Any CPU
{602B0ECB-3E91-4B17-961A-0EBA5C922DA1}.Debug|x86.ActiveCfg = Debug|Any CPU
{602B0ECB-3E91-4B17-961A-0EBA5C922DA1}.Debug|x86.Build.0 = Debug|Any CPU
{602B0ECB-3E91-4B17-961A-0EBA5C922DA1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{602B0ECB-3E91-4B17-961A-0EBA5C922DA1}.Release|Any CPU.Build.0 = Release|Any CPU
{602B0ECB-3E91-4B17-961A-0EBA5C922DA1}.Release|ARM.ActiveCfg = Release|Any CPU
{602B0ECB-3E91-4B17-961A-0EBA5C922DA1}.Release|ARM.Build.0 = Release|Any CPU
{602B0ECB-3E91-4B17-961A-0EBA5C922DA1}.Release|ARM64.ActiveCfg = Release|Any CPU
{602B0ECB-3E91-4B17-961A-0EBA5C922DA1}.Release|ARM64.Build.0 = Release|Any CPU
{602B0ECB-3E91-4B17-961A-0EBA5C922DA1}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{602B0ECB-3E91-4B17-961A-0EBA5C922DA1}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{602B0ECB-3E91-4B17-961A-0EBA5C922DA1}.Release|x64.ActiveCfg = Release|Any CPU
{602B0ECB-3E91-4B17-961A-0EBA5C922DA1}.Release|x64.Build.0 = Release|Any CPU
{602B0ECB-3E91-4B17-961A-0EBA5C922DA1}.Release|x86.ActiveCfg = Release|Any CPU
{602B0ECB-3E91-4B17-961A-0EBA5C922DA1}.Release|x86.Build.0 = Release|Any CPU
{3200F3AF-5D50-40FD-BB47-92EDB2DD85B9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3200F3AF-5D50-40FD-BB47-92EDB2DD85B9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3200F3AF-5D50-40FD-BB47-92EDB2DD85B9}.Debug|ARM.ActiveCfg = Debug|Any CPU
{3200F3AF-5D50-40FD-BB47-92EDB2DD85B9}.Debug|ARM.Build.0 = Debug|Any CPU
{3200F3AF-5D50-40FD-BB47-92EDB2DD85B9}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{3200F3AF-5D50-40FD-BB47-92EDB2DD85B9}.Debug|ARM64.Build.0 = Debug|Any CPU
{3200F3AF-5D50-40FD-BB47-92EDB2DD85B9}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{3200F3AF-5D50-40FD-BB47-92EDB2DD85B9}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{3200F3AF-5D50-40FD-BB47-92EDB2DD85B9}.Debug|x64.ActiveCfg = Debug|Any CPU
{3200F3AF-5D50-40FD-BB47-92EDB2DD85B9}.Debug|x64.Build.0 = Debug|Any CPU
{3200F3AF-5D50-40FD-BB47-92EDB2DD85B9}.Debug|x86.ActiveCfg = Debug|Any CPU
{3200F3AF-5D50-40FD-BB47-92EDB2DD85B9}.Debug|x86.Build.0 = Debug|Any CPU
{3200F3AF-5D50-40FD-BB47-92EDB2DD85B9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3200F3AF-5D50-40FD-BB47-92EDB2DD85B9}.Release|Any CPU.Build.0 = Release|Any CPU
{3200F3AF-5D50-40FD-BB47-92EDB2DD85B9}.Release|ARM.ActiveCfg = Release|Any CPU
{3200F3AF-5D50-40FD-BB47-92EDB2DD85B9}.Release|ARM.Build.0 = Release|Any CPU
{3200F3AF-5D50-40FD-BB47-92EDB2DD85B9}.Release|ARM64.ActiveCfg = Release|Any CPU
{3200F3AF-5D50-40FD-BB47-92EDB2DD85B9}.Release|ARM64.Build.0 = Release|Any CPU
{3200F3AF-5D50-40FD-BB47-92EDB2DD85B9}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{3200F3AF-5D50-40FD-BB47-92EDB2DD85B9}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{3200F3AF-5D50-40FD-BB47-92EDB2DD85B9}.Release|x64.ActiveCfg = Release|Any CPU
{3200F3AF-5D50-40FD-BB47-92EDB2DD85B9}.Release|x64.Build.0 = Release|Any CPU
{3200F3AF-5D50-40FD-BB47-92EDB2DD85B9}.Release|x86.ActiveCfg = Release|Any CPU
{3200F3AF-5D50-40FD-BB47-92EDB2DD85B9}.Release|x86.Build.0 = Release|Any CPU
{C3AAF4F7-2939-438B-B5E4-9D7B547C1E5E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C3AAF4F7-2939-438B-B5E4-9D7B547C1E5E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C3AAF4F7-2939-438B-B5E4-9D7B547C1E5E}.Debug|ARM.ActiveCfg = Debug|Any CPU
{C3AAF4F7-2939-438B-B5E4-9D7B547C1E5E}.Debug|ARM.Build.0 = Debug|Any CPU
{C3AAF4F7-2939-438B-B5E4-9D7B547C1E5E}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{C3AAF4F7-2939-438B-B5E4-9D7B547C1E5E}.Debug|ARM64.Build.0 = Debug|Any CPU
{C3AAF4F7-2939-438B-B5E4-9D7B547C1E5E}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{C3AAF4F7-2939-438B-B5E4-9D7B547C1E5E}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{C3AAF4F7-2939-438B-B5E4-9D7B547C1E5E}.Debug|x64.ActiveCfg = Debug|Any CPU
{C3AAF4F7-2939-438B-B5E4-9D7B547C1E5E}.Debug|x64.Build.0 = Debug|Any CPU
{C3AAF4F7-2939-438B-B5E4-9D7B547C1E5E}.Debug|x86.ActiveCfg = Debug|Any CPU
{C3AAF4F7-2939-438B-B5E4-9D7B547C1E5E}.Debug|x86.Build.0 = Debug|Any CPU
{C3AAF4F7-2939-438B-B5E4-9D7B547C1E5E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C3AAF4F7-2939-438B-B5E4-9D7B547C1E5E}.Release|Any CPU.Build.0 = Release|Any CPU
{C3AAF4F7-2939-438B-B5E4-9D7B547C1E5E}.Release|ARM.ActiveCfg = Release|Any CPU
{C3AAF4F7-2939-438B-B5E4-9D7B547C1E5E}.Release|ARM.Build.0 = Release|Any CPU
{C3AAF4F7-2939-438B-B5E4-9D7B547C1E5E}.Release|ARM64.ActiveCfg = Release|Any CPU
{C3AAF4F7-2939-438B-B5E4-9D7B547C1E5E}.Release|ARM64.Build.0 = Release|Any CPU
{C3AAF4F7-2939-438B-B5E4-9D7B547C1E5E}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{C3AAF4F7-2939-438B-B5E4-9D7B547C1E5E}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{C3AAF4F7-2939-438B-B5E4-9D7B547C1E5E}.Release|x64.ActiveCfg = Release|Any CPU
{C3AAF4F7-2939-438B-B5E4-9D7B547C1E5E}.Release|x64.Build.0 = Release|Any CPU
{C3AAF4F7-2939-438B-B5E4-9D7B547C1E5E}.Release|x86.ActiveCfg = Release|Any CPU
{C3AAF4F7-2939-438B-B5E4-9D7B547C1E5E}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{43A5D94B-71F9-44A0-B5CA-B8BA2061B220} = {3C95AB92-B731-4D0A-854F-850203047E55}
{100BBE7D-CD80-4DE5-94F3-666D5911537A} = {43A5D94B-71F9-44A0-B5CA-B8BA2061B220}
{9010B8A4-CB52-4EB8-BBD0-855A784D5579} = {43A5D94B-71F9-44A0-B5CA-B8BA2061B220}
{2CA02339-41F8-45BA-BC76-4F5EC23F7C49} = {3C95AB92-B731-4D0A-854F-850203047E55}
{6BC7A7C5-F550-4B6F-9366-386EE7F84AE4} = {2CA02339-41F8-45BA-BC76-4F5EC23F7C49}
{2C8D6879-BAC3-437E-B209-CB693E00F8A9} = {2CA02339-41F8-45BA-BC76-4F5EC23F7C49}
{45690090-D045-43D4-8F51-EA845DA5F95E} = {2CA02339-41F8-45BA-BC76-4F5EC23F7C49}
{6C0FA782-4DDF-4E0D-A80B-E9E84D8041AD} = {3C95AB92-B731-4D0A-854F-850203047E55}
{19F22A39-2E54-40C1-8F5D-FB1AE39DD78B} = {6C0FA782-4DDF-4E0D-A80B-E9E84D8041AD}
{62838905-DF8B-41AE-B7B4-17A9E6E51647} = {6C0FA782-4DDF-4E0D-A80B-E9E84D8041AD}
{60A0817C-D6CD-4C86-A5DF-1E4D18F97E25} = {3C95AB92-B731-4D0A-854F-850203047E55}
{4C5197D3-9080-4F04-9413-C353D5B03640} = {60A0817C-D6CD-4C86-A5DF-1E4D18F97E25}
{33F89AD2-A00E-4F33-B1E1-3DB45E674B24} = {60A0817C-D6CD-4C86-A5DF-1E4D18F97E25}
{DB20E493-39DD-4B90-A709-40A93E10C8CD} = {3C95AB92-B731-4D0A-854F-850203047E55}
{38830DB6-08C8-4F3D-889E-EE59F6BE63D8} = {DB20E493-39DD-4B90-A709-40A93E10C8CD}
{1417753A-BB2A-42C4-A38A-53B0C50591B4} = {DB20E493-39DD-4B90-A709-40A93E10C8CD}
{433AA439-DC1D-47DC-BEE8-7090FAEEAA87} = {9C04D9DA-5D6F-48BB-9D4C-B8D4A328A19F}
{602B0ECB-3E91-4B17-961A-0EBA5C922DA1} = {6C0FA782-4DDF-4E0D-A80B-E9E84D8041AD}
{3200F3AF-5D50-40FD-BB47-92EDB2DD85B9} = {60A0817C-D6CD-4C86-A5DF-1E4D18F97E25}
{C3AAF4F7-2939-438B-B5E4-9D7B547C1E5E} = {DB20E493-39DD-4B90-A709-40A93E10C8CD}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {1D2F3C25-1CB4-4A51-9E97-9A24121445FD}
EndGlobalSection
EndGlobal

@ -0,0 +1,59 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
# ========================================================================
#
# Copyright (C) 2013-2014 MARC CHEVALDONNE
# marc.chevaldonne.free.fr
#
# Module : Morpion.sln
# Author : Marc Chevaldonné
# Creation date : 2014-05-07
#
# ========================================================================
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "giMorpionCore", "giMorpionCore\giMorpionCore.csproj", "{100BBE7D-CD80-4DE5-94F3-666D5911537A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MorpionGame", "MorpionGame\MorpionGame.csproj", "{9010B8A4-CB52-4EB8-BBD0-855A784D5579}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|Mixed Platforms = Debug|Mixed Platforms
Debug|Win32 = Debug|Win32
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|Mixed Platforms = Release|Mixed Platforms
Release|Win32 = Release|Win32
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Debug|Win32.ActiveCfg = Debug|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Debug|x86.ActiveCfg = Debug|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Release|Any CPU.Build.0 = Release|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Release|Win32.ActiveCfg = Release|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Release|x86.ActiveCfg = Release|Any CPU
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Debug|Any CPU.ActiveCfg = Debug|x86
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Debug|Mixed Platforms.Build.0 = Debug|x86
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Debug|Win32.ActiveCfg = Debug|x86
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Debug|x86.ActiveCfg = Debug|x86
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Debug|x86.Build.0 = Debug|x86
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Release|Any CPU.ActiveCfg = Release|x86
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Release|Mixed Platforms.ActiveCfg = Release|x86
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Release|Mixed Platforms.Build.0 = Release|x86
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Release|Win32.ActiveCfg = Release|x86
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Release|x86.ActiveCfg = Release|x86
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<AssemblyName>MorpionGame</AssemblyName>
<OutputType>Exe</OutputType>
<PackageId>MorpionGame</PackageId>
<RuntimeFrameworkVersion>2.2</RuntimeFrameworkVersion>
<PackageTargetFallback>$(PackageTargetFallback);dnxcore50</PackageTargetFallback>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\giMorpionCore\giMorpionCore.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,28 @@
// ========================================================================
//
// Copyright (C) 2013-2014 MARC CHEVALDONNE
// marc.chevaldonne.free.fr
//
// Module : Program.cs
// Author : Marc Chevaldonné
// Creation date : 2014-05-07
//
// ========================================================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using giMorpionCore;
namespace MorpionGame
{
class Program
{
static void Main(string[] args)
{
Game game = new Game();
game.Start();
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

@ -0,0 +1,67 @@
// ========================================================================
//
// Copyright (C) 2013-2014 MARC CHEVALDONNE
// marc.chevaldonne.free.fr
//
// Module : Case.cs
// Author : Marc Chevaldonné
// Creation date : 2014-05-07
//
// ========================================================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace giMorpionCore
{
/// <summary>
/// représente une case du jeu du Morpion
/// </summary>
public struct Case
{
/// <summary>
/// ligne de la case
/// </summary>
public int Line
{
get
{
return mLine;
}
private set
{
mLine = value;
}
}
private int mLine;
/// <summary>
/// colonne de la case
/// </summary>
public int Column
{
get
{
return mColumn;
}
private set
{
mColumn = value;
}
}
private int mColumn;
/// <summary>
/// constructeur
/// </summary>
/// <param name="line">ligne de la case</param>
/// <param name="column">colonne de la case</param>
public Case(int line, int column)
{
mLine = line;
mColumn = column;
}
}
}

@ -0,0 +1,286 @@
// ========================================================================
//
// Copyright (C) 2013-2014 MARC CHEVALDONNE
// marc.chevaldonne.free.fr
//
// Module : Game.cs
// Author : Marc Chevaldonné
// Creation date : 2014-05-07
//
// ========================================================================
using System;
using System.Linq;
/// <summary>
/// contient les classes gérant le fonctionnement du jeu
/// </summary>
namespace giMorpionCore
{
/// <summary>
/// contient les méthodes de base pour le jeu du Morpion : démarrage du jeu, test de fin du jeu, insertion d'une pièce...
/// </summary>
public class Game
{
/// <summary>
/// exception lors de l'insertion de pièces
/// </summary>
public class GameException : Exception
{
public GameException(string message)
: base(message)
{
}
}
/// <summary>
/// grille du morpion
/// </summary>
public int[,] Board
{
get
{
return (int[,])mBoard.Clone();
}
}
/// <seealso cref="Board"/>
private int[,] mBoard = new int[3, 3];
/// <summary>
/// constructeur : crée deux joueurs et initialise la grille à vide
/// </summary>
public Game()
{
mPlayers[0] = new Player(this);
mPlayers[1] = new Player(this);
mBoard = new int[,] { { -1, -1, -1 }, { -1, -1, -1 }, { -1, -1, -1 } };
}
/// <summary>
/// démarre le jeu du Morpion
/// </summary>
public virtual void Start()
{
Console.WriteLine("Game Starts at last !!!");
Display();
int winnerId;
giMorpionCore.Case[] places;
while (!IsGameOver(out winnerId, out places))
{
if (NotifyNextPlayer())
{
ChangeNextPlayer();
}
}
}
/// <summary>
/// insère une pièce
/// </summary>
/// <param name="place">case où la pièce doit être insérée</param>
/// <param name="playerId">joueur insérant la pièce</param>
/// <returns>true si la pièce peut être insérée, false sinon (case en dehors de la grille, ou case déjà occupée)</returns>
protected internal virtual bool InsertPiece(Case place, int playerId)
{
if (place.Line < 0 || place.Line >= 3 || place.Column < 0 || place.Column >= 3)
{
throw new GameException("Les indices de ligne et colonne doivent être compris entre 0 et 2 inclus");
}
if (playerId < 0 || playerId >= 2)
{
throw new GameException("L'indice du joueur doit être compris entre 0 et 1 inclus");
}
if (mBoard[place.Line, place.Column] != -1)
{
return false;
}
mBoard[place.Line, place.Column] = playerId;
System.Threading.Thread.Sleep(mRandom.Next(2000));
return true;
}
/// <summary>
/// met à jour le prochain joueur
/// </summary>
void ChangeNextPlayer()
{
mNextPlayer++;
mNextPlayer %= 2;
}
static Random mRandom = new Random();
/// <summary>
/// teste si la partie est terminée
/// </summary>
/// <param name="winnerId">identifiant du vainqueur (0 ou 1) si la partie est gagnée, -1 en cas d'égalité</param>
/// <param name="places">cases ayant permis au vainqueur de gagner (non significatives si la partie n'est pas terminée ou s'il y a égalité)</param>
/// <returns>true si terminée, false sinon</returns>
protected virtual bool IsGameOver(out int winnerId, out Case[] places)
{
places = new Case[3];
winnerId = -1;
if(CheckLines(ref winnerId, ref places)
|| CheckColumns(ref winnerId, ref places)
|| CheckDiagonals(ref winnerId, ref places))
{
Console.Clear();
Display(places);
Console.WriteLine("Congratulations Player {0} for your victory !", winnerId);
return true;
}
bool isfull = mBoard.Cast<int>().Count(c => c == -1) == 0;
if (isfull)
{
winnerId = -1;
Console.Clear();
Display();
Console.WriteLine("Deuce");
return true;
}
return false;
}
private bool CheckLines(ref int winnerId, ref Case[] places)
{
for (int l = 0; l <= 2; l++)
{
if (mBoard[l, 0] != -1 && mBoard[l, 0] == mBoard[l, 1] && mBoard[l, 0] == mBoard[l, 2])
{
winnerId = mBoard[l, 0];
places[0] = new Case(l, 0);
places[1] = new Case(l, 1);
places[2] = new Case(l, 2);
return true;
}
}
return false;
}
private bool CheckColumns(ref int winnerId, ref Case[] places)
{
for (int c = 0; c <= 2; c++)
{
if (mBoard[0, c] != -1 && mBoard[0, c] == mBoard[1, c] && mBoard[0, c] == mBoard[2, c])
{
winnerId = mBoard[0, c];
places[0] = new Case(0, c);
places[1] = new Case(1, c);
places[2] = new Case(2, c);
return true;
}
}
return false;
}
private bool CheckDiagonals(ref int winnerId, ref Case[] places)
{
if (mBoard[0, 0] != -1 && mBoard[0, 0] == mBoard[1, 1] && mBoard[0, 0] == mBoard[2, 2])
{
winnerId = mBoard[0, 0];
places[0] = new Case(0, 0);
places[1] = new Case(1, 1);
places[2] = new Case(2, 2);
return true;
}
if (mBoard[0, 2] != -1 && mBoard[0, 2] == mBoard[1, 1] && mBoard[2, 0] == mBoard[0, 2])
{
winnerId = mBoard[0, 2];
places[0] = new Case(0, 2);
places[1] = new Case(1, 1);
places[2] = new Case(2, 0);
return true;
}
return false;
}
/// <summary>
/// identifiant du prochain joueur
/// </summary>
protected int NextPlayer
{
get
{
return mNextPlayer;
}
}
/// <seealso cref="NextPlayer"/>
private int mNextPlayer = 0;
/// <summary>
/// joueurs du jeu
/// </summary>
private Player[] mPlayers = new Player[2];
/// <summary>
/// renseigne le prochain joueur qu'il doit joueur et le fait jouer
/// </summary>
/// <returns>rend true si le joueur a pu jouer</returns>
protected virtual bool NotifyNextPlayer()
{
Console.WriteLine("Player {0}, it's your turn !", mNextPlayer);
Case place = mPlayers[mNextPlayer].Play();
bool result = InsertPiece(place, mPlayers[mNextPlayer].Id);
Console.Clear();
Display(place);
return result;
}
/// <summary>
/// affiche la grille du morpion
/// </summary>
/// <param name="highlightedCases">les éventuelles cases à mettre en surbrillance</param>
protected virtual void Display(params giMorpionCore.Case[] highlightedCases)
{
Console.ForegroundColor = ConsoleColor.White;
Console.WriteLine(" 0 1 2 ");
for (int line = 0; line < 3; line++)
{
Console.ForegroundColor = ConsoleColor.White;
Console.Write(" " + line + " ");
for (int column = 0; column < 3; column++)
{
Console.BackgroundColor = ConsoleColor.Cyan;
foreach (giMorpionCore.Case place in highlightedCases)
{
if (place.Line == line && place.Column == column)
{
Console.BackgroundColor = ConsoleColor.Red;
break;
}
}
DisplayCaseContent(line, column);
}
Console.BackgroundColor = ConsoleColor.Black;
Console.WriteLine();
}
Console.ForegroundColor = ConsoleColor.White;
}
/// <summary>
/// affiche le contenu d'une case en fonction du joueur
/// </summary>
/// <param name="line">la ligne de la case à prendre en compte</param>
/// <param name="column">la colonne de la case à prendre en compte</param>
private void DisplayCaseContent(int line, int column)
{
if (mBoard[line, column] == 0)
{
Console.ForegroundColor = ConsoleColor.DarkYellow;
Console.Write(" O ");
return;
}
if (mBoard[line, column] == 1)
{
Console.ForegroundColor = ConsoleColor.DarkBlue;
Console.Write(" X ");
return;
}
Console.Write(" ");
}
}
}

@ -0,0 +1,71 @@
// ========================================================================
//
// Copyright (C) 2013-2014 MARC CHEVALDONNE
// marc.chevaldonne.free.fr
//
// Module : Player.cs
// Author : Marc Chevaldonné
// Creation date : 2014-05-07
//
// ========================================================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace giMorpionCore
{
/// <summary>
/// joueur du Morpion (c'est un joueur automatique qui joue aléatoirement dans une case)
/// </summary>
public class Player
{
/// <summary>
/// compteur statique pour créer un id automatique
/// </summary>
static private int mIdCounter = 0;
/// <summary>
/// identifiant du joueur
/// </summary>
public int Id
{
get;
internal set;
}
/// <summary>
/// constructeur (l'identifant est créé automatiquement et le jeu est relié à ce joueur)
/// </summary>
/// <param name="game">le jeu auquel ce joueur appartient</param>
internal Player(Game game)
{
Id = mIdCounter;
mIdCounter++;
mGame = game;
}
/// <summary>
/// le jeu auquel ce joueur appartient
/// </summary>
internal Game mGame;
/// <summary>
/// méthode permettant au joueur de jouer (choix aléatoire d'une case dans laquelle il va jouer)
/// </summary>
/// <returns>la case dans laquelle il veut jouer</returns>
protected internal Case Play()
{
Random rdm = new Random();
int line = rdm.Next(0,3);
int column = rdm.Next(0,3);
while (mGame.Board[line, column] != -1)
{
line = rdm.Next(0, 3);
column = rdm.Next(0, 3);
}
return new Case(line, column);
}
}
}

@ -0,0 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
</Project>

@ -0,0 +1,73 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
# ========================================================================
#
# Copyright (C) 2013-2014 MARC CHEVALDONNE
# marc.chevaldonne.free.fr
#
# Module : Morpion.sln
# Author : Marc Chevaldonné
# Creation date : 2014-05-07
#
# ========================================================================
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "giMorpionCore", "giMorpionCore\giMorpionCore.csproj", "{100BBE7D-CD80-4DE5-94F3-666D5911537A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MorpionGame", "MorpionGame\MorpionGame.csproj", "{9010B8A4-CB52-4EB8-BBD0-855A784D5579}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MorpionGameWpf", "MorpionGameWpf\MorpionGameWpf.csproj", "{45690090-D045-43D4-8F51-EA845DA5F95E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|Mixed Platforms = Debug|Mixed Platforms
Debug|Win32 = Debug|Win32
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|Mixed Platforms = Release|Mixed Platforms
Release|Win32 = Release|Win32
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Debug|Win32.ActiveCfg = Debug|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Debug|x86.ActiveCfg = Debug|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Release|Any CPU.Build.0 = Release|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Release|Win32.ActiveCfg = Release|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Release|x86.ActiveCfg = Release|Any CPU
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Debug|Any CPU.ActiveCfg = Debug|x86
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Debug|Mixed Platforms.Build.0 = Debug|x86
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Debug|Win32.ActiveCfg = Debug|x86
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Debug|x86.ActiveCfg = Debug|x86
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Debug|x86.Build.0 = Debug|x86
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Release|Any CPU.ActiveCfg = Release|x86
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Release|Mixed Platforms.ActiveCfg = Release|x86
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Release|Mixed Platforms.Build.0 = Release|x86
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Release|Win32.ActiveCfg = Release|x86
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Release|x86.ActiveCfg = Release|x86
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Release|x86.Build.0 = Release|x86
{45690090-D045-43D4-8F51-EA845DA5F95E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{45690090-D045-43D4-8F51-EA845DA5F95E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{45690090-D045-43D4-8F51-EA845DA5F95E}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{45690090-D045-43D4-8F51-EA845DA5F95E}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{45690090-D045-43D4-8F51-EA845DA5F95E}.Debug|Win32.ActiveCfg = Debug|Any CPU
{45690090-D045-43D4-8F51-EA845DA5F95E}.Debug|x86.ActiveCfg = Debug|Any CPU
{45690090-D045-43D4-8F51-EA845DA5F95E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{45690090-D045-43D4-8F51-EA845DA5F95E}.Release|Any CPU.Build.0 = Release|Any CPU
{45690090-D045-43D4-8F51-EA845DA5F95E}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{45690090-D045-43D4-8F51-EA845DA5F95E}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{45690090-D045-43D4-8F51-EA845DA5F95E}.Release|Win32.ActiveCfg = Release|Any CPU
{45690090-D045-43D4-8F51-EA845DA5F95E}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

@ -0,0 +1,132 @@
// ========================================================================
//
// Copyright (C) 2013-2014 MARC CHEVALDONNE
// marc.chevaldonne.free.fr
//
// Module : ConsoleDisplayGame.cs
// Author : Marc Chevaldonné
// Creation date : 2014-05-07
//
// ========================================================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MorpionGame
{
/// <summary>
/// un afficheur du jeu de Morpion en mode Console
/// </summary>
class ConsoleDisplayGame : giMorpionCore.IDisplayGame
{
/// <summary>
/// appelée lorsque le jeu démarre
/// </summary>
/// <param name="game">le jeu de Morpion en cours</param>
public void GameStarted(giMorpionCore.Game game)
{
Console.WriteLine("Game Starts at last !!!");
Display(game);
}
/// <summary>
/// appelée lorsque le jeu se termine
/// </summary>
/// <param name="game">le jeu de Morpion en cours</param>
/// <param name="winnerId">identifiant du vainqueur (-1 si égalité)</param>
/// <param name="winningPlaces">la liste des cases qui lui ont permis de gagner</param>
public void GameOver(giMorpionCore.Game game, int winnerId, giMorpionCore.Case[] winningPlaces)
{
Console.Clear();
if (winnerId == -1)
{
Display(game);
Console.WriteLine("Deuce");
return;
}
Display(game, winningPlaces);
Console.WriteLine("Congratulations Player {0} for your victory !", winnerId);
}
/// <summary>
/// appelée lorsqu'une pièce est insérée
/// </summary>
/// <param name="game">le jeu de Morpion en cours</param>
/// <param name="playerId">identifiant du joueur qui insère une pièce</param>
/// <param name="place">case dans laquelle il a inséré sa pièce</param>
public void PieceInserted(giMorpionCore.Game game, int playerId, giMorpionCore.Case place)
{
Console.Clear();
Display(game, place);
}
/// <summary>
/// appelée lorsqu'on invite un joueur à jouer
/// </summary>
/// <param name="game">le jeu de Morpion en cours</param>
/// <param name="playerId">identifiant du joueur qui doit jouer</param>
public void PlayerNotified(giMorpionCore.Game game, int playerId)
{
Console.WriteLine("Player {0}, it's your turn !", playerId);
}
/// <summary>
/// affiche la grille du jeu de Morpion
/// </summary>
/// <param name="game">le jeu à afficher</param>
/// <param name="highlightedCases">les éventuelles cases à mettre en surbrillance</param>
private static void Display(giMorpionCore.Game game, params giMorpionCore.Case[] highlightedCases)
{
Console.ForegroundColor = ConsoleColor.White;
int[,] board = game.Board;
Console.WriteLine(" 0 1 2 ");
for (int line = 0; line < 3; line++)
{
Console.ForegroundColor = ConsoleColor.White;
Console.Write(" " + line + " ");
for (int column = 0; column < 3; column++)
{
Console.BackgroundColor = ConsoleColor.Cyan;
foreach (giMorpionCore.Case place in highlightedCases)
{
if (place.Line == line && place.Column == column)
{
Console.BackgroundColor = ConsoleColor.Red;
break;
}
}
DisplayCaseContent(board, line, column);
}
Console.BackgroundColor = ConsoleColor.Black;
Console.WriteLine();
}
Console.ForegroundColor = ConsoleColor.White;
}
/// <summary>
/// affiche le contenu d'une case en fonction du joueur
/// </summary>
/// <param name="board">la grille du jeu du Morpion prise en compte</param>
/// <param name="line">la ligne de la case à prendre en compte</param>
/// <param name="column">la colonne de la case à prendre en compte</param>
private static void DisplayCaseContent(int[,] board, int line, int column)
{
if (board[line, column] == 0)
{
Console.ForegroundColor = ConsoleColor.DarkYellow;
Console.Write(" O ");
return;
}
if (board[line, column] == 1)
{
Console.ForegroundColor = ConsoleColor.DarkBlue;
Console.Write(" X ");
return;
}
Console.Write(" ");
}
}
}

@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<AssemblyName>MorpionGame</AssemblyName>
<OutputType>Exe</OutputType>
<PackageId>MorpionGame</PackageId>
<RuntimeFrameworkVersion>2.2</RuntimeFrameworkVersion>
<PackageTargetFallback>$(PackageTargetFallback);dnxcore50</PackageTargetFallback>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\giMorpionCore\giMorpionCore.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,28 @@
// ========================================================================
//
// Copyright (C) 2013-2014 MARC CHEVALDONNE
// marc.chevaldonne.free.fr
//
// Module : Program.cs
// Author : Marc Chevaldonné
// Creation date : 2014-05-07
//
// ========================================================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using giMorpionCore;
namespace MorpionGame
{
class Program
{
static void Main(string[] args)
{
Game game = new Game(new ConsoleDisplayGame());
game.Start();
}
}
}

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- ======================================================================
Copyright (C) 2013-2014 MARC CHEVALDONNE
marc.chevaldonne.free.fr
Module : App.config
Author : Marc Chevaldonné
Creation date : 2014-05-07
======================================================================== -->
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/>
</startup>
</configuration>

@ -0,0 +1,19 @@
<!-- ======================================================================
Copyright (C) 2013-2014 MARC CHEVALDONNE
marc.chevaldonne.free.fr
Module : App.xaml
Author : Marc Chevaldonné
Creation date : 2014-05-07
======================================================================== -->
<Application x:Class="MorpionGameWpf.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>

@ -0,0 +1,28 @@
// ========================================================================
//
// Copyright (C) 2013-2014 MARC CHEVALDONNE
// marc.chevaldonne.free.fr
//
// Module : App.xaml.cs
// Author : Marc Chevaldonné
// Creation date : 2014-05-07
//
// ========================================================================
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
namespace MorpionGameWpf
{
/// <summary>
/// Logique d'interaction pour App.xaml
/// </summary>
public partial class App : Application
{
}
}

@ -0,0 +1,23 @@
<!-- ======================================================================
Copyright (C) 2013-2014 MARC CHEVALDONNE
marc.chevaldonne.free.fr
Module : MainWindow.xaml
Author : Marc Chevaldonné
Creation date : 2014-05-07
======================================================================== -->
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:MorpionGameWpf" x:Class="MorpionGameWpf.MainWindow"
Title="MainWindow" Height="350" Width="525" MouseDown="Window_MouseDown_1">
<DockPanel>
<TextBlock DockPanel.Dock="Top" x:Name="mTextBlockMessages"/>
<local:MorpionGrid x:Name="mGrille"/>
</DockPanel>
</Window>

@ -0,0 +1,86 @@
// ========================================================================
//
// Copyright (C) 2013-2014 MARC CHEVALDONNE
// marc.chevaldonne.free.fr
//
// Module : MainWindow.xaml.cs
// Author : Marc Chevaldonné
// Creation date : 2014-05-07
//
// ========================================================================
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;
using giMorpionCore;
namespace MorpionGameWpf
{
/// <summary>
/// Logique d'interaction pour MainWindow.xaml
/// </summary>
public partial class MainWindow : Window, IDisplayGame
{
Game game;
public MainWindow()
{
InitializeComponent();
game = new Game(this);
mGrille.Game = game;
}
public void GameStarted(Game game)
{
mTextBlockMessages.Text = "Game Starts at last !!!";
mGrille.Update();
this.Dispatcher.Invoke(EmptyDelegate, System.Windows.Threading.DispatcherPriority.ApplicationIdle);
}
public void GameOver(Game game, int winnerId, Case[] winningPlaces)
{
if (winnerId == -1)
{
mGrille.Update();
mTextBlockMessages.Text = "Deuce";
return;
}
mGrille.Update(winningPlaces);
mTextBlockMessages.Text = string.Format("Congratulations Player {0} for your victory !", winnerId);
this.Dispatcher.Invoke(EmptyDelegate, System.Windows.Threading.DispatcherPriority.ApplicationIdle);
}
public void PieceInserted(Game game, int playerId, Case place)
{
mGrille.Update(place);
this.Dispatcher.Invoke(EmptyDelegate, System.Windows.Threading.DispatcherPriority.ApplicationIdle);
}
Action EmptyDelegate = delegate() { };
public void PlayerNotified(Game game, int playerId)
{
mTextBlockMessages.Text = string.Format("Player {0}, it's your turn !", playerId);
this.Dispatcher.Invoke(EmptyDelegate, System.Windows.Threading.DispatcherPriority.ApplicationIdle);
}
private void Window_MouseDown_1(object sender, MouseButtonEventArgs e)
{
game.Start();
}
}
}

@ -0,0 +1,143 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- ======================================================================
Copyright (C) 2013-2014 MARC CHEVALDONNE
marc.chevaldonne.free.fr
Module : MorpionGameWpf.csproj
Author : Marc Chevaldonné
Creation date : 2014-05-07
======================================================================== -->
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{45690090-D045-43D4-8F51-EA845DA5F95E}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>MorpionGameWpf</RootNamespace>
<AssemblyName>MorpionGameWpf</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<StartupObject>MorpionGameWpf.App</StartupObject>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Runtime.InteropServices.RuntimeInformation, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\System.Runtime.InteropServices.RuntimeInformation.4.3.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Page Include="MorpionGrid.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="MorpionGridCase.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Compile Include="MorpionGrid.xaml.cs">
<DependentUpon>MorpionGrid.xaml</DependentUpon>
</Compile>
<Compile Include="MorpionGridCase.xaml.cs">
<DependentUpon>MorpionGridCase.xaml</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<AppDesigner Include="Properties\" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\giMorpionCore\giMorpionCore.csproj">
<Project>{6bc7a7c5-f550-4b6f-9366-386ee7f84ae4}</Project>
<Name>giMorpionCore %281. Morpion\v2_solutionAvecInterfaces\giMorpionCore%29</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

@ -0,0 +1,21 @@
<!-- ======================================================================
Copyright (C) 2013-2014 MARC CHEVALDONNE
marc.chevaldonne.free.fr
Module : MorpionGrid.xaml
Author : Marc Chevaldonné
Creation date : 2014-05-07
======================================================================== -->
<UserControl x:Class="MorpionGameWpf.MorpionGrid"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid Name="mGrid">
</Grid>
</UserControl>

@ -0,0 +1,94 @@
// ========================================================================
//
// Copyright (C) 2013-2014 MARC CHEVALDONNE
// marc.chevaldonne.free.fr
//
// Module : MorpionGrid.xaml.cs
// Author : Marc Chevaldonné
// Creation date : 2014-05-07
//
// ========================================================================
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;
using giMorpionCore;
namespace MorpionGameWpf
{
/// <summary>
/// Logique d'interaction pour MorpionGrid.xaml
/// </summary>
public partial class MorpionGrid : UserControl
{
public MorpionGrid()
{
InitializeComponent();
}
public Game Game
{
get { return (Game)GetValue(GameProperty); }
set { SetValue(GameProperty, value); }
}
// Using a DependencyProperty as the backing store for Game. This enables animation, styling, binding, etc...
public static readonly DependencyProperty GameProperty =
DependencyProperty.Register("Game", typeof(Game), typeof(MorpionGrid));
static Dictionary<int, string> mPlayerSymbols = new Dictionary<int, string>() { {-1, " "}, { 0, "O" }, { 1, "X" } };
public void Update(params Case[] highlightedPlaces)
{
if(Game == null)
{
return;
}
int[,] board = Game.Board;
if (mGrid.RowDefinitions.Count == 0)
{
for (int i = 0; i < board.GetLength(0); i++)
{
mGrid.RowDefinitions.Add(new RowDefinition());
}
for (int i = 0; i < board.GetLength(1); i++)
{
mGrid.ColumnDefinitions.Add(new ColumnDefinition());
}
}
mGrid.Children.Clear();
for (int i = 0; i < board.GetLength(0); i++)
{
for (int j = 0; j < board.GetLength(1); j++)
{
var newCase = new MorpionGridCase() { PlayerId = mPlayerSymbols[board[i,j]]};
if (highlightedPlaces.Cast<Case>().Contains(new Case(i, j)))
{
newCase.BackgroundColor = Brushes.Red;
}
newCase.SetValue(Grid.RowProperty, i);
newCase.SetValue(Grid.ColumnProperty, j);
mGrid.Children.Add(newCase);
}
}
}
}
}

@ -0,0 +1,23 @@
<!-- ======================================================================
Copyright (C) 2013-2014 MARC CHEVALDONNE
marc.chevaldonne.free.fr
Module : MorpionGridCase.xaml
Author : Marc Chevaldonné
Creation date : 2014-05-07
======================================================================== -->
<UserControl x:Class="MorpionGameWpf.MorpionGridCase"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300"
x:Name="root">
<Grid Background="{Binding BackgroundColor, ElementName=root}">
<TextBlock Text="{Binding PlayerId, ElementName=root}" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="30" FontWeight="Bold"/>
</Grid>
</UserControl>

@ -0,0 +1,66 @@
// ========================================================================
//
// Copyright (C) 2013-2014 MARC CHEVALDONNE
// marc.chevaldonne.free.fr
//
// Module : MorpionGridCase.xaml.cs
// Author : Marc Chevaldonné
// Creation date : 2014-05-07
//
// ========================================================================
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 MorpionGameWpf
{
/// <summary>
/// Logique d'interaction pour MorpionGridCase.xaml
/// </summary>
public partial class MorpionGridCase : UserControl
{
public MorpionGridCase()
{
InitializeComponent();
}
public string PlayerId
{
get { return (string)GetValue(PlayerIdProperty); }
set { SetValue(PlayerIdProperty, value); }
}
// Using a DependencyProperty as the backing store for PlayerId. This enables animation, styling, binding, etc...
public static readonly DependencyProperty PlayerIdProperty =
DependencyProperty.Register("PlayerId", typeof(string), typeof(MorpionGridCase), new PropertyMetadata(" "));
public SolidColorBrush BackgroundColor
{
get { return (SolidColorBrush)GetValue(BackgroundColorProperty); }
set { SetValue(BackgroundColorProperty, value); }
}
// Using a DependencyProperty as the backing store for BackgroundColor. This enables animation, styling, binding, etc...
public static readonly DependencyProperty BackgroundColorProperty =
DependencyProperty.Register("BackgroundColor", typeof(SolidColorBrush), typeof(MorpionGridCase), new PropertyMetadata(Brushes.AliceBlue));
}
}

@ -0,0 +1,66 @@
// ========================================================================
//
// Copyright (C) 2013-2014 MARC CHEVALDONNE
// marc.chevaldonne.free.fr
//
// Module : AssemblyInfo.cs
// Author : Marc Chevaldonné
// Creation date : 2014-05-07
//
// ========================================================================
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows;
// Les informations générales relatives à un assembly dépendent de
// l'ensemble d'attributs suivant. Changez les valeurs de ces attributs pour modifier les informations
// associées à un assembly.
[assembly: AssemblyTitle("MorpionGameWpf")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MorpionGameWpf")]
[assembly: AssemblyCopyright("Copyright © 2014")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// L'affectation de la valeur false à ComVisible rend les types invisibles dans cet assembly
// aux composants COM. Si vous devez accéder à un type dans cet assembly à partir de
// COM, affectez la valeur true à l'attribut ComVisible sur ce type.
[assembly: ComVisible(false)]
//Pour commencer à générer des applications localisables, définissez
//<UICulture>CultureYouAreCodingWith</UICulture> dans votre fichier .csproj
//dans <PropertyGroup>. Par exemple, si vous utilisez le français
//dans vos fichiers sources, définissez <UICulture> à fr-FR. Puis, supprimez les marques de commentaire de
//l'attribut NeutralResourceLanguage ci-dessous. Mettez à jour "fr-FR" dans
//la ligne ci-après pour qu'elle corresponde au paramètre UICulture du fichier projet.
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //où se trouvent les dictionnaires de ressources spécifiques à un thème
//(utilisé si une ressource est introuvable dans la page,
// ou dictionnaires de ressources de l'application)
ResourceDictionaryLocation.SourceAssembly //où se trouve le dictionnaire de ressources générique
//(utilisé si une ressource est introuvable dans la page,
// dans l'application ou dans l'un des dictionnaires de ressources spécifiques à un thème)
)]
// Les informations de version pour un assembly se composent des quatre valeurs suivantes :
//
// Version principale
// Version secondaire
// Numéro de build
// Révision
//
// Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut
// en utilisant '*', comme indiqué ci-dessous :
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

@ -0,0 +1,63 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Ce code a été généré par un outil.
// Version du runtime :4.0.30319.42000
//
// Les modifications apportées à ce fichier peuvent provoquer un comportement incorrect et seront perdues si
// le code est régénéré.
// </auto-generated>
//------------------------------------------------------------------------------
namespace MorpionGameWpf.Properties {
using System;
/// <summary>
/// Une classe de ressource fortement typée destinée, entre autres, à la consultation des chaînes localisées.
/// </summary>
// Cette classe a été générée automatiquement par la classe StronglyTypedResourceBuilder
// à l'aide d'un outil, tel que ResGen ou Visual Studio.
// Pour ajouter ou supprimer un membre, modifiez votre fichier .ResX, puis réexécutez ResGen
// avec l'option /str ou régénérez votre projet VS.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Retourne l'instance ResourceManager mise en cache utilisée par cette classe.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MorpionGameWpf.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Remplace la propriété CurrentUICulture du thread actuel pour toutes
/// les recherches de ressources à l'aide de cette classe de ressource fortement typée.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}

@ -0,0 +1,128 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- ======================================================================
Copyright (C) 2013-2014 MARC CHEVALDONNE
marc.chevaldonne.free.fr
Module : Resources.resx
Author : Marc Chevaldonné
Creation date : 2014-05-07
======================================================================== -->
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

@ -0,0 +1,26 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Ce code a été généré par un outil.
// Version du runtime :4.0.30319.42000
//
// Les modifications apportées à ce fichier peuvent provoquer un comportement incorrect et seront perdues si
// le code est régénéré.
// </auto-generated>
//------------------------------------------------------------------------------
namespace MorpionGameWpf.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.1.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
}
}

@ -0,0 +1,18 @@
<?xml version='1.0' encoding='utf-8'?>
<!-- ======================================================================
Copyright (C) 2013-2014 MARC CHEVALDONNE
marc.chevaldonne.free.fr
Module : Settings.settings
Author : Marc Chevaldonné
Creation date : 2014-05-07
======================================================================== -->
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.NETCore.Platforms" version="2.2.2" targetFramework="net472" />
<package id="System.Runtime.InteropServices.RuntimeInformation" version="4.3.0" targetFramework="net45" />
</packages>

Binary file not shown.

After

Width:  |  Height:  |  Size: 62 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

@ -0,0 +1,67 @@
// ========================================================================
//
// Copyright (C) 2013-2014 MARC CHEVALDONNE
// marc.chevaldonne.free.fr
//
// Module : Case.cs
// Author : Marc Chevaldonné
// Creation date : 2014-05-07
//
// ========================================================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace giMorpionCore
{
/// <summary>
/// représente une case du jeu du Morpion
/// </summary>
public struct Case
{
/// <summary>
/// ligne de la case
/// </summary>
public int Line
{
get
{
return mLine;
}
private set
{
mLine = value;
}
}
private int mLine;
/// <summary>
/// colonne de la case
/// </summary>
public int Column
{
get
{
return mColumn;
}
private set
{
mColumn = value;
}
}
private int mColumn;
/// <summary>
/// constructeur
/// </summary>
/// <param name="line">ligne de la case</param>
/// <param name="column">colonne de la case</param>
public Case(int line, int column)
{
mLine = line;
mColumn = column;
}
}
}

@ -0,0 +1,236 @@
// ========================================================================
//
// Copyright (C) 2013-2014 MARC CHEVALDONNE
// marc.chevaldonne.free.fr
//
// Module : Game.cs
// Author : Marc Chevaldonné
// Creation date : 2014-05-07
//
// ========================================================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
/// <summary>
/// contient les classes gérant le fonctionnement du jeu
/// </summary>
namespace giMorpionCore
{
/// <summary>
/// contient les méthodes de base pour le jeu du Morpion : démarrage du jeu, test de fin du jeu, insertion d'une pièce...
/// </summary>
public class Game
{
/// <summary>
/// exception lors de l'insertion de pièces
/// </summary>
public class GameException : Exception
{
public GameException(string message)
: base(message)
{
}
}
/// <summary>
/// grille du morpion
/// </summary>
public int[,] Board
{
get
{
return (int[,])mBoard.Clone();
}
}
/// <seealso cref="Board"/>
private int[,] mBoard = new int[3, 3];
/// <summary>
/// le responsable de l'affichage du jeu
/// </summary>
IDisplayGame mDisplayer;
/// <summary>
/// constructeur : crée deux joueurs et initialise la grille à vide
/// </summary>
public Game(IDisplayGame displayer)
{
mDisplayer = displayer;
mPlayers[0] = new Player(this);
mPlayers[1] = new Player(this);
mBoard = new int[,] { { -1, -1, -1 }, { -1, -1, -1 }, { -1, -1, -1 } };
}
/// <summary>
/// démarre le jeu du Morpion (renseigne le premier joueur que c'est à lui de joueur en appelant NotifyNextPlayer)
/// </summary>
public virtual void Start()
{
mDisplayer.GameStarted(this);
int winnerId;
giMorpionCore.Case[] places;
while (!IsGameOver(out winnerId, out places))
{
if (NotifyNextPlayer())
{
ChangeNextPlayer();
}
}
}
/// <summary>
/// insère une pièce
/// </summary>
/// <param name="place">case où la pièce doit être insérée</param>
/// <param name="playerId">joueur insérant la pièce</param>
/// <returns>true si la pièce peut être insérée, false sinon (case en dehors de la grille, ou case déjà occupée)</returns>
/// <remarks>si la pièce peut être insérée, cette méthode désigne le prochain joueur</remarks>
protected internal virtual bool InsertPiece(Case place, int playerId)
{
if (place.Line < 0 || place.Line >= 3 || place.Column < 0 || place.Column >= 3)
{
throw new GameException("Les indices de ligne et colonne doivent être compris entre 0 et 2 inclus");
}
if (playerId < 0 || playerId >= 2)
{
throw new GameException("L'indice du joueur doit être compris entre 0 et 1 inclus");
}
if (mBoard[place.Line, place.Column] != -1)
{
return false;
}
mBoard[place.Line, place.Column] = playerId;
System.Threading.Thread.Sleep(mRandom.Next(2000));
return true;
}
/// <summary>
/// met à jour le prochain joueur
/// </summary>
void ChangeNextPlayer()
{
mNextPlayer++;
mNextPlayer %= 2;
}
static Random mRandom = new Random();
/// <summary>
/// teste si la partie est terminée
/// </summary>
/// <param name="winnerId">identifiant du vainqueur (0 ou 1) si la partie est gagnée, -1 en cas d'égalité</param>
/// <param name="places">cases ayant permis au vainqueur de gagner (non significatives si la partie n'est pas terminée ou s'il y a égalité)</param>
/// <returns>true si terminée, false sinon</returns>
protected virtual bool IsGameOver(out int winnerId, out Case[] places)
{
places = new Case[3];
winnerId = -1;
if(CheckLines(ref winnerId, ref places)
|| CheckColumns(ref winnerId, ref places)
|| CheckDiagonals(ref winnerId, ref places))
{
mDisplayer.GameOver(this, winnerId, places);
return true;
}
bool isfull = mBoard.Cast<int>().Count(c => c == -1) == 0;
if (isfull)
{
mDisplayer.GameOver(this, -1, null);
return true;
}
return false;
}
private bool CheckLines(ref int winnerId, ref Case[] places)
{
for (int l = 0; l <= 2; l++)
{
if (mBoard[l, 0] != -1 && mBoard[l, 0] == mBoard[l, 1] && mBoard[l, 0] == mBoard[l, 2])
{
winnerId = mBoard[l, 0];
places[0] = new Case(l, 0);
places[1] = new Case(l, 1);
places[2] = new Case(l, 2);
return true;
}
}
return false;
}
private bool CheckColumns(ref int winnerId, ref Case[] places)
{
for (int c = 0; c <= 2; c++)
{
if (mBoard[0, c] != -1 && mBoard[0, c] == mBoard[1, c] && mBoard[0, c] == mBoard[2, c])
{
winnerId = mBoard[0, c];
places[0] = new Case(0, c);
places[1] = new Case(1, c);
places[2] = new Case(2, c);
return true;
}
}
return false;
}
private bool CheckDiagonals(ref int winnerId, ref Case[] places)
{
if (mBoard[0, 0] != -1 && mBoard[0, 0] == mBoard[1, 1] && mBoard[0, 0] == mBoard[2, 2])
{
winnerId = mBoard[0, 0];
places[0] = new Case(0, 0);
places[1] = new Case(1, 1);
places[2] = new Case(2, 2);
return true;
}
if (mBoard[0, 2] != -1 && mBoard[0, 2] == mBoard[1, 1] && mBoard[2, 0] == mBoard[0, 2])
{
winnerId = mBoard[0, 2];
places[0] = new Case(0, 2);
places[1] = new Case(1, 1);
places[2] = new Case(2, 0);
return true;
}
return false;
}
/// <summary>
/// identifiant du prochain joueur
/// </summary>
protected int NextPlayer
{
get
{
return mNextPlayer;
}
}
/// <seealso cref="NextPlayer"/>
private int mNextPlayer = 0;
/// <summary>
/// joueurs du jeu
/// </summary>
private Player[] mPlayers = new Player[2];
/// <summary>
/// renseigne le prochain joueur qu'il doit joueur et le fait jouer
/// </summary>
/// <returns>rend true si le joueur a pu jouer</returns>
protected virtual bool NotifyNextPlayer()
{
mDisplayer.PlayerNotified(this, mNextPlayer);
Case place = mPlayers[mNextPlayer].Play();
bool result = InsertPiece(place, mPlayers[mNextPlayer].Id);
mDisplayer.PieceInserted(this, mPlayers[mNextPlayer].Id, place);
return result;
}
}
}

@ -0,0 +1,53 @@
// ========================================================================
//
// Copyright (C) 2013-2014 MARC CHEVALDONNE
// marc.chevaldonne.free.fr
//
// Module : IDisplayGame.cs
// Author : Marc Chevaldonné
// Creation date : 2014-05-07
//
// ========================================================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace giMorpionCore
{
/// <summary>
/// un afficheur du jeu de Morpion
/// </summary>
public interface IDisplayGame
{
/// <summary>
/// appelée lorsque le jeu démarre
/// </summary>
/// <param name="game">le jeu de Morpion en cours</param>
void GameStarted(Game game);
/// <summary>
/// appelée lorsque le jeu se termine
/// </summary>
/// <param name="game">le jeu de Morpion en cours</param>
/// <param name="winnerId">identifiant du vainqueur (-1 si égalité)</param>
/// <param name="winningPlaces">la liste des cases qui lui ont permis de gagner</param>
void GameOver(Game game, int winnerId, Case[] winningPlaces);
/// <summary>
/// appelée lorsqu'une pièce est insérée
/// </summary>
/// <param name="game">le jeu de Morpion en cours</param>
/// <param name="playerId">identifiant du joueur qui insère une pièce</param>
/// <param name="place">case dans laquelle il a inséré sa pièce</param>
void PieceInserted(Game game, int playerId, Case place);
/// <summary>
/// appelée lorsqu'on invite un joueur à jouer
/// </summary>
/// <param name="game">le jeu de Morpion en cours</param>
/// <param name="playerId">identifiant du joueur qui doit jouer</param>
void PlayerNotified(Game game, int playerId);
}
}

@ -0,0 +1,71 @@
// ========================================================================
//
// Copyright (C) 2013-2014 MARC CHEVALDONNE
// marc.chevaldonne.free.fr
//
// Module : Player.cs
// Author : Marc Chevaldonné
// Creation date : 2014-05-07
//
// ========================================================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace giMorpionCore
{
/// <summary>
/// joueur du Morpion (c'est un joueur automatique qui joue aléatoirement dans une case)
/// </summary>
public class Player
{
/// <summary>
/// compteur statique pour créer un id automatique
/// </summary>
static private int mIdCounter = 0;
/// <summary>
/// identifiant du joueur
/// </summary>
public int Id
{
get;
internal set;
}
/// <summary>
/// constructeur (l'identifant est créé automatiquement et le jeu est relié à ce joueur)
/// </summary>
/// <param name="game">le jeu auquel ce joueur appartient</param>
internal Player(Game game)
{
Id = mIdCounter;
mIdCounter++;
mGame = game;
}
/// <summary>
/// le jeu auquel ce joueur appartient
/// </summary>
internal Game mGame;
/// <summary>
/// méthode permettant au joueur de jouer (choix aléatoire d'une case dans laquelle il va jouer)
/// </summary>
/// <returns>la case dans laquelle il veut jouer</returns>
protected internal Case Play()
{
Random rdm = new Random();
int line = rdm.Next(0, 3);
int column = rdm.Next(0, 3);
while (mGame.Board[line, column] != -1)
{
line = rdm.Next(0, 3);
column = rdm.Next(0, 3);
}
return new Case(line, column);
}
}
}

@ -0,0 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
</Project>

@ -0,0 +1,73 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
# ========================================================================
#
# Copyright (C) 2013-2014 MARC CHEVALDONNE
# marc.chevaldonne.free.fr
#
# Module : Morpion.sln
# Author : Marc Chevaldonné
# Creation date : 2014-05-07
#
# ========================================================================
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "giMorpionCore", "giMorpionCore\giMorpionCore.csproj", "{100BBE7D-CD80-4DE5-94F3-666D5911537A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MorpionGame", "MorpionGame\MorpionGame.csproj", "{9010B8A4-CB52-4EB8-BBD0-855A784D5579}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MorpionGameWpf", "MorpionGameWpf\MorpionGameWpf.csproj", "{45690090-D045-43D4-8F51-EA845DA5F95E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|Mixed Platforms = Debug|Mixed Platforms
Debug|Win32 = Debug|Win32
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|Mixed Platforms = Release|Mixed Platforms
Release|Win32 = Release|Win32
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Debug|Win32.ActiveCfg = Debug|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Debug|x86.ActiveCfg = Debug|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Release|Any CPU.Build.0 = Release|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Release|Win32.ActiveCfg = Release|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Release|x86.ActiveCfg = Release|Any CPU
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Debug|Any CPU.ActiveCfg = Debug|x86
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Debug|Mixed Platforms.Build.0 = Debug|x86
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Debug|Win32.ActiveCfg = Debug|x86
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Debug|x86.ActiveCfg = Debug|x86
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Debug|x86.Build.0 = Debug|x86
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Release|Any CPU.ActiveCfg = Release|x86
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Release|Mixed Platforms.ActiveCfg = Release|x86
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Release|Mixed Platforms.Build.0 = Release|x86
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Release|Win32.ActiveCfg = Release|x86
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Release|x86.ActiveCfg = Release|x86
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Release|x86.Build.0 = Release|x86
{45690090-D045-43D4-8F51-EA845DA5F95E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{45690090-D045-43D4-8F51-EA845DA5F95E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{45690090-D045-43D4-8F51-EA845DA5F95E}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{45690090-D045-43D4-8F51-EA845DA5F95E}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{45690090-D045-43D4-8F51-EA845DA5F95E}.Debug|Win32.ActiveCfg = Debug|Any CPU
{45690090-D045-43D4-8F51-EA845DA5F95E}.Debug|x86.ActiveCfg = Debug|Any CPU
{45690090-D045-43D4-8F51-EA845DA5F95E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{45690090-D045-43D4-8F51-EA845DA5F95E}.Release|Any CPU.Build.0 = Release|Any CPU
{45690090-D045-43D4-8F51-EA845DA5F95E}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{45690090-D045-43D4-8F51-EA845DA5F95E}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{45690090-D045-43D4-8F51-EA845DA5F95E}.Release|Win32.ActiveCfg = Release|Any CPU
{45690090-D045-43D4-8F51-EA845DA5F95E}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<AssemblyName>MorpionGame</AssemblyName>
<OutputType>Exe</OutputType>
<PackageId>MorpionGame</PackageId>
<RuntimeFrameworkVersion>2.2</RuntimeFrameworkVersion>
<PackageTargetFallback>$(PackageTargetFallback);dnxcore50</PackageTargetFallback>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\giMorpionCore\giMorpionCore.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,106 @@
// ========================================================================
//
// Copyright (C) 2013-2014 MARC CHEVALDONNE
// marc.chevaldonne.free.fr
//
// Module : Program.cs
// Author : Marc Chevaldonné
// Creation date : 2014-05-07
//
// ========================================================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using giMorpionCore;
namespace MorpionGame
{
class Program
{
static void Main(string[] args)
{
Game game = new Game();
game.OnGameStarted += new Game.GameStarted((Game g) =>
{
Console.WriteLine("Game Starts at last !!!");
Display(g);
});
game.OnGameOver += OnGameOver;
game.OnPieceInserted += (g, playerId, place) => Console.Clear();
game.OnPieceInserted += (Game g, int playerId, Case place) => Display(g, place);
game.OnPlayerNotified += (Game g, int playerId) => Console.WriteLine("Player {0}, it's your turn !", playerId);
game.Start();
}
private static void OnGameOver(Game game, int winnerId, Case[] winningPlaces)
{
Console.Clear();
if (winnerId == -1)
{
Display(game);
Console.WriteLine("Deuce");
return;
}
Display(game, winningPlaces);
Console.WriteLine("Congratulations Player {0} for your victory !", winnerId);
}
private static void Display(giMorpionCore.Game game, params giMorpionCore.Case[] highlightedCases)
{
Console.ForegroundColor = ConsoleColor.White;
int[,] board = game.Board;
Console.WriteLine(" 0 1 2 ");
for (int line = 0; line < 3; line++)
{
Console.ForegroundColor = ConsoleColor.White;
Console.Write(" " + line + " ");
for (int column = 0; column < 3; column++)
{
Console.BackgroundColor = ConsoleColor.Cyan;
foreach (giMorpionCore.Case place in highlightedCases)
{
if (place.Line == line && place.Column == column)
{
Console.BackgroundColor = ConsoleColor.Red;
break;
}
}
DisplayCaseContent(board, line, column);
}
Console.BackgroundColor = ConsoleColor.Black;
Console.WriteLine();
}
Console.ForegroundColor = ConsoleColor.White;
}
/// <summary>
/// affiche le contenu d'une case en fonction du joueur
/// </summary>
/// <param name="board">la grille du jeu du Morpion prise en compte</param>
/// <param name="line">la ligne de la case à prendre en compte</param>
/// <param name="column">la colonne de la case à prendre en compte</param>
private static void DisplayCaseContent(int[,] board, int line, int column)
{
if (board[line, column] == 0)
{
Console.ForegroundColor = ConsoleColor.DarkYellow;
Console.Write(" O ");
return;
}
if (board[line, column] == 1)
{
Console.ForegroundColor = ConsoleColor.DarkBlue;
Console.Write(" X ");
return;
}
Console.Write(" ");
}
}
}

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- ======================================================================
Copyright (C) 2013-2014 MARC CHEVALDONNE
marc.chevaldonne.free.fr
Module : App.config
Author : Marc Chevaldonné
Creation date : 2014-05-07
======================================================================== -->
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>

@ -0,0 +1,19 @@
<!-- ======================================================================
Copyright (C) 2013-2014 MARC CHEVALDONNE
marc.chevaldonne.free.fr
Module : App.xaml
Author : Marc Chevaldonné
Creation date : 2014-05-07
======================================================================== -->
<Application x:Class="MorpionGameWpf.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>

@ -0,0 +1,28 @@
// ========================================================================
//
// Copyright (C) 2013-2014 MARC CHEVALDONNE
// marc.chevaldonne.free.fr
//
// Module : App.xaml.cs
// Author : Marc Chevaldonné
// Creation date : 2014-05-07
//
// ========================================================================
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
namespace MorpionGameWpf
{
/// <summary>
/// Logique d'interaction pour App.xaml
/// </summary>
public partial class App : Application
{
}
}

@ -0,0 +1,23 @@
<!-- ======================================================================
Copyright (C) 2013-2014 MARC CHEVALDONNE
marc.chevaldonne.free.fr
Module : MainWindow.xaml
Author : Marc Chevaldonné
Creation date : 2014-05-07
======================================================================== -->
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:MorpionGameWpf" x:Class="MorpionGameWpf.MainWindow"
Title="MainWindow" Height="350" Width="525" MouseDown="Window_MouseDown_1">
<DockPanel>
<TextBlock DockPanel.Dock="Top" x:Name="mTextBlockMessages"/>
<local:MorpionGrid x:Name="mGrille"/>
</DockPanel>
</Window>

@ -0,0 +1,87 @@
// ========================================================================
//
// Copyright (C) 2013-2014 MARC CHEVALDONNE
// marc.chevaldonne.free.fr
//
// Module : MainWindow.xaml.cs
// Author : Marc Chevaldonné
// Creation date : 2014-05-07
//
// ========================================================================
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;
using giMorpionCore;
namespace MorpionGameWpf
{
/// <summary>
/// Logique d'interaction pour MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
Game game;
public MainWindow()
{
InitializeComponent();
game = new Game();
game.OnGameStarted += (Game g) =>
{
mTextBlockMessages.Text = "Game Starts at last !!!";
mGrille.Update();
this.Dispatcher.Invoke(EmptyDelegate, System.Windows.Threading.DispatcherPriority.ApplicationIdle);
};
game.OnGameOver += (Game g, int winnerId, Case[] winningPlaces) =>
{
if (winnerId == -1)
{
mGrille.Update();
mTextBlockMessages.Text = "Deuce";
return;
}
mGrille.Update(winningPlaces);
mTextBlockMessages.Text = string.Format("Congratulations Player {0} for your victory !", winnerId);
this.Dispatcher.Invoke(EmptyDelegate, System.Windows.Threading.DispatcherPriority.ApplicationIdle);
};
game.OnPieceInserted += (Game g, int playerId, Case place) =>
{
mGrille.Update(place);
this.Dispatcher.Invoke(EmptyDelegate, System.Windows.Threading.DispatcherPriority.ApplicationIdle);
};
game.OnPlayerNotified += (Game g, int playerId) =>
{
mTextBlockMessages.Text = string.Format("Player {0}, it's your turn !", playerId);
this.Dispatcher.Invoke(EmptyDelegate, System.Windows.Threading.DispatcherPriority.ApplicationIdle);
};
mGrille.Game = game;
}
Action EmptyDelegate = delegate() { };
private void Window_MouseDown_1(object sender, MouseButtonEventArgs e)
{
game.Start();
}
}
}

@ -0,0 +1,131 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- ======================================================================
Copyright (C) 2013-2014 MARC CHEVALDONNE
marc.chevaldonne.free.fr
Module : MorpionGameWpf.csproj
Author : Marc Chevaldonné
Creation date : 2014-05-07
======================================================================== -->
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{602B0ECB-3E91-4B17-961A-0EBA5C922DA1}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>MorpionGameWpf</RootNamespace>
<AssemblyName>MorpionGameWpf</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
</Compile>
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
</Compile>
<Page Include="MorpionGrid.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="MorpionGridCase.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Compile Include="MorpionGrid.xaml.cs">
<DependentUpon>MorpionGrid.xaml</DependentUpon>
</Compile>
<Compile Include="MorpionGridCase.xaml.cs">
<DependentUpon>MorpionGridCase.xaml</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<AppDesigner Include="Properties\" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\giMorpionCore\giMorpionCore.csproj">
<Project>{19f22a39-2e54-40c1-8f5d-fb1ae39dd78b}</Project>
<Name>giMorpionCore %281. Morpion\v3_solutionAvecDélégués\giMorpionCore%29</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

@ -0,0 +1,21 @@
<!-- ======================================================================
Copyright (C) 2013-2014 MARC CHEVALDONNE
marc.chevaldonne.free.fr
Module : MorpionGrid.xaml
Author : Marc Chevaldonné
Creation date : 2014-05-07
======================================================================== -->
<UserControl x:Class="MorpionGameWpf.MorpionGrid"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid Name="mGrid">
</Grid>
</UserControl>

@ -0,0 +1,94 @@
// ========================================================================
//
// Copyright (C) 2013-2014 MARC CHEVALDONNE
// marc.chevaldonne.free.fr
//
// Module : MorpionGrid.xaml.cs
// Author : Marc Chevaldonné
// Creation date : 2014-05-07
//
// ========================================================================
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;
using giMorpionCore;
namespace MorpionGameWpf
{
/// <summary>
/// Logique d'interaction pour MorpionGrid.xaml
/// </summary>
public partial class MorpionGrid : UserControl
{
public MorpionGrid()
{
InitializeComponent();
}
public Game Game
{
get { return (Game)GetValue(GameProperty); }
set { SetValue(GameProperty, value); }
}
// Using a DependencyProperty as the backing store for Game. This enables animation, styling, binding, etc...
public static readonly DependencyProperty GameProperty =
DependencyProperty.Register("Game", typeof(Game), typeof(MorpionGrid));
static Dictionary<int, string> mPlayerSymbols = new Dictionary<int, string>() { {-1, " "}, { 0, "O" }, { 1, "X" } };
public void Update(params Case[] winningPlaces)
{
if(Game == null)
{
return;
}
int[,] board = Game.Board;
if (mGrid.RowDefinitions.Count == 0)
{
for (int i = 0; i < board.GetLength(0); i++)
{
mGrid.RowDefinitions.Add(new RowDefinition());
}
for (int i = 0; i < board.GetLength(1); i++)
{
mGrid.ColumnDefinitions.Add(new ColumnDefinition());
}
}
mGrid.Children.Clear();
for (int i = 0; i < board.GetLength(0); i++)
{
for (int j = 0; j < board.GetLength(1); j++)
{
var newCase = new MorpionGridCase() { PlayerId = mPlayerSymbols[board[i,j]]};
if (winningPlaces.Cast<Case>().Contains(new Case(i, j)))
{
newCase.BackgroundColor = Brushes.Red;
}
newCase.SetValue(Grid.RowProperty, i);
newCase.SetValue(Grid.ColumnProperty, j);
mGrid.Children.Add(newCase);
}
}
}
}
}

@ -0,0 +1,23 @@
<!-- ======================================================================
Copyright (C) 2013-2014 MARC CHEVALDONNE
marc.chevaldonne.free.fr
Module : MorpionGridCase.xaml
Author : Marc Chevaldonné
Creation date : 2014-05-07
======================================================================== -->
<UserControl x:Class="MorpionGameWpf.MorpionGridCase"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300"
x:Name="root">
<Grid Background="{Binding BackgroundColor, ElementName=root}">
<TextBlock Text="{Binding PlayerId, ElementName=root}" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="30" FontWeight="Bold"/>
</Grid>
</UserControl>

@ -0,0 +1,66 @@
// ========================================================================
//
// Copyright (C) 2013-2014 MARC CHEVALDONNE
// marc.chevaldonne.free.fr
//
// Module : MorpionGridCase.xaml.cs
// Author : Marc Chevaldonné
// Creation date : 2014-05-07
//
// ========================================================================
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 MorpionGameWpf
{
/// <summary>
/// Logique d'interaction pour MorpionGridCase.xaml
/// </summary>
public partial class MorpionGridCase : UserControl
{
public MorpionGridCase()
{
InitializeComponent();
}
public string PlayerId
{
get { return (string)GetValue(PlayerIdProperty); }
set { SetValue(PlayerIdProperty, value); }
}
// Using a DependencyProperty as the backing store for PlayerId. This enables animation, styling, binding, etc...
public static readonly DependencyProperty PlayerIdProperty =
DependencyProperty.Register("PlayerId", typeof(string), typeof(MorpionGridCase), new PropertyMetadata(" "));
public SolidColorBrush BackgroundColor
{
get { return (SolidColorBrush)GetValue(BackgroundColorProperty); }
set { SetValue(BackgroundColorProperty, value); }
}
// Using a DependencyProperty as the backing store for BackgroundColor. This enables animation, styling, binding, etc...
public static readonly DependencyProperty BackgroundColorProperty =
DependencyProperty.Register("BackgroundColor", typeof(SolidColorBrush), typeof(MorpionGridCase), new PropertyMetadata(Brushes.AliceBlue));
}
}

@ -0,0 +1,66 @@
// ========================================================================
//
// Copyright (C) 2013-2014 MARC CHEVALDONNE
// marc.chevaldonne.free.fr
//
// Module : AssemblyInfo.cs
// Author : Marc Chevaldonné
// Creation date : 2014-05-07
//
// ========================================================================
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows;
// Les informations générales relatives à un assembly dépendent de
// l'ensemble d'attributs suivant. Changez les valeurs de ces attributs pour modifier les informations
// associées à un assembly.
[assembly: AssemblyTitle("MorpionGameWpf")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MorpionGameWpf")]
[assembly: AssemblyCopyright("Copyright © 2014")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// L'affectation de la valeur false à ComVisible rend les types invisibles dans cet assembly
// aux composants COM. Si vous devez accéder à un type dans cet assembly à partir de
// COM, affectez la valeur true à l'attribut ComVisible sur ce type.
[assembly: ComVisible(false)]
//Pour commencer à générer des applications localisables, définissez
//<UICulture>CultureYouAreCodingWith</UICulture> dans votre fichier .csproj
//dans <PropertyGroup>. Par exemple, si vous utilisez le français
//dans vos fichiers sources, définissez <UICulture> à fr-FR. Puis, supprimez les marques de commentaire de
//l'attribut NeutralResourceLanguage ci-dessous. Mettez à jour "fr-FR" dans
//la ligne ci-après pour qu'elle corresponde au paramètre UICulture du fichier projet.
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //où se trouvent les dictionnaires de ressources spécifiques à un thème
//(utilisé si une ressource est introuvable dans la page,
// ou dictionnaires de ressources de l'application)
ResourceDictionaryLocation.SourceAssembly //où se trouve le dictionnaire de ressources générique
//(utilisé si une ressource est introuvable dans la page,
// dans l'application ou dans l'un des dictionnaires de ressources spécifiques à un thème)
)]
// Les informations de version pour un assembly se composent des quatre valeurs suivantes :
//
// Version principale
// Version secondaire
// Numéro de build
// Révision
//
// Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut
// en utilisant '*', comme indiqué ci-dessous :
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

@ -0,0 +1,63 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Ce code a été généré par un outil.
// Version du runtime :4.0.30319.42000
//
// Les modifications apportées à ce fichier peuvent provoquer un comportement incorrect et seront perdues si
// le code est régénéré.
// </auto-generated>
//------------------------------------------------------------------------------
namespace MorpionGameWpf.Properties {
using System;
/// <summary>
/// Une classe de ressource fortement typée destinée, entre autres, à la consultation des chaînes localisées.
/// </summary>
// Cette classe a été générée automatiquement par la classe StronglyTypedResourceBuilder
// à l'aide d'un outil, tel que ResGen ou Visual Studio.
// Pour ajouter ou supprimer un membre, modifiez votre fichier .ResX, puis réexécutez ResGen
// avec l'option /str ou régénérez votre projet VS.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Retourne l'instance ResourceManager mise en cache utilisée par cette classe.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MorpionGameWpf.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Remplace la propriété CurrentUICulture du thread actuel pour toutes
/// les recherches de ressources à l'aide de cette classe de ressource fortement typée.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}

@ -0,0 +1,128 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- ======================================================================
Copyright (C) 2013-2014 MARC CHEVALDONNE
marc.chevaldonne.free.fr
Module : Resources.resx
Author : Marc Chevaldonné
Creation date : 2014-05-07
======================================================================== -->
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

@ -0,0 +1,26 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Ce code a été généré par un outil.
// Version du runtime :4.0.30319.42000
//
// Les modifications apportées à ce fichier peuvent provoquer un comportement incorrect et seront perdues si
// le code est régénéré.
// </auto-generated>
//------------------------------------------------------------------------------
namespace MorpionGameWpf.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.1.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
}
}

@ -0,0 +1,18 @@
<?xml version='1.0' encoding='utf-8'?>
<!-- ======================================================================
Copyright (C) 2013-2014 MARC CHEVALDONNE
marc.chevaldonne.free.fr
Module : Settings.settings
Author : Marc Chevaldonné
Creation date : 2014-05-07
======================================================================== -->
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

@ -0,0 +1,67 @@
// ========================================================================
//
// Copyright (C) 2013-2014 MARC CHEVALDONNE
// marc.chevaldonne.free.fr
//
// Module : Case.cs
// Author : Marc Chevaldonné
// Creation date : 2014-05-07
//
// ========================================================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace giMorpionCore
{
/// <summary>
/// représente une case du jeu du Morpion
/// </summary>
public struct Case
{
/// <summary>
/// ligne de la case
/// </summary>
public int Line
{
get
{
return mLine;
}
private set
{
mLine = value;
}
}
private int mLine;
/// <summary>
/// colonne de la case
/// </summary>
public int Column
{
get
{
return mColumn;
}
private set
{
mColumn = value;
}
}
private int mColumn;
/// <summary>
/// constructeur
/// </summary>
/// <param name="line">ligne de la case</param>
/// <param name="column">colonne de la case</param>
public Case(int line, int column)
{
mLine = line;
mColumn = column;
}
}
}

@ -0,0 +1,257 @@
// ========================================================================
//
// Copyright (C) 2013-2014 MARC CHEVALDONNE
// marc.chevaldonne.free.fr
//
// Module : Game.cs
// Author : Marc Chevaldonné
// Creation date : 2014-05-07
//
// ========================================================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
/// <summary>
/// contient les classes gérant le fonctionnement du jeu
/// </summary>
namespace giMorpionCore
{
/// <summary>
/// contient les méthodes de base pour le jeu du Morpion : démarrage du jeu, test de fin du jeu, insertion d'une pièce...
/// </summary>
public class Game
{
/// <summary>
/// exception lors de l'insertion de pièces
/// </summary>
public class GameException : Exception
{
public GameException(string message)
: base(message)
{
}
}
/// <summary>
/// grille du morpion
/// </summary>
public int[,] Board
{
get
{
return (int[,])mBoard.Clone();
}
}
/// <seealso cref="Board"/>
private int[,] mBoard = new int[3, 3];
public delegate void GameStarted(Game game);
public delegate void GameOver(Game game, int winnerId, Case[] winningPlaces);
public delegate void PieceInserted(Game game, int playerId, Case place);
public delegate void PlayerNotified(Game game, int playerId);
public GameStarted OnGameStarted;
public GameOver OnGameOver;
public PieceInserted OnPieceInserted;
public PlayerNotified OnPlayerNotified;
/// <summary>
/// constructeur : crée deux joueurs et initialise la grille à vide
/// </summary>
public Game()
{
mPlayers[0] = new Player(this);
mPlayers[1] = new Player(this);
mBoard = new int[,] { { -1, -1, -1 }, { -1, -1, -1 }, { -1, -1, -1 } };
}
/// <summary>
/// démarre le jeu du Morpion
/// </summary>
public virtual void Start()
{
if (OnGameStarted != null)
{
OnGameStarted(this);
}
int winnerId;
giMorpionCore.Case[] places;
while (!IsGameOver(out winnerId, out places))
{
if (NotifyNextPlayer())
{
ChangeNextPlayer();
}
}
}
/// <summary>
/// insère une pièce
/// </summary>
/// <param name="place">case où la pièce doit être insérée</param>
/// <param name="playerId">joueur insérant la pièce</param>
/// <returns>true si la pièce peut être insérée, false sinon (case en dehors de la grille, ou case déjà occupée)</returns>
/// <remarks>si la pièce peut être insérée, cette méthode désigne le prochain joueur</remarks>
protected internal virtual bool InsertPiece(Case place, int playerId)
{
if (place.Line < 0 || place.Line >= 3 || place.Column < 0 || place.Column >= 3)
{
throw new GameException("Les indices de ligne et colonne doivent être compris entre 0 et 2 inclus");
}
if (playerId < 0 || playerId >= 2)
{
throw new GameException("L'indice du joueur doit être compris entre 0 et 1 inclus");
}
if (mBoard[place.Line, place.Column] != -1)
{
return false;
}
mBoard[place.Line, place.Column] = playerId;
System.Threading.Thread.Sleep(mRandom.Next(2000));
return true;
}
/// <summary>
/// met à jour le prochain joueur
/// </summary>
void ChangeNextPlayer()
{
mNextPlayer++;
mNextPlayer %= 2;
}
static Random mRandom = new Random();
/// <summary>
/// teste si la partie est terminée
/// </summary>
/// <param name="winnerId">identifiant du vainqueur (0 ou 1) si la partie est gagnée, -1 en cas d'égalité</param>
/// <param name="places">cases ayant permis au vainqueur de gagner (non significatives si la partie n'est pas terminée ou s'il y a égalité)</param>
/// <returns>true si terminée, false sinon</returns>
protected virtual bool IsGameOver(out int winnerId, out Case[] places)
{
places = new Case[3];
winnerId = -1;
if(CheckLines(ref winnerId, ref places)
|| CheckColumns(ref winnerId, ref places)
|| CheckDiagonals(ref winnerId, ref places))
{
if (OnGameOver != null)
{
OnGameOver(this, winnerId, places);
}
return true;
}
bool isfull = mBoard.Cast<int>().Count(c => c == -1) == 0;
if (isfull)
{
if (OnGameOver != null)
{
OnGameOver(this, -1, null);
}
return true;
}
return false;
}
private bool CheckLines(ref int winnerId, ref Case[] places)
{
for (int l = 0; l <= 2; l++)
{
if (mBoard[l, 0] != -1 && mBoard[l, 0] == mBoard[l, 1] && mBoard[l, 0] == mBoard[l, 2])
{
winnerId = mBoard[l, 0];
places[0] = new Case(l, 0);
places[1] = new Case(l, 1);
places[2] = new Case(l, 2);
return true;
}
}
return false;
}
private bool CheckColumns(ref int winnerId, ref Case[] places)
{
for (int c = 0; c <= 2; c++)
{
if (mBoard[0, c] != -1 && mBoard[0, c] == mBoard[1, c] && mBoard[0, c] == mBoard[2, c])
{
winnerId = mBoard[0, c];
places[0] = new Case(0, c);
places[1] = new Case(1, c);
places[2] = new Case(2, c);
return true;
}
}
return false;
}
private bool CheckDiagonals(ref int winnerId, ref Case[] places)
{
if (mBoard[0, 0] != -1 && mBoard[0, 0] == mBoard[1, 1] && mBoard[0, 0] == mBoard[2, 2])
{
winnerId = mBoard[0, 0];
places[0] = new Case(0, 0);
places[1] = new Case(1, 1);
places[2] = new Case(2, 2);
return true;
}
if (mBoard[0, 2] != -1 && mBoard[0, 2] == mBoard[1, 1] && mBoard[2, 0] == mBoard[0, 2])
{
winnerId = mBoard[0, 2];
places[0] = new Case(0, 2);
places[1] = new Case(1, 1);
places[2] = new Case(2, 0);
return true;
}
return false;
}
/// <summary>
/// identifiant du prochain joueur
/// </summary>
protected int NextPlayer
{
get
{
return mNextPlayer;
}
}
/// <seealso cref="NextPlayer"/>
private int mNextPlayer = 0;
/// <summary>
/// joueurs du jeu
/// </summary>
private Player[] mPlayers = new Player[2];
/// <summary>
/// renseigne le prochain joueur qu'il doit joueur et le fait jouer
/// </summary>
/// <returns>rend true si le joueur a pu jouer</returns>
protected virtual bool NotifyNextPlayer()
{
if (OnPlayerNotified != null)
{
OnPlayerNotified(this, mNextPlayer);
}
Case place = mPlayers[mNextPlayer].Play();
bool result = InsertPiece(place, mPlayers[mNextPlayer].Id);
if (OnPieceInserted != null)
{
OnPieceInserted(this, mPlayers[mNextPlayer].Id, place);
}
return result;
}
}
}

@ -0,0 +1,71 @@
// ========================================================================
//
// Copyright (C) 2013-2014 MARC CHEVALDONNE
// marc.chevaldonne.free.fr
//
// Module : Player.cs
// Author : Marc Chevaldonné
// Creation date : 2014-05-07
//
// ========================================================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace giMorpionCore
{
/// <summary>
/// joueur du Morpion (c'est un joueur automatique qui joue aléatoirement dans une case)
/// </summary>
public class Player
{
/// <summary>
/// compteur statique pour créer un id automatique
/// </summary>
static private int mIdCounter = 0;
/// <summary>
/// identifiant du joueur
/// </summary>
public int Id
{
get;
internal set;
}
/// <summary>
/// constructeur (l'identifant est créé automatiquement et le jeu est relié à ce joueur)
/// </summary>
/// <param name="game">le jeu auquel ce joueur appartient</param>
internal Player(Game game)
{
Id = mIdCounter;
mIdCounter++;
mGame = game;
}
/// <summary>
/// le jeu auquel ce joueur appartient
/// </summary>
internal Game mGame;
/// <summary>
/// méthode permettant au joueur de jouer (choix aléatoire d'une case dans laquelle il va jouer)
/// </summary>
/// <returns>la case dans laquelle il veut jouer</returns>
protected internal Case Play()
{
Random rdm = new Random();
int line = rdm.Next(0, 3);
int column = rdm.Next(0, 3);
while (mGame.Board[line, column] != -1)
{
line = rdm.Next(0, 3);
column = rdm.Next(0, 3);
}
return new Case(line, column);
}
}
}

@ -0,0 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
</Project>

@ -0,0 +1,73 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
# ========================================================================
#
# Copyright (C) 2013-2014 MARC CHEVALDONNE
# marc.chevaldonne.free.fr
#
# Module : Morpion.sln
# Author : Marc Chevaldonné
# Creation date : 2014-05-07
#
# ========================================================================
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "giMorpionCore", "giMorpionCore\giMorpionCore.csproj", "{100BBE7D-CD80-4DE5-94F3-666D5911537A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MorpionGame", "MorpionGame\MorpionGame.csproj", "{9010B8A4-CB52-4EB8-BBD0-855A784D5579}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MorpionGameWpf", "MorpionGameWpf\MorpionGameWpf.csproj", "{45690090-D045-43D4-8F51-EA845DA5F95E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|Mixed Platforms = Debug|Mixed Platforms
Debug|Win32 = Debug|Win32
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|Mixed Platforms = Release|Mixed Platforms
Release|Win32 = Release|Win32
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Debug|Win32.ActiveCfg = Debug|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Debug|x86.ActiveCfg = Debug|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Release|Any CPU.Build.0 = Release|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Release|Win32.ActiveCfg = Release|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Release|x86.ActiveCfg = Release|Any CPU
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Debug|Any CPU.ActiveCfg = Debug|x86
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Debug|Mixed Platforms.Build.0 = Debug|x86
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Debug|Win32.ActiveCfg = Debug|x86
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Debug|x86.ActiveCfg = Debug|x86
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Debug|x86.Build.0 = Debug|x86
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Release|Any CPU.ActiveCfg = Release|x86
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Release|Mixed Platforms.ActiveCfg = Release|x86
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Release|Mixed Platforms.Build.0 = Release|x86
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Release|Win32.ActiveCfg = Release|x86
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Release|x86.ActiveCfg = Release|x86
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Release|x86.Build.0 = Release|x86
{45690090-D045-43D4-8F51-EA845DA5F95E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{45690090-D045-43D4-8F51-EA845DA5F95E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{45690090-D045-43D4-8F51-EA845DA5F95E}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{45690090-D045-43D4-8F51-EA845DA5F95E}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{45690090-D045-43D4-8F51-EA845DA5F95E}.Debug|Win32.ActiveCfg = Debug|Any CPU
{45690090-D045-43D4-8F51-EA845DA5F95E}.Debug|x86.ActiveCfg = Debug|Any CPU
{45690090-D045-43D4-8F51-EA845DA5F95E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{45690090-D045-43D4-8F51-EA845DA5F95E}.Release|Any CPU.Build.0 = Release|Any CPU
{45690090-D045-43D4-8F51-EA845DA5F95E}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{45690090-D045-43D4-8F51-EA845DA5F95E}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{45690090-D045-43D4-8F51-EA845DA5F95E}.Release|Win32.ActiveCfg = Release|Any CPU
{45690090-D045-43D4-8F51-EA845DA5F95E}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<AssemblyName>MorpionGame</AssemblyName>
<OutputType>Exe</OutputType>
<PackageId>MorpionGame</PackageId>
<RuntimeFrameworkVersion>2.2</RuntimeFrameworkVersion>
<PackageTargetFallback>$(PackageTargetFallback);dnxcore50</PackageTargetFallback>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\giMorpionCore\giMorpionCore.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,106 @@
// ========================================================================
//
// Copyright (C) 2013-2014 MARC CHEVALDONNE
// marc.chevaldonne.free.fr
//
// Module : Program.cs
// Author : Marc Chevaldonné
// Creation date : 2014-05-07
//
// ========================================================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using giMorpionCore;
namespace MorpionGame
{
class Program
{
static void Main(string[] args)
{
Game game = new Game();
game.OnGameStarted += new Game.GameStarted((Game g) =>
{
Console.WriteLine("Game Starts at last !!!");
Display(g);
});
game.OnGameOver += OnGameOver;
game.OnPieceInserted += new Game.PieceInserted((Game g, int playerId, Case place) => Console.Clear());
game.OnPieceInserted += (Game g, int playerId, Case place) => Display(g, place);
game.OnPlayerNotified += (Game g, int playerId) => Console.WriteLine("Player {0}, it's your turn !", playerId);
game.Start();
}
private static void OnGameOver(Game game, int winnerId, Case[] winningPlaces)
{
Console.Clear();
if (winnerId == -1)
{
Display(game);
Console.WriteLine("Deuce");
return;
}
Display(game, winningPlaces);
Console.WriteLine("Congratulations Player {0} for your victory !", winnerId);
}
private static void Display(giMorpionCore.Game game, params giMorpionCore.Case[] highlightedCases)
{
Console.ForegroundColor = ConsoleColor.White;
int[,] board = game.Board;
Console.WriteLine(" 0 1 2 ");
for (int line = 0; line < 3; line++)
{
Console.ForegroundColor = ConsoleColor.White;
Console.Write(" " + line + " ");
for (int column = 0; column < 3; column++)
{
Console.BackgroundColor = ConsoleColor.Cyan;
foreach (giMorpionCore.Case place in highlightedCases)
{
if (place.Line == line && place.Column == column)
{
Console.BackgroundColor = ConsoleColor.Red;
break;
}
}
DisplayCaseContent(board, line, column);
}
Console.BackgroundColor = ConsoleColor.Black;
Console.WriteLine();
}
Console.ForegroundColor = ConsoleColor.White;
}
/// <summary>
/// affiche le contenu d'une case en fonction du joueur
/// </summary>
/// <param name="board">la grille du jeu du Morpion prise en compte</param>
/// <param name="line">la ligne de la case à prendre en compte</param>
/// <param name="column">la colonne de la case à prendre en compte</param>
private static void DisplayCaseContent(int[,] board, int line, int column)
{
if (board[line, column] == 0)
{
Console.ForegroundColor = ConsoleColor.DarkYellow;
Console.Write(" O ");
return;
}
if (board[line, column] == 1)
{
Console.ForegroundColor = ConsoleColor.DarkBlue;
Console.Write(" X ");
return;
}
Console.Write(" ");
}
}
}

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- ======================================================================
Copyright (C) 2013-2014 MARC CHEVALDONNE
marc.chevaldonne.free.fr
Module : App.config
Author : Marc Chevaldonné
Creation date : 2014-05-07
======================================================================== -->
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>

@ -0,0 +1,19 @@
<!-- ======================================================================
Copyright (C) 2013-2014 MARC CHEVALDONNE
marc.chevaldonne.free.fr
Module : App.xaml
Author : Marc Chevaldonné
Creation date : 2014-05-07
======================================================================== -->
<Application x:Class="MorpionGameWpf.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>

@ -0,0 +1,28 @@
// ========================================================================
//
// Copyright (C) 2013-2014 MARC CHEVALDONNE
// marc.chevaldonne.free.fr
//
// Module : App.xaml.cs
// Author : Marc Chevaldonné
// Creation date : 2014-05-07
//
// ========================================================================
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
namespace MorpionGameWpf
{
/// <summary>
/// Logique d'interaction pour App.xaml
/// </summary>
public partial class App : Application
{
}
}

@ -0,0 +1,23 @@
<!-- ======================================================================
Copyright (C) 2013-2014 MARC CHEVALDONNE
marc.chevaldonne.free.fr
Module : MainWindow.xaml
Author : Marc Chevaldonné
Creation date : 2014-05-07
======================================================================== -->
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:MorpionGameWpf" x:Class="MorpionGameWpf.MainWindow"
Title="MainWindow" Height="350" Width="525" MouseDown="Window_MouseDown_1">
<DockPanel>
<TextBlock DockPanel.Dock="Top" x:Name="mTextBlockMessages"/>
<local:MorpionGrid x:Name="mGrille"/>
</DockPanel>
</Window>

@ -0,0 +1,87 @@
// ========================================================================
//
// Copyright (C) 2013-2014 MARC CHEVALDONNE
// marc.chevaldonne.free.fr
//
// Module : MainWindow.xaml.cs
// Author : Marc Chevaldonné
// Creation date : 2014-05-07
//
// ========================================================================
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;
using giMorpionCore;
namespace MorpionGameWpf
{
/// <summary>
/// Logique d'interaction pour MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
Game game;
public MainWindow()
{
InitializeComponent();
game = new Game();
game.OnGameStarted += (Game g) =>
{
mTextBlockMessages.Text = "Game Starts at last !!!";
mGrille.Update();
this.Dispatcher.Invoke(EmptyDelegate, System.Windows.Threading.DispatcherPriority.ApplicationIdle);
};
game.OnGameOver += (Game g, int winnerId, Case[] winningPlaces) =>
{
if (winnerId == -1)
{
mGrille.Update();
mTextBlockMessages.Text = "Deuce";
return;
}
mGrille.Update(winningPlaces);
mTextBlockMessages.Text = string.Format("Congratulations Player {0} for your victory !", winnerId);
this.Dispatcher.Invoke(EmptyDelegate, System.Windows.Threading.DispatcherPriority.ApplicationIdle);
};
game.OnPieceInserted += (Game g, int playerId, Case place) =>
{
mGrille.Update(place);
this.Dispatcher.Invoke(EmptyDelegate, System.Windows.Threading.DispatcherPriority.ApplicationIdle);
};
game.OnPlayerNotified += (Game g, int playerId) =>
{
mTextBlockMessages.Text = string.Format("Player {0}, it's your turn !", playerId);
this.Dispatcher.Invoke(EmptyDelegate, System.Windows.Threading.DispatcherPriority.ApplicationIdle);
};
mGrille.Game = game;
}
Action EmptyDelegate = delegate() { };
private void Window_MouseDown_1(object sender, MouseButtonEventArgs e)
{
game.Start();
}
}
}

@ -0,0 +1,133 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- ======================================================================
Copyright (C) 2013-2014 MARC CHEVALDONNE
marc.chevaldonne.free.fr
Module : MorpionGameWpf.csproj
Author : Marc Chevaldonné
Creation date : 2014-05-07
======================================================================== -->
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{3200F3AF-5D50-40FD-BB47-92EDB2DD85B9}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>MorpionGameWpf</RootNamespace>
<AssemblyName>MorpionGameWpf</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Page Include="MorpionGrid.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="MorpionGridCase.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Compile Include="MorpionGrid.xaml.cs">
<DependentUpon>MorpionGrid.xaml</DependentUpon>
</Compile>
<Compile Include="MorpionGridCase.xaml.cs">
<DependentUpon>MorpionGridCase.xaml</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<AppDesigner Include="Properties\" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\giMorpionCore\giMorpionCore.csproj">
<Project>{4c5197d3-9080-4f04-9413-c353d5b03640}</Project>
<Name>giMorpionCore %281. Morpion\v4_solutionAvecEvent\giMorpionCore%29</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

@ -0,0 +1,21 @@
<!-- ======================================================================
Copyright (C) 2013-2014 MARC CHEVALDONNE
marc.chevaldonne.free.fr
Module : MorpionGrid.xaml
Author : Marc Chevaldonné
Creation date : 2014-05-07
======================================================================== -->
<UserControl x:Class="MorpionGameWpf.MorpionGrid"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid Name="mGrid">
</Grid>
</UserControl>

@ -0,0 +1,94 @@
// ========================================================================
//
// Copyright (C) 2013-2014 MARC CHEVALDONNE
// marc.chevaldonne.free.fr
//
// Module : MorpionGrid.xaml.cs
// Author : Marc Chevaldonné
// Creation date : 2014-05-07
//
// ========================================================================
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;
using giMorpionCore;
namespace MorpionGameWpf
{
/// <summary>
/// Logique d'interaction pour MorpionGrid.xaml
/// </summary>
public partial class MorpionGrid : UserControl
{
public MorpionGrid()
{
InitializeComponent();
}
public Game Game
{
get { return (Game)GetValue(GameProperty); }
set { SetValue(GameProperty, value); }
}
// Using a DependencyProperty as the backing store for Game. This enables animation, styling, binding, etc...
public static readonly DependencyProperty GameProperty =
DependencyProperty.Register("Game", typeof(Game), typeof(MorpionGrid));
static Dictionary<int, string> mPlayerSymbols = new Dictionary<int, string>() { {-1, " "}, { 0, "O" }, { 1, "X" } };
public void Update(params Case[] winningPlaces)
{
if(Game == null)
{
return;
}
int[,] board = Game.Board;
if (mGrid.RowDefinitions.Count == 0)
{
for (int i = 0; i < board.GetLength(0); i++)
{
mGrid.RowDefinitions.Add(new RowDefinition());
}
for (int i = 0; i < board.GetLength(1); i++)
{
mGrid.ColumnDefinitions.Add(new ColumnDefinition());
}
}
mGrid.Children.Clear();
for (int i = 0; i < board.GetLength(0); i++)
{
for (int j = 0; j < board.GetLength(1); j++)
{
var newCase = new MorpionGridCase() { PlayerId = mPlayerSymbols[board[i,j]]};
if (winningPlaces.Cast<Case>().Contains(new Case(i, j)))
{
newCase.BackgroundColor = Brushes.Red;
}
newCase.SetValue(Grid.RowProperty, i);
newCase.SetValue(Grid.ColumnProperty, j);
mGrid.Children.Add(newCase);
}
}
}
}
}

@ -0,0 +1,23 @@
<!-- ======================================================================
Copyright (C) 2013-2014 MARC CHEVALDONNE
marc.chevaldonne.free.fr
Module : MorpionGridCase.xaml
Author : Marc Chevaldonné
Creation date : 2014-05-07
======================================================================== -->
<UserControl x:Class="MorpionGameWpf.MorpionGridCase"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300"
x:Name="root">
<Grid Background="{Binding BackgroundColor, ElementName=root}">
<TextBlock Text="{Binding PlayerId, ElementName=root}" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="30" FontWeight="Bold"/>
</Grid>
</UserControl>

@ -0,0 +1,66 @@
// ========================================================================
//
// Copyright (C) 2013-2014 MARC CHEVALDONNE
// marc.chevaldonne.free.fr
//
// Module : MorpionGridCase.xaml.cs
// Author : Marc Chevaldonné
// Creation date : 2014-05-07
//
// ========================================================================
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 MorpionGameWpf
{
/// <summary>
/// Logique d'interaction pour MorpionGridCase.xaml
/// </summary>
public partial class MorpionGridCase : UserControl
{
public MorpionGridCase()
{
InitializeComponent();
}
public string PlayerId
{
get { return (string)GetValue(PlayerIdProperty); }
set { SetValue(PlayerIdProperty, value); }
}
// Using a DependencyProperty as the backing store for PlayerId. This enables animation, styling, binding, etc...
public static readonly DependencyProperty PlayerIdProperty =
DependencyProperty.Register("PlayerId", typeof(string), typeof(MorpionGridCase), new PropertyMetadata(" "));
public SolidColorBrush BackgroundColor
{
get { return (SolidColorBrush)GetValue(BackgroundColorProperty); }
set { SetValue(BackgroundColorProperty, value); }
}
// Using a DependencyProperty as the backing store for BackgroundColor. This enables animation, styling, binding, etc...
public static readonly DependencyProperty BackgroundColorProperty =
DependencyProperty.Register("BackgroundColor", typeof(SolidColorBrush), typeof(MorpionGridCase), new PropertyMetadata(Brushes.AliceBlue));
}
}

@ -0,0 +1,66 @@
// ========================================================================
//
// Copyright (C) 2013-2014 MARC CHEVALDONNE
// marc.chevaldonne.free.fr
//
// Module : AssemblyInfo.cs
// Author : Marc Chevaldonné
// Creation date : 2014-05-07
//
// ========================================================================
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows;
// Les informations générales relatives à un assembly dépendent de
// l'ensemble d'attributs suivant. Changez les valeurs de ces attributs pour modifier les informations
// associées à un assembly.
[assembly: AssemblyTitle("MorpionGameWpf")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MorpionGameWpf")]
[assembly: AssemblyCopyright("Copyright © 2014")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// L'affectation de la valeur false à ComVisible rend les types invisibles dans cet assembly
// aux composants COM. Si vous devez accéder à un type dans cet assembly à partir de
// COM, affectez la valeur true à l'attribut ComVisible sur ce type.
[assembly: ComVisible(false)]
//Pour commencer à générer des applications localisables, définissez
//<UICulture>CultureYouAreCodingWith</UICulture> dans votre fichier .csproj
//dans <PropertyGroup>. Par exemple, si vous utilisez le français
//dans vos fichiers sources, définissez <UICulture> à fr-FR. Puis, supprimez les marques de commentaire de
//l'attribut NeutralResourceLanguage ci-dessous. Mettez à jour "fr-FR" dans
//la ligne ci-après pour qu'elle corresponde au paramètre UICulture du fichier projet.
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //où se trouvent les dictionnaires de ressources spécifiques à un thème
//(utilisé si une ressource est introuvable dans la page,
// ou dictionnaires de ressources de l'application)
ResourceDictionaryLocation.SourceAssembly //où se trouve le dictionnaire de ressources générique
//(utilisé si une ressource est introuvable dans la page,
// dans l'application ou dans l'un des dictionnaires de ressources spécifiques à un thème)
)]
// Les informations de version pour un assembly se composent des quatre valeurs suivantes :
//
// Version principale
// Version secondaire
// Numéro de build
// Révision
//
// Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut
// en utilisant '*', comme indiqué ci-dessous :
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

@ -0,0 +1,63 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Ce code a été généré par un outil.
// Version du runtime :4.0.30319.42000
//
// Les modifications apportées à ce fichier peuvent provoquer un comportement incorrect et seront perdues si
// le code est régénéré.
// </auto-generated>
//------------------------------------------------------------------------------
namespace MorpionGameWpf.Properties {
using System;
/// <summary>
/// Une classe de ressource fortement typée destinée, entre autres, à la consultation des chaînes localisées.
/// </summary>
// Cette classe a été générée automatiquement par la classe StronglyTypedResourceBuilder
// à l'aide d'un outil, tel que ResGen ou Visual Studio.
// Pour ajouter ou supprimer un membre, modifiez votre fichier .ResX, puis réexécutez ResGen
// avec l'option /str ou régénérez votre projet VS.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Retourne l'instance ResourceManager mise en cache utilisée par cette classe.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MorpionGameWpf.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Remplace la propriété CurrentUICulture du thread actuel pour toutes
/// les recherches de ressources à l'aide de cette classe de ressource fortement typée.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}

@ -0,0 +1,128 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- ======================================================================
Copyright (C) 2013-2014 MARC CHEVALDONNE
marc.chevaldonne.free.fr
Module : Resources.resx
Author : Marc Chevaldonné
Creation date : 2014-05-07
======================================================================== -->
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

@ -0,0 +1,41 @@
// ========================================================================
//
// Copyright (C) 2013-2014 MARC CHEVALDONNE
// marc.chevaldonne.free.fr
//
// Module : Settings.Designer.cs
// Author : Marc Chevaldonné
// Creation date : 2014-05-07
//
// ========================================================================
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.17929
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace MorpionGameWpf.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
return defaultInstance;
}
}
}
}

@ -0,0 +1,18 @@
<?xml version='1.0' encoding='utf-8'?>
<!-- ======================================================================
Copyright (C) 2013-2014 MARC CHEVALDONNE
marc.chevaldonne.free.fr
Module : Settings.settings
Author : Marc Chevaldonné
Creation date : 2014-05-07
======================================================================== -->
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

@ -0,0 +1,67 @@
// ========================================================================
//
// Copyright (C) 2013-2014 MARC CHEVALDONNE
// marc.chevaldonne.free.fr
//
// Module : Case.cs
// Author : Marc Chevaldonné
// Creation date : 2014-05-07
//
// ========================================================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace giMorpionCore
{
/// <summary>
/// représente une case du jeu du Morpion
/// </summary>
public struct Case
{
/// <summary>
/// ligne de la case
/// </summary>
public int Line
{
get
{
return mLine;
}
private set
{
mLine = value;
}
}
private int mLine;
/// <summary>
/// colonne de la case
/// </summary>
public int Column
{
get
{
return mColumn;
}
private set
{
mColumn = value;
}
}
private int mColumn;
/// <summary>
/// constructeur
/// </summary>
/// <param name="line">ligne de la case</param>
/// <param name="column">colonne de la case</param>
public Case(int line, int column)
{
mLine = line;
mColumn = column;
}
}
}

@ -0,0 +1,257 @@
// ========================================================================
//
// Copyright (C) 2013-2014 MARC CHEVALDONNE
// marc.chevaldonne.free.fr
//
// Module : Game.cs
// Author : Marc Chevaldonné
// Creation date : 2014-05-07
//
// ========================================================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
/// <summary>
/// contient les classes gérant le fonctionnement du jeu
/// </summary>
namespace giMorpionCore
{
/// <summary>
/// contient les méthodes de base pour le jeu du Morpion : démarrage du jeu, test de fin du jeu, insertion d'une pièce...
/// </summary>
public class Game
{
/// <summary>
/// exception lors de l'insertion de pièces
/// </summary>
public class GameException : Exception
{
public GameException(string message)
: base(message)
{
}
}
/// <summary>
/// grille du morpion
/// </summary>
public int[,] Board
{
get
{
return (int[,])mBoard.Clone();
}
}
/// <seealso cref="Board"/>
private int[,] mBoard = new int[3, 3];
public delegate void GameStarted(Game game);
public delegate void GameOver(Game game, int winnerId, Case[] winningPlaces);
public delegate void PieceInserted(Game game, int playerId, Case place);
public delegate void PlayerNotified(Game game, int playerId);
public event GameStarted OnGameStarted;
public event GameOver OnGameOver;
public event PieceInserted OnPieceInserted;
public event PlayerNotified OnPlayerNotified;
/// <summary>
/// constructeur : crée deux joueurs et initialise la grille à vide
/// </summary>
public Game()
{
mPlayers[0] = new Player(this);
mPlayers[1] = new Player(this);
mBoard = new int[,] { { -1, -1, -1 }, { -1, -1, -1 }, { -1, -1, -1 } };
}
/// <summary>
/// démarre le jeu du Morpion
/// </summary>
public virtual void Start()
{
if (OnGameStarted != null)
{
OnGameStarted(this);
}
int winnerId;
giMorpionCore.Case[] places;
while (!IsGameOver(out winnerId, out places))
{
if (NotifyNextPlayer())
{
ChangeNextPlayer();
}
}
}
/// <summary>
/// insère une pièce
/// </summary>
/// <param name="place">case où la pièce doit être insérée</param>
/// <param name="playerId">joueur insérant la pièce</param>
/// <returns>true si la pièce peut être insérée, false sinon (case en dehors de la grille, ou case déjà occupée)</returns>
/// <remarks>si la pièce peut être insérée, cette méthode désigne le prochain joueur</remarks>
protected internal virtual bool InsertPiece(Case place, int playerId)
{
if (place.Line < 0 || place.Line >= 3 || place.Column < 0 || place.Column >= 3)
{
throw new GameException("Les indices de ligne et colonne doivent être compris entre 0 et 2 inclus");
}
if (playerId < 0 || playerId >= 2)
{
throw new GameException("L'indice du joueur doit être compris entre 0 et 1 inclus");
}
if (mBoard[place.Line, place.Column] != -1)
{
return false;
}
mBoard[place.Line, place.Column] = playerId;
System.Threading.Thread.Sleep(mRandom.Next(2000));
return true;
}
/// <summary>
/// met à jour le prochain joueur
/// </summary>
void ChangeNextPlayer()
{
mNextPlayer++;
mNextPlayer %= 2;
}
static Random mRandom = new Random();
/// <summary>
/// teste si la partie est terminée
/// </summary>
/// <param name="winnerId">identifiant du vainqueur (0 ou 1) si la partie est gagnée, -1 en cas d'égalité</param>
/// <param name="places">cases ayant permis au vainqueur de gagner (non significatives si la partie n'est pas terminée ou s'il y a égalité)</param>
/// <returns>true si terminée, false sinon</returns>
protected virtual bool IsGameOver(out int winnerId, out Case[] places)
{
places = new Case[3];
winnerId = -1;
if (CheckLines(ref winnerId, ref places)
|| CheckColumns(ref winnerId, ref places)
|| CheckDiagonals(ref winnerId, ref places))
{
if (OnGameOver != null)
{
OnGameOver(this, winnerId, places);
}
return true;
}
bool isfull = mBoard.Cast<int>().Count(c => c == -1) == 0;
if (isfull)
{
if (OnGameOver != null)
{
OnGameOver(this, -1, null);
}
return true;
}
return false;
}
private bool CheckLines(ref int winnerId, ref Case[] places)
{
for (int l = 0; l <= 2; l++)
{
if (mBoard[l, 0] != -1 && mBoard[l, 0] == mBoard[l, 1] && mBoard[l, 0] == mBoard[l, 2])
{
winnerId = mBoard[l, 0];
places[0] = new Case(l, 0);
places[1] = new Case(l, 1);
places[2] = new Case(l, 2);
return true;
}
}
return false;
}
private bool CheckColumns(ref int winnerId, ref Case[] places)
{
for (int c = 0; c <= 2; c++)
{
if (mBoard[0, c] != -1 && mBoard[0, c] == mBoard[1, c] && mBoard[0, c] == mBoard[2, c])
{
winnerId = mBoard[0, c];
places[0] = new Case(0, c);
places[1] = new Case(1, c);
places[2] = new Case(2, c);
return true;
}
}
return false;
}
private bool CheckDiagonals(ref int winnerId, ref Case[] places)
{
if (mBoard[0, 0] != -1 && mBoard[0, 0] == mBoard[1, 1] && mBoard[0, 0] == mBoard[2, 2])
{
winnerId = mBoard[0, 0];
places[0] = new Case(0, 0);
places[1] = new Case(1, 1);
places[2] = new Case(2, 2);
return true;
}
if (mBoard[0, 2] != -1 && mBoard[0, 2] == mBoard[1, 1] && mBoard[2, 0] == mBoard[0, 2])
{
winnerId = mBoard[0, 2];
places[0] = new Case(0, 2);
places[1] = new Case(1, 1);
places[2] = new Case(2, 0);
return true;
}
return false;
}
/// <summary>
/// identifiant du prochain joueur
/// </summary>
protected int NextPlayer
{
get
{
return mNextPlayer;
}
}
/// <seealso cref="NextPlayer"/>
private int mNextPlayer = 0;
/// <summary>
/// joueurs du jeu
/// </summary>
private Player[] mPlayers = new Player[2];
/// <summary>
/// renseigne le prochain joueur qu'il doit joueur et le fait jouer
/// </summary>
/// <returns>rend true si le joueur a pu jouer</returns>
protected virtual bool NotifyNextPlayer()
{
if (OnPlayerNotified != null)
{
OnPlayerNotified(this, mNextPlayer);
}
Case place = mPlayers[mNextPlayer].Play();
bool result = InsertPiece(place, mPlayers[mNextPlayer].Id);
if (OnPieceInserted != null)
{
OnPieceInserted(this, mPlayers[mNextPlayer].Id, place);
}
return result;
}
}
}

@ -0,0 +1,71 @@
// ========================================================================
//
// Copyright (C) 2013-2014 MARC CHEVALDONNE
// marc.chevaldonne.free.fr
//
// Module : Player.cs
// Author : Marc Chevaldonné
// Creation date : 2014-05-07
//
// ========================================================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace giMorpionCore
{
/// <summary>
/// joueur du Morpion (c'est un joueur automatique qui joue aléatoirement dans une case)
/// </summary>
public class Player
{
/// <summary>
/// compteur statique pour créer un id automatique
/// </summary>
static private int mIdCounter = 0;
/// <summary>
/// identifiant du joueur
/// </summary>
public int Id
{
get;
internal set;
}
/// <summary>
/// constructeur (l'identifant est créé automatiquement et le jeu est relié à ce joueur)
/// </summary>
/// <param name="game">le jeu auquel ce joueur appartient</param>
internal Player(Game game)
{
Id = mIdCounter;
mIdCounter++;
mGame = game;
}
/// <summary>
/// le jeu auquel ce joueur appartient
/// </summary>
internal Game mGame;
/// <summary>
/// méthode permettant au joueur de jouer (choix aléatoire d'une case dans laquelle il va jouer)
/// </summary>
/// <returns>la case dans laquelle il veut jouer</returns>
protected internal Case Play()
{
Random rdm = new Random();
int line = rdm.Next(0, 3);
int column = rdm.Next(0, 3);
while (mGame.Board[line, column] != -1)
{
line = rdm.Next(0, 3);
column = rdm.Next(0, 3);
}
return new Case(line, column);
}
}
}

@ -0,0 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
</Project>

@ -0,0 +1,73 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
# ========================================================================
#
# Copyright (C) 2013-2014 MARC CHEVALDONNE
# marc.chevaldonne.free.fr
#
# Module : Morpion.sln
# Author : Marc Chevaldonné
# Creation date : 2014-05-07
#
# ========================================================================
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "giMorpionCore", "giMorpionCore\giMorpionCore.csproj", "{100BBE7D-CD80-4DE5-94F3-666D5911537A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MorpionGame", "MorpionGame\MorpionGame.csproj", "{9010B8A4-CB52-4EB8-BBD0-855A784D5579}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MorpionGameWpf", "MorpionGameWpf\MorpionGameWpf.csproj", "{45690090-D045-43D4-8F51-EA845DA5F95E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|Mixed Platforms = Debug|Mixed Platforms
Debug|Win32 = Debug|Win32
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|Mixed Platforms = Release|Mixed Platforms
Release|Win32 = Release|Win32
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Debug|Win32.ActiveCfg = Debug|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Debug|x86.ActiveCfg = Debug|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Release|Any CPU.Build.0 = Release|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Release|Win32.ActiveCfg = Release|Any CPU
{100BBE7D-CD80-4DE5-94F3-666D5911537A}.Release|x86.ActiveCfg = Release|Any CPU
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Debug|Any CPU.ActiveCfg = Debug|x86
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Debug|Mixed Platforms.Build.0 = Debug|x86
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Debug|Win32.ActiveCfg = Debug|x86
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Debug|x86.ActiveCfg = Debug|x86
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Debug|x86.Build.0 = Debug|x86
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Release|Any CPU.ActiveCfg = Release|x86
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Release|Mixed Platforms.ActiveCfg = Release|x86
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Release|Mixed Platforms.Build.0 = Release|x86
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Release|Win32.ActiveCfg = Release|x86
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Release|x86.ActiveCfg = Release|x86
{9010B8A4-CB52-4EB8-BBD0-855A784D5579}.Release|x86.Build.0 = Release|x86
{45690090-D045-43D4-8F51-EA845DA5F95E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{45690090-D045-43D4-8F51-EA845DA5F95E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{45690090-D045-43D4-8F51-EA845DA5F95E}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{45690090-D045-43D4-8F51-EA845DA5F95E}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{45690090-D045-43D4-8F51-EA845DA5F95E}.Debug|Win32.ActiveCfg = Debug|Any CPU
{45690090-D045-43D4-8F51-EA845DA5F95E}.Debug|x86.ActiveCfg = Debug|Any CPU
{45690090-D045-43D4-8F51-EA845DA5F95E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{45690090-D045-43D4-8F51-EA845DA5F95E}.Release|Any CPU.Build.0 = Release|Any CPU
{45690090-D045-43D4-8F51-EA845DA5F95E}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{45690090-D045-43D4-8F51-EA845DA5F95E}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{45690090-D045-43D4-8F51-EA845DA5F95E}.Release|Win32.ActiveCfg = Release|Any CPU
{45690090-D045-43D4-8F51-EA845DA5F95E}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<AssemblyName>MorpionGame</AssemblyName>
<OutputType>Exe</OutputType>
<PackageId>MorpionGame</PackageId>
<RuntimeFrameworkVersion>2.2</RuntimeFrameworkVersion>
<PackageTargetFallback>$(PackageTargetFallback);dnxcore50</PackageTargetFallback>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\giMorpionCore\giMorpionCore.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,106 @@
// ========================================================================
//
// Copyright (C) 2013-2014 MARC CHEVALDONNE
// marc.chevaldonne.free.fr
//
// Module : Program.cs
// Author : Marc Chevaldonné
// Creation date : 2014-05-07
//
// ========================================================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using giMorpionCore;
namespace MorpionGame
{
class Program
{
static void Main()
{
Game game = new Game();
game.GameStarted += new EventHandler<EventArgs>((object sender, EventArgs args) =>
{
Console.WriteLine("Game Starts at last !!!");
Display(sender as Game);
});
game.GameOver += OnGameOver;
game.PieceInserted += new EventHandler<Game.PieceInsertedEventArgs>((object sender, Game.PieceInsertedEventArgs args) => Console.Clear());
game.PieceInserted += (object sender, Game.PieceInsertedEventArgs args) => Display(sender as Game, args.Place);
game.PlayerNotified += (sender, args) => Console.WriteLine("Player {0}, it's your turn !", args.PlayerId);
game.Start();
}
private static void OnGameOver(object sender, Game.GameOverEventArgs args)
{
Console.Clear();
if (args.WinnerId == -1)
{
Display(sender as Game);
Console.WriteLine("Deuce");
return;
}
Display(sender as Game, args.WinningPlaces.ToArray());
Console.WriteLine("Congratulations Player {0} for your victory !", args.WinnerId);
}
private static void Display(giMorpionCore.Game game, params giMorpionCore.Case[] highlightedCases)
{
Console.ForegroundColor = ConsoleColor.White;
int[,] board = game.Board;
Console.WriteLine(" 0 1 2 ");
for (int line = 0; line < 3; line++)
{
Console.ForegroundColor = ConsoleColor.White;
Console.Write(" " + line + " ");
for (int column = 0; column < 3; column++)
{
Console.BackgroundColor = ConsoleColor.Cyan;
foreach (giMorpionCore.Case place in highlightedCases)
{
if (place.Line == line && place.Column == column)
{
Console.BackgroundColor = ConsoleColor.Red;
break;
}
}
DisplayCaseContent(board, line, column);
}
Console.BackgroundColor = ConsoleColor.Black;
Console.WriteLine();
}
Console.ForegroundColor = ConsoleColor.White;
}
/// <summary>
/// affiche le contenu d'une case en fonction du joueur
/// </summary>
/// <param name="board">la grille du jeu du Morpion prise en compte</param>
/// <param name="line">la ligne de la case à prendre en compte</param>
/// <param name="column">la colonne de la case à prendre en compte</param>
private static void DisplayCaseContent(int[,] board, int line, int column)
{
if (board[line, column] == 0)
{
Console.ForegroundColor = ConsoleColor.DarkYellow;
Console.Write(" O ");
return;
}
if (board[line, column] == 1)
{
Console.ForegroundColor = ConsoleColor.DarkBlue;
Console.Write(" X ");
return;
}
Console.Write(" ");
}
}
}

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- ======================================================================
Copyright (C) 2013-2014 MARC CHEVALDONNE
marc.chevaldonne.free.fr
Module : App.config
Author : Marc Chevaldonné
Creation date : 2014-05-07
======================================================================== -->
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>

@ -0,0 +1,19 @@
<!-- ======================================================================
Copyright (C) 2013-2014 MARC CHEVALDONNE
marc.chevaldonne.free.fr
Module : App.xaml
Author : Marc Chevaldonné
Creation date : 2014-05-07
======================================================================== -->
<Application x:Class="MorpionGameWpf.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>

@ -0,0 +1,28 @@
// ========================================================================
//
// Copyright (C) 2013-2014 MARC CHEVALDONNE
// marc.chevaldonne.free.fr
//
// Module : App.xaml.cs
// Author : Marc Chevaldonné
// Creation date : 2014-05-07
//
// ========================================================================
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
namespace MorpionGameWpf
{
/// <summary>
/// Logique d'interaction pour App.xaml
/// </summary>
public partial class App : Application
{
}
}

@ -0,0 +1,23 @@
<!-- ======================================================================
Copyright (C) 2013-2014 MARC CHEVALDONNE
marc.chevaldonne.free.fr
Module : MainWindow.xaml
Author : Marc Chevaldonné
Creation date : 2014-05-07
======================================================================== -->
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:MorpionGameWpf" x:Class="MorpionGameWpf.MainWindow"
Title="MainWindow" Height="350" Width="525" MouseDown="Window_MouseDown_1">
<DockPanel>
<TextBlock DockPanel.Dock="Top" x:Name="mTextBlockMessages"/>
<local:MorpionGrid x:Name="mGrille"/>
</DockPanel>
</Window>

@ -0,0 +1,87 @@
// ========================================================================
//
// Copyright (C) 2013-2014 MARC CHEVALDONNE
// marc.chevaldonne.free.fr
//
// Module : MainWindow.xaml.cs
// Author : Marc Chevaldonné
// Creation date : 2014-05-07
//
// ========================================================================
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;
using giMorpionCore;
namespace MorpionGameWpf
{
/// <summary>
/// Logique d'interaction pour MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
Game game;
public MainWindow()
{
InitializeComponent();
game = new Game();
game.GameStarted += (sender, args) =>
{
mTextBlockMessages.Text = "Game Starts at last !!!";
mGrille.Update();
this.Dispatcher.Invoke(EmptyDelegate, System.Windows.Threading.DispatcherPriority.ApplicationIdle);
};
game.GameOver += (sender, args) =>
{
if (args.WinnerId == -1)
{
mGrille.Update();
mTextBlockMessages.Text = "Deuce";
return;
}
mGrille.Update(args.WinningPlaces.ToArray());
mTextBlockMessages.Text = string.Format("Congratulations Player {0} for your victory !", args.WinnerId);
this.Dispatcher.Invoke(EmptyDelegate, System.Windows.Threading.DispatcherPriority.ApplicationIdle);
};
game.PieceInserted += (sender, args) =>
{
mGrille.Update(args.Place);
this.Dispatcher.Invoke(EmptyDelegate, System.Windows.Threading.DispatcherPriority.ApplicationIdle);
};
game.PlayerNotified += (sender, args) =>
{
mTextBlockMessages.Text = string.Format("Player {0}, it's your turn !", args.PlayerId);
this.Dispatcher.Invoke(EmptyDelegate, System.Windows.Threading.DispatcherPriority.ApplicationIdle);
};
mGrille.Game = game;
}
Action EmptyDelegate = delegate() { };
private void Window_MouseDown_1(object sender, MouseButtonEventArgs e)
{
game.Start();
}
}
}

@ -0,0 +1,133 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- ======================================================================
Copyright (C) 2013-2014 MARC CHEVALDONNE
marc.chevaldonne.free.fr
Module : MorpionGameWpf.csproj
Author : Marc Chevaldonné
Creation date : 2014-05-07
======================================================================== -->
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{C3AAF4F7-2939-438B-B5E4-9D7B547C1E5E}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>MorpionGameWpf</RootNamespace>
<AssemblyName>MorpionGameWpf</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Page Include="MorpionGrid.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="MorpionGridCase.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Compile Include="MorpionGrid.xaml.cs">
<DependentUpon>MorpionGrid.xaml</DependentUpon>
</Compile>
<Compile Include="MorpionGridCase.xaml.cs">
<DependentUpon>MorpionGridCase.xaml</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<AppDesigner Include="Properties\" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\giMorpionCore\giMorpionCore.csproj">
<Project>{38830db6-08c8-4f3d-889e-ee59f6be63d8}</Project>
<Name>giMorpionCore %281. Morpion\v5_solutionAvecPatternStandardDesEvénements\giMorpionCore%29</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

@ -0,0 +1,21 @@
<!-- ======================================================================
Copyright (C) 2013-2014 MARC CHEVALDONNE
marc.chevaldonne.free.fr
Module : MorpionGrid.xaml
Author : Marc Chevaldonné
Creation date : 2014-05-07
======================================================================== -->
<UserControl x:Class="MorpionGameWpf.MorpionGrid"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid Name="mGrid">
</Grid>
</UserControl>

@ -0,0 +1,94 @@
// ========================================================================
//
// Copyright (C) 2013-2014 MARC CHEVALDONNE
// marc.chevaldonne.free.fr
//
// Module : MorpionGrid.xaml.cs
// Author : Marc Chevaldonné
// Creation date : 2014-05-07
//
// ========================================================================
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;
using giMorpionCore;
namespace MorpionGameWpf
{
/// <summary>
/// Logique d'interaction pour MorpionGrid.xaml
/// </summary>
public partial class MorpionGrid : UserControl
{
public MorpionGrid()
{
InitializeComponent();
}
public Game Game
{
get { return (Game)GetValue(GameProperty); }
set { SetValue(GameProperty, value); }
}
// Using a DependencyProperty as the backing store for Game. This enables animation, styling, binding, etc...
public static readonly DependencyProperty GameProperty =
DependencyProperty.Register("Game", typeof(Game), typeof(MorpionGrid));
static Dictionary<int, string> mPlayerSymbols = new Dictionary<int, string>() { {-1, " "}, { 0, "O" }, { 1, "X" } };
public void Update(params Case[] winningPlaces)
{
if(Game == null)
{
return;
}
int[,] board = Game.Board;
if (mGrid.RowDefinitions.Count == 0)
{
for (int i = 0; i < board.GetLength(0); i++)
{
mGrid.RowDefinitions.Add(new RowDefinition());
}
for (int i = 0; i < board.GetLength(1); i++)
{
mGrid.ColumnDefinitions.Add(new ColumnDefinition());
}
}
mGrid.Children.Clear();
for (int i = 0; i < board.GetLength(0); i++)
{
for (int j = 0; j < board.GetLength(1); j++)
{
var newCase = new MorpionGridCase() { PlayerId = mPlayerSymbols[board[i,j]]};
if (winningPlaces.Cast<Case>().Contains(new Case(i, j)))
{
newCase.BackgroundColor = Brushes.Red;
}
newCase.SetValue(Grid.RowProperty, i);
newCase.SetValue(Grid.ColumnProperty, j);
mGrid.Children.Add(newCase);
}
}
}
}
}

@ -0,0 +1,23 @@
<!-- ======================================================================
Copyright (C) 2013-2014 MARC CHEVALDONNE
marc.chevaldonne.free.fr
Module : MorpionGridCase.xaml
Author : Marc Chevaldonné
Creation date : 2014-05-07
======================================================================== -->
<UserControl x:Class="MorpionGameWpf.MorpionGridCase"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300"
x:Name="root">
<Grid Background="{Binding BackgroundColor, ElementName=root}">
<TextBlock Text="{Binding PlayerId, ElementName=root}" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="30" FontWeight="Bold"/>
</Grid>
</UserControl>

@ -0,0 +1,66 @@
// ========================================================================
//
// Copyright (C) 2013-2014 MARC CHEVALDONNE
// marc.chevaldonne.free.fr
//
// Module : MorpionGridCase.xaml.cs
// Author : Marc Chevaldonné
// Creation date : 2014-05-07
//
// ========================================================================
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 MorpionGameWpf
{
/// <summary>
/// Logique d'interaction pour MorpionGridCase.xaml
/// </summary>
public partial class MorpionGridCase : UserControl
{
public MorpionGridCase()
{
InitializeComponent();
}
public string PlayerId
{
get { return (string)GetValue(PlayerIdProperty); }
set { SetValue(PlayerIdProperty, value); }
}
// Using a DependencyProperty as the backing store for PlayerId. This enables animation, styling, binding, etc...
public static readonly DependencyProperty PlayerIdProperty =
DependencyProperty.Register("PlayerId", typeof(string), typeof(MorpionGridCase), new PropertyMetadata(" "));
public SolidColorBrush BackgroundColor
{
get { return (SolidColorBrush)GetValue(BackgroundColorProperty); }
set { SetValue(BackgroundColorProperty, value); }
}
// Using a DependencyProperty as the backing store for BackgroundColor. This enables animation, styling, binding, etc...
public static readonly DependencyProperty BackgroundColorProperty =
DependencyProperty.Register("BackgroundColor", typeof(SolidColorBrush), typeof(MorpionGridCase), new PropertyMetadata(Brushes.AliceBlue));
}
}

@ -0,0 +1,66 @@
// ========================================================================
//
// Copyright (C) 2013-2014 MARC CHEVALDONNE
// marc.chevaldonne.free.fr
//
// Module : AssemblyInfo.cs
// Author : Marc Chevaldonné
// Creation date : 2014-05-07
//
// ========================================================================
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows;
// Les informations générales relatives à un assembly dépendent de
// l'ensemble d'attributs suivant. Changez les valeurs de ces attributs pour modifier les informations
// associées à un assembly.
[assembly: AssemblyTitle("MorpionGameWpf")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MorpionGameWpf")]
[assembly: AssemblyCopyright("Copyright © 2014")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// L'affectation de la valeur false à ComVisible rend les types invisibles dans cet assembly
// aux composants COM. Si vous devez accéder à un type dans cet assembly à partir de
// COM, affectez la valeur true à l'attribut ComVisible sur ce type.
[assembly: ComVisible(false)]
//Pour commencer à générer des applications localisables, définissez
//<UICulture>CultureYouAreCodingWith</UICulture> dans votre fichier .csproj
//dans <PropertyGroup>. Par exemple, si vous utilisez le français
//dans vos fichiers sources, définissez <UICulture> à fr-FR. Puis, supprimez les marques de commentaire de
//l'attribut NeutralResourceLanguage ci-dessous. Mettez à jour "fr-FR" dans
//la ligne ci-après pour qu'elle corresponde au paramètre UICulture du fichier projet.
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //où se trouvent les dictionnaires de ressources spécifiques à un thème
//(utilisé si une ressource est introuvable dans la page,
// ou dictionnaires de ressources de l'application)
ResourceDictionaryLocation.SourceAssembly //où se trouve le dictionnaire de ressources générique
//(utilisé si une ressource est introuvable dans la page,
// dans l'application ou dans l'un des dictionnaires de ressources spécifiques à un thème)
)]
// Les informations de version pour un assembly se composent des quatre valeurs suivantes :
//
// Version principale
// Version secondaire
// Numéro de build
// Révision
//
// Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut
// en utilisant '*', comme indiqué ci-dessous :
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

@ -0,0 +1,63 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Ce code a été généré par un outil.
// Version du runtime :4.0.30319.42000
//
// Les modifications apportées à ce fichier peuvent provoquer un comportement incorrect et seront perdues si
// le code est régénéré.
// </auto-generated>
//------------------------------------------------------------------------------
namespace MorpionGameWpf.Properties {
using System;
/// <summary>
/// Une classe de ressource fortement typée destinée, entre autres, à la consultation des chaînes localisées.
/// </summary>
// Cette classe a été générée automatiquement par la classe StronglyTypedResourceBuilder
// à l'aide d'un outil, tel que ResGen ou Visual Studio.
// Pour ajouter ou supprimer un membre, modifiez votre fichier .ResX, puis réexécutez ResGen
// avec l'option /str ou régénérez votre projet VS.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Retourne l'instance ResourceManager mise en cache utilisée par cette classe.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MorpionGameWpf.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Remplace la propriété CurrentUICulture du thread actuel pour toutes
/// les recherches de ressources à l'aide de cette classe de ressource fortement typée.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}

@ -0,0 +1,128 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- ======================================================================
Copyright (C) 2013-2014 MARC CHEVALDONNE
marc.chevaldonne.free.fr
Module : Resources.resx
Author : Marc Chevaldonné
Creation date : 2014-05-07
======================================================================== -->
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

@ -0,0 +1,41 @@
// ========================================================================
//
// Copyright (C) 2013-2014 MARC CHEVALDONNE
// marc.chevaldonne.free.fr
//
// Module : Settings.Designer.cs
// Author : Marc Chevaldonné
// Creation date : 2014-05-07
//
// ========================================================================
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.17929
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace MorpionGameWpf.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
return defaultInstance;
}
}
}
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save