diff --git a/HtmlTableGenerator/Services/GeneratorTools.cs b/HtmlTableGenerator/Services/GeneratorTools.cs
index 205e153..179c64e 100644
--- a/HtmlTableGenerator/Services/GeneratorTools.cs
+++ b/HtmlTableGenerator/Services/GeneratorTools.cs
@@ -117,26 +117,31 @@ public static void CreateTextBoxes(Grid grid, TableData tableData)
public static async Task ReadCsv(string filePath)
{
- string[] strings;
- try
+ if (!string.IsNullOrEmpty(filePath))
{
- strings = await File.ReadAllLinesAsync(filePath);
- }
- catch (FileNotFoundException ex)
- {
- MessageBox.Show("Error: The file could not be found. " + ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
- return null;
- }
- catch (ArgumentException)
- {
- MessageBox.Show("Error: Path cannot be empty. ", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
- return null;
+ string[] strings;
+ try
+ {
+ strings = await File.ReadAllLinesAsync(filePath);
+ }
+ catch (FileNotFoundException ex)
+ {
+ MessageBox.Show("Error: The file could not be found. " + ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
+ return null;
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show("Error: An error occurred.\n" + ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
+ return null;
+ }
+ return strings;
}
- catch (Exception ex)
+ else
{
- MessageBox.Show("Error: An error occurred.\n" + ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
+ MessageBox.Show("Warning: Path must not be empty.", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
return null;
}
- return strings;
+
+
}
}
\ No newline at end of file
diff --git a/HtmlTableGenerator/ViewModel/MainViewModel.cs b/HtmlTableGenerator/ViewModel/MainViewModel.cs
index ce95378..5921298 100644
--- a/HtmlTableGenerator/ViewModel/MainViewModel.cs
+++ b/HtmlTableGenerator/ViewModel/MainViewModel.cs
@@ -6,7 +6,6 @@
using HtmlTableGenerator.View;
using Microsoft.Win32;
using System;
-using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
@@ -25,8 +24,8 @@ public partial class MainViewModel : ObservableObject
public MainViewModel()
{
- rowText = "0";
- columnText = "0";
+ rowText = "1";
+ columnText = "1";
filePath = string.Empty;
tableData = new TableData();
}
@@ -73,24 +72,17 @@ private void ProcessTableContent()
int row = int.Parse(RowText);
int column = int.Parse(ColumnText);
- if (row > 0 && column > 0)
- {
- tableData.Row = row;
- tableData.Column = column;
+ tableData.Row = row;
+ tableData.Column = column;
- TableInputWindow tableInputWindow = new();
- Grid grid = tableInputWindow.TableGrid;
+ TableInputWindow tableInputWindow = new();
+ Grid grid = tableInputWindow.TableGrid;
- GeneratorTools.AdjustGrid(row, column, grid);
- GeneratorTools.CreateHeaders(grid, row, column);
- GeneratorTools.CreateTextBoxes(grid, tableData);
- SendTableData(tableData);
- tableInputWindow.Show();
- }
- else
- {
- MessageBox.Show("Row and Column must greater than 0.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
- }
+ GeneratorTools.AdjustGrid(row, column, grid);
+ GeneratorTools.CreateHeaders(grid, row, column);
+ GeneratorTools.CreateTextBoxes(grid, tableData);
+ SendTableData(tableData);
+ tableInputWindow.Show();
}
private void SendTableData(TableData tableData) => WeakReferenceMessenger.Default.Send(tableData);