Skip to content

Commit

Permalink
minimal fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
fokklz committed Sep 13, 2023
1 parent 7c4404a commit 3818241
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 33 deletions.
46 changes: 26 additions & 20 deletions EasyWord/Pages/Learning.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,36 +164,42 @@ private void BtnSettings_Click(object sender, RoutedEventArgs e)
/// <param name="e">Additional event data</param>
private void BtnCsvImport_Click(object sender, RoutedEventArgs e)
{
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Filter = "CSV Dateien (*.csv)|*.csv";

if (openFileDialog.ShowDialog() == true)
try
{
// Store the selected file path
string filePath = openFileDialog.FileName;
// User confirmed, proceed with import
if (App.Config.Words.Words.Count == 0)
{
// If the word list is null, simply import the CSV
App.Config.Words = WordList.ImportFromCSV(filePath);
}
else
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Filter = "CSV Dateien (*.csv)|*.csv";

if (openFileDialog.ShowDialog() == true)
{
var confirmResult = MessageBox.Show("Willst du die aktuelle Liste überschreiben?", "Confirmation", MessageBoxButton.YesNo);
if (confirmResult == MessageBoxResult.Yes)
// Store the selected file path
string filePath = openFileDialog.FileName;
// User confirmed, proceed with import
if (App.Config.Words.Words.Count == 0)
{
// If the word list is null, simply import the CSV
App.Config.Words = WordList.ImportFromCSV(filePath);
}
else
{
// If the word list already exists, extend it
WordList importedWords = WordList.ImportFromCSV(filePath);
App.Config.Words.ExtendFromCSV(filePath);
var confirmResult = MessageBox.Show("Willst du die aktuelle Liste überschreiben?", "Confirmation", MessageBoxButton.YesNo);
if (confirmResult == MessageBoxResult.Yes)
{
// If the word list is null, simply import the CSV
App.Config.Words = WordList.ImportFromCSV(filePath);
}
else
{
// If the word list already exists, extend it
WordList importedWords = WordList.ImportFromCSV(filePath);
App.Config.Words.ExtendFromCSV(filePath);
}
}
// Update the view to reflect the changes
UpdateView();
}
// Update the view to reflect the changes
UpdateView();
} catch
{
MessageBox.Show("Die Wörter konnten nicht Importiert werden. Überprüfe die Formatierung der CSV.");
}
}

Expand Down
17 changes: 14 additions & 3 deletions EasyWord/Pages/Settings.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="60"/>
<RowDefinition Height="80"/>
<RowDefinition Height="110"/>
<RowDefinition Height="50"/>
<RowDefinition Height="50"/>
<RowDefinition Height="*"/>
Expand Down Expand Up @@ -65,7 +65,8 @@
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="45" />
<RowDefinition Height="45" />
</Grid.RowDefinitions>
<Button
x:Name="ResetStats"
Expand All @@ -77,9 +78,19 @@
<TextBlock Text="Stats Zurücksetzen"/>
</StackPanel>
</Button>
<Button
x:Name="ResetBuckets"
Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="2"
HorizontalAlignment="Center"
Style="{StaticResource MaterialDesignRaisedButton}" Click="ResetBuckets_Click">
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
<materialDesign:PackIcon Kind="Bucket" Margin="0,2.5,10,0"/>
<TextBlock Text="Buckets Löschen"/>
</StackPanel>
</Button>
<Button
x:Name="ResetAll"
Grid.Column="1"
Grid.Column="2"
HorizontalAlignment="Center"
Style="{StaticResource MaterialDesignRaisedButton}" Click="ResetAll_Click">
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
Expand Down
34 changes: 25 additions & 9 deletions EasyWord/Pages/Settings.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ private void ExportState_Click(object sender, RoutedEventArgs e)
// Create a SaveFileDialog
SaveFileDialog saveFileDialog = new SaveFileDialog();
saveFileDialog.Filter = "XML Files (*.xml)|*.xml";
saveFileDialog.Title = "Export XML Datei";
saveFileDialog.Title = "XML Datei Exportieren";
saveFileDialog.DefaultExt = "xml";

// Show the SaveFileDialog and get the selected file path
Expand All @@ -122,16 +122,21 @@ private void ExportState_Click(object sender, RoutedEventArgs e)

private void ImportState_Click(object sender, RoutedEventArgs e)
{
try
{
OpenFileDialog importPath = new OpenFileDialog();
importPath.Filter = "XML Files (*.xml)|*.xml";
importPath.Title = "XML Datei wählen";
importPath.DefaultExt = "xml";

OpenFileDialog importPath = new OpenFileDialog();
importPath.Filter = "XML Files (*.xml)|*.xml";
importPath.Title = "Wähle XML Datei";
importPath.DefaultExt = "xml";

if (importPath.ShowDialog() == true)
if (importPath.ShowDialog() == true)
{
WordList importedWords = FileProvider.LoadConfig<WordList>(importPath.FileName);
App.Config.Words = importedWords;
}
}catch
{
WordList importedWords = FileProvider.LoadConfig<WordList>(importPath.FileName);
App.Config.Words = importedWords;
MessageBox.Show("Der Stand konnte nicht importiert werden. Stelle sicher das die XML Datei richtig Formatiert ist.");
}
}

Expand Down Expand Up @@ -175,5 +180,16 @@ private void LearnEnglish_Unchecked(object sender, RoutedEventArgs e)
{
App.Config.TranslationDirection = false;
}

/// <summary>
/// Reset all buckets
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ResetBuckets_Click(object sender, RoutedEventArgs e)
{
App.Config.Words.ResetAllBuckets();
App.SaveSettings();
}
}
}
2 changes: 1 addition & 1 deletion EasyWord/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.0.0.1
0.0.0.2

0 comments on commit 3818241

Please sign in to comment.