HF is almost done

This commit is contained in:
Digi 2025-02-21 06:58:11 +01:00
parent 5c776bdac7
commit 806cec4e0a
14 changed files with 475 additions and 19 deletions

View File

@ -14,38 +14,73 @@
<Grid.RowDefinitions>
<RowDefinition Height="25"></RowDefinition>
<RowDefinition Height="10*"></RowDefinition>
<RowDefinition Height="35*"></RowDefinition>
<RowDefinition Height="5*"></RowDefinition>
<RowDefinition Height="30*"></RowDefinition>
<RowDefinition Height="10*"></RowDefinition>
<RowDefinition Height="20*"></RowDefinition>
<RowDefinition Height="18*"></RowDefinition>
<RowDefinition Height="2*"></RowDefinition>
</Grid.RowDefinitions>
<Menu Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2">
<MenuItem Header="Fájl">
<MenuItem Header="Fájl megnyitása">
<MenuItem Header="submenu"></MenuItem>
<MenuItem Header="Megnyitás" Name="open" Click="open_Click">
</MenuItem>
<MenuItem Header="Fájl bezárása"></MenuItem>
<Separator></Separator>
<MenuItem Header="Kilépés">
<MenuItem.Icon>
<Image Source="close.png"></Image>
</MenuItem.Icon>
<MenuItem Header="Kilépés" Click="MenuItem_Click">
</MenuItem>
</MenuItem>
<MenuItem Header="Műveletek">
<MenuItem Header="Fájl megnyitása" IsCheckable="True"></MenuItem>
<MenuItem Header="Fájl bezárása" IsCheckable="True"></MenuItem>
<MenuItem Header="Statisztika"></MenuItem>
<MenuItem Header="Nyertesek" ></MenuItem>
</MenuItem>
<MenuItem Header="Súgó">
<MenuItem Header="Névjegy" Name="informatoin" Click="informatoin_Click"></MenuItem>
</MenuItem>
<MenuItem Header="Súgó"></MenuItem>
</Menu>
<GroupBox Grid.Row="2" Grid.Column="1">
<GroupBox.Header>asd</GroupBox.Header>
<Label Content="Választási eredmények" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="20" Foreground="Blue" FontWeight="Bold"></Label>
<Label Content="Jelöltek listája:" Grid.Row="2" Grid.Column="0" Margin="10 0 0 0"></Label>
<ListBox Grid.Row="3" Grid.Column="0" Grid.RowSpan="3" x:Name="jeloltekListBox" SelectionChanged="jeloltekListBox_SelectionChanged" Margin="10">
</ListBox>
<GroupBox Grid.Row="3" Grid.Column="1">
<GroupBox.Header>Kiválasztott jelölt adatai</GroupBox.Header>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBox Text="asd"></TextBox>
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<Label Grid.Row="0" Grid.Column="0" VerticalAlignment="Center">Név:</Label>
<TextBox Grid.Row="0" Grid.Column="1" Grid.ColumnSpan="3" x:Name="nevTextBox" Margin="5"></TextBox>
<Label Grid.Row="1" Grid.Column="0" VerticalAlignment="Center" Grid.ColumnSpan="3">Választókerület száma:</Label>
<TextBox Grid.Row="1" Grid.Column="3" x:Name="valasztokeruletSzamaTextBox" Margin="5"></TextBox>
<Label Grid.Row="2" Grid.Column="0" VerticalAlignment="Center">Párt:</Label>
<TextBox Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="3" x:Name="partTextBox" Margin="5"></TextBox>
<Label Grid.Row="3" Grid.Column="0" VerticalAlignment="Center" Grid.ColumnSpan="3">Szavazatok száma:</Label>
<TextBox Grid.Row="3" Grid.Column="3" x:Name="szavazatokSzamaTextBox" Margin="5"></TextBox>
</Grid>
</GroupBox>
<Button Grid.Row="4" Grid.Column="1" Margin="12" Content="Ebben a kerületben voltak még:" Name="keruletButton" Click="keruletButton_Click">
</Button>
<ListBox Grid.Row="5" Grid.Column="1" Margin="5" Name="keruletListBox">
</ListBox>
</Grid>
</Window>

View File

