|
@@ -1,6 +1,8 @@
|
|
|
using Avalonia.Controls;
|
|
|
using Avalonia.Interactivity;
|
|
|
using Avalonia.Markup.Xaml.MarkupExtensions;
|
|
|
+using Avalonia.Media;
|
|
|
+using System;
|
|
|
using System.IO;
|
|
|
|
|
|
namespace AvaloniaApplication2
|
|
@@ -61,16 +63,80 @@ namespace AvaloniaApplication2
|
|
|
// ïðîáåãàåìñÿ ïî âñåìó ñïèñêó âûáðàííûõ ðåëèãèé (òàê êàê ó ñïèñêà íàñòðîåí ìíîæåñòâåííûé âûáîð ïðè óñëîâèè çàæàòèÿ Ctrl)
|
|
|
foreach (TextBlock item in lbReligions.SelectedItems)
|
|
|
{
|
|
|
- religions += religions + item.Text + ", "; // äîáàâëÿåì ðåëèãèþ â ñòðîêó ÿåðåç çàïÿòóþ
|
|
|
+ religions += item.Text + ", "; // äîáàâëÿåì ðåëèãèþ â ñòðîêó ÿåðåç çàïÿòóþ
|
|
|
}
|
|
|
country.religions = religions;
|
|
|
|
|
|
// çàïèñü à ôàéë
|
|
|
using (StreamWriter sw = new StreamWriter("users.csv",true,System.Text.Encoding.UTF8))
|
|
|
{
|
|
|
- sw.WriteLine(country.name + ";" + country.capital + ";" + country.continent + ";" + country.form + ";" + country.religions + ";" + country.isNATO);
|
|
|
- ShowMessage.Text = "Çàïèñü äîáàâëåíà";
|
|
|
+ sw.WriteLine(country.name + ";" + country.capital + ";" + country.continent + ";" + country.form + ";" + country.religions + ";" + country.isNATO);
|
|
|
}
|
|
|
- }
|
|
|
+ }
|
|
|
+
|
|
|
+ public SolidColorBrush color(string continent)
|
|
|
+ {
|
|
|
+ switch (continent)
|
|
|
+ {
|
|
|
+ case "Åâðàçèÿ":
|
|
|
+ return new SolidColorBrush(Color.FromArgb(50,255, 0, 0));
|
|
|
+ case "Àìåðèêà":
|
|
|
+ return new SolidColorBrush(Color.FromArgb(50, 0, 255, 0));
|
|
|
+ case "Àôðèêà":
|
|
|
+ return new SolidColorBrush(Color.FromArgb(50, 0, 0, 255));
|
|
|
+ default:
|
|
|
+ return new SolidColorBrush(Color.FromRgb(0, 0, 0));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ private void ShowCountriesClick(object sender, RoutedEventArgs e)
|
|
|
+ {
|
|
|
+ ShowCountries.IsVisible = true;
|
|
|
+ WritePanel.IsVisible = false;
|
|
|
+
|
|
|
+ using (StreamReader sr = new StreamReader("users.csv"))
|
|
|
+ {
|
|
|
+ string line ="";
|
|
|
+ while (!sr.EndOfStream)
|
|
|
+ {
|
|
|
+ line = sr.ReadLine();
|
|
|
+ string[] lineArray = line.Split(';');
|
|
|
+ TextBlock tbName = new TextBlock()
|
|
|
+ {
|
|
|
+ Text = "Íàçâàíèå ñòðàíû: " + lineArray[0],
|
|
|
+ };
|
|
|
+ TextBlock tbCapital = new TextBlock()
|
|
|
+ {
|
|
|
+ Text = "Ñòîëèöà: "+lineArray[1]
|
|
|
+ };
|
|
|
+ TextBlock tbIsNATO = new TextBlock();
|
|
|
+ if (Convert.ToBoolean(lineArray[5])) tbIsNATO.Text = "Âõîäèò ñ ÍÀÒÎ";
|
|
|
+ else tbIsNATO.Text = "Íå âõîäèò â ñîñòàâ ÍÀÒÎ";
|
|
|
+
|
|
|
+ StackPanel spCountry = new StackPanel();
|
|
|
+ spCountry.HorizontalAlignment = Avalonia.Layout.HorizontalAlignment.Center;
|
|
|
+ spCountry.Children.Add(tbName);
|
|
|
+ spCountry.Children.Add(tbCapital);
|
|
|
+ spCountry.Children.Add(tbIsNATO);
|
|
|
+
|
|
|
+
|
|
|
+ Border border = new Border();
|
|
|
+ border.Background = color(lineArray[2]);
|
|
|
+ border.BorderBrush = Brushes.Indigo;
|
|
|
+ border.BorderThickness = new Avalonia.Thickness(2);
|
|
|
+ border.CornerRadius = new Avalonia.CornerRadius(50);
|
|
|
+ border.Margin = new Avalonia.Thickness(10);
|
|
|
+ border.Padding = new Avalonia.Thickness(20);
|
|
|
+
|
|
|
+ border.Child = spCountry;
|
|
|
+
|
|
|
+ ShowCountries.Children.Add(border);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ private void Back_Click(object sender, RoutedEventArgs e)
|
|
|
+ {
|
|
|
+ ShowCountries.IsVisible = false;
|
|
|
+ WritePanel.IsVisible = true;
|
|
|
+ }
|
|
|
}
|
|
|
}
|