Bladeren bron

Добавлено открытие диалогового окна и часть считывания

ПроваленкоЛН 2 maanden geleden
bovenliggende
commit
f22ab7b9bb
2 gewijzigde bestanden met toevoegingen van 43 en 0 verwijderingen
  1. 4 0
      AvaloniaApplication1/MainWindow.axaml
  2. 39 0
      AvaloniaApplication1/MainWindow.axaml.cs

+ 4 - 0
AvaloniaApplication1/MainWindow.axaml

@@ -15,6 +15,7 @@
 			<TextBlock  Name="Viss"></TextBlock>
 			<TextBlock  Name="VisY"></TextBlock>
 			<TextBlock  Name="Znak"></TextBlock>
+			<TextBlock  Name="Por"></TextBlock>
 		</StackPanel>
 		<StackPanel Margin="100 250 100 100">
 
@@ -25,6 +26,9 @@
 			<Button Classes ="but" Margin="0 10" VerticalAlignment="Center" Click="Button_Click" Width="160" Height="30" HorizontalAlignment="Center">
 				Подтвердить выбор
 			</Button>
+			<Button Classes ="but" Margin="0 10" VerticalAlignment="Center" Click="File" Width="160" Height="30" HorizontalAlignment="Center">
+				Считать с файла
+			</Button>
 		</StackPanel>
 	</Grid>
 	

+ 39 - 0
AvaloniaApplication1/MainWindow.axaml.cs

@@ -6,9 +6,20 @@ using System;
 using System.Data;
 using System.Diagnostics;
 using System.Runtime.Intrinsics.Arm;
+using Avalonia.Threading;
+using System.Runtime.InteropServices;
+using System.Threading.Tasks;
+using Tmds.DBus.Protocol;
+using System.IO;
 
 namespace AvaloniaApplication1
 {
+    struct DateB
+    {
+        int dayB;
+        int monthB;
+        int yearB;
+    }
     public partial class MainWindow : Window
     {
         public MainWindow()
@@ -194,5 +205,33 @@ namespace AvaloniaApplication1
             }
             
         }
+
+        [Obsolete]
+        public async void File(object source, RoutedEventArgs args)
+        {
+            string path;
+            OpenFileDialog OFD = new OpenFileDialog();
+            OFD.AllowMultiple = false;
+            OFD.Filters.Add(new FileDialogFilter() { Name = "CSV ôàéëû", Extensions = { "csv" } });
+            var result = await OFD.ShowAsync(this);
+            if (result != null)
+            {
+                path = result[0];
+                using(StreamReader sr = new StreamReader(path))
+                {
+                    int k = 0;
+                    string line = sr.ReadLine();
+                    while (line != null)
+                    {
+                        if (string.IsNullOrWhiteSpace(line))
+                        {
+                            k++;
+                        }
+                        line = sr.ReadLine();
+                    }
+                    Por.Text = k.ToString();
+                };
+            }          
+        }
     }
 }