Commit 794e6fb4 authored by M1888's avatar M1888

iltakoodailut

parent 9e03ca56
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="Lottokone.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
......@@ -36,4 +38,21 @@
</setting>
</Lottokone.Properties.Settings>
</userSettings>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="mssqllocaldb" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
<provider invariantName="System.Data.SQLite.EF6" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />
</providers>
</entityFramework>
<system.data>
<DbProviderFactories>
<remove invariant="System.Data.SQLite.EF6" />
<add name="SQLite Data Provider (Entity Framework 6)" invariant="System.Data.SQLite.EF6" description=".NET Framework Data Provider for SQLite (Entity Framework 6)" type="System.Data.SQLite.EF6.SQLiteProviderFactory, System.Data.SQLite.EF6" />
<remove invariant="System.Data.SQLite" /><add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".NET Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" /></DbProviderFactories>
</system.data>
</configuration>
\ No newline at end of file
......@@ -26,5 +26,11 @@
<Setter Property="FontSize" Value="16" />
</Style>
<Style TargetType="TextBox" x:Key="Lottonumero">
<Setter Property="Width" Value="50" />
<Setter Property="MinWidth" Value="20"/>
<Setter Property="Margin" Value="3" />
</Style>
</Application.Resources>
</Application>
......@@ -76,6 +76,7 @@
<TextBox Style="{StaticResource Asetusboksi}" x:Name="txbVakiorivit" Text="{Binding Vakiorivit, Mode=TwoWay}" />
</DockPanel>
<TextBlock Margin="25,-5,0,0">Montako vakioriviä haluat pelata?</TextBlock>
<Button Content="Aseta rivit" Width="100" x:Name="btnRivit" Click="BtnRivit_Click" />
</StackPanel>
</StackPanel>
......
......@@ -11,6 +11,7 @@ using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Lottokone.Model;
namespace Lottokone
{
......@@ -33,7 +34,8 @@ namespace Lottokone
private void BtnRivit_Click(object sender, RoutedEventArgs e)
{
var ikkuna = new Lottorivit();
ikkuna.ShowDialog();
}
}
}
......@@ -13,6 +13,8 @@
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
......@@ -34,11 +36,27 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll</HintPath>
</Reference>
<Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll</HintPath>
</Reference>
<Reference Include="MedallionRandom, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\MedallionRandom.1.1.0\lib\net452\MedallionRandom.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Data" />
<Reference Include="System.Data.SQLite, Version=1.0.110.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
<HintPath>packages\System.Data.SQLite.Core.1.0.110.0\lib\net46\System.Data.SQLite.dll</HintPath>
</Reference>
<Reference Include="System.Data.SQLite.EF6, Version=1.0.110.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
<HintPath>packages\System.Data.SQLite.EF6.1.0.110.0\lib\net46\System.Data.SQLite.EF6.dll</HintPath>
</Reference>
<Reference Include="System.Data.SQLite.Linq, Version=1.0.110.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
<HintPath>packages\System.Data.SQLite.Linq.1.0.110.0\lib\net46\System.Data.SQLite.Linq.dll</HintPath>
</Reference>
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
......@@ -57,11 +75,21 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="Lottorivit.xaml.cs">
<DependentUpon>Lottorivit.xaml</DependentUpon>
</Compile>
<Compile Include="Settings.cs" />
<Compile Include="Voitto.xaml.cs">
<DependentUpon>Voitto.xaml</DependentUpon>
</Compile>
<Page Include="Asetukset.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Lottorivit.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
......@@ -77,6 +105,10 @@
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Page Include="Voitto.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Compile Include="Model\Lotto.cs" />
......@@ -113,5 +145,15 @@
<ItemGroup>
<Resource Include="Resources\lotto.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\lottovoittaja.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="packages\System.Data.SQLite.Core.1.0.110.0\build\net46\System.Data.SQLite.Core.targets" Condition="Exists('packages\System.Data.SQLite.Core.1.0.110.0\build\net46\System.Data.SQLite.Core.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('packages\System.Data.SQLite.Core.1.0.110.0\build\net46\System.Data.SQLite.Core.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\System.Data.SQLite.Core.1.0.110.0\build\net46\System.Data.SQLite.Core.targets'))" />
</Target>
</Project>
\ No newline at end of file
......@@ -5,8 +5,13 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Lottokone"
mc:Ignorable="d"
Title="Lottorivit" Height="450" Width="800">
<Grid>
Title="Lottorivit" Height="450" Width="400">
<Grid x:Name="grdRivit">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
</Grid>
</Window>
......@@ -19,6 +19,10 @@ namespace Lottokone
/// </summary>
public partial class Lottorivit : Window
{
private Button btnSave;
private Label lblInfo;
public Lottorivit()
{
InitializeComponent();
......@@ -27,43 +31,82 @@ namespace Lottokone
public void NaytaKontrollit()
{
/*
StackPanel rivit = new StackPanel();
for (int i = 0; i < Properties.Settings.Default.Vakiorivit; i++)
{
StackPanel rivi = new StackPanel();
rivi.Orientation = Orientation.Horizontal;
rivi.Name = "spRivi{i}";
rivi.Name = $"spRivi{i}";
Grid.SetRow(rivi, i);
Label l = new Label();
l.Content = $"Rivi {i}: ";
rivi.Children.Add(l);
for (int j = 0; j < 7; j++)
{
TextBox tb = new TextBox();
tb.Style = Resources["Lottonumero"] as Style;
tb.TextChanged += txbChanged;
Grid.SetColumn(tb, j);
rivi.Children.Add(tb);
}
rivit.Children.Add(rivi);
}
grdRivit.Children.Add(rivit);
StackPanel spAlarivi = new StackPanel();
Grid.SetRow(spAlarivi, Properties.Settings.Default.Vakiorivit);
btnSave = new Button();
btnSave.Content = "Tallenna";
btnSave.Click += btnSave_Click;
spAlarivi.Children.Add(btnSave);
lblInfo = new Label();
lblInfo.Style = Resources["Isompi"] as Style;
spAlarivi.Children.Add(lblInfo);
grdRivit.Children.Add(spAlarivi);*/
}
public void btnSave_Click(object sender, RoutedEventArgs e)
{
}
public void txbChanged(object sender, TextChangedEventArgs e)
{
TextBox tb = sender as TextBox;
if(tb != null)
if (tb != null)
{
if(int.TryParse(tb.Text, out int result))
bool ok = true;
if (int.TryParse(tb.Text, out int result))
{
if(result < 1)
if (result < 1)
{
tb.Text = "1";
ok = false;
}
else if (result > 40)
{
tb.Text = "40";
ok = false;
}
}
else
{
ok = false;
}
if (ok)
{
lblInfo.Content = "";
btnSave.IsEnabled = true;
}
else
{
MessageBox.Show("Syötä vain numeroita 1-40");
lblInfo.Content = "Syötä vain numeroita 1-40";
btnSave.IsEnabled = false;
}
}
}
......
......@@ -9,7 +9,6 @@
<Window.Background>
<ImageBrush ImageSource="Resources/lotto.png" />
</Window.Background>
<Grid>
<StackPanel Orientation="Horizontal">
<StackPanel Margin="0,10,0,0">
<Button x:Name="btnNext" Margin="0,5,0,0" Content="Seuraava viikko" Click="btnNext_Click"/>
......@@ -17,11 +16,12 @@
<Button x:Name="btnStop" Margin="0,5,0,0" Content="Pysäytä" Click="btnStop_Click"/>
<Button x:Name="btnSettings" Margin="0,50,0,0" Content="Asetukset" Click="btnSettings_Click" />
</StackPanel>
<StackPanel x:Name="spLotto" Width="250">
<StackPanel x:Name="spLotto" Width="250" Background="White" Opacity="0.6" VerticalAlignment="Top">
<Label Style="{StaticResource Isompi}" Content="{Binding Vuosi}" ContentStringFormat="Vuosi: {0}"/>
<Label Style="{StaticResource Isompi}" Content="{Binding Viikko}" ContentStringFormat="Viikko: {0}"/>
<Label Style="{StaticResource Isompi}" Content="{Binding Rivimaara}" ContentStringFormat="Rivejä: {0:N0}"/>
<Label Style="{StaticResource Isompi}" Content="{Binding Potti}" ContentStringFormat="Potti: {0:C0}"/>
<Label Style="{StaticResource Isompi}" Content="{Binding Paavoitto}" ContentStringFormat="Päävoitto: {0:C0}"/>
<Label Style="{StaticResource Isompi}">Voittorivi:</Label>
<Label Style="{StaticResource Isompi}" Content="{Binding Voittorivi}" />
</StackPanel>
......@@ -29,14 +29,17 @@
<Label Style="{StaticResource Isompi}" Content="Status:"/>
<ListView Height="350" Width="300" x:Name="lstStatus" ItemsSource="{Binding Value, UpdateSourceTrigger=PropertyChanged}" Opacity="0.7"/>
</StackPanel>
<StackPanel x:Name="spPlayer" Width="300" Margin="5,0,0,0">
<StackPanel>
<StackPanel x:Name="spPlayer" Width="300" Margin="5,0,0,0" Background="White" Opacity="0.8">
<Label Style="{StaticResource Isompi}" Content="{Binding Nimi}" ContentStringFormat="Nimi: {0}" />
<Label Style="{StaticResource Isompi}" Content="{Binding Saldo}" ContentStringFormat="Tilin saldo: {0:C0}" />
<Label Style="{StaticResource Isompi}" Content="{Binding Riveja}" ContentStringFormat="Rivejä: {0:N0}" />
</StackPanel>
<StackPanel Width="300">
<Label Style="{StaticResource Isompi}" Content="Omat voitot:" Margin="0,100,0,0"/>
<ListView x:Name="lstVoitot" Height="180" Width="300" Opacity="0.7">
</ListView>
</StackPanel>
</StackPanel>
</Grid>
</StackPanel>
</Window>
......@@ -83,9 +83,9 @@ namespace Lottokone
default:
break;
}
if(s.Length > 0)
if (s.Length > 0)
{
lock(voittolukko)
lock (voittolukko)
{
voitot.Insert(0, s);
}
......@@ -174,7 +174,8 @@ namespace Lottokone
private void btnSettings_Click(object sender, RoutedEventArgs e)
{
new Asetukset().ShowDialog();
var a = new Asetukset();
a.ShowDialog();
}
}
}
......@@ -36,16 +36,6 @@ namespace Lottokone.Model
private ConcurrentBag<Pelaaja> oikein6_1;
private ConcurrentBag<Pelaaja> oikein7;
// Lista kaikista kierroksen voittajista. Tämä voidaan käydä läpi lottokoneen
// ulkopuolella, ja tarkistaa onko meidän pelaaja listalla.
public IEnumerable<Pelaaja> Voittajat
{
get
{
return oikein5.Concat(oikein6).Concat(oikein6_1).Concat(oikein7);
}
}
private short viikko;
public short Viikko
{
......@@ -89,6 +79,20 @@ namespace Lottokone.Model
public ConcurrentBag<Pelaaja> Pelaajat { get; set; }
private int paavoitto;
public int Paavoitto
{
get
{
return paavoitto;
}
set
{
paavoitto = value;
RaisePropertyChanged();
}
}
private int potti;
public int Potti
{
......@@ -165,6 +169,7 @@ namespace Lottokone.Model
public Lotto()
{
Potti = 0;
Paavoitto = 1_250_000;
Viikko = 0;
Vuosi = 1;
Pelaajat = new ConcurrentBag<Pelaaja>();
......@@ -330,16 +335,20 @@ namespace Lottokone.Model
if (!oikein7.IsEmpty)
{
int voittajia = oikein7.Count();
int voitto = (int)((potti / 100) * 60) / voittajia;
int voitto = (int)(paavoitto / voittajia);
Paavoitto = 1_250_000;
Status = $"!!! 7 oikein !!!! {voitto:C0} ({voittajia:N0} kpl) !!!";
while (oikein7.TryTake(out Pelaaja p) != false)
{
p.Saldo += voitto;
Potti -= voitto;
}
}
else
{
Paavoitto = (int)(Paavoitto * 1.1);
}
}
protected void RaisePropertyChanged([CallerMemberName] string propertyName = null)
......
......@@ -5,7 +5,10 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Lottokone"
mc:Ignorable="d"
Title="Voitto" Height="450" Width="800">
Title="Voittajan on helppo hymyillä" Height="600" Width="400">
<Window.Background>
<ImageBrush ImageSource="Resources/lottovoittaja.png"/>
</Window.Background>
<Grid>
</Grid>
......
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="EntityFramework" version="6.2.0" targetFramework="net461" />
<package id="MedallionRandom" version="1.1.0" targetFramework="net461" />
<package id="System.Data.SQLite" version="1.0.110.0" targetFramework="net461" />
<package id="System.Data.SQLite.Core" version="1.0.110.0" targetFramework="net461" />
<package id="System.Data.SQLite.EF6" version="1.0.110.0" targetFramework="net461" />
<package id="System.Data.SQLite.Linq" version="1.0.110.0" targetFramework="net461" />
</packages>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment