Compare commits
2 Commits
f767fe6e35
...
82fcaaaf90
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
82fcaaaf90 | ||
|
|
2236c19c07 |
@@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="..\packages\Microsoft.ML.FastTree.5.0.0-preview.1.25127.4\build\netstandard2.0\Microsoft.ML.FastTree.props" Condition="Exists('..\packages\Microsoft.ML.FastTree.5.0.0-preview.1.25127.4\build\netstandard2.0\Microsoft.ML.FastTree.props')" />
|
||||
<Import Project="..\packages\Microsoft.ML.5.0.0-preview.1.25127.4\build\netstandard2.0\Microsoft.ML.props" Condition="Exists('..\packages\Microsoft.ML.5.0.0-preview.1.25127.4\build\netstandard2.0\Microsoft.ML.props')" />
|
||||
<Import Project="..\packages\Microsoft.ML.CpuMath.5.0.0-preview.1.25127.4\build\netstandard2.0\Microsoft.ML.CpuMath.props" Condition="Exists('..\packages\Microsoft.ML.CpuMath.5.0.0-preview.1.25127.4\build\netstandard2.0\Microsoft.ML.CpuMath.props')" />
|
||||
<Import Project="..\packages\Microsoft.ML.FastTree.5.0.0-preview.25503.2\build\netstandard2.0\Microsoft.ML.FastTree.props" Condition="Exists('..\packages\Microsoft.ML.FastTree.5.0.0-preview.25503.2\build\netstandard2.0\Microsoft.ML.FastTree.props')" />
|
||||
<Import Project="..\packages\Microsoft.ML.5.0.0-preview.25503.2\build\netstandard2.0\Microsoft.ML.props" Condition="Exists('..\packages\Microsoft.ML.5.0.0-preview.25503.2\build\netstandard2.0\Microsoft.ML.props')" />
|
||||
<Import Project="..\packages\Microsoft.ML.CpuMath.5.0.0-preview.25503.2\build\netstandard2.0\Microsoft.ML.CpuMath.props" Condition="Exists('..\packages\Microsoft.ML.CpuMath.5.0.0-preview.25503.2\build\netstandard2.0\Microsoft.ML.CpuMath.props')" />
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
@@ -59,49 +59,50 @@
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="CsvHelper, Version=33.0.0.0, Culture=neutral, PublicKeyToken=8c4959082be5c823, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\CsvHelper.33.0.1\lib\net48\CsvHelper.dll</HintPath>
|
||||
<HintPath>..\packages\CsvHelper.33.1.0\lib\net48\CsvHelper.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Dapper, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Dapper.2.1.66\lib\net461\Dapper.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=10.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.10.0.0-preview.4.25258.110\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
|
||||
<HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.10.0.0-rc.1.25451.107\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Bcl.HashCode, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Bcl.HashCode.6.0.0\lib\net462\Microsoft.Bcl.HashCode.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Bcl.Numerics, Version=10.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Bcl.Numerics.10.0.0-preview.4.25258.110\lib\net462\Microsoft.Bcl.Numerics.dll</HintPath>
|
||||
<HintPath>..\packages\Microsoft.Bcl.Numerics.10.0.0-rc.1.25451.107\lib\net462\Microsoft.Bcl.Numerics.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.ML.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.ML.5.0.0-preview.1.25127.4\lib\netstandard2.0\Microsoft.ML.Core.dll</HintPath>
|
||||
<HintPath>..\packages\Microsoft.ML.5.0.0-preview.25503.2\lib\netstandard2.0\Microsoft.ML.Core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.ML.CpuMath, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.ML.CpuMath.5.0.0-preview.1.25127.4\lib\netstandard2.0\Microsoft.ML.CpuMath.dll</HintPath>
|
||||
<HintPath>..\packages\Microsoft.ML.CpuMath.5.0.0-preview.25503.2\lib\netstandard2.0\Microsoft.ML.CpuMath.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.ML.Data, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.ML.5.0.0-preview.1.25127.4\lib\netstandard2.0\Microsoft.ML.Data.dll</HintPath>
|
||||
<HintPath>..\packages\Microsoft.ML.5.0.0-preview.25503.2\lib\netstandard2.0\Microsoft.ML.Data.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.ML.DataView, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.ML.DataView.5.0.0-preview.1.25127.4\lib\netstandard2.0\Microsoft.ML.DataView.dll</HintPath>
|
||||
<HintPath>..\packages\Microsoft.ML.DataView.5.0.0-preview.25503.2\lib\netstandard2.0\Microsoft.ML.DataView.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.ML.FastTree, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.ML.FastTree.5.0.0-preview.1.25127.4\lib\netstandard2.0\Microsoft.ML.FastTree.dll</HintPath>
|
||||
<HintPath>..\packages\Microsoft.ML.FastTree.5.0.0-preview.25503.2\lib\netstandard2.0\Microsoft.ML.FastTree.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.ML.KMeansClustering, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.ML.5.0.0-preview.1.25127.4\lib\netstandard2.0\Microsoft.ML.KMeansClustering.dll</HintPath>
|
||||
<HintPath>..\packages\Microsoft.ML.5.0.0-preview.25503.2\lib\netstandard2.0\Microsoft.ML.KMeansClustering.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.ML.PCA, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.ML.5.0.0-preview.1.25127.4\lib\netstandard2.0\Microsoft.ML.PCA.dll</HintPath>
|
||||
<HintPath>..\packages\Microsoft.ML.5.0.0-preview.25503.2\lib\netstandard2.0\Microsoft.ML.PCA.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.ML.StandardTrainers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.ML.5.0.0-preview.1.25127.4\lib\netstandard2.0\Microsoft.ML.StandardTrainers.dll</HintPath>
|
||||
<HintPath>..\packages\Microsoft.ML.5.0.0-preview.25503.2\lib\netstandard2.0\Microsoft.ML.StandardTrainers.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.ML.Transforms, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.ML.5.0.0-preview.1.25127.4\lib\netstandard2.0\Microsoft.ML.Transforms.dll</HintPath>
|
||||
<HintPath>..\packages\Microsoft.ML.5.0.0-preview.25503.2\lib\netstandard2.0\Microsoft.ML.Transforms.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
<HintPath>..\packages\Newtonsoft.Json.13.0.4\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="RestSharp, Version=112.1.1.0, Culture=neutral, PublicKeyToken=598062e77f915f75, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\RestSharp.112.1.1-alpha.0.4\lib\net48\RestSharp.dll</HintPath>
|
||||
@@ -111,21 +112,21 @@
|
||||
<HintPath>..\packages\System.Buffers.4.6.1\lib\net462\System.Buffers.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.CodeDom, Version=10.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.CodeDom.10.0.0-preview.4.25258.110\lib\net462\System.CodeDom.dll</HintPath>
|
||||
<HintPath>..\packages\System.CodeDom.10.0.0-rc.1.25451.107\lib\net462\System.CodeDom.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Collections.Immutable, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Collections.Immutable.10.0.0-preview.4.25258.110\lib\net462\System.Collections.Immutable.dll</HintPath>
|
||||
<HintPath>..\packages\System.Collections.Immutable.10.0.0-rc.1.25451.107\lib\net462\System.Collections.Immutable.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.IO.Pipelines, Version=10.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.IO.Pipelines.10.0.0-preview.2.25163.2\lib\net462\System.IO.Pipelines.dll</HintPath>
|
||||
<HintPath>..\packages\System.IO.Pipelines.10.0.0-rc.1.25451.107\lib\net462\System.IO.Pipelines.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Memory, Version=4.0.5.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Memory.4.6.3\lib\net462\System.Memory.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Numerics" />
|
||||
<Reference Include="System.Numerics.Tensors, Version=10.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Numerics.Tensors.10.0.0-preview.4.25258.110\lib\net462\System.Numerics.Tensors.dll</HintPath>
|
||||
<HintPath>..\packages\System.Numerics.Tensors.10.0.0-rc.1.25451.107\lib\net462\System.Numerics.Tensors.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Numerics.Vectors, Version=4.1.6.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Numerics.Vectors.4.6.1\lib\net462\System.Numerics.Vectors.dll</HintPath>
|
||||
@@ -134,13 +135,13 @@
|
||||
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.6.1.2\lib\net462\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Text.Encodings.Web, Version=10.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Text.Encodings.Web.10.0.0-preview.2.25163.2\lib\net462\System.Text.Encodings.Web.dll</HintPath>
|
||||
<HintPath>..\packages\System.Text.Encodings.Web.10.0.0-rc.1.25451.107\lib\net462\System.Text.Encodings.Web.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Text.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Text.Json.10.0.0-preview.2.25163.2\lib\net462\System.Text.Json.dll</HintPath>
|
||||
<HintPath>..\packages\System.Text.Json.10.0.0-rc.1.25451.107\lib\net462\System.Text.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Threading.Channels, Version=10.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Threading.Channels.10.0.0-preview.4.25258.110\lib\net462\System.Threading.Channels.dll</HintPath>
|
||||
<HintPath>..\packages\System.Threading.Channels.10.0.0-rc.1.25451.107\lib\net462\System.Threading.Channels.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.4.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.6.3\lib\net462\System.Threading.Tasks.Extensions.dll</HintPath>
|
||||
@@ -199,6 +200,31 @@
|
||||
</Compile>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="UI\Controls\ModernButton.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="UI\Controls\ModernDataGridView.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="UI\Controls\ModernDateTimePicker.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="UI\Controls\ModernLabel.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="UI\Controls\ModernPanel.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="UI\Controls\ModernProgressBar.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="UI\Controls\ModernTabControl.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="UI\Controls\ModernTextBox.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="UI\ModernTheme.cs" />
|
||||
<EmbeddedResource Include="Main.resx">
|
||||
<DependentUpon>Main.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
@@ -240,10 +266,10 @@
|
||||
<ErrorText>Questo progetto fa riferimento a uno o più pacchetti NuGet che non sono presenti in questo computer. Usare lo strumento di ripristino dei pacchetti NuGet per scaricarli. Per altre informazioni, vedere http://go.microsoft.com/fwlink/?LinkID=322105. Il file mancante è {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\System.ValueTuple.4.6.1\build\net471\System.ValueTuple.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\System.ValueTuple.4.6.1\build\net471\System.ValueTuple.targets'))" />
|
||||
<Error Condition="!Exists('..\packages\Microsoft.ML.CpuMath.5.0.0-preview.1.25127.4\build\netstandard2.0\Microsoft.ML.CpuMath.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.ML.CpuMath.5.0.0-preview.1.25127.4\build\netstandard2.0\Microsoft.ML.CpuMath.props'))" />
|
||||
<Error Condition="!Exists('..\packages\Microsoft.ML.5.0.0-preview.1.25127.4\build\netstandard2.0\Microsoft.ML.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.ML.5.0.0-preview.1.25127.4\build\netstandard2.0\Microsoft.ML.props'))" />
|
||||
<Error Condition="!Exists('..\packages\Microsoft.ML.5.0.0-preview.1.25127.4\build\netstandard2.0\Microsoft.ML.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.ML.5.0.0-preview.1.25127.4\build\netstandard2.0\Microsoft.ML.targets'))" />
|
||||
<Error Condition="!Exists('..\packages\Microsoft.ML.FastTree.5.0.0-preview.1.25127.4\build\netstandard2.0\Microsoft.ML.FastTree.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.ML.FastTree.5.0.0-preview.1.25127.4\build\netstandard2.0\Microsoft.ML.FastTree.props'))" />
|
||||
<Error Condition="!Exists('..\packages\Microsoft.ML.CpuMath.5.0.0-preview.25503.2\build\netstandard2.0\Microsoft.ML.CpuMath.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.ML.CpuMath.5.0.0-preview.25503.2\build\netstandard2.0\Microsoft.ML.CpuMath.props'))" />
|
||||
<Error Condition="!Exists('..\packages\Microsoft.ML.5.0.0-preview.25503.2\build\netstandard2.0\Microsoft.ML.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.ML.5.0.0-preview.25503.2\build\netstandard2.0\Microsoft.ML.props'))" />
|
||||
<Error Condition="!Exists('..\packages\Microsoft.ML.5.0.0-preview.25503.2\build\netstandard2.0\Microsoft.ML.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.ML.5.0.0-preview.25503.2\build\netstandard2.0\Microsoft.ML.targets'))" />
|
||||
<Error Condition="!Exists('..\packages\Microsoft.ML.FastTree.5.0.0-preview.25503.2\build\netstandard2.0\Microsoft.ML.FastTree.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.ML.FastTree.5.0.0-preview.25503.2\build\netstandard2.0\Microsoft.ML.FastTree.props'))" />
|
||||
</Target>
|
||||
<Import Project="..\packages\Microsoft.ML.5.0.0-preview.1.25127.4\build\netstandard2.0\Microsoft.ML.targets" Condition="Exists('..\packages\Microsoft.ML.5.0.0-preview.1.25127.4\build\netstandard2.0\Microsoft.ML.targets')" />
|
||||
<Import Project="..\packages\Microsoft.ML.5.0.0-preview.25503.2\build\netstandard2.0\Microsoft.ML.targets" Condition="Exists('..\packages\Microsoft.ML.5.0.0-preview.25503.2\build\netstandard2.0\Microsoft.ML.targets')" />
|
||||
</Project>
|
||||
@@ -1,20 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.Json.Nodes;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace HorseRacingPredictor.Football.Database
|
||||
{
|
||||
internal class BetType : HorseRacingPredictor.Football.Manager.Database
|
||||
{
|
||||
public void Upsert(SqlConnection connection, JsonNode betType)
|
||||
public void Upsert(SqlConnection connection, JToken betType)
|
||||
{
|
||||
try
|
||||
{
|
||||
var id = betType["id"]?.GetValue<int>();
|
||||
var id = betType["id"]?.Value<int>();
|
||||
if (id == null) return; // Salta il record se l'id è null
|
||||
|
||||
var query = @"
|
||||
@@ -29,7 +25,7 @@ namespace HorseRacingPredictor.Football.Database
|
||||
using (var command = new SqlCommand(query, connection))
|
||||
{
|
||||
command.Parameters.AddWithValue("@bet_type_id", id);
|
||||
command.Parameters.AddWithValue("@name", betType["name"]?.GetValue<string>() ?? "");
|
||||
command.Parameters.AddWithValue("@name", betType["name"]?.Value<string>() ?? "");
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.Json.Nodes;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace HorseRacingPredictor.Football.Database
|
||||
{
|
||||
internal class Bookmaker : HorseRacingPredictor.Football.Manager.Database
|
||||
{
|
||||
public void Upsert(SqlConnection connection, JsonNode bookmaker)
|
||||
public void Upsert(SqlConnection connection, JToken bookmaker)
|
||||
{
|
||||
try
|
||||
{
|
||||
var id = bookmaker["id"]?.GetValue<int>();
|
||||
var id = bookmaker["id"]?.Value<int>();
|
||||
if (id == null) return; // Salta il record se l'id è null
|
||||
|
||||
var query = @"
|
||||
@@ -29,7 +25,7 @@ namespace HorseRacingPredictor.Football.Database
|
||||
using (var command = new SqlCommand(query, connection))
|
||||
{
|
||||
command.Parameters.AddWithValue("@bookmaker_id", id);
|
||||
command.Parameters.AddWithValue("@name", bookmaker["name"]?.GetValue<string>() ?? "");
|
||||
command.Parameters.AddWithValue("@name", bookmaker["name"]?.Value<string>() ?? "");
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.Json.Nodes;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace HorseRacingPredictor.Football.Database
|
||||
{
|
||||
internal class Comparison : HorseRacingPredictor.Football.Manager.Database
|
||||
{
|
||||
public void Upsert(SqlConnection connection, int predictionId, JsonNode comparison)
|
||||
public void Upsert(SqlConnection connection, int predictionId, JToken comparison)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -56,20 +52,20 @@ namespace HorseRacingPredictor.Football.Database
|
||||
command.Parameters.AddWithValue("@prediction_id", predictionId);
|
||||
|
||||
// Aggiungi tutti i parametri del confronto
|
||||
command.Parameters.AddWithValue("@form_home", comparison["form"]?["home"]?.GetValue<string>() ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("@form_away", comparison["form"]?["away"]?.GetValue<string>() ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("@att_home", comparison["att"]?["home"]?.GetValue<string>() ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("@att_away", comparison["att"]?["away"]?.GetValue<string>() ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("@def_home", comparison["def"]?["home"]?.GetValue<string>() ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("@def_away", comparison["def"]?["away"]?.GetValue<string>() ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("@poisson_home", comparison["poisson_distribution"]?["home"]?.GetValue<string>() ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("@poisson_away", comparison["poisson_distribution"]?["away"]?.GetValue<string>() ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("@h2h_home", comparison["h2h"]?["home"]?.GetValue<string>() ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("@h2h_away", comparison["h2h"]?["away"]?.GetValue<string>() ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("@goals_home", comparison["goals"]?["home"]?.GetValue<string>() ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("@goals_away", comparison["goals"]?["away"]?.GetValue<string>() ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("@total_home", comparison["total"]?["home"]?.GetValue<string>() ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("@total_away", comparison["total"]?["away"]?.GetValue<string>() ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("@form_home", comparison["form"]?["home"]?.Value<string>() ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("@form_away", comparison["form"]?["away"]?.Value<string>() ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("@att_home", comparison["att"]?["home"]?.Value<string>() ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("@att_away", comparison["att"]?["away"]?.Value<string>() ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("@def_home", comparison["def"]?["home"]?.Value<string>() ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("@def_away", comparison["def"]?["away"]?.Value<string>() ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("@poisson_home", comparison["poisson_distribution"]?["home"]?.Value<string>() ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("@poisson_away", comparison["poisson_distribution"]?["away"]?.Value<string>() ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("@h2h_home", comparison["h2h"]?["home"]?.Value<string>() ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("@h2h_away", comparison["h2h"]?["away"]?.Value<string>() ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("@goals_home", comparison["goals"]?["home"]?.Value<string>() ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("@goals_away", comparison["goals"]?["away"]?.Value<string>() ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("@total_home", comparison["total"]?["home"]?.Value<string>() ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("@total_away", comparison["total"]?["away"]?.Value<string>() ?? (object)DBNull.Value);
|
||||
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Text.Json.Nodes;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace HorseRacingPredictor.Football.Database
|
||||
{
|
||||
internal class Fixture : HorseRacingPredictor.Football.Manager.Database
|
||||
{
|
||||
public void Upsert(SqlConnection connection, SqlTransaction transaction, JsonNode fixture)
|
||||
public void Upsert(SqlConnection connection, SqlTransaction transaction, JToken fixture)
|
||||
{
|
||||
try
|
||||
{
|
||||
var id = fixture["id"]?.GetValue<int>();
|
||||
var id = fixture["id"]?.Value<int>();
|
||||
if (id == null) return; // Salta il record se l'id è null
|
||||
|
||||
var query = @"
|
||||
@@ -63,20 +63,20 @@ namespace HorseRacingPredictor.Football.Database
|
||||
|
||||
// Parametri principali
|
||||
command.Parameters.AddWithValue("@fixture_id", id);
|
||||
command.Parameters.AddWithValue("@timezone", fixture["timezone"]?.GetValue<string>() ?? "");
|
||||
command.Parameters.AddWithValue("@date", fixture["date"]?.GetValue<DateTime>() ?? DateTime.MinValue);
|
||||
command.Parameters.AddWithValue("@timestamp", fixture["timestamp"]?.GetValue<long>() ?? 0L);
|
||||
command.Parameters.AddWithValue("@referee", fixture["referee"]?.GetValue<string>() ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("@timezone", fixture["timezone"]?.Value<string>() ?? "");
|
||||
command.Parameters.AddWithValue("@date", fixture["date"]?.Value<DateTime>() ?? DateTime.MinValue);
|
||||
command.Parameters.AddWithValue("@timestamp", fixture["timestamp"]?.Value<long>() ?? 0L);
|
||||
command.Parameters.AddWithValue("@referee", fixture["referee"]?.Value<string>() ?? (object)DBNull.Value);
|
||||
|
||||
// Parametri venue
|
||||
int? venueId = venue?["id"]?.GetValue<int?>();
|
||||
int? venueId = venue?["id"]?.Value<int?>();
|
||||
command.Parameters.AddWithValue("@venue_id", venueId.HasValue ? (object)venueId.Value : DBNull.Value);
|
||||
|
||||
// Parametri status
|
||||
command.Parameters.AddWithValue("@status_long", status?["long"]?.GetValue<string>() ?? "");
|
||||
command.Parameters.AddWithValue("@status_short", status?["short"]?.GetValue<string>() ?? "");
|
||||
command.Parameters.AddWithValue("@status_long", status?["long"]?.Value<string>() ?? "");
|
||||
command.Parameters.AddWithValue("@status_short", status?["short"]?.Value<string>() ?? "");
|
||||
|
||||
int? elapsed = status?["elapsed"]?.GetValue<int?>();
|
||||
int? elapsed = status?["elapsed"]?.Value<int?>();
|
||||
int? extra = null; // Assumo che l'API restituisca questo valore, altrimenti va gestito come gli altri
|
||||
|
||||
command.Parameters.AddWithValue("@status_elapsed", elapsed.HasValue ? (object)elapsed.Value : DBNull.Value);
|
||||
@@ -101,11 +101,11 @@ namespace HorseRacingPredictor.Football.Database
|
||||
/// <summary>
|
||||
/// Metodo di supporto per inserire/aggiornare le informazioni sulla venue
|
||||
/// </summary>
|
||||
private void UpsertVenue(SqlConnection connection, SqlTransaction transaction, JsonNode venue)
|
||||
private void UpsertVenue(SqlConnection connection, SqlTransaction transaction, JToken venue)
|
||||
{
|
||||
try
|
||||
{
|
||||
var id = venue["id"]?.GetValue<int>();
|
||||
var id = venue["id"]?.Value<int>();
|
||||
if (id == null) return;
|
||||
|
||||
var query = @"
|
||||
@@ -121,8 +121,8 @@ namespace HorseRacingPredictor.Football.Database
|
||||
using (var command = new SqlCommand(query, connection, transaction))
|
||||
{
|
||||
command.Parameters.AddWithValue("@venue_id", id);
|
||||
command.Parameters.AddWithValue("@name", venue["name"]?.GetValue<string>() ?? "");
|
||||
command.Parameters.AddWithValue("@city", venue["city"]?.GetValue<string>() ?? "");
|
||||
command.Parameters.AddWithValue("@name", venue["name"]?.Value<string>() ?? "");
|
||||
command.Parameters.AddWithValue("@city", venue["city"]?.Value<string>() ?? "");
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,20 +3,20 @@ using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.Json.Nodes;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace HorseRacingPredictor.Football.Database
|
||||
{
|
||||
internal class FixtureLeague : HorseRacingPredictor.Football.Manager.Database
|
||||
{
|
||||
public void Upsert(SqlConnection connection, SqlTransaction transaction, int fixtureId, int leagueId, JsonNode leagueData)
|
||||
public void Upsert(SqlConnection connection, SqlTransaction transaction, int fixtureId, int leagueId, JToken leagueData)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Estrai i valori prima della query per utilizzarli nel log
|
||||
string round = leagueData["round"]?.GetValue<string>() ?? "";
|
||||
bool? standings = leagueData["standings"]?.GetValue<bool?>();
|
||||
string round = leagueData["round"]?.Value<string>() ?? "";
|
||||
bool? standings = leagueData["standings"]?.Value<bool?>();
|
||||
string standingsValue = standings.HasValue ? standings.Value.ToString() : "NULL";
|
||||
|
||||
// Log dell'operazione prima di tentare l'upsert
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
using System;
|
||||
using System.Data.SqlClient;
|
||||
using System.Text.Json.Nodes;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace HorseRacingPredictor.Football.Database
|
||||
{
|
||||
internal class Goals : HorseRacingPredictor.Football.Manager.Database
|
||||
{
|
||||
public void Upsert(SqlConnection connection, JsonNode goals, int fixtureId)
|
||||
public void Upsert(SqlConnection connection, JToken goals, int fixtureId)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -27,8 +27,8 @@ namespace HorseRacingPredictor.Football.Database
|
||||
END";
|
||||
using (var command = new SqlCommand(query, connection))
|
||||
{
|
||||
command.Parameters.AddWithValue("@home", goals["home"]?.GetValue<int?>() ?? 0);
|
||||
command.Parameters.AddWithValue("@away", goals["away"]?.GetValue<int?>() ?? 0);
|
||||
command.Parameters.AddWithValue("@home", goals["home"]?.Value<int?>() ?? 0);
|
||||
command.Parameters.AddWithValue("@away", goals["away"]?.Value<int?>() ?? 0);
|
||||
command.Parameters.AddWithValue("@fixture_id", fixtureId);
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
using System;
|
||||
using System.Data.SqlClient;
|
||||
using System.Text.Json.Nodes;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace HorseRacingPredictor.Football.Database
|
||||
{
|
||||
internal class League : HorseRacingPredictor.Football.Manager.Database
|
||||
{
|
||||
public void Upsert(SqlConnection connection, JsonNode league)
|
||||
public void Upsert(SqlConnection connection, JToken league)
|
||||
{
|
||||
try
|
||||
{
|
||||
var id = league["id"]?.GetValue<int>();
|
||||
var id = league["id"]?.Value<int>();
|
||||
if (id == null) return; // Salta il record se l'id è null
|
||||
|
||||
var query = @"
|
||||
@@ -25,11 +25,11 @@ namespace HorseRacingPredictor.Football.Database
|
||||
using (var command = new SqlCommand(query, connection))
|
||||
{
|
||||
command.Parameters.AddWithValue("@league_id", id);
|
||||
command.Parameters.AddWithValue("@name", league["name"]?.GetValue<string>() ?? "");
|
||||
command.Parameters.AddWithValue("@country", league["country"]?.GetValue<string>() ?? "");
|
||||
command.Parameters.AddWithValue("@logo", league["logo"]?.GetValue<string>() ?? "");
|
||||
command.Parameters.AddWithValue("@flag", league["flag"]?.GetValue<string>() ?? "");
|
||||
command.Parameters.AddWithValue("@season", league["season"]?.GetValue<int>() ?? 0);
|
||||
command.Parameters.AddWithValue("@name", league["name"]?.Value<string>() ?? "");
|
||||
command.Parameters.AddWithValue("@country", league["country"]?.Value<string>() ?? "");
|
||||
command.Parameters.AddWithValue("@logo", league["logo"]?.Value<string>() ?? "");
|
||||
command.Parameters.AddWithValue("@flag", league["flag"]?.Value<string>() ?? "");
|
||||
command.Parameters.AddWithValue("@season", league["season"]?.Value<int>() ?? 0);
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
@@ -39,11 +39,11 @@ namespace HorseRacingPredictor.Football.Database
|
||||
}
|
||||
}
|
||||
|
||||
public void Upsert(SqlConnection connection, SqlTransaction transaction, JsonNode league)
|
||||
public void Upsert(SqlConnection connection, SqlTransaction transaction, JToken league)
|
||||
{
|
||||
try
|
||||
{
|
||||
var id = league["id"]?.GetValue<int>();
|
||||
var id = league["id"]?.Value<int>();
|
||||
if (id == null) return; // Salta il record se l'id è null
|
||||
|
||||
var query = @"
|
||||
@@ -58,11 +58,11 @@ namespace HorseRacingPredictor.Football.Database
|
||||
using (var command = new SqlCommand(query, connection, transaction))
|
||||
{
|
||||
command.Parameters.AddWithValue("@league_id", id);
|
||||
command.Parameters.AddWithValue("@name", league["name"]?.GetValue<string>() ?? "");
|
||||
command.Parameters.AddWithValue("@country", league["country"]?.GetValue<string>() ?? "");
|
||||
command.Parameters.AddWithValue("@logo", league["logo"]?.GetValue<string>() ?? "");
|
||||
command.Parameters.AddWithValue("@flag", league["flag"]?.GetValue<string>() ?? "");
|
||||
command.Parameters.AddWithValue("@season", league["season"]?.GetValue<int>() ?? 0);
|
||||
command.Parameters.AddWithValue("@name", league["name"]?.Value<string>() ?? "");
|
||||
command.Parameters.AddWithValue("@country", league["country"]?.Value<string>() ?? "");
|
||||
command.Parameters.AddWithValue("@logo", league["logo"]?.Value<string>() ?? "");
|
||||
command.Parameters.AddWithValue("@flag", league["flag"]?.Value<string>() ?? "");
|
||||
command.Parameters.AddWithValue("@season", league["season"]?.Value<int>() ?? 0);
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
using System;
|
||||
using System.Data.SqlClient;
|
||||
using System.Text.Json.Nodes;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace HorseRacingPredictor.Football.Database
|
||||
{
|
||||
internal class LeagueStats : HorseRacingPredictor.Football.Manager.Database
|
||||
{
|
||||
public int Insert(SqlConnection connection, int? teamId, int? predictionId, bool isHome, JsonNode stats)
|
||||
public int Insert(SqlConnection connection, int? teamId, int? predictionId, bool isHome, JToken stats)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -35,27 +35,27 @@ namespace HorseRacingPredictor.Football.Database
|
||||
command.Parameters.AddWithValue("@team_id", teamId.HasValue ? (object)teamId.Value : DBNull.Value);
|
||||
command.Parameters.AddWithValue("@prediction_id", predictionId.HasValue ? (object)predictionId.Value : DBNull.Value);
|
||||
command.Parameters.AddWithValue("@is_home", isHome);
|
||||
command.Parameters.AddWithValue("@form", stats["form"]?.GetValue<string>() ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("@form", stats["form"]?.Value<string>() ?? (object)DBNull.Value);
|
||||
|
||||
var fixtures = stats["fixtures"];
|
||||
command.Parameters.AddWithValue("@fixtures_played_home", fixtures?["played"]?["home"]?.GetValue<int?>() ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("@fixtures_played_away", fixtures?["played"]?["away"]?.GetValue<int?>() ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("@fixtures_played_total", fixtures?["played"]?["total"]?.GetValue<int?>() ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("@fixtures_played_home", fixtures?["played"]?["home"]?.Value<int?>() ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("@fixtures_played_away", fixtures?["played"]?["away"]?.Value<int?>() ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("@fixtures_played_total", fixtures?["played"]?["total"]?.Value<int?>() ?? (object)DBNull.Value);
|
||||
|
||||
var wins = stats["fixtures"]?["wins"];
|
||||
command.Parameters.AddWithValue("@wins_home", wins?["home"]?.GetValue<int?>() ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("@wins_away", wins?["away"]?.GetValue<int?>() ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("@wins_total", wins?["total"]?.GetValue<int?>() ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("@wins_home", wins?["home"]?.Value<int?>() ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("@wins_away", wins?["away"]?.Value<int?>() ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("@wins_total", wins?["total"]?.Value<int?>() ?? (object)DBNull.Value);
|
||||
|
||||
var draws = stats["fixtures"]?["draws"];
|
||||
command.Parameters.AddWithValue("@draws_home", draws?["home"]?.GetValue<int?>() ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("@draws_away", draws?["away"]?.GetValue<int?>() ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("@draws_total", draws?["total"]?.GetValue<int?>() ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("@draws_home", draws?["home"]?.Value<int?>() ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("@draws_away", draws?["away"]?.Value<int?>() ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("@draws_total", draws?["total"]?.Value<int?>() ?? (object)DBNull.Value);
|
||||
|
||||
var loses = stats["fixtures"]?["loses"];
|
||||
command.Parameters.AddWithValue("@loses_home", loses?["home"]?.GetValue<int?>() ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("@loses_away", loses?["away"]?.GetValue<int?>() ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("@loses_total", loses?["total"]?.GetValue<int?>() ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("@loses_home", loses?["home"]?.Value<int?>() ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("@loses_away", loses?["away"]?.Value<int?>() ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("@loses_total", loses?["total"]?.Value<int?>() ?? (object)DBNull.Value);
|
||||
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
@@ -1,26 +1,27 @@
|
||||
using System;
|
||||
using System.Data.SqlClient;
|
||||
using System.Text.Json.Nodes;
|
||||
using System.Linq;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace HorseRacingPredictor.Football.Database
|
||||
{
|
||||
internal class Odds : HorseRacingPredictor.Football.Manager.Database
|
||||
{
|
||||
public void Upsert(SqlConnection connection, JsonNode bookmakers, int fixtureId)
|
||||
public void Upsert(SqlConnection connection, JToken bookmakers, int fixtureId)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Aggiungiamo log per tracciare la struttura dei dati
|
||||
LogError($"Inizio elaborazione quote per fixture {fixtureId} con {bookmakers?.AsArray().Count ?? 0} bookmakers", null);
|
||||
LogError($"Inizio elaborazione quote per fixture {fixtureId} con {bookmakers?.Children().Count() ?? 0} bookmakers", null);
|
||||
|
||||
// Per ogni bookmaker
|
||||
foreach (var bookmaker in bookmakers.AsArray())
|
||||
foreach (var bookmaker in bookmakers.Children())
|
||||
{
|
||||
int bookmakerId = bookmaker["id"].GetValue<int>();
|
||||
int bookmakerId = bookmaker["id"].Value<int>();
|
||||
var bets = bookmaker["bets"];
|
||||
|
||||
// Cerchiamo le quote di tipo Match Winner (1X2)
|
||||
foreach (var bet in bets.AsArray())
|
||||
foreach (var bet in bets.Children())
|
||||
{
|
||||
// Gestiamo in modo più sicuro il recupero di valori dal JSON
|
||||
string betName = GetStringValueSafe(bet, "name");
|
||||
@@ -35,7 +36,7 @@ namespace HorseRacingPredictor.Football.Database
|
||||
if (betTypeId == 0) continue;
|
||||
|
||||
// Estrai e salva le quote
|
||||
foreach (var value in bet["values"].AsArray())
|
||||
foreach (var value in bet["values"].Children())
|
||||
{
|
||||
// Gestiamo in modo più sicuro il recupero di valori dal JSON
|
||||
string valueType = GetStringValueSafe(value, "value");
|
||||
@@ -128,9 +129,9 @@ namespace HorseRacingPredictor.Football.Database
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ottiene un valore stringa da un JsonNode in modo sicuro
|
||||
/// Ottiene un valore stringa da un JToken in modo sicuro
|
||||
/// </summary>
|
||||
private string GetStringValueSafe(JsonNode node, string propertyName)
|
||||
private string GetStringValueSafe(JToken node, string propertyName)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -140,10 +141,10 @@ namespace HorseRacingPredictor.Football.Database
|
||||
var value = node[propertyName];
|
||||
|
||||
// Gestiamo diversi tipi di nodi
|
||||
if (value.GetValueKind() == System.Text.Json.JsonValueKind.String)
|
||||
return value.GetValue<string>();
|
||||
else if (value.GetValueKind() == System.Text.Json.JsonValueKind.Number)
|
||||
return value.GetValue<decimal>().ToString();
|
||||
if (value.Type == JTokenType.String)
|
||||
return value.Value<string>();
|
||||
else if (value.Type == JTokenType.Float || value.Type == JTokenType.Integer)
|
||||
return value.Value<decimal>().ToString();
|
||||
else
|
||||
return value.ToString();
|
||||
}
|
||||
@@ -155,9 +156,9 @@ namespace HorseRacingPredictor.Football.Database
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ottiene un valore decimale da un JsonNode in modo sicuro
|
||||
/// Ottiene un valore decimale da un JToken in modo sicuro
|
||||
/// </summary>
|
||||
private decimal GetDecimalValueSafe(JsonNode node, string propertyName)
|
||||
private decimal GetDecimalValueSafe(JToken node, string propertyName)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -167,15 +168,15 @@ namespace HorseRacingPredictor.Football.Database
|
||||
var value = node[propertyName];
|
||||
|
||||
// Gestiamo diversi tipi di nodi
|
||||
if (value.GetValueKind() == System.Text.Json.JsonValueKind.Number)
|
||||
if (value.Type == JTokenType.Float || value.Type == JTokenType.Integer)
|
||||
{
|
||||
// Assicuriamoci che il valore sia esattamente quello originale
|
||||
return value.GetValue<decimal>();
|
||||
return value.Value<decimal>();
|
||||
}
|
||||
else if (value.GetValueKind() == System.Text.Json.JsonValueKind.String)
|
||||
else if (value.Type == JTokenType.String)
|
||||
{
|
||||
// Utilizziamo InvariantCulture per garantire una corretta interpretazione dei decimali
|
||||
if (decimal.TryParse(value.GetValue<string>(),
|
||||
if (decimal.TryParse(value.Value<string>(),
|
||||
System.Globalization.NumberStyles.Any,
|
||||
System.Globalization.CultureInfo.InvariantCulture,
|
||||
out decimal result))
|
||||
@@ -185,7 +186,7 @@ namespace HorseRacingPredictor.Football.Database
|
||||
}
|
||||
|
||||
// Aggiungiamo un log più dettagliato per aiutare il debug
|
||||
LogError($"Impossibile convertire '{value}' (tipo: {value.GetValueKind()}) in decimal per proprietà '{propertyName}'", null);
|
||||
LogError($"Impossibile convertire '{value}' (tipo: {value.Type}) in decimal per proprietà '{propertyName}'", null);
|
||||
return 0;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
using System;
|
||||
using System.Data.SqlClient;
|
||||
using System.Text.Json.Nodes;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace HorseRacingPredictor.Football.Database
|
||||
{
|
||||
internal class Prediction : HorseRacingPredictor.Football.Manager.Database
|
||||
{
|
||||
public void Upsert(SqlConnection connection, JsonNode predictions, int fixtureId)
|
||||
public void Upsert(SqlConnection connection, JToken predictions, int fixtureId)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Estrazione dei dati dalla risposta JSON
|
||||
string advice = predictions["advice"]?.GetValue<string>();
|
||||
string advice = predictions["advice"]?.Value<string>();
|
||||
if (string.IsNullOrEmpty(advice)) return; // Nessuna previsione se non c'è consiglio
|
||||
|
||||
// Estrazione degli altri valori, con gestione null
|
||||
int? winnerId = predictions["winner"]?["id"]?.GetValue<int?>();
|
||||
string winnerName = predictions["winner"]?["name"]?.GetValue<string>();
|
||||
string winnerComment = predictions["winner"]?["comment"]?.GetValue<string>();
|
||||
bool? winOrDraw = predictions["win_or_draw"]?.GetValue<bool?>();
|
||||
string underOver = predictions["under_over"]?.GetValue<string>();
|
||||
string goalsHome = predictions["goals"]?["home"]?.GetValue<string>();
|
||||
string goalsAway = predictions["goals"]?["away"]?.GetValue<string>();
|
||||
string percentHome = predictions["percent"]?["home"]?.GetValue<string>();
|
||||
string percentDraw = predictions["percent"]?["draw"]?.GetValue<string>();
|
||||
string percentAway = predictions["percent"]?["away"]?.GetValue<string>();
|
||||
int? winnerId = predictions["winner"]?["id"]?.Value<int?>();
|
||||
string winnerName = predictions["winner"]?["name"]?.Value<string>();
|
||||
string winnerComment = predictions["winner"]?["comment"]?.Value<string>();
|
||||
bool? winOrDraw = predictions["win_or_draw"]?.Value<bool?>();
|
||||
string underOver = predictions["under_over"]?.Value<string>();
|
||||
string goalsHome = predictions["goals"]?["home"]?.Value<string>();
|
||||
string goalsAway = predictions["goals"]?["away"]?.Value<string>();
|
||||
string percentHome = predictions["percent"]?["home"]?.Value<string>();
|
||||
string percentDraw = predictions["percent"]?["draw"]?.Value<string>();
|
||||
string percentAway = predictions["percent"]?["away"]?.Value<string>();
|
||||
|
||||
// Query per l'upsert con tutti i campi disponibili
|
||||
var query = @"
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
using System;
|
||||
using System.Data.SqlClient;
|
||||
using System.Text.Json.Nodes;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace HorseRacingPredictor.Football.Database
|
||||
{
|
||||
internal class Score : HorseRacingPredictor.Football.Manager.Database
|
||||
{
|
||||
public void Upsert(SqlConnection connection, JsonNode score, int fixtureId)
|
||||
public void Upsert(SqlConnection connection, JToken score, int fixtureId)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -26,14 +26,14 @@ namespace HorseRacingPredictor.Football.Database
|
||||
END";
|
||||
using (var command = new SqlCommand(query, connection))
|
||||
{
|
||||
command.Parameters.AddWithValue("@home_halftime", score["halftime"]["home"]?.GetValue<int?>() ?? 0);
|
||||
command.Parameters.AddWithValue("@away_halftime", score["halftime"]["away"]?.GetValue<int?>() ?? 0);
|
||||
command.Parameters.AddWithValue("@home_fulltime", score["fulltime"]["home"]?.GetValue<int?>() ?? 0);
|
||||
command.Parameters.AddWithValue("@away_fulltime", score["fulltime"]["away"]?.GetValue<int?>() ?? 0);
|
||||
command.Parameters.AddWithValue("@home_extratime", score["extratime"]["home"]?.GetValue<int?>() ?? 0);
|
||||
command.Parameters.AddWithValue("@away_extratime", score["extratime"]["away"]?.GetValue<int?>() ?? 0);
|
||||
command.Parameters.AddWithValue("@home_penalty", score["penalty"]["home"]?.GetValue<int?>() ?? 0);
|
||||
command.Parameters.AddWithValue("@away_penalty", score["penalty"]["away"]?.GetValue<int?>() ?? 0);
|
||||
command.Parameters.AddWithValue("@home_halftime", score["halftime"]?["home"]?.Value<int?>() ?? 0);
|
||||
command.Parameters.AddWithValue("@away_halftime", score["halftime"]?["away"]?.Value<int?>() ?? 0);
|
||||
command.Parameters.AddWithValue("@home_fulltime", score["fulltime"]?["home"]?.Value<int?>() ?? 0);
|
||||
command.Parameters.AddWithValue("@away_fulltime", score["fulltime"]?["away"]?.Value<int?>() ?? 0);
|
||||
command.Parameters.AddWithValue("@home_extratime", score["extratime"]?["home"]?.Value<int?>() ?? 0);
|
||||
command.Parameters.AddWithValue("@away_extratime", score["extratime"]?["away"]?.Value<int?>() ?? 0);
|
||||
command.Parameters.AddWithValue("@home_penalty", score["penalty"]?["home"]?.Value<int?>() ?? 0);
|
||||
command.Parameters.AddWithValue("@away_penalty", score["penalty"]?["away"]?.Value<int?>() ?? 0);
|
||||
command.Parameters.AddWithValue("@fixture_id", fixtureId);
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
using System;
|
||||
using System.Data.SqlClient;
|
||||
using System.Text.Json.Nodes;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace HorseRacingPredictor.Football.Database
|
||||
{
|
||||
internal class Team : HorseRacingPredictor.Football.Manager.Database
|
||||
{
|
||||
public void UpsertTeams(SqlConnection connection, SqlTransaction transaction, JsonNode teams, int fixtureId)
|
||||
public void UpsertTeams(SqlConnection connection, SqlTransaction transaction, JToken teams, int fixtureId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var homeTeamId = teams["home"]["id"]?.GetValue<int>();
|
||||
var awayTeamId = teams["away"]["id"]?.GetValue<int>();
|
||||
var homeTeamId = teams["home"]["id"]?.Value<int>();
|
||||
var awayTeamId = teams["away"]["id"]?.Value<int>();
|
||||
if (homeTeamId == null || awayTeamId == null) return; // Salta il record se uno degli id è null
|
||||
|
||||
var queryTeam = @"
|
||||
@@ -31,14 +31,14 @@ namespace HorseRacingPredictor.Football.Database
|
||||
|
||||
// Upsert home team
|
||||
command.Parameters.AddWithValue("@team_id", homeTeamId);
|
||||
command.Parameters.AddWithValue("@name", homeTeam["name"]?.GetValue<string>() ?? "");
|
||||
command.Parameters.AddWithValue("@logo", homeTeam["logo"]?.GetValue<string>() ?? "");
|
||||
command.Parameters.AddWithValue("@name", homeTeam["name"]?.Value<string>() ?? "");
|
||||
command.Parameters.AddWithValue("@logo", homeTeam["logo"]?.Value<string>() ?? "");
|
||||
command.ExecuteNonQuery();
|
||||
|
||||
// Upsert away team
|
||||
command.Parameters["@team_id"].Value = awayTeamId;
|
||||
command.Parameters["@name"].Value = awayTeam["name"]?.GetValue<string>() ?? "";
|
||||
command.Parameters["@logo"].Value = awayTeam["logo"]?.GetValue<string>() ?? "";
|
||||
command.Parameters["@name"].Value = awayTeam["name"]?.Value<string>() ?? "";
|
||||
command.Parameters["@logo"].Value = awayTeam["logo"]?.Value<string>() ?? "";
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,16 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.Json.Nodes;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace HorseRacingPredictor.Football.Database
|
||||
{
|
||||
internal class TeamStats : HorseRacingPredictor.Football.Manager.Database
|
||||
{
|
||||
public int Insert(SqlConnection connection, int? teamId, int? predictionId, bool isHome, JsonNode stats)
|
||||
public int Insert(SqlConnection connection, int? teamId, int? predictionId, bool isHome, JToken stats)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -35,18 +31,18 @@ namespace HorseRacingPredictor.Football.Database
|
||||
command.Parameters.AddWithValue("@team_id", teamId.HasValue ? (object)teamId.Value : DBNull.Value);
|
||||
command.Parameters.AddWithValue("@prediction_id", predictionId.HasValue ? (object)predictionId.Value : DBNull.Value);
|
||||
command.Parameters.AddWithValue("@is_home", isHome);
|
||||
command.Parameters.AddWithValue("@played", stats["played"]?.GetValue<int?>() ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("@form", stats["form"]?.GetValue<string>() ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("@att", stats["att"]?.GetValue<string>() ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("@def", stats["def"]?.GetValue<string>() ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("@played", stats["played"]?.Value<int?>() ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("@form", stats["form"]?.Value<string>() ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("@att", stats["att"]?.Value<string>() ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("@def", stats["def"]?.Value<string>() ?? (object)DBNull.Value);
|
||||
|
||||
var goalsFor = stats["goals"]?["for"];
|
||||
command.Parameters.AddWithValue("@goals_for_total", goalsFor?["total"]?.GetValue<int?>() ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("@goals_for_average", goalsFor?["average"]?.GetValue<string>() ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("@goals_for_total", goalsFor?["total"]?.Value<int?>() ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("@goals_for_average", goalsFor?["average"]?.Value<string>() ?? (object)DBNull.Value);
|
||||
|
||||
var goalsAgainst = stats["goals"]?["against"];
|
||||
command.Parameters.AddWithValue("@goals_against_total", goalsAgainst?["total"]?.GetValue<int?>() ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("@goals_against_average", goalsAgainst?["average"]?.GetValue<string>() ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("@goals_against_total", goalsAgainst?["total"]?.Value<int?>() ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("@goals_against_average", goalsAgainst?["average"]?.Value<string>() ?? (object)DBNull.Value);
|
||||
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
@@ -2,12 +2,11 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using RestSharp;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Nodes;
|
||||
using System.Data.SqlClient;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using RestSharp;
|
||||
|
||||
namespace HorseRacingPredictor.Football
|
||||
{
|
||||
@@ -156,20 +155,20 @@ namespace HorseRacingPredictor.Football
|
||||
return;
|
||||
}
|
||||
|
||||
var json = JsonDocument.Parse(fixturesResponse.Content).RootElement;
|
||||
var json = JObject.Parse(fixturesResponse.Content);
|
||||
|
||||
// Verifica che la risposta contenga dati validi
|
||||
if (!json.TryGetProperty("response", out var responseElement))
|
||||
if (json["response"] == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Per ogni partita, recupera la previsione
|
||||
foreach (var item in responseElement.EnumerateArray())
|
||||
foreach (var item in json["response"])
|
||||
{
|
||||
try
|
||||
{
|
||||
int fixtureId = item.GetProperty("fixture").GetProperty("id").GetInt32();
|
||||
int fixtureId = item["fixture"]["id"].Value<int>();
|
||||
|
||||
// Utilizza il prediction manager per ottenere la previsione
|
||||
_predictionManager.GetPredictionByFixture(fixtureId);
|
||||
@@ -255,11 +254,10 @@ namespace HorseRacingPredictor.Football
|
||||
responses.Add(response);
|
||||
|
||||
// Controlla se ci sono altre pagine
|
||||
var json = JsonDocument.Parse(response.Content).RootElement;
|
||||
if (json.TryGetProperty("paging", out var pagingElement) &&
|
||||
pagingElement.TryGetProperty("total", out var totalElement))
|
||||
var json = JObject.Parse(response.Content);
|
||||
if (json["paging"] != null && json["paging"]["total"] != null)
|
||||
{
|
||||
int totalPages = totalElement.GetInt32();
|
||||
int totalPages = json["paging"]["total"].Value<int>();
|
||||
hasMorePages = currentPage < totalPages;
|
||||
}
|
||||
else
|
||||
@@ -281,7 +279,7 @@ namespace HorseRacingPredictor.Football
|
||||
{
|
||||
try
|
||||
{
|
||||
var jsonObject = JsonNode.Parse(jsonResponse);
|
||||
var jsonObject = JObject.Parse(jsonResponse);
|
||||
|
||||
_database.ExecuteTransactionalQuery("l'elaborazione dei dati calcistici", (connection, transaction) =>
|
||||
{
|
||||
@@ -291,7 +289,7 @@ namespace HorseRacingPredictor.Football
|
||||
((Manager.Database)_database).DisableAllConstraints(connection, transaction);
|
||||
|
||||
// FASE 1: Inserisci le leghe
|
||||
foreach (var responseItem in jsonObject["response"].AsArray())
|
||||
foreach (var responseItem in jsonObject["response"])
|
||||
{
|
||||
var league = responseItem["league"];
|
||||
if (league != null && league["id"] != null)
|
||||
@@ -301,11 +299,11 @@ namespace HorseRacingPredictor.Football
|
||||
}
|
||||
|
||||
// FASE 2: Inserisci i bookmakers e i tipi di scommessa
|
||||
foreach (var responseItem in jsonObject["response"].AsArray())
|
||||
foreach (var responseItem in jsonObject["response"])
|
||||
{
|
||||
if (responseItem["bookmakers"] != null)
|
||||
{
|
||||
foreach (var bookmaker in responseItem["bookmakers"].AsArray())
|
||||
foreach (var bookmaker in responseItem["bookmakers"])
|
||||
{
|
||||
if (bookmaker["id"] != null)
|
||||
{
|
||||
@@ -314,7 +312,7 @@ namespace HorseRacingPredictor.Football
|
||||
// Tipi di scommessa
|
||||
if (bookmaker["bets"] != null)
|
||||
{
|
||||
foreach (var bet in bookmaker["bets"].AsArray())
|
||||
foreach (var bet in bookmaker["bets"])
|
||||
{
|
||||
if (bet["id"] != null && bet["name"] != null)
|
||||
{
|
||||
@@ -328,7 +326,7 @@ namespace HorseRacingPredictor.Football
|
||||
}
|
||||
|
||||
// FASE 3: Inserisci le squadre (senza relazione con fixture)
|
||||
foreach (var responseItem in jsonObject["response"].AsArray())
|
||||
foreach (var responseItem in jsonObject["response"])
|
||||
{
|
||||
var teams = responseItem["teams"];
|
||||
if (teams != null && teams["home"] != null && teams["away"] != null &&
|
||||
@@ -340,7 +338,7 @@ namespace HorseRacingPredictor.Football
|
||||
}
|
||||
|
||||
// FASE 4: Inserisci i fixture e venue
|
||||
foreach (var responseItem in jsonObject["response"].AsArray())
|
||||
foreach (var responseItem in jsonObject["response"])
|
||||
{
|
||||
var fixture = responseItem["fixture"];
|
||||
if (fixture != null && fixture["id"] != null)
|
||||
@@ -350,7 +348,7 @@ namespace HorseRacingPredictor.Football
|
||||
}
|
||||
|
||||
// FASE 5: Inserisci relazioni tra entità e dati dipendenti
|
||||
foreach (var responseItem in jsonObject["response"].AsArray())
|
||||
foreach (var responseItem in jsonObject["response"])
|
||||
{
|
||||
int? fixtureId = null;
|
||||
try
|
||||
@@ -358,7 +356,7 @@ namespace HorseRacingPredictor.Football
|
||||
var fixture = responseItem["fixture"];
|
||||
if (fixture != null && fixture["id"] != null)
|
||||
{
|
||||
fixtureId = fixture["id"].GetValue<int>();
|
||||
fixtureId = fixture["id"].Value<int>();
|
||||
|
||||
// Relazioni fixture-team
|
||||
var teams = responseItem["teams"];
|
||||
@@ -372,7 +370,7 @@ namespace HorseRacingPredictor.Football
|
||||
var league = responseItem["league"];
|
||||
if (league != null && league["id"] != null)
|
||||
{
|
||||
int leagueId = league["id"].GetValue<int>();
|
||||
int leagueId = league["id"].Value<int>();
|
||||
_fixtureLeagueRepository.Upsert(connection, transaction, fixtureId.Value, leagueId, league);
|
||||
}
|
||||
|
||||
@@ -399,7 +397,7 @@ namespace HorseRacingPredictor.Football
|
||||
}
|
||||
|
||||
// FASE 6: Inserisci dati che richiedono fixture e teams: quote e previsioni
|
||||
foreach (var responseItem in jsonObject["response"].AsArray())
|
||||
foreach (var responseItem in jsonObject["response"])
|
||||
{
|
||||
int? fixtureId = null;
|
||||
try
|
||||
@@ -407,7 +405,7 @@ namespace HorseRacingPredictor.Football
|
||||
var fixture = responseItem["fixture"];
|
||||
if (fixture != null && fixture["id"] != null)
|
||||
{
|
||||
fixtureId = fixture["id"].GetValue<int>();
|
||||
fixtureId = fixture["id"].Value<int>();
|
||||
|
||||
// Quote
|
||||
if (responseItem["bookmakers"] != null)
|
||||
@@ -442,15 +440,15 @@ namespace HorseRacingPredictor.Football
|
||||
}
|
||||
|
||||
// Head-to-head
|
||||
if (predictions["h2h"] != null && predictions["h2h"].AsArray().Any())
|
||||
if (predictions["h2h"] != null && predictions["h2h"].Any())
|
||||
{
|
||||
_h2hRepository.DeleteForPrediction(connection, predictionId.Value);
|
||||
|
||||
foreach (var h2hFixture in predictions["h2h"].AsArray())
|
||||
foreach (var h2hFixture in predictions["h2h"])
|
||||
{
|
||||
if (h2hFixture["fixture"] != null && h2hFixture["fixture"]["id"] != null)
|
||||
{
|
||||
_h2hRepository.Insert(connection, predictionId.Value, h2hFixture["fixture"]["id"].GetValue<int>());
|
||||
_h2hRepository.Insert(connection, predictionId.Value, h2hFixture["fixture"]["id"].Value<int>());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -462,7 +460,7 @@ namespace HorseRacingPredictor.Football
|
||||
// Home team stats
|
||||
if (teams["home"] != null && teams["home"]["id"] != null && predictions["teams"]["home"] != null)
|
||||
{
|
||||
int homeTeamId = teams["home"]["id"].GetValue<int>();
|
||||
int homeTeamId = teams["home"]["id"].Value<int>();
|
||||
|
||||
if (predictions["teams"]["home"]["team"] != null)
|
||||
{
|
||||
@@ -480,7 +478,7 @@ namespace HorseRacingPredictor.Football
|
||||
// Away team stats
|
||||
if (teams["away"] != null && teams["away"]["id"] != null && predictions["teams"]["away"] != null)
|
||||
{
|
||||
int awayTeamId = teams["away"]["id"].GetValue<int>();
|
||||
int awayTeamId = teams["away"]["id"].Value<int>();
|
||||
|
||||
if (predictions["teams"]["away"]["team"] != null)
|
||||
{
|
||||
@@ -583,36 +581,36 @@ namespace HorseRacingPredictor.Football
|
||||
|
||||
try
|
||||
{
|
||||
var json = JsonDocument.Parse(response.Content).RootElement;
|
||||
var json = JObject.Parse(response.Content);
|
||||
|
||||
// Verifica che la risposta contenga dati validi
|
||||
if (!json.TryGetProperty("response", out var responseElement))
|
||||
if (json["response"] == null)
|
||||
{
|
||||
return dataTable;
|
||||
}
|
||||
|
||||
// Aggiungi righe
|
||||
foreach (var item in responseElement.EnumerateArray())
|
||||
foreach (var item in json["response"])
|
||||
{
|
||||
try
|
||||
{
|
||||
var row = dataTable.NewRow();
|
||||
|
||||
// Estrai i dati dalla risposta JSON
|
||||
row["ID"] = item.GetProperty("fixture").GetProperty("id").GetInt32();
|
||||
row["Paese"] = item.GetProperty("league").GetProperty("country").GetString();
|
||||
row["Campionato"] = item.GetProperty("league").GetProperty("name").GetString();
|
||||
row["Data / Ora"] = DateTime.Parse(item.GetProperty("fixture").GetProperty("date").GetString());
|
||||
row["Stato"] = item.GetProperty("fixture").GetProperty("status").GetProperty("long").GetString();
|
||||
row["Casa"] = item.GetProperty("teams").GetProperty("home").GetProperty("name").GetString();
|
||||
row["Trasferta"] = item.GetProperty("teams").GetProperty("away").GetProperty("name").GetString();
|
||||
row["ID"] = item["fixture"]["id"].Value<int>();
|
||||
row["Paese"] = item["league"]["country"].Value<string>();
|
||||
row["Campionato"] = item["league"]["name"].Value<string>();
|
||||
row["Data / Ora"] = DateTime.Parse(item["fixture"]["date"].Value<string>());
|
||||
row["Stato"] = item["fixture"]["status"]["long"].Value<string>();
|
||||
row["Casa"] = item["teams"]["home"]["name"].Value<string>();
|
||||
row["Trasferta"] = item["teams"]["away"]["name"].Value<string>();
|
||||
|
||||
// Per i goals, controlla se sono null
|
||||
var goalsElement = item.GetProperty("goals");
|
||||
row["Goals Casa"] = goalsElement.GetProperty("home").ValueKind == JsonValueKind.Null ?
|
||||
0 : goalsElement.GetProperty("home").GetInt32();
|
||||
row["Goals Trasferta"] = goalsElement.GetProperty("away").ValueKind == JsonValueKind.Null ?
|
||||
0 : goalsElement.GetProperty("away").GetInt32();
|
||||
var goalsElement = item["goals"];
|
||||
row["Goals Casa"] = goalsElement["home"].Type == JTokenType.Null ?
|
||||
0 : goalsElement["home"].Value<int>();
|
||||
row["Goals Trasferta"] = goalsElement["away"].Type == JTokenType.Null ?
|
||||
0 : goalsElement["away"].Value<int>();
|
||||
|
||||
// Le colonne delle quote e previsione rimangono temporaneamente vuote
|
||||
row["Quota Casa"] = DBNull.Value;
|
||||
@@ -662,18 +660,18 @@ namespace HorseRacingPredictor.Football
|
||||
continue;
|
||||
}
|
||||
|
||||
var json = JsonDocument.Parse(response.Content).RootElement;
|
||||
var json = JObject.Parse(response.Content);
|
||||
|
||||
if (!json.TryGetProperty("response", out var responseElement))
|
||||
if (json["response"] == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach (var item in responseElement.EnumerateArray())
|
||||
foreach (var item in json["response"])
|
||||
{
|
||||
try
|
||||
{
|
||||
int fixtureId = item.GetProperty("fixture").GetProperty("id").GetInt32();
|
||||
int fixtureId = item["fixture"]["id"].Value<int>();
|
||||
|
||||
// Trova la riga corrispondente nella tabella delle partite
|
||||
DataRow[] matchingRows = combinedTable.Select($"ID = {fixtureId}");
|
||||
@@ -682,23 +680,23 @@ namespace HorseRacingPredictor.Football
|
||||
DataRow row = matchingRows[0];
|
||||
|
||||
// Cerca le quote del bookmaker (assumiamo Bet365 con ID 8)
|
||||
if (item.TryGetProperty("bookmakers", out var bookmakersElement))
|
||||
if (item["bookmakers"] != null)
|
||||
{
|
||||
foreach (var bookmaker in bookmakersElement.EnumerateArray())
|
||||
foreach (var bookmaker in item["bookmakers"])
|
||||
{
|
||||
if (bookmaker.GetProperty("id").GetInt32() == 8) // Bet365
|
||||
if (bookmaker["id"].Value<int>() == 8) // Bet365
|
||||
{
|
||||
if (bookmaker.TryGetProperty("bets", out var betsElement))
|
||||
if (bookmaker["bets"] != null)
|
||||
{
|
||||
foreach (var bet in betsElement.EnumerateArray())
|
||||
foreach (var bet in bookmaker["bets"])
|
||||
{
|
||||
if (bet.GetProperty("name").GetString() == "Match Winner")
|
||||
if (bet["name"].Value<string>() == "Match Winner")
|
||||
{
|
||||
// Elabora le quote 1X2
|
||||
foreach (var value in bet.GetProperty("values").EnumerateArray())
|
||||
foreach (var value in bet["values"])
|
||||
{
|
||||
string betType = value.GetProperty("value").GetString();
|
||||
string odd = value.GetProperty("odd").GetString();
|
||||
string betType = value["value"].Value<string>();
|
||||
string odd = value["odd"].Value<string>();
|
||||
|
||||
switch (betType)
|
||||
{
|
||||
@@ -729,16 +727,15 @@ namespace HorseRacingPredictor.Football
|
||||
var predictionResponse = _predictionManager.GetPredictionByFixture(fixtureId);
|
||||
if (predictionResponse != null && predictionResponse.IsSuccessful)
|
||||
{
|
||||
var predictionJson = JsonDocument.Parse(predictionResponse.Content).RootElement;
|
||||
if (predictionJson.TryGetProperty("response", out var predResponse) &&
|
||||
predResponse.EnumerateArray().Any())
|
||||
var predictionJson = JObject.Parse(predictionResponse.Content);
|
||||
if (predictionJson["response"] != null && predictionJson["response"].Any())
|
||||
{
|
||||
var prediction = predResponse.EnumerateArray().First();
|
||||
if (prediction.TryGetProperty("predictions", out var predsElement) &&
|
||||
predsElement.TryGetProperty("winner", out var winnerElement) &&
|
||||
winnerElement.TryGetProperty("name", out var winnerNameElement))
|
||||
var prediction = predictionJson["response"].First;
|
||||
if (prediction["predictions"] != null &&
|
||||
prediction["predictions"]["winner"] != null &&
|
||||
prediction["predictions"]["winner"]["name"] != null)
|
||||
{
|
||||
row["Previsione"] = winnerNameElement.GetString();
|
||||
row["Previsione"] = prediction["predictions"]["winner"]["name"].Value<string>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ using System;
|
||||
using System.Threading.Tasks;
|
||||
using RestSharp;
|
||||
using HorseRacingPredictor.Football.Database;
|
||||
using HorseRacingPredictor.Football.API;
|
||||
using League = HorseRacingPredictor.Football.API.League;
|
||||
using Fixture = HorseRacingPredictor.Football.API.Fixture;
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
using BettingPredictor.UI.Controls;
|
||||
using BettingPredictor.UI;
|
||||
|
||||
namespace BettingPredictor
|
||||
{
|
||||
@@ -9,37 +12,29 @@ namespace BettingPredictor
|
||||
// Container
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
// Grafica
|
||||
private TabControl tabControl;
|
||||
// Grafica moderna
|
||||
private ModernTabControl tabControl;
|
||||
|
||||
// Horse tab
|
||||
private TabPage tabPageHorse;
|
||||
private TextBox textBoxFolderPath;
|
||||
private Button buttonBrowse;
|
||||
private Button buttonPredict; // New button for predictions
|
||||
private Button buttonImport; // New button for import
|
||||
private ProgressBar progressBarHorse;
|
||||
private Label labelStatusHorse;
|
||||
private DataGridView dataGridViewHorse;
|
||||
private ModernPanel panelHorseTop;
|
||||
private ModernTextBox textBoxFolderPath;
|
||||
private ModernButton buttonBrowse;
|
||||
private ModernButton buttonPredict;
|
||||
private ModernButton buttonImport;
|
||||
private ModernProgressBar progressBarHorse;
|
||||
private ModernLabel labelStatusHorse;
|
||||
private ModernDataGridView dataGridViewHorse;
|
||||
|
||||
// Replace the buttonLoadFootball with buttonImportFootball and add buttonDownloadFootball
|
||||
// Football tab
|
||||
private TabPage tabPageFootball;
|
||||
private DateTimePicker dateTimePicker;
|
||||
private Button buttonImportFootball;
|
||||
private Button buttonDownloadFootball;
|
||||
private DataGridView dataGridViewFootball;
|
||||
private ProgressBar progressBarFootball;
|
||||
private Label labelStatusFootball;
|
||||
|
||||
// ApiOptions class definition - rimosso GetLeagueData
|
||||
public static class ApiOptions
|
||||
{
|
||||
public const string GetLeagueFixtures = "Visualizza elenco partite alla data";
|
||||
public const string GetLeagueOdds = "Visualizza elenco quote partite";
|
||||
|
||||
public static readonly string[] AllOptions = { GetLeagueFixtures, GetLeagueOdds };
|
||||
}
|
||||
private ModernPanel panelFootballTop;
|
||||
private ModernDateTimePicker dateTimePicker;
|
||||
private ModernButton buttonImportFootball;
|
||||
private ModernButton buttonDownloadFootball;
|
||||
private ModernDataGridView dataGridViewFootball;
|
||||
private ModernProgressBar progressBarFootball;
|
||||
private ModernLabel labelStatusFootball;
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
@@ -53,308 +48,313 @@ namespace BettingPredictor
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.tabControl = new System.Windows.Forms.TabControl();
|
||||
|
||||
// Horse Tab
|
||||
this.tabPageHorse = new System.Windows.Forms.TabPage();
|
||||
this.textBoxFolderPath = new System.Windows.Forms.TextBox();
|
||||
this.buttonBrowse = new System.Windows.Forms.Button();
|
||||
this.buttonPredict = new System.Windows.Forms.Button(); // New button for predictions
|
||||
this.buttonImport = new System.Windows.Forms.Button(); // New button for import
|
||||
this.progressBarHorse = new System.Windows.Forms.ProgressBar();
|
||||
this.labelStatusHorse = new System.Windows.Forms.Label();
|
||||
this.dataGridViewHorse = new System.Windows.Forms.DataGridView();
|
||||
|
||||
// In the InitializeComponent method, update:
|
||||
// Football Tab
|
||||
this.tabPageFootball = new System.Windows.Forms.TabPage();
|
||||
this.dateTimePicker = new System.Windows.Forms.DateTimePicker();
|
||||
this.buttonImportFootball = new System.Windows.Forms.Button();
|
||||
this.buttonDownloadFootball = new System.Windows.Forms.Button();
|
||||
this.progressBarFootball = new System.Windows.Forms.ProgressBar();
|
||||
this.labelStatusFootball = new System.Windows.Forms.Label();
|
||||
this.dataGridViewFootball = new System.Windows.Forms.DataGridView();
|
||||
|
||||
this.tabControl.SuspendLayout();
|
||||
this.tabPageHorse.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridViewHorse)).BeginInit();
|
||||
this.tabPageFootball.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridViewFootball)).BeginInit();
|
||||
|
||||
// Form settings
|
||||
this.SuspendLayout();
|
||||
|
||||
|
||||
// Inizializza i componenti
|
||||
InitializeTabControl();
|
||||
InitializeHorseTab();
|
||||
InitializeFootballTab();
|
||||
|
||||
//
|
||||
// Main Form
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(1400, 800);
|
||||
this.BackColor = ModernTheme.Colors.PrimaryBackground;
|
||||
this.Controls.Add(this.tabControl);
|
||||
this.Font = ModernTheme.Fonts.RegularFont;
|
||||
this.Name = "Main";
|
||||
this.Text = "Betting Predictor - Modern UI";
|
||||
this.StartPosition = FormStartPosition.CenterScreen;
|
||||
this.Load += new System.EventHandler(this.Main_Load);
|
||||
|
||||
this.ResumeLayout(false);
|
||||
}
|
||||
|
||||
private void InitializeTabControl()
|
||||
{
|
||||
this.tabControl = new ModernTabControl();
|
||||
this.tabPageHorse = new TabPage();
|
||||
this.tabPageFootball = new TabPage();
|
||||
|
||||
//
|
||||
// tabControl
|
||||
//
|
||||
this.tabControl.Controls.Add(this.tabPageHorse);
|
||||
this.tabControl.Controls.Add(this.tabPageFootball);
|
||||
this.tabControl.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.tabControl.Location = new System.Drawing.Point(0, 0);
|
||||
this.tabControl.Dock = DockStyle.Fill;
|
||||
this.tabControl.Location = new Point(0, 0);
|
||||
this.tabControl.Name = "tabControl";
|
||||
this.tabControl.SelectedIndex = 0;
|
||||
this.tabControl.Size = new System.Drawing.Size(800, 450);
|
||||
this.tabControl.Size = new Size(1400, 800);
|
||||
this.tabControl.TabIndex = 0;
|
||||
|
||||
}
|
||||
|
||||
private void InitializeHorseTab()
|
||||
{
|
||||
// Inizializza i controlli
|
||||
this.panelHorseTop = new ModernPanel();
|
||||
this.textBoxFolderPath = new ModernTextBox();
|
||||
this.buttonBrowse = new ModernButton();
|
||||
this.buttonImport = new ModernButton();
|
||||
this.buttonPredict = new ModernButton();
|
||||
this.progressBarHorse = new ModernProgressBar();
|
||||
this.labelStatusHorse = new ModernLabel();
|
||||
this.dataGridViewHorse = new ModernDataGridView();
|
||||
|
||||
this.tabPageHorse.SuspendLayout();
|
||||
this.panelHorseTop.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridViewHorse)).BeginInit();
|
||||
|
||||
//
|
||||
// tabPageHorse
|
||||
//
|
||||
this.tabPageHorse.BackColor = ModernTheme.Colors.PrimaryBackground;
|
||||
this.tabPageHorse.Controls.Add(this.dataGridViewHorse);
|
||||
this.tabPageHorse.Controls.Add(this.labelStatusHorse);
|
||||
this.tabPageHorse.Controls.Add(this.progressBarHorse);
|
||||
this.tabPageHorse.Controls.Add(this.buttonPredict); // Add new button
|
||||
this.tabPageHorse.Controls.Add(this.buttonImport); // Add new button
|
||||
this.tabPageHorse.Controls.Add(this.buttonBrowse);
|
||||
this.tabPageHorse.Controls.Add(this.textBoxFolderPath);
|
||||
this.tabPageHorse.Location = new System.Drawing.Point(4, 22);
|
||||
this.tabPageHorse.Controls.Add(this.panelHorseTop);
|
||||
this.tabPageHorse.Location = new Point(4, 44);
|
||||
this.tabPageHorse.Name = "tabPageHorse";
|
||||
this.tabPageHorse.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.tabPageHorse.Size = new System.Drawing.Size(792, 424);
|
||||
this.tabPageHorse.Padding = new Padding(ModernTheme.Spacing.Large);
|
||||
this.tabPageHorse.Size = new Size(1392, 752);
|
||||
this.tabPageHorse.TabIndex = 0;
|
||||
this.tabPageHorse.Text = "Horse";
|
||||
this.tabPageHorse.UseVisualStyleBackColor = true;
|
||||
|
||||
this.tabPageHorse.Text = "🏇 Horse Racing";
|
||||
|
||||
//
|
||||
// panelHorseTop
|
||||
//
|
||||
this.panelHorseTop.BackColor = ModernTheme.Colors.SecondaryBackground;
|
||||
this.panelHorseTop.BorderRadius = ModernTheme.BorderRadius.Large;
|
||||
this.panelHorseTop.BorderColor = ModernTheme.Colors.BorderPrimary;
|
||||
this.panelHorseTop.BorderWidth = 1;
|
||||
this.panelHorseTop.Controls.Add(this.textBoxFolderPath);
|
||||
this.panelHorseTop.Controls.Add(this.buttonBrowse);
|
||||
this.panelHorseTop.Controls.Add(this.buttonImport);
|
||||
this.panelHorseTop.Controls.Add(this.buttonPredict);
|
||||
this.panelHorseTop.Dock = DockStyle.Top;
|
||||
this.panelHorseTop.Location = new Point(15, 15);
|
||||
this.panelHorseTop.Name = "panelHorseTop";
|
||||
this.panelHorseTop.Padding = new Padding(ModernTheme.Spacing.Medium);
|
||||
this.panelHorseTop.Size = new Size(1362, 60);
|
||||
this.panelHorseTop.TabIndex = 0;
|
||||
|
||||
//
|
||||
// textBoxFolderPath
|
||||
//
|
||||
this.textBoxFolderPath.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.textBoxFolderPath.Location = new System.Drawing.Point(8, 8);
|
||||
this.textBoxFolderPath.Anchor = ((AnchorStyles)(((AnchorStyles.Top | AnchorStyles.Left) | AnchorStyles.Right)));
|
||||
this.textBoxFolderPath.Location = new Point(10, 15);
|
||||
this.textBoxFolderPath.Name = "textBoxFolderPath";
|
||||
this.textBoxFolderPath.ReadOnly = true;
|
||||
this.textBoxFolderPath.Size = new System.Drawing.Size(510, 20);
|
||||
this.textBoxFolderPath.Size = new Size(920, 30);
|
||||
this.textBoxFolderPath.TabIndex = 0;
|
||||
|
||||
this.textBoxFolderPath.Text = "Seleziona una cartella...";
|
||||
this.textBoxFolderPath.ForeColor = ModernTheme.Colors.TextSecondary;
|
||||
|
||||
//
|
||||
// buttonBrowse
|
||||
//
|
||||
this.buttonBrowse.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonBrowse.Location = new System.Drawing.Point(524, 6); // Moved position to make room for Predict button
|
||||
this.buttonBrowse.Size = new System.Drawing.Size(80, 23);
|
||||
this.buttonBrowse.Anchor = ((AnchorStyles)((AnchorStyles.Top | AnchorStyles.Right)));
|
||||
this.buttonBrowse.Location = new Point(940, 15);
|
||||
this.buttonBrowse.Name = "buttonBrowse";
|
||||
this.buttonBrowse.Size = new Size(120, 30);
|
||||
this.buttonBrowse.TabIndex = 1;
|
||||
this.buttonBrowse.Text = "Sfoglia...";
|
||||
this.buttonBrowse.UseVisualStyleBackColor = true;
|
||||
this.buttonBrowse.Click += new System.EventHandler(this.buttonBrowse_Click);
|
||||
|
||||
this.buttonBrowse.Text = "📁 Sfoglia";
|
||||
this.buttonBrowse.NormalColor = ModernTheme.Colors.AccentPrimary;
|
||||
this.buttonBrowse.HoverColor = ModernTheme.Colors.AccentSecondary;
|
||||
this.buttonBrowse.Click += new EventHandler(this.buttonBrowse_Click);
|
||||
|
||||
//
|
||||
// buttonImport
|
||||
//
|
||||
this.buttonImport.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonImport.Location = new System.Drawing.Point(610, 6);
|
||||
this.buttonImport.Anchor = ((AnchorStyles)((AnchorStyles.Top | AnchorStyles.Right)));
|
||||
this.buttonImport.Location = new Point(1070, 15);
|
||||
this.buttonImport.Name = "buttonImport";
|
||||
this.buttonImport.Size = new System.Drawing.Size(80, 23);
|
||||
this.buttonImport.TabIndex = 6;
|
||||
this.buttonImport.Text = "Importa";
|
||||
this.buttonImport.UseVisualStyleBackColor = true;
|
||||
this.buttonImport.Click += new System.EventHandler(this.buttonImport_Click);
|
||||
|
||||
this.buttonImport.Size = new Size(130, 30);
|
||||
this.buttonImport.TabIndex = 2;
|
||||
this.buttonImport.Text = "📥 Importa";
|
||||
this.buttonImport.NormalColor = ModernTheme.Colors.AccentSuccess;
|
||||
this.buttonImport.HoverColor = ColorTranslator.FromHtml("#6FE9D0");
|
||||
this.buttonImport.Enabled = false;
|
||||
this.buttonImport.Click += new EventHandler(this.buttonImport_Click);
|
||||
|
||||
//
|
||||
// buttonPredict
|
||||
//
|
||||
this.buttonPredict.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonPredict.Location = new System.Drawing.Point(696, 6);
|
||||
this.buttonPredict.Anchor = ((AnchorStyles)((AnchorStyles.Top | AnchorStyles.Right)));
|
||||
this.buttonPredict.Location = new Point(1210, 15);
|
||||
this.buttonPredict.Name = "buttonPredict";
|
||||
this.buttonPredict.Size = new System.Drawing.Size(80, 23);
|
||||
this.buttonPredict.TabIndex = 5;
|
||||
this.buttonPredict.Text = "Predici";
|
||||
this.buttonPredict.UseVisualStyleBackColor = true;
|
||||
this.buttonPredict.Click += new System.EventHandler(this.buttonPredict_Click);
|
||||
|
||||
this.buttonPredict.Size = new Size(130, 30);
|
||||
this.buttonPredict.TabIndex = 3;
|
||||
this.buttonPredict.Text = "🎯 Predici";
|
||||
this.buttonPredict.NormalColor = ModernTheme.Colors.AccentWarning;
|
||||
this.buttonPredict.HoverColor = ColorTranslator.FromHtml("#E8B198");
|
||||
this.buttonPredict.Click += new EventHandler(this.buttonPredict_Click);
|
||||
|
||||
//
|
||||
// progressBarHorse
|
||||
//
|
||||
this.progressBarHorse.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.progressBarHorse.Location = new System.Drawing.Point(8, 34);
|
||||
this.progressBarHorse.Anchor = ((AnchorStyles)(((AnchorStyles.Top | AnchorStyles.Left) | AnchorStyles.Right)));
|
||||
this.progressBarHorse.Location = new Point(15, 85);
|
||||
this.progressBarHorse.Name = "progressBarHorse";
|
||||
this.progressBarHorse.Size = new System.Drawing.Size(762, 20);
|
||||
this.progressBarHorse.TabIndex = 2;
|
||||
|
||||
this.progressBarHorse.Size = new Size(1362, 6);
|
||||
this.progressBarHorse.TabIndex = 1;
|
||||
|
||||
//
|
||||
// labelStatusHorse
|
||||
//
|
||||
this.labelStatusHorse.AutoSize = true;
|
||||
this.labelStatusHorse.Location = new System.Drawing.Point(8, 57);
|
||||
this.labelStatusHorse.ForeColor = ModernTheme.Colors.TextSecondary;
|
||||
this.labelStatusHorse.Font = ModernTheme.Fonts.RegularFont;
|
||||
this.labelStatusHorse.Location = new Point(15, 100);
|
||||
this.labelStatusHorse.Name = "labelStatusHorse";
|
||||
this.labelStatusHorse.Size = new System.Drawing.Size(38, 13);
|
||||
this.labelStatusHorse.TabIndex = 3;
|
||||
this.labelStatusHorse.Size = new Size(38, 13);
|
||||
this.labelStatusHorse.TabIndex = 2;
|
||||
this.labelStatusHorse.Text = "Pronto";
|
||||
|
||||
this.labelStatusHorse.BackColor = Color.Transparent;
|
||||
|
||||
//
|
||||
// dataGridViewHorse
|
||||
//
|
||||
this.dataGridViewHorse.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.dataGridViewHorse.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dataGridViewHorse.Location = new System.Drawing.Point(8, 73);
|
||||
this.dataGridViewHorse.Anchor = ((AnchorStyles)((((AnchorStyles.Top | AnchorStyles.Bottom) | AnchorStyles.Left) | AnchorStyles.Right)));
|
||||
this.dataGridViewHorse.Location = new Point(15, 125);
|
||||
this.dataGridViewHorse.Name = "dataGridViewHorse";
|
||||
this.dataGridViewHorse.ReadOnly = true;
|
||||
this.dataGridViewHorse.Size = new System.Drawing.Size(762, 343);
|
||||
this.dataGridViewHorse.TabIndex = 4;
|
||||
|
||||
// Update controls add to the tab page:
|
||||
this.dataGridViewHorse.Size = new Size(1362, 612);
|
||||
this.dataGridViewHorse.TabIndex = 3;
|
||||
|
||||
this.tabPageHorse.ResumeLayout(false);
|
||||
this.tabPageHorse.PerformLayout();
|
||||
this.panelHorseTop.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridViewHorse)).EndInit();
|
||||
}
|
||||
|
||||
private void InitializeFootballTab()
|
||||
{
|
||||
// Inizializza i controlli
|
||||
this.panelFootballTop = new ModernPanel();
|
||||
this.dateTimePicker = new ModernDateTimePicker();
|
||||
this.buttonDownloadFootball = new ModernButton();
|
||||
this.buttonImportFootball = new ModernButton();
|
||||
this.progressBarFootball = new ModernProgressBar();
|
||||
this.labelStatusFootball = new ModernLabel();
|
||||
this.dataGridViewFootball = new ModernDataGridView();
|
||||
|
||||
this.tabPageFootball.SuspendLayout();
|
||||
this.panelFootballTop.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridViewFootball)).BeginInit();
|
||||
|
||||
//
|
||||
// tabPageFootball
|
||||
//
|
||||
this.tabPageFootball.BackColor = ModernTheme.Colors.PrimaryBackground;
|
||||
this.tabPageFootball.Controls.Add(this.dataGridViewFootball);
|
||||
this.tabPageFootball.Controls.Add(this.labelStatusFootball);
|
||||
this.tabPageFootball.Controls.Add(this.progressBarFootball);
|
||||
this.tabPageFootball.Controls.Add(this.buttonImportFootball);
|
||||
this.tabPageFootball.Controls.Add(this.buttonDownloadFootball);
|
||||
this.tabPageFootball.Controls.Add(this.dateTimePicker);
|
||||
this.tabPageFootball.Location = new System.Drawing.Point(4, 22);
|
||||
this.tabPageFootball.Controls.Add(this.panelFootballTop);
|
||||
this.tabPageFootball.Location = new Point(4, 44);
|
||||
this.tabPageFootball.Name = "tabPageFootball";
|
||||
this.tabPageFootball.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.tabPageFootball.Size = new System.Drawing.Size(792, 424);
|
||||
this.tabPageFootball.Padding = new Padding(ModernTheme.Spacing.Large);
|
||||
this.tabPageFootball.Size = new Size(1392, 752);
|
||||
this.tabPageFootball.TabIndex = 1;
|
||||
this.tabPageFootball.Text = "Football";
|
||||
this.tabPageFootball.UseVisualStyleBackColor = true;
|
||||
|
||||
this.tabPageFootball.Text = "⚽ Football";
|
||||
|
||||
//
|
||||
// panelFootballTop
|
||||
//
|
||||
this.panelFootballTop.BackColor = ModernTheme.Colors.SecondaryBackground;
|
||||
this.panelFootballTop.BorderRadius = ModernTheme.BorderRadius.Large;
|
||||
this.panelFootballTop.BorderColor = ModernTheme.Colors.BorderPrimary;
|
||||
this.panelFootballTop.BorderWidth = 1;
|
||||
this.panelFootballTop.Controls.Add(this.dateTimePicker);
|
||||
this.panelFootballTop.Controls.Add(this.buttonDownloadFootball);
|
||||
this.panelFootballTop.Controls.Add(this.buttonImportFootball);
|
||||
this.panelFootballTop.Dock = DockStyle.Top;
|
||||
this.panelFootballTop.Location = new Point(15, 15);
|
||||
this.panelFootballTop.Name = "panelFootballTop";
|
||||
this.panelFootballTop.Padding = new Padding(ModernTheme.Spacing.Medium);
|
||||
this.panelFootballTop.Size = new Size(1362, 60);
|
||||
this.panelFootballTop.TabIndex = 0;
|
||||
|
||||
//
|
||||
// dateTimePicker
|
||||
//
|
||||
this.dateTimePicker.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.dateTimePicker.Format = System.Windows.Forms.DateTimePickerFormat.Short;
|
||||
this.dateTimePicker.Location = new System.Drawing.Point(8, 8);
|
||||
this.dateTimePicker.Anchor = ((AnchorStyles)(((AnchorStyles.Top | AnchorStyles.Left) | AnchorStyles.Right)));
|
||||
this.dateTimePicker.CalendarMonthBackground = ModernTheme.Colors.TertiaryBackground;
|
||||
this.dateTimePicker.CalendarForeColor = ModernTheme.Colors.TextPrimary;
|
||||
this.dateTimePicker.CalendarTitleBackColor = ModernTheme.Colors.SecondaryBackground;
|
||||
this.dateTimePicker.CalendarTitleForeColor = ModernTheme.Colors.TextPrimary;
|
||||
this.dateTimePicker.CalendarTrailingForeColor = ModernTheme.Colors.TextDisabled;
|
||||
this.dateTimePicker.Font = ModernTheme.Fonts.RegularFont;
|
||||
this.dateTimePicker.Location = new Point(10, 18);
|
||||
this.dateTimePicker.Name = "dateTimePicker";
|
||||
// Update dateTimePicker size to make room for two buttons
|
||||
this.dateTimePicker.Size = new System.Drawing.Size(596, 20);
|
||||
this.dateTimePicker.TabIndex = 1;
|
||||
this.dateTimePicker.Value = System.DateTime.Today;
|
||||
|
||||
// buttonDownloadFootball properties
|
||||
this.buttonDownloadFootball.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonDownloadFootball.Location = new System.Drawing.Point(610, 6);
|
||||
this.dateTimePicker.Size = new Size(1090, 25);
|
||||
this.dateTimePicker.TabIndex = 0;
|
||||
this.dateTimePicker.Value = DateTime.Today;
|
||||
|
||||
//
|
||||
// buttonDownloadFootball
|
||||
//
|
||||
this.buttonDownloadFootball.Anchor = ((AnchorStyles)((AnchorStyles.Top | AnchorStyles.Right)));
|
||||
this.buttonDownloadFootball.Location = new Point(1110, 15);
|
||||
this.buttonDownloadFootball.Name = "buttonDownloadFootball";
|
||||
this.buttonDownloadFootball.Size = new System.Drawing.Size(75, 23);
|
||||
this.buttonDownloadFootball.TabIndex = 6;
|
||||
this.buttonDownloadFootball.Text = "Scarica";
|
||||
this.buttonDownloadFootball.UseVisualStyleBackColor = true;
|
||||
this.buttonDownloadFootball.Click += new System.EventHandler(this.buttonDownloadFootball_Click);
|
||||
|
||||
// buttonImportFootball properties (replace buttonLoadFootball)
|
||||
this.buttonImportFootball.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonImportFootball.Location = new System.Drawing.Point(695, 6);
|
||||
this.buttonDownloadFootball.Size = new Size(120, 30);
|
||||
this.buttonDownloadFootball.TabIndex = 1;
|
||||
this.buttonDownloadFootball.Text = "📥 Scarica";
|
||||
this.buttonDownloadFootball.NormalColor = ModernTheme.Colors.AccentPrimary;
|
||||
this.buttonDownloadFootball.HoverColor = ModernTheme.Colors.AccentSecondary;
|
||||
this.buttonDownloadFootball.Click += new EventHandler(this.buttonDownloadFootball_Click);
|
||||
|
||||
//
|
||||
// buttonImportFootball
|
||||
//
|
||||
this.buttonImportFootball.Anchor = ((AnchorStyles)((AnchorStyles.Top | AnchorStyles.Right)));
|
||||
this.buttonImportFootball.Location = new Point(1240, 15);
|
||||
this.buttonImportFootball.Name = "buttonImportFootball";
|
||||
this.buttonImportFootball.Size = new System.Drawing.Size(75, 23);
|
||||
this.buttonImportFootball.Size = new Size(110, 30);
|
||||
this.buttonImportFootball.TabIndex = 2;
|
||||
this.buttonImportFootball.Text = "Importa";
|
||||
this.buttonImportFootball.UseVisualStyleBackColor = true;
|
||||
this.buttonImportFootball.Click += new System.EventHandler(this.buttonImportFootball_Click);
|
||||
|
||||
this.buttonImportFootball.Text = "🔄 Importa";
|
||||
this.buttonImportFootball.NormalColor = ModernTheme.Colors.AccentSuccess;
|
||||
this.buttonImportFootball.HoverColor = ColorTranslator.FromHtml("#6FE9D0");
|
||||
this.buttonImportFootball.Click += new EventHandler(this.buttonImportFootball_Click);
|
||||
|
||||
//
|
||||
// progressBarFootball
|
||||
//
|
||||
this.progressBarFootball.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.progressBarFootball.Location = new System.Drawing.Point(8, 35);
|
||||
this.progressBarFootball.Anchor = ((AnchorStyles)(((AnchorStyles.Top | AnchorStyles.Left) | AnchorStyles.Right)));
|
||||
this.progressBarFootball.Location = new Point(15, 85);
|
||||
this.progressBarFootball.Name = "progressBarFootball";
|
||||
this.progressBarFootball.Size = new System.Drawing.Size(762, 20);
|
||||
this.progressBarFootball.TabIndex = 3;
|
||||
|
||||
this.progressBarFootball.Size = new Size(1362, 6);
|
||||
this.progressBarFootball.TabIndex = 1;
|
||||
|
||||
//
|
||||
// labelStatusFootball
|
||||
//
|
||||
this.labelStatusFootball.AutoSize = true;
|
||||
this.labelStatusFootball.Location = new System.Drawing.Point(8, 58);
|
||||
this.labelStatusFootball.ForeColor = ModernTheme.Colors.TextSecondary;
|
||||
this.labelStatusFootball.Font = ModernTheme.Fonts.RegularFont;
|
||||
this.labelStatusFootball.Location = new Point(15, 100);
|
||||
this.labelStatusFootball.Name = "labelStatusFootball";
|
||||
this.labelStatusFootball.Size = new System.Drawing.Size(38, 13);
|
||||
this.labelStatusFootball.TabIndex = 4;
|
||||
this.labelStatusFootball.Size = new Size(38, 13);
|
||||
this.labelStatusFootball.TabIndex = 2;
|
||||
this.labelStatusFootball.Text = "Pronto";
|
||||
|
||||
this.labelStatusFootball.BackColor = Color.Transparent;
|
||||
|
||||
//
|
||||
// dataGridViewFootball
|
||||
//
|
||||
this.dataGridViewFootball.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.dataGridViewFootball.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dataGridViewFootball.Location = new System.Drawing.Point(8, 74);
|
||||
this.dataGridViewFootball.Anchor = ((AnchorStyles)((((AnchorStyles.Top | AnchorStyles.Bottom) | AnchorStyles.Left) | AnchorStyles.Right)));
|
||||
this.dataGridViewFootball.Location = new Point(15, 125);
|
||||
this.dataGridViewFootball.Name = "dataGridViewFootball";
|
||||
this.dataGridViewFootball.ReadOnly = true;
|
||||
this.dataGridViewFootball.Size = new System.Drawing.Size(762, 342);
|
||||
this.dataGridViewFootball.TabIndex = 5;
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Controls.Add(this.tabControl);
|
||||
this.Name = "Main";
|
||||
this.Text = "Betting Predictor";
|
||||
this.Load += new System.EventHandler(this.Main_Load);
|
||||
this.tabControl.ResumeLayout(false);
|
||||
this.tabPageHorse.ResumeLayout(false);
|
||||
this.tabPageHorse.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridViewHorse)).EndInit();
|
||||
this.dataGridViewFootball.Size = new Size(1362, 612);
|
||||
this.dataGridViewFootball.TabIndex = 3;
|
||||
|
||||
this.tabPageFootball.ResumeLayout(false);
|
||||
this.tabPageFootball.PerformLayout();
|
||||
this.panelFootballTop.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridViewFootball)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
}
|
||||
}
|
||||
|
||||
public partial class ProgressDialog : Form
|
||||
{
|
||||
public ProgressDialog()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void UpdateProgress(int currentPage, int totalPages)
|
||||
{
|
||||
progressBar.Maximum = totalPages;
|
||||
progressBar.Value = currentPage;
|
||||
labelProgress.Text = $"Scaricamento pagina {currentPage} di {totalPages}";
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.progressBar = new System.Windows.Forms.ProgressBar();
|
||||
this.labelProgress = new System.Windows.Forms.Label();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// progressBar
|
||||
//
|
||||
this.progressBar.Location = new System.Drawing.Point(12, 12);
|
||||
this.progressBar.Name = "progressBar";
|
||||
this.progressBar.Size = new System.Drawing.Size(360, 23);
|
||||
this.progressBar.TabIndex = 0;
|
||||
//
|
||||
// labelProgress
|
||||
//
|
||||
this.labelProgress.AutoSize = true;
|
||||
this.labelProgress.Location = new System.Drawing.Point(12, 38);
|
||||
this.labelProgress.Name = "labelProgress";
|
||||
this.labelProgress.Size = new System.Drawing.Size(0, 13);
|
||||
this.labelProgress.TabIndex = 1;
|
||||
//
|
||||
// ProgressDialog
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(384, 61);
|
||||
this.Controls.Add(this.labelProgress);
|
||||
this.Controls.Add(this.progressBar);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "ProgressDialog";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "Scaricamento in corso...";
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
}
|
||||
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
private ProgressBar progressBar;
|
||||
private Label labelProgress;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
using HorseRacingPredictor.Football.Manager;
|
||||
using HorseRacingPredictor.Horses;
|
||||
using HorseRacingPredictor.Horses.ML;
|
||||
using BettingPredictor.UI;
|
||||
using BettingPredictor.UI.Controls;
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.IO;
|
||||
@@ -230,7 +232,7 @@ namespace BettingPredictor
|
||||
/// <summary>
|
||||
/// Formatta la griglia dei dati dei cavalli per una migliore visualizzazione
|
||||
/// </summary>
|
||||
private void FormatHorseDataGrid(DataGridView grid)
|
||||
private void FormatHorseDataGrid(ModernDataGridView grid)
|
||||
{
|
||||
if (grid.Columns.Count == 0)
|
||||
return;
|
||||
@@ -280,44 +282,9 @@ namespace BettingPredictor
|
||||
grid.Columns[columnName].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
|
||||
}
|
||||
|
||||
// Colora le righe in base al risultato
|
||||
grid.CellFormatting += (sender, e) =>
|
||||
{
|
||||
if (e.RowIndex >= 0 && e.ColumnIndex >= 0)
|
||||
{
|
||||
var row = grid.Rows[e.RowIndex];
|
||||
if (grid.Columns.Contains("Risultato Reale") && row.Cells["Risultato Reale"].Value != null)
|
||||
{
|
||||
string resultStr = row.Cells["Risultato Reale"].Value.ToString();
|
||||
if (int.TryParse(resultStr, out int result))
|
||||
{
|
||||
if (result == 1)
|
||||
row.DefaultCellStyle.BackColor = System.Drawing.Color.LightGreen;
|
||||
else if (result <= 3)
|
||||
row.DefaultCellStyle.BackColor = System.Drawing.Color.LightYellow;
|
||||
}
|
||||
}
|
||||
if (grid.Columns.Contains("Risultato Reale") && grid.Columns.Contains("Posizione Prevista"))
|
||||
{
|
||||
var realResultCell = row.Cells["Risultato Reale"];
|
||||
var predictedCell = row.Cells["Posizione Prevista"];
|
||||
if (realResultCell.Value != null && predictedCell.Value != null)
|
||||
{
|
||||
if (int.TryParse(realResultCell.Value.ToString(), out int realPos) &&
|
||||
float.TryParse(predictedCell.Value.ToString(), out float predictedPos))
|
||||
{
|
||||
if (Math.Abs(realPos - predictedPos) <= 0.5)
|
||||
{
|
||||
predictedCell.Style.BackColor = System.Drawing.Color.LightGreen;
|
||||
predictedCell.Style.ForeColor = System.Drawing.Color.DarkGreen;
|
||||
predictedCell.Style.Font = new System.Drawing.Font(grid.Font, System.Drawing.FontStyle.Bold);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Usa il metodo della griglia moderna per evidenziare i vincitori
|
||||
grid.HighlightWinnerRows();
|
||||
|
||||
// Abilita il riordino delle colonne
|
||||
grid.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
|
||||
grid.AllowUserToOrderColumns = true;
|
||||
@@ -382,7 +349,7 @@ namespace BettingPredictor
|
||||
/// <summary>
|
||||
/// Nuovo metodo per gestire l'importazione dei dati calcistici
|
||||
/// </summary>
|
||||
private async Task ImportFootballDataAsync(DataGridView dataGridViewFootball)
|
||||
private async Task ImportFootballDataAsync(ModernDataGridView dataGridViewFootball)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -442,7 +409,7 @@ namespace BettingPredictor
|
||||
/// <summary>
|
||||
/// Metodo aggiornato per il processo completo (scaricamento + importazione)
|
||||
/// </summary>
|
||||
private async Task ProcessFootballDataAsync(DateTime selectedDate, DataGridView dataGridViewFootball)
|
||||
private async Task ProcessFootballDataAsync(DateTime selectedDate, ModernDataGridView dataGridViewFootball)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -468,7 +435,7 @@ namespace BettingPredictor
|
||||
/// <summary>
|
||||
/// Formatta la griglia dei dati calcistici per una migliore visualizzazione
|
||||
/// </summary>
|
||||
private void FormatFootballDataGrid(DataGridView grid)
|
||||
private void FormatFootballDataGrid(ModernDataGridView grid)
|
||||
{
|
||||
if (grid.Columns.Count == 0)
|
||||
return;
|
||||
@@ -505,21 +472,6 @@ namespace BettingPredictor
|
||||
grid.Columns[columnName].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
|
||||
}
|
||||
|
||||
// Colora le righe in base al risultato della previsione
|
||||
grid.CellFormatting += (sender, e) =>
|
||||
{
|
||||
if (e.RowIndex >= 0 && grid.Columns.Contains("Risultato") && e.ColumnIndex >= 0)
|
||||
{
|
||||
var resultCell = grid.Rows[e.RowIndex].Cells["Risultato"];
|
||||
if (resultCell.Value != null)
|
||||
{
|
||||
// Se la previsione è corretta, colora di verde
|
||||
if (Convert.ToInt32(resultCell.Value) == 1)
|
||||
grid.Rows[e.RowIndex].DefaultCellStyle.BackColor = System.Drawing.Color.LightGreen;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Abilita il riordino delle colonne
|
||||
grid.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
|
||||
grid.AllowUserToOrderColumns = true;
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace BettingPredictor.UI.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Pulsante moderno con tema scuro e effetti hover
|
||||
/// </summary>
|
||||
public class ModernButton : Button
|
||||
{
|
||||
private bool isHovering = false;
|
||||
private Color normalColor = ModernTheme.Colors.AccentPrimary;
|
||||
private Color hoverColor = ModernTheme.Colors.AccentSecondary;
|
||||
private int borderRadius = ModernTheme.BorderRadius.Medium;
|
||||
|
||||
public ModernButton()
|
||||
{
|
||||
// Configurazione base
|
||||
FlatStyle = FlatStyle.Flat;
|
||||
FlatAppearance.BorderSize = 0;
|
||||
BackColor = normalColor;
|
||||
ForeColor = ModernTheme.Colors.TextPrimary;
|
||||
Font = ModernTheme.Fonts.ButtonFont;
|
||||
Cursor = Cursors.Hand;
|
||||
Size = new Size(100, 35);
|
||||
|
||||
// Abilita il double buffering per evitare flickering
|
||||
SetStyle(ControlStyles.UserPaint |
|
||||
ControlStyles.AllPaintingInWmPaint |
|
||||
ControlStyles.OptimizedDoubleBuffer, true);
|
||||
}
|
||||
|
||||
public Color NormalColor
|
||||
{
|
||||
get => normalColor;
|
||||
set
|
||||
{
|
||||
normalColor = value;
|
||||
if (!isHovering) BackColor = value;
|
||||
}
|
||||
}
|
||||
|
||||
public Color HoverColor
|
||||
{
|
||||
get => hoverColor;
|
||||
set => hoverColor = value;
|
||||
}
|
||||
|
||||
public int BorderRadius
|
||||
{
|
||||
get => borderRadius;
|
||||
set
|
||||
{
|
||||
borderRadius = value;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnMouseEnter(EventArgs e)
|
||||
{
|
||||
base.OnMouseEnter(e);
|
||||
isHovering = true;
|
||||
BackColor = hoverColor;
|
||||
}
|
||||
|
||||
protected override void OnMouseLeave(EventArgs e)
|
||||
{
|
||||
base.OnMouseLeave(e);
|
||||
isHovering = false;
|
||||
BackColor = normalColor;
|
||||
}
|
||||
|
||||
protected override void OnPaint(PaintEventArgs e)
|
||||
{
|
||||
e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
|
||||
|
||||
// Disegna il background con bordi arrotondati
|
||||
using (GraphicsPath path = GetRoundedRectangle(ClientRectangle, borderRadius))
|
||||
{
|
||||
using (SolidBrush brush = new SolidBrush(BackColor))
|
||||
{
|
||||
e.Graphics.FillPath(brush, path);
|
||||
}
|
||||
}
|
||||
|
||||
// Disegna il testo centrato
|
||||
TextRenderer.DrawText(e.Graphics, Text, Font, ClientRectangle,
|
||||
ForeColor, TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter);
|
||||
}
|
||||
|
||||
private GraphicsPath GetRoundedRectangle(Rectangle rect, int radius)
|
||||
{
|
||||
GraphicsPath path = new GraphicsPath();
|
||||
int diameter = radius * 2;
|
||||
|
||||
path.AddArc(rect.X, rect.Y, diameter, diameter, 180, 90);
|
||||
path.AddArc(rect.Right - diameter, rect.Y, diameter, diameter, 270, 90);
|
||||
path.AddArc(rect.Right - diameter, rect.Bottom - diameter, diameter, diameter, 0, 90);
|
||||
path.AddArc(rect.X, rect.Bottom - diameter, diameter, diameter, 90, 90);
|
||||
path.CloseFigure();
|
||||
|
||||
return path;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace BettingPredictor.UI.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// DataGridView moderna con tema scuro
|
||||
/// </summary>
|
||||
public class ModernDataGridView : DataGridView
|
||||
{
|
||||
public ModernDataGridView()
|
||||
{
|
||||
// Configurazione base
|
||||
BackgroundColor = ModernTheme.Colors.PrimaryBackground;
|
||||
GridColor = ModernTheme.Colors.BorderPrimary;
|
||||
BorderStyle = BorderStyle.None;
|
||||
|
||||
// Colori delle celle
|
||||
DefaultCellStyle.BackColor = ModernTheme.Colors.GridRowEven;
|
||||
DefaultCellStyle.ForeColor = ModernTheme.Colors.TextPrimary;
|
||||
DefaultCellStyle.SelectionBackColor = ModernTheme.Colors.GridSelected;
|
||||
DefaultCellStyle.SelectionForeColor = ModernTheme.Colors.TextPrimary;
|
||||
DefaultCellStyle.Font = ModernTheme.Fonts.RegularFont;
|
||||
|
||||
// Alternating row color
|
||||
AlternatingRowsDefaultCellStyle.BackColor = ModernTheme.Colors.GridRowOdd;
|
||||
AlternatingRowsDefaultCellStyle.ForeColor = ModernTheme.Colors.TextPrimary;
|
||||
|
||||
// Header
|
||||
ColumnHeadersDefaultCellStyle.BackColor = ModernTheme.Colors.GridHeader;
|
||||
ColumnHeadersDefaultCellStyle.ForeColor = ModernTheme.Colors.TextPrimary;
|
||||
ColumnHeadersDefaultCellStyle.Font = ModernTheme.Fonts.SubtitleFont;
|
||||
ColumnHeadersDefaultCellStyle.SelectionBackColor = ModernTheme.Colors.GridHeader;
|
||||
ColumnHeadersDefaultCellStyle.SelectionForeColor = ModernTheme.Colors.TextPrimary;
|
||||
ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.Single;
|
||||
ColumnHeadersHeight = 35;
|
||||
|
||||
// Row
|
||||
RowHeadersDefaultCellStyle.BackColor = ModernTheme.Colors.GridHeader;
|
||||
RowHeadersDefaultCellStyle.ForeColor = ModernTheme.Colors.TextPrimary;
|
||||
RowHeadersDefaultCellStyle.SelectionBackColor = ModernTheme.Colors.GridHeader;
|
||||
RowHeadersDefaultCellStyle.SelectionForeColor = ModernTheme.Colors.TextPrimary;
|
||||
RowHeadersVisible = false;
|
||||
|
||||
// Altre impostazioni
|
||||
EnableHeadersVisualStyles = false;
|
||||
AllowUserToAddRows = false;
|
||||
AllowUserToDeleteRows = false;
|
||||
ReadOnly = true;
|
||||
SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
MultiSelect = false;
|
||||
AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||
RowTemplate.Height = 30;
|
||||
|
||||
// Abilita il double buffering per evitare flickering
|
||||
DoubleBuffered = true;
|
||||
|
||||
// Eventi per l'hover effect
|
||||
CellMouseEnter += OnCellMouseEnterHandler;
|
||||
CellMouseLeave += OnCellMouseLeaveHandler;
|
||||
}
|
||||
|
||||
private void OnCellMouseEnterHandler(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
if (e.RowIndex >= 0)
|
||||
{
|
||||
Rows[e.RowIndex].DefaultCellStyle.BackColor = ModernTheme.Colors.GridHover;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnCellMouseLeaveHandler(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
if (e.RowIndex >= 0)
|
||||
{
|
||||
// Ripristina il colore originale in base all'indice della riga
|
||||
if (e.RowIndex % 2 == 0)
|
||||
Rows[e.RowIndex].DefaultCellStyle.BackColor = ModernTheme.Colors.GridRowEven;
|
||||
else
|
||||
Rows[e.RowIndex].DefaultCellStyle.BackColor = ModernTheme.Colors.GridRowOdd;
|
||||
}
|
||||
}
|
||||
|
||||
public void HighlightWinnerRows()
|
||||
{
|
||||
if (Columns.Contains("Risultato Reale"))
|
||||
{
|
||||
foreach (DataGridViewRow row in Rows)
|
||||
{
|
||||
if (row.Cells["Risultato Reale"].Value != null &&
|
||||
row.Cells["Risultato Reale"].Value.ToString() == "1")
|
||||
{
|
||||
row.DefaultCellStyle.BackColor = ModernTheme.Colors.StatusWin;
|
||||
}
|
||||
else if (row.Cells["Risultato Reale"].Value != null &&
|
||||
int.TryParse(row.Cells["Risultato Reale"].Value.ToString(), out int pos) && pos <= 3)
|
||||
{
|
||||
row.DefaultCellStyle.BackColor = ModernTheme.Colors.StatusPlace;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace BettingPredictor.UI.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// DateTimePicker moderna con tema scuro
|
||||
/// Nota: Il controllo DateTimePicker di WinForms non supporta completamente il custom painting,
|
||||
/// quindi alcuni elementi potrebbero mantenere lo stile di sistema
|
||||
/// </summary>
|
||||
public class ModernDateTimePicker : DateTimePicker
|
||||
{
|
||||
public ModernDateTimePicker()
|
||||
{
|
||||
// Configurazione base
|
||||
Font = ModernTheme.Fonts.RegularFont;
|
||||
Format = DateTimePickerFormat.Custom;
|
||||
CustomFormat = "dd/MM/yyyy";
|
||||
|
||||
// Imposta i colori per il calendario
|
||||
CalendarMonthBackground = ModernTheme.Colors.TertiaryBackground;
|
||||
CalendarForeColor = ModernTheme.Colors.TextPrimary;
|
||||
CalendarTitleBackColor = ModernTheme.Colors.SecondaryBackground;
|
||||
CalendarTitleForeColor = ModernTheme.Colors.TextPrimary;
|
||||
CalendarTrailingForeColor = ModernTheme.Colors.TextDisabled;
|
||||
|
||||
// Dimensioni
|
||||
Height = 30;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Imposta il formato lungo (con ora)
|
||||
/// </summary>
|
||||
public void SetLongFormat()
|
||||
{
|
||||
CustomFormat = "dd/MM/yyyy HH:mm";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Imposta il formato corto (solo data)
|
||||
/// </summary>
|
||||
public void SetShortFormat()
|
||||
{
|
||||
CustomFormat = "dd/MM/yyyy";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace BettingPredictor.UI.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Label moderna con tema scuro e testo ben visibile
|
||||
/// </summary>
|
||||
public class ModernLabel : Label
|
||||
{
|
||||
public ModernLabel()
|
||||
{
|
||||
// Configurazione base per visibilità su sfondo scuro
|
||||
ForeColor = ModernTheme.Colors.TextSecondary;
|
||||
Font = ModernTheme.Fonts.RegularFont;
|
||||
BackColor = Color.Transparent;
|
||||
AutoSize = true;
|
||||
|
||||
// Abilita anti-aliasing per testo più leggibile
|
||||
SetStyle(ControlStyles.OptimizedDoubleBuffer |
|
||||
ControlStyles.AllPaintingInWmPaint, true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Imposta lo stile del label come titolo
|
||||
/// </summary>
|
||||
public void SetAsTitleLabel()
|
||||
{
|
||||
Font = ModernTheme.Fonts.TitleFont;
|
||||
ForeColor = ModernTheme.Colors.TextPrimary;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Imposta lo stile del label come sottotitolo
|
||||
/// </summary>
|
||||
public void SetAsSubtitleLabel()
|
||||
{
|
||||
Font = ModernTheme.Fonts.SubtitleFont;
|
||||
ForeColor = ModernTheme.Colors.TextPrimary;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Imposta lo stile del label come testo di stato
|
||||
/// </summary>
|
||||
public void SetAsStatusLabel()
|
||||
{
|
||||
Font = ModernTheme.Fonts.RegularFont;
|
||||
ForeColor = ModernTheme.Colors.TextSecondary;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Imposta lo stile del label come testo di successo
|
||||
/// </summary>
|
||||
public void SetAsSuccessLabel()
|
||||
{
|
||||
Font = ModernTheme.Fonts.RegularFont;
|
||||
ForeColor = ModernTheme.Colors.AccentSuccess;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Imposta lo stile del label come testo di errore
|
||||
/// </summary>
|
||||
public void SetAsErrorLabel()
|
||||
{
|
||||
Font = ModernTheme.Fonts.RegularFont;
|
||||
ForeColor = ModernTheme.Colors.AccentError;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Imposta lo stile del label come testo di warning
|
||||
/// </summary>
|
||||
public void SetAsWarningLabel()
|
||||
{
|
||||
Font = ModernTheme.Fonts.RegularFont;
|
||||
ForeColor = ModernTheme.Colors.AccentWarning;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace BettingPredictor.UI.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Panel moderno con tema scuro e bordi arrotondati
|
||||
/// </summary>
|
||||
public class ModernPanel : Panel
|
||||
{
|
||||
private int borderRadius = ModernTheme.BorderRadius.Medium;
|
||||
private Color borderColor = ModernTheme.Colors.BorderPrimary;
|
||||
private int borderWidth = 1;
|
||||
|
||||
public ModernPanel()
|
||||
{
|
||||
BackColor = ModernTheme.Colors.SecondaryBackground;
|
||||
|
||||
// Abilita il double buffering
|
||||
SetStyle(ControlStyles.UserPaint |
|
||||
ControlStyles.AllPaintingInWmPaint |
|
||||
ControlStyles.OptimizedDoubleBuffer |
|
||||
ControlStyles.ResizeRedraw, true);
|
||||
}
|
||||
|
||||
public int BorderRadius
|
||||
{
|
||||
get => borderRadius;
|
||||
set
|
||||
{
|
||||
borderRadius = value;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
public Color BorderColor
|
||||
{
|
||||
get => borderColor;
|
||||
set
|
||||
{
|
||||
borderColor = value;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
public int BorderWidth
|
||||
{
|
||||
get => borderWidth;
|
||||
set
|
||||
{
|
||||
borderWidth = value;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnPaint(PaintEventArgs e)
|
||||
{
|
||||
base.OnPaint(e);
|
||||
e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
|
||||
|
||||
// Disegna il background con bordi arrotondati
|
||||
using (GraphicsPath path = GetRoundedRectangle(ClientRectangle, borderRadius))
|
||||
{
|
||||
// Background
|
||||
using (SolidBrush brush = new SolidBrush(BackColor))
|
||||
{
|
||||
e.Graphics.FillPath(brush, path);
|
||||
}
|
||||
|
||||
// Bordo
|
||||
if (borderWidth > 0)
|
||||
{
|
||||
using (Pen pen = new Pen(borderColor, borderWidth))
|
||||
{
|
||||
e.Graphics.DrawPath(pen, path);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private GraphicsPath GetRoundedRectangle(Rectangle rect, int radius)
|
||||
{
|
||||
GraphicsPath path = new GraphicsPath();
|
||||
int diameter = radius * 2;
|
||||
|
||||
rect.Inflate(-borderWidth / 2, -borderWidth / 2);
|
||||
|
||||
path.AddArc(rect.X, rect.Y, diameter, diameter, 180, 90);
|
||||
path.AddArc(rect.Right - diameter, rect.Y, diameter, diameter, 270, 90);
|
||||
path.AddArc(rect.Right - diameter, rect.Bottom - diameter, diameter, diameter, 0, 90);
|
||||
path.AddArc(rect.X, rect.Bottom - diameter, diameter, diameter, 90, 90);
|
||||
path.CloseFigure();
|
||||
|
||||
return path;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace BettingPredictor.UI.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// ProgressBar moderna con tema scuro e animazioni fluide
|
||||
/// </summary>
|
||||
public class ModernProgressBar : ProgressBar
|
||||
{
|
||||
public ModernProgressBar()
|
||||
{
|
||||
// Configurazione base
|
||||
SetStyle(ControlStyles.UserPaint |
|
||||
ControlStyles.AllPaintingInWmPaint |
|
||||
ControlStyles.OptimizedDoubleBuffer, true);
|
||||
|
||||
Height = 6;
|
||||
BackColor = ModernTheme.Colors.TertiaryBackground;
|
||||
ForeColor = ModernTheme.Colors.AccentPrimary;
|
||||
}
|
||||
|
||||
protected override void OnPaint(PaintEventArgs e)
|
||||
{
|
||||
Rectangle rect = ClientRectangle;
|
||||
Graphics g = e.Graphics;
|
||||
|
||||
// Disegna il background
|
||||
using (SolidBrush brush = new SolidBrush(ModernTheme.Colors.TertiaryBackground))
|
||||
{
|
||||
g.FillRectangle(brush, rect);
|
||||
}
|
||||
|
||||
// Calcola la larghezza del progresso
|
||||
int progressWidth = (int)(rect.Width * ((double)Value / Maximum));
|
||||
|
||||
// Disegna la barra di progresso
|
||||
if (progressWidth > 0)
|
||||
{
|
||||
Rectangle progressRect = new Rectangle(rect.X, rect.Y, progressWidth, rect.Height);
|
||||
using (SolidBrush brush = new SolidBrush(ForeColor))
|
||||
{
|
||||
g.FillRectangle(brush, progressRect);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SetProgressColor(Color color)
|
||||
{
|
||||
ForeColor = color;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace BettingPredictor.UI.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// TabControl moderna con tema scuro
|
||||
/// </summary>
|
||||
public class ModernTabControl : TabControl
|
||||
{
|
||||
public ModernTabControl()
|
||||
{
|
||||
SetStyle(ControlStyles.UserPaint |
|
||||
ControlStyles.AllPaintingInWmPaint |
|
||||
ControlStyles.OptimizedDoubleBuffer |
|
||||
ControlStyles.ResizeRedraw, true);
|
||||
|
||||
DrawMode = TabDrawMode.OwnerDrawFixed;
|
||||
SizeMode = TabSizeMode.Fixed;
|
||||
ItemSize = new Size(120, 40);
|
||||
Padding = new Point(20, 0);
|
||||
}
|
||||
|
||||
protected override void OnPaint(PaintEventArgs e)
|
||||
{
|
||||
e.Graphics.Clear(ModernTheme.Colors.PrimaryBackground);
|
||||
e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
|
||||
|
||||
// Disegna il background del tab panel
|
||||
Rectangle tabPanelRect = new Rectangle(0, ItemSize.Height, Width, Height - ItemSize.Height);
|
||||
using (SolidBrush brush = new SolidBrush(ModernTheme.Colors.SecondaryBackground))
|
||||
{
|
||||
e.Graphics.FillRectangle(brush, tabPanelRect);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnDrawItem(DrawItemEventArgs e)
|
||||
{
|
||||
Graphics g = e.Graphics;
|
||||
g.SmoothingMode = SmoothingMode.AntiAlias;
|
||||
|
||||
// Get tab rectangle
|
||||
Rectangle tabRect = GetTabRect(e.Index);
|
||||
|
||||
bool isSelected = (e.Index == SelectedIndex);
|
||||
|
||||
// Disegna il background della tab
|
||||
Color backColor = isSelected ? ModernTheme.Colors.SecondaryBackground : ModernTheme.Colors.PrimaryBackground;
|
||||
using (SolidBrush brush = new SolidBrush(backColor))
|
||||
{
|
||||
g.FillRectangle(brush, tabRect);
|
||||
}
|
||||
|
||||
// Disegna la linea di selezione in alto
|
||||
if (isSelected)
|
||||
{
|
||||
Rectangle accentRect = new Rectangle(tabRect.X, tabRect.Y, tabRect.Width, 3);
|
||||
using (SolidBrush brush = new SolidBrush(ModernTheme.Colors.AccentPrimary))
|
||||
{
|
||||
g.FillRectangle(brush, accentRect);
|
||||
}
|
||||
}
|
||||
|
||||
// Disegna il testo della tab
|
||||
string tabText = TabPages[e.Index].Text;
|
||||
Color textColor = isSelected ? ModernTheme.Colors.TextPrimary : ModernTheme.Colors.TextSecondary;
|
||||
Font tabFont = isSelected ? ModernTheme.Fonts.SubtitleFont : ModernTheme.Fonts.RegularFont;
|
||||
|
||||
StringFormat sf = new StringFormat
|
||||
{
|
||||
Alignment = StringAlignment.Center,
|
||||
LineAlignment = StringAlignment.Center
|
||||
};
|
||||
|
||||
using (SolidBrush brush = new SolidBrush(textColor))
|
||||
{
|
||||
g.DrawString(tabText, tabFont, brush, tabRect, sf);
|
||||
}
|
||||
|
||||
// Disegna il bordo tra le tabs
|
||||
if (e.Index < TabCount - 1)
|
||||
{
|
||||
using (Pen pen = new Pen(ModernTheme.Colors.BorderPrimary, 1))
|
||||
{
|
||||
g.DrawLine(pen, tabRect.Right, tabRect.Top + 10, tabRect.Right, tabRect.Bottom - 10);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnSelectedIndexChanged(EventArgs e)
|
||||
{
|
||||
base.OnSelectedIndexChanged(e);
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace BettingPredictor.UI.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// TextBox moderno con tema scuro e bordi arrotondati
|
||||
/// </summary>
|
||||
public class ModernTextBox : TextBox
|
||||
{
|
||||
private Color borderColor = ModernTheme.Colors.BorderPrimary;
|
||||
private Color focusBorderColor = ModernTheme.Colors.BorderAccent;
|
||||
private bool isFocused = false;
|
||||
private int borderRadius = ModernTheme.BorderRadius.Medium;
|
||||
|
||||
public ModernTextBox()
|
||||
{
|
||||
// Configurazione base
|
||||
BorderStyle = BorderStyle.None;
|
||||
BackColor = ModernTheme.Colors.TertiaryBackground;
|
||||
ForeColor = ModernTheme.Colors.TextPrimary;
|
||||
Font = ModernTheme.Fonts.RegularFont;
|
||||
Padding = new Padding(8, 8, 8, 8);
|
||||
|
||||
// Abilita il double buffering
|
||||
SetStyle(ControlStyles.UserPaint |
|
||||
ControlStyles.AllPaintingInWmPaint |
|
||||
ControlStyles.OptimizedDoubleBuffer, true);
|
||||
}
|
||||
|
||||
public Color BorderColor
|
||||
{
|
||||
get => borderColor;
|
||||
set
|
||||
{
|
||||
borderColor = value;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
public Color FocusBorderColor
|
||||
{
|
||||
get => focusBorderColor;
|
||||
set
|
||||
{
|
||||
focusBorderColor = value;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
public int BorderRadius
|
||||
{
|
||||
get => borderRadius;
|
||||
set
|
||||
{
|
||||
borderRadius = value;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnEnter(EventArgs e)
|
||||
{
|
||||
base.OnEnter(e);
|
||||
isFocused = true;
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
protected override void OnLeave(EventArgs e)
|
||||
{
|
||||
base.OnLeave(e);
|
||||
isFocused = false;
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
protected override void OnReadOnlyChanged(EventArgs e)
|
||||
{
|
||||
base.OnReadOnlyChanged(e);
|
||||
// Cambia il colore del testo per i campi read-only
|
||||
if (ReadOnly)
|
||||
{
|
||||
ForeColor = ModernTheme.Colors.TextSecondary;
|
||||
BackColor = ModernTheme.Colors.SecondaryBackground;
|
||||
}
|
||||
else
|
||||
{
|
||||
ForeColor = ModernTheme.Colors.TextPrimary;
|
||||
BackColor = ModernTheme.Colors.TertiaryBackground;
|
||||
}
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
protected override void OnPaint(PaintEventArgs e)
|
||||
{
|
||||
e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
|
||||
|
||||
// Disegna il background
|
||||
using (GraphicsPath path = GetRoundedRectangle(ClientRectangle, borderRadius))
|
||||
{
|
||||
using (SolidBrush brush = new SolidBrush(BackColor))
|
||||
{
|
||||
e.Graphics.FillPath(brush, path);
|
||||
}
|
||||
|
||||
// Disegna il bordo
|
||||
Color currentBorderColor = isFocused ? focusBorderColor : borderColor;
|
||||
using (Pen pen = new Pen(currentBorderColor, 1.5f))
|
||||
{
|
||||
e.Graphics.DrawPath(pen, path);
|
||||
}
|
||||
}
|
||||
|
||||
// Disegna il testo
|
||||
if (!string.IsNullOrEmpty(Text))
|
||||
{
|
||||
TextRenderer.DrawText(e.Graphics, Text, Font,
|
||||
new Rectangle(8, 0, Width - 16, Height),
|
||||
ForeColor, TextFormatFlags.Left | TextFormatFlags.VerticalCenter);
|
||||
}
|
||||
}
|
||||
|
||||
private GraphicsPath GetRoundedRectangle(Rectangle rect, int radius)
|
||||
{
|
||||
GraphicsPath path = new GraphicsPath();
|
||||
int diameter = radius * 2;
|
||||
|
||||
rect.Inflate(-1, -1);
|
||||
|
||||
path.AddArc(rect.X, rect.Y, diameter, diameter, 180, 90);
|
||||
path.AddArc(rect.Right - diameter, rect.Y, diameter, diameter, 270, 90);
|
||||
path.AddArc(rect.Right - diameter, rect.Bottom - diameter, diameter, diameter, 0, 90);
|
||||
path.AddArc(rect.X, rect.Bottom - diameter, diameter, diameter, 90, 90);
|
||||
path.CloseFigure();
|
||||
|
||||
return path;
|
||||
}
|
||||
}
|
||||
}
|
||||
74
HorseRacingPredictor/HorseRacingPredictor/UI/ModernTheme.cs
Normal file
74
HorseRacingPredictor/HorseRacingPredictor/UI/ModernTheme.cs
Normal file
@@ -0,0 +1,74 @@
|
||||
using System.Drawing;
|
||||
|
||||
namespace BettingPredictor.UI
|
||||
{
|
||||
/// <summary>
|
||||
/// Gestione del tema scuro moderno per l'applicazione
|
||||
/// </summary>
|
||||
public static class ModernTheme
|
||||
{
|
||||
// Colori principali del tema scuro
|
||||
public static class Colors
|
||||
{
|
||||
// Background colors
|
||||
public static readonly Color PrimaryBackground = ColorTranslator.FromHtml("#1E1E1E");
|
||||
public static readonly Color SecondaryBackground = ColorTranslator.FromHtml("#252526");
|
||||
public static readonly Color TertiaryBackground = ColorTranslator.FromHtml("#2D2D30");
|
||||
public static readonly Color HoverBackground = ColorTranslator.FromHtml("#3E3E42");
|
||||
|
||||
// Accent colors
|
||||
public static readonly Color AccentPrimary = ColorTranslator.FromHtml("#007ACC");
|
||||
public static readonly Color AccentSecondary = ColorTranslator.FromHtml("#00A8E8");
|
||||
public static readonly Color AccentSuccess = ColorTranslator.FromHtml("#4EC9B0");
|
||||
public static readonly Color AccentWarning = ColorTranslator.FromHtml("#CE9178");
|
||||
public static readonly Color AccentError = ColorTranslator.FromHtml("#F48771");
|
||||
|
||||
// Text colors
|
||||
public static readonly Color TextPrimary = ColorTranslator.FromHtml("#FFFFFF");
|
||||
public static readonly Color TextSecondary = ColorTranslator.FromHtml("#CCCCCC");
|
||||
public static readonly Color TextDisabled = ColorTranslator.FromHtml("#808080");
|
||||
|
||||
// Border colors
|
||||
public static readonly Color BorderPrimary = ColorTranslator.FromHtml("#3F3F46");
|
||||
public static readonly Color BorderAccent = ColorTranslator.FromHtml("#007ACC");
|
||||
|
||||
// Grid colors
|
||||
public static readonly Color GridHeader = ColorTranslator.FromHtml("#2D2D30");
|
||||
public static readonly Color GridRowEven = ColorTranslator.FromHtml("#252526");
|
||||
public static readonly Color GridRowOdd = ColorTranslator.FromHtml("#1E1E1E");
|
||||
public static readonly Color GridSelected = ColorTranslator.FromHtml("#094771");
|
||||
public static readonly Color GridHover = ColorTranslator.FromHtml("#2A2D2E");
|
||||
|
||||
// Status colors
|
||||
public static readonly Color StatusWin = ColorTranslator.FromHtml("#4EC9B0");
|
||||
public static readonly Color StatusPlace = ColorTranslator.FromHtml("#CE9178");
|
||||
public static readonly Color StatusNormal = ColorTranslator.FromHtml("#3E3E42");
|
||||
}
|
||||
|
||||
// Font configurations
|
||||
public static class Fonts
|
||||
{
|
||||
public static readonly Font TitleFont = new Font("Segoe UI", 16F, FontStyle.Bold);
|
||||
public static readonly Font SubtitleFont = new Font("Segoe UI", 12F, FontStyle.Bold);
|
||||
public static readonly Font RegularFont = new Font("Segoe UI", 9.75F, FontStyle.Regular);
|
||||
public static readonly Font SmallFont = new Font("Segoe UI", 8.25F, FontStyle.Regular);
|
||||
public static readonly Font ButtonFont = new Font("Segoe UI", 9.75F, FontStyle.Regular);
|
||||
}
|
||||
|
||||
// Spacing and sizing
|
||||
public static class Spacing
|
||||
{
|
||||
public const int Small = 5;
|
||||
public const int Medium = 10;
|
||||
public const int Large = 15;
|
||||
public const int ExtraLarge = 20;
|
||||
}
|
||||
|
||||
public static class BorderRadius
|
||||
{
|
||||
public const int Small = 3;
|
||||
public const int Medium = 5;
|
||||
public const int Large = 8;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,28 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="CsvHelper" version="33.0.1" targetFramework="net481" />
|
||||
<package id="Microsoft.Bcl.AsyncInterfaces" version="10.0.0-preview.4.25258.110" targetFramework="net481" />
|
||||
<package id="CsvHelper" version="33.1.0" targetFramework="net481" />
|
||||
<package id="Microsoft.Bcl.AsyncInterfaces" version="10.0.0-rc.1.25451.107" targetFramework="net481" />
|
||||
<package id="Microsoft.Bcl.HashCode" version="6.0.0" targetFramework="net481" />
|
||||
<package id="Microsoft.Bcl.Numerics" version="10.0.0-preview.4.25258.110" targetFramework="net481" />
|
||||
<package id="Microsoft.Bcl.Numerics" version="10.0.0-rc.1.25451.107" targetFramework="net481" />
|
||||
<package id="Microsoft.CSharp" version="4.7.0" targetFramework="net481" />
|
||||
<package id="Microsoft.ML" version="5.0.0-preview.1.25127.4" targetFramework="net481" />
|
||||
<package id="Microsoft.ML.CpuMath" version="5.0.0-preview.1.25127.4" targetFramework="net481" />
|
||||
<package id="Microsoft.ML.DataView" version="5.0.0-preview.1.25127.4" targetFramework="net481" />
|
||||
<package id="Microsoft.ML.FastTree" version="5.0.0-preview.1.25127.4" targetFramework="net481" />
|
||||
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net481" />
|
||||
<package id="Microsoft.ML" version="5.0.0-preview.25503.2" targetFramework="net481" />
|
||||
<package id="Microsoft.ML.CpuMath" version="5.0.0-preview.25503.2" targetFramework="net481" />
|
||||
<package id="Microsoft.ML.DataView" version="5.0.0-preview.25503.2" targetFramework="net481" />
|
||||
<package id="Microsoft.ML.FastTree" version="5.0.0-preview.25503.2" targetFramework="net481" />
|
||||
<package id="Newtonsoft.Json" version="13.0.4" targetFramework="net481" />
|
||||
<package id="RestSharp" version="112.1.1-alpha.0.4" targetFramework="net481" />
|
||||
<package id="System.Buffers" version="4.6.1" targetFramework="net481" />
|
||||
<package id="System.CodeDom" version="10.0.0-preview.4.25258.110" targetFramework="net481" />
|
||||
<package id="System.Collections.Immutable" version="10.0.0-preview.4.25258.110" targetFramework="net481" />
|
||||
<package id="System.CodeDom" version="10.0.0-rc.1.25451.107" targetFramework="net481" />
|
||||
<package id="System.Collections.Immutable" version="10.0.0-rc.1.25451.107" targetFramework="net481" />
|
||||
<package id="System.IO.Pipelines" version="10.0.0-rc.1.25451.107" targetFramework="net481" />
|
||||
<package id="System.Memory" version="4.6.3" targetFramework="net481" />
|
||||
<package id="System.Numerics.Tensors" version="10.0.0-preview.4.25258.110" targetFramework="net481" />
|
||||
<package id="System.Numerics.Tensors" version="10.0.0-rc.1.25451.107" targetFramework="net481" />
|
||||
<package id="System.Numerics.Vectors" version="4.6.1" targetFramework="net481" />
|
||||
<package id="System.Reflection.Emit.Lightweight" version="4.7.0" targetFramework="net481" />
|
||||
<package id="System.Runtime.CompilerServices.Unsafe" version="6.1.2" targetFramework="net481" />
|
||||
<package id="System.Threading.Channels" version="10.0.0-preview.4.25258.110" targetFramework="net481" />
|
||||
<package id="System.Text.Encodings.Web" version="10.0.0-rc.1.25451.107" targetFramework="net481" />
|
||||
<package id="System.Text.Json" version="10.0.0-rc.1.25451.107" targetFramework="net481" />
|
||||
<package id="System.Threading.Channels" version="10.0.0-rc.1.25451.107" targetFramework="net481" />
|
||||
<package id="System.Threading.Tasks.Extensions" version="4.6.3" targetFramework="net481" />
|
||||
<package id="System.ValueTuple" version="4.6.1" targetFramework="net481" />
|
||||
</packages>
|
||||
Reference in New Issue
Block a user