using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.IO;
using static System.Net.Mime.MediaTypeNames;
namespace WpfApp1
{
///
/// Логика взаимодействия для MainWindow.xaml
///
public partial class MainWindow : Window
{
string pant = "1.txt";
public MainWindow()
{
InitializeComponent();
}
struct people
{
public string name;
public string dateB;
public string pol;
public string di;
}
List peopleList = new List();
int n = 1;
bool flag = false;
int count = 0;
string zapis()
{
string text = "";
text += tb_name + " ";
text += dp_date + " ";
if (lb_pol.SelectedItem is per person)
{
text += person.pol + " ";
//MessageBox.Show(person.pol);
}
if(cb_1.IsChecked == true)
{
text += cb_1.Content;
}
if(cb_2.IsChecked == true)
{
text += cb_2.Content;
}
if(cb_3.IsChecked == true)
{
text += cb_3.Content;
}
return text;
}
void initialDate(int n)
{
using (StreamReader sr = new StreamReader(pant))
{
try
{
if (flag == true)
{
for (int i = 0; i < count; i++)
{
sr.ReadLine();
}
}
string[] pl = sr.ReadLine().Split(' ');
people peoples = new people();
peoples.name = (pl[n]);
peoples.dateB = pl[n + 1];
peoples.pol = pl[n + 3];
peoples.di = pl[n + 4];
peopleList.Add(peoples);
}
catch
{
MessageBox.Show("больше данных нет");
}
}
}
void show()
{
initialDate(n);
foreach (people people in peopleList)
{
nameV.Content = Convert.ToString(people.name);
datenV.Content = Convert.ToString(people.dateB);
polV.Content = Convert.ToString(people.pol);
diV.Content = Convert.ToString(people.di);
}
}
private void Button_Click(object sender, RoutedEventArgs e)
{
File.AppendAllText(pant, zapis() + Environment.NewLine);
}
private void Button_Click_1(object sender, RoutedEventArgs e)
{
show();
flag = true;
}
private void Button_Click_2(object sender, RoutedEventArgs e)
{
if (flag==true)
{
count++;
show();
}
}
}
}