Skip to content

Commit

Permalink
Added the possibility to import a "Template" when there is already Bl…
Browse files Browse the repository at this point in the history
…ocks (#30)
  • Loading branch information
Leo-Peyronnet committed Nov 5, 2021
1 parent 435d928 commit a37cdbf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
5 changes: 4 additions & 1 deletion Datalya/Classes/BlockTemplate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ public static void Import(string filePath, bool fromNew = false)

if (!fromNew)
{
Global.CurrentDataBase.Blocks = template.Blocks; // Set
for (int i = 0; i < template.Blocks.Count; i++)
{
Global.CurrentDataBase.Blocks.Add(template.Blocks[i]); // Set
}
}
else
{
Expand Down
19 changes: 6 additions & 13 deletions Datalya/Pages/CreatorPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,22 +165,15 @@ internal void SaveChanges()

private void ImportBlockBtn_Click(object sender, RoutedEventArgs e)
{
if (Global.CurrentDataBase.Blocks.Count == 0)
OpenFileDialog openFileDialog = new()
{
OpenFileDialog openFileDialog = new()
{
Filter = $"{Properties.Resources.Template}|*.datalyabt",
Title = Properties.Resources.ImportTemplate
}; // Create OpenFileDialog
Filter = $"{Properties.Resources.Template}|*.datalyabt",
Title = Properties.Resources.ImportTemplate
}; // Create OpenFileDialog

if (openFileDialog.ShowDialog() ?? true)
{
BlockTemplateManager.Import(openFileDialog.FileName); // Import
}
}
else
if (openFileDialog.ShowDialog() ?? true)
{
MessageBox.Show(Properties.Resources.CannotImportTemplateBlockExists, Properties.Resources.Datalya, MessageBoxButton.OK, MessageBoxImage.Error); // Show message
BlockTemplateManager.Import(openFileDialog.FileName); // Import
}
}

Expand Down

0 comments on commit a37cdbf

Please sign in to comment.