@ -1,10 +1,13 @@
using System;
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
@ -18,11 +21,161 @@ namespace ValasztasGUI
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public static class Eredmeny
{
public static List<Kepviselo> kepviselok = new List<Kepviselo>();
}
public class Kepviselo
{
public int Kerulet;
public int Szavazat;
public string VezetekNev;
public string KeresztNev;
public string Part;
public Kepviselo(int kerulet, int szavazat,
string vezetekNev, string keresztNev,
string part)
{
this.Kerulet = kerulet;
this.Szavazat = szavazat;
this.VezetekNev = vezetekNev;
this.KeresztNev = keresztNev;
this.Part = part;
}
public string adatokKiir()
{
return $"{this.VezetekNev};{this.KeresztNev};{this.Kerulet};{this.Part};{this.Szavazat}";
}
public static List<Kepviselo> LoadFromTxt(string path)
{
List<Kepviselo> kepviselok = new List<Kepviselo>();
FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read);
StreamReader streamReader = new StreamReader(fileStream);
var lines = streamReader.ReadToEnd().Split('\n');
foreach (var item in lines)
{
string[] data = item.Split(' ');
Kepviselo kepviselo = new Kepviselo(Convert.ToInt32(data[0]), Convert.ToInt32(data[1]), data[2], data[3], data[4]);
kepviselok.Add(kepviselo);
}
streamReader.Close();
fileStream.Close();
return kepviselok;
}
public static void SzavazatKiir(List<Kepviselo> kepviselok, string[] nev)
{
foreach (var item in kepviselok)
{
if (item.VezetekNev == nev[0] && item.KeresztNev == nev[1])
{
Console.WriteLine($"{item.VezetekNev} {item.KeresztNev} nevű képviselőjelölt {item.Szavazat} darab szavazatot kapott.");
return;
}
}
Console.WriteLine("Ilyen nevű képviselőjelölt nem szerepel a nyilvántartásban!");
}
public static void Legtobb(List<Kepviselo> kepviselok)
{
List<Kepviselo> legjobbkepviselok = new List<Kepviselo>();
Kepviselo kepviselo = kepviselok[0];
foreach (var item in kepviselok)
{
if (item.Szavazat > kepviselo.Szavazat)
{
kepviselo = item;
}
}
legjobbkepviselok.Add(kepviselo);
foreach (var item in kepviselok)
{
if (item.Szavazat == kepviselo.Szavazat && item.KeresztNev != kepviselo.KeresztNev && item.VezetekNev != kepviselo.VezetekNev)
{
legjobbkepviselok.Add(item);
}
}
string fuggetlen = "független";
foreach (var item in legjobbkepviselok)
{
Console.WriteLine($"" +
$"A legtöbb szavazatot kapta: " +
$"\t{item.VezetekNev} {item.KeresztNev} {(item.Part == "-" ? fuggetlen : item.Part)}");
}
}
public static void ValosztokeruletiGyoztesek(List<Kepviselo> kepviselok)
{
var asd = kepviselok.OrderBy(x => x.Szavazat).OrderBy(x => x.Kerulet).GroupBy(x => x.Kerulet);
StreamWriter streamWriter = new StreamWriter("kepviselok.txt", false);
foreach (var item in asd)
{
Kepviselo kepviselo = item.Last();
streamWriter.WriteLine($"{kepviselo.Kerulet} {kepviselo.VezetekNev} {kepviselo.KeresztNev} {kepviselo.Part}");
}
streamWriter.Close();
}
}
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void MenuItem_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
private void informatoin_Click(object sender, RoutedEventArgs e)
{
MessageBox.Show("Helyhatósági választásokat elemző program", "Névjegy");
}
private void jeloltekListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
}
private void keruletButton_Click(object sender, RoutedEventArgs e)
{
}
private void open_Click(object sender, RoutedEventArgs e)
{
OpenFileDialog dialog = new OpenFileDialog();
dialog.ShowDialog();
string path = dialog.FileName;
Eredmeny.kepviselok = Kepviselo.LoadFromTxt(path);
foreach (var item in Eredmeny.kepviselok)
{
jeloltekListBox.Items.Add(item.adatokKiir());
}
}
}
}

View File

@ -1,4 +1,4 @@
#pragma checksum "..\..\MainWindow.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "D7B927837D5F33807216B6926AD2149EA5FACB60ACA879EC40190F95BCA7BBFA"
#pragma checksum "..\..\MainWindow.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "E69C0D3D90D50994BB2ECC74394B05316B5DDAB84366D92A274A48910B19F9CC"
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
@ -40,6 +40,78 @@ namespace ValasztasGUI {
/// </summary>
public partial class MainWindow : System.Windows.Window, System.Windows.Markup.IComponentConnector {
#line 25 "..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.MenuItem open;
#line default
#line hidden
#line 36 "..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.MenuItem informatoin;
#line default
#line hidden
#line 43 "..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.ListBox jeloltekListBox;
#line default
#line hidden
#line 64 "..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBox nevTextBox;
#line default
#line hidden
#line 67 "..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBox valasztokeruletSzamaTextBox;
#line default
#line hidden
#line 70 "..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBox partTextBox;
#line default
#line hidden
#line 73 "..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBox szavazatokSzamaTextBox;
#line default
#line hidden
#line 77 "..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.Button keruletButton;
#line default
#line hidden
#line 81 "..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.ListBox keruletListBox;
#line default
#line hidden
private bool _contentLoaded;
/// <summary>
@ -68,6 +140,68 @@ namespace ValasztasGUI {
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")]
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
switch (connectionId)
{
case 1:
this.open = ((System.Windows.Controls.MenuItem)(target));
#line 25 "..\..\MainWindow.xaml"
this.open.Click += new System.Windows.RoutedEventHandler(this.open_Click);
#line default
#line hidden
return;
case 2:
#line 28 "..\..\MainWindow.xaml"
((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.MenuItem_Click);
#line default
#line hidden
return;
case 3:
this.informatoin = ((System.Windows.Controls.MenuItem)(target));
#line 36 "..\..\MainWindow.xaml"
this.informatoin.Click += new System.Windows.RoutedEventHandler(this.informatoin_Click);
#line default
#line hidden
return;
case 4:
this.jeloltekListBox = ((System.Windows.Controls.ListBox)(target));
#line 43 "..\..\MainWindow.xaml"
this.jeloltekListBox.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(this.jeloltekListBox_SelectionChanged);
#line default
#line hidden
return;
case 5:
this.nevTextBox = ((System.Windows.Controls.TextBox)(target));
return;
case 6:
this.valasztokeruletSzamaTextBox = ((System.Windows.Controls.TextBox)(target));
return;
case 7:
this.partTextBox = ((System.Windows.Controls.TextBox)(target));
return;
case 8:
this.szavazatokSzamaTextBox = ((System.Windows.Controls.TextBox)(target));
return;
case 9:
this.keruletButton = ((System.Windows.Controls.Button)(target));
#line 77 "..\..\MainWindow.xaml"
this.keruletButton.Click += new System.Windows.RoutedEventHandler(this.keruletButton_Click);
#line default
#line hidden
return;
case 10:
this.keruletListBox = ((System.Windows.Controls.ListBox)(target));
return;
}
this._contentLoaded = true;
}
}

View File

@ -1,4 +1,4 @@
#pragma checksum "..\..\MainWindow.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "D7B927837D5F33807216B6926AD2149EA5FACB60ACA879EC40190F95BCA7BBFA"
#pragma checksum "..\..\MainWindow.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "E69C0D3D90D50994BB2ECC74394B05316B5DDAB84366D92A274A48910B19F9CC"
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
@ -40,6 +40,78 @@ namespace ValasztasGUI {
/// </summary>
public partial class MainWindow : System.Windows.Window, System.Windows.Markup.IComponentConnector {
#line 25 "..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.MenuItem open;
#line default
#line hidden
#line 36 "..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.MenuItem informatoin;
#line default
#line hidden
#line 43 "..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.ListBox jeloltekListBox;
#line default
#line hidden
#line 64 "..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBox nevTextBox;
#line default
#line hidden
#line 67 "..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBox valasztokeruletSzamaTextBox;
#line default
#line hidden
#line 70 "..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBox partTextBox;
#line default
#line hidden
#line 73 "..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBox szavazatokSzamaTextBox;
#line default
#line hidden
#line 77 "..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.Button keruletButton;
#line default
#line hidden
#line 81 "..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.ListBox keruletListBox;
#line default
#line hidden
private bool _contentLoaded;
/// <summary>
@ -68,6 +140,68 @@ namespace ValasztasGUI {
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")]
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
switch (connectionId)
{
case 1:
this.open = ((System.Windows.Controls.MenuItem)(target));
#line 25 "..\..\MainWindow.xaml"
this.open.Click += new System.Windows.RoutedEventHandler(this.open_Click);
#line default
#line hidden
return;
case 2:
#line 28 "..\..\MainWindow.xaml"
((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.MenuItem_Click);
#line default
#line hidden
return;
case 3:
this.informatoin = ((System.Windows.Controls.MenuItem)(target));
#line 36 "..\..\MainWindow.xaml"
this.informatoin.Click += new System.Windows.RoutedEventHandler(this.informatoin_Click);
#line default
#line hidden
return;
case 4:
this.jeloltekListBox = ((System.Windows.Controls.ListBox)(target));
#line 43 "..\..\MainWindow.xaml"
this.jeloltekListBox.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(this.jeloltekListBox_SelectionChanged);
#line default
#line hidden
return;
case 5:
this.nevTextBox = ((System.Windows.Controls.TextBox)(target));
return;
case 6:
this.valasztokeruletSzamaTextBox = ((System.Windows.Controls.TextBox)(target));
return;
case 7:
this.partTextBox = ((System.Windows.Controls.TextBox)(target));
return;
case 8:
this.szavazatokSzamaTextBox = ((System.Windows.Controls.TextBox)(target));
return;
case 9:
this.keruletButton = ((System.Windows.Controls.Button)(target));
#line 77 "..\..\MainWindow.xaml"
this.keruletButton.Click += new System.Windows.RoutedEventHandler(this.keruletButton_Click);
#line default
#line hidden
return;
case 10:
this.keruletListBox = ((System.Windows.Controls.ListBox)(target));
return;
}
this._contentLoaded = true;
}
}