diff --git a/GUI/FileErrorDialog.xaml.cs b/GUI/FileErrorDialog.xaml.cs
index 7fcb5725..420e9129 100644
--- a/GUI/FileErrorDialog.xaml.cs
+++ b/GUI/FileErrorDialog.xaml.cs
@@ -16,6 +16,16 @@ namespace GARbro.GUI
this.DataContext = new ViewModel { Title = title, Text = error_text };
}
+ new public FileErrorDialogResult ShowDialog ()
+ {
+ bool dialog_result = base.ShowDialog() ?? false;
+ return new FileErrorDialogResult
+ {
+ Continue = dialog_result,
+ IgnoreErrors = IgnoreErrors.IsChecked ?? false
+ };
+ }
+
private void ContinueButton_Click (object sender, RoutedEventArgs e)
{
this.DialogResult = true;
@@ -73,4 +83,10 @@ namespace GARbro.GUI
public event EventHandler CanExecuteChanged;
}
}
+
+ public struct FileErrorDialogResult
+ {
+ public bool Continue;
+ public bool IgnoreErrors;
+ }
}
diff --git a/GUI/FileExistsDialog.xaml b/GUI/FileExistsDialog.xaml
new file mode 100644
index 00000000..bb1c2689
--- /dev/null
+++ b/GUI/FileExistsDialog.xaml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/GUI/FileExistsDialog.xaml.cs b/GUI/FileExistsDialog.xaml.cs
new file mode 100644
index 00000000..b308f1df
--- /dev/null
+++ b/GUI/FileExistsDialog.xaml.cs
@@ -0,0 +1,72 @@
+using System;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Input;
+
+namespace GARbro.GUI
+{
+ ///
+ /// Interaction logic for FileExistsDialog.xaml
+ ///
+ public partial class FileExistsDialog : Rnd.Windows.ModalWindow
+ {
+ public FileExistsDialog (string title, string text)
+ {
+ InitializeComponent ();
+ this.Title = title;
+ this.Notice.Text = text;
+ }
+
+ new public FileExistsDialogResult ShowDialog ()
+ {
+ bool dialog_result = base.ShowDialog() ?? false;
+ if (!dialog_result)
+ FileAction = ExistingFileAction.Abort;
+ return new FileExistsDialogResult
+ {
+ Action = FileAction,
+ ApplyToAll = ApplyToAll.IsChecked ?? false
+ };
+ }
+
+ public ExistingFileAction FileAction { get; set; }
+
+ private void SkipButton_Click (object sender, RoutedEventArgs e)
+ {
+ this.DialogResult = true;
+ this.FileAction = ExistingFileAction.Skip;
+ }
+
+ private void OverwriteButton_Click (object sender, RoutedEventArgs e)
+ {
+ this.DialogResult = true;
+ this.FileAction = ExistingFileAction.Overwrite;
+ }
+
+ private void RenameButton_Click (object sender, RoutedEventArgs e)
+ {
+ this.DialogResult = true;
+ this.FileAction = ExistingFileAction.Rename;
+ }
+
+ private void AbortButton_Click (object sender, RoutedEventArgs e)
+ {
+ this.DialogResult = false;
+ this.FileAction = ExistingFileAction.Abort;
+ }
+ }
+
+ public enum ExistingFileAction
+ {
+ Skip,
+ Overwrite,
+ Rename,
+ Abort
+ }
+
+ public struct FileExistsDialogResult
+ {
+ public ExistingFileAction Action;
+ public bool ApplyToAll;
+ }
+}
diff --git a/GUI/GARbro.GUI.csproj b/GUI/GARbro.GUI.csproj
index bf565e0e..1a19b592 100644
--- a/GUI/GARbro.GUI.csproj
+++ b/GUI/GARbro.GUI.csproj
@@ -147,6 +147,9 @@
FileErrorDialog.xaml
+
+ FileExistsDialog.xaml
+
@@ -203,6 +206,10 @@
Designer
MSBuild:Compile
+
+ Designer
+ MSBuild:Compile
+
MSBuild:Compile
Designer
diff --git a/GUI/GarConvert.cs b/GUI/GarConvert.cs
index 1d61da9d..57365053 100644
--- a/GUI/GarConvert.cs
+++ b/GUI/GarConvert.cs
@@ -143,42 +143,38 @@ namespace GARbro.GUI
void ConvertWorker (object sender, DoWorkEventArgs e)
{
m_pending_error = null;
- try
+ int total = m_source.Count();
+ int i = 0;
+ foreach (var entry in m_source)
{
- int total = m_source.Count();
- int i = 0;
- foreach (var entry in m_source)
+ if (m_progress_dialog.CancellationPending)
{
- if (m_progress_dialog.CancellationPending)
- throw new OperationCanceledException();
- var filename = entry.Name;
- int progress = i++*100/total;
- m_progress_dialog.ReportProgress (progress, string.Format (guiStrings.MsgConvertingFile,
- Path.GetFileName (filename)), null);
- try
- {
- if ("image" == entry.Type)
- ConvertImage (filename);
- else if ("audio" == entry.Type)
- ConvertAudio (filename);
- }
- catch (NotImplementedException X)
- {
- // target format creation not implemented
- m_pending_error = X;
- break;
- }
- catch (Exception X)
- {
- if (!IgnoreErrors)
- throw;
- m_failed.Add (Tuple.Create (Path.GetFileName (filename), X.Message));
- }
+ m_pending_error = new OperationCanceledException();
+ break;
+ }
+ var filename = entry.Name;
+ int progress = i++*100/total;
+ m_progress_dialog.ReportProgress (progress, string.Format (guiStrings.MsgConvertingFile,
+ Path.GetFileName (filename)), null);
+ try
+ {
+ if ("image" == entry.Type)
+ ConvertImage (filename);
+ else if ("audio" == entry.Type)
+ ConvertAudio (filename);
+ }
+ catch (Exception X)
+ {
+ if (!IgnoreErrors)
+ {
+ var error_text = string.Format (guiStrings.TextErrorConverting, entry.Name, X.Message);
+ var result = m_main.Dispatcher.Invoke (() => m_main.ShowErrorDialog (guiStrings.TextMediaConvertError, error_text, m_progress_dialog.GetWindowHandle()));
+ if (!result.Continue)
+ break;
+ IgnoreErrors = result.IgnoreErrors;
+ }
+ m_failed.Add (Tuple.Create (Path.GetFileName (filename), X.Message));
}
- }
- catch (Exception X)
- {
- m_pending_error = X;
}
}
diff --git a/GUI/GarExtract.cs b/GUI/GarExtract.cs
index be5a0a10..be378361 100644
--- a/GUI/GarExtract.cs
+++ b/GUI/GarExtract.cs
@@ -304,8 +304,10 @@ namespace GARbro.GUI
if (!m_ignore_errors)
{
var error_text = string.Format (guiStrings.TextErrorExtracting, entry.Name, X.Message);
- if (!m_main.Dispatcher.Invoke (() => ShowErrorDialog (error_text)))
+ var result = m_main.Dispatcher.Invoke (() => m_main.ShowErrorDialog (guiStrings.TextExtractionError, error_text, m_progress_dialog.GetWindowHandle()));
+ if (!result.Continue)
break;
+ m_ignore_errors = result.IgnoreErrors;
}
++m_skip_count;
}
@@ -411,31 +413,6 @@ namespace GARbro.GUI
throw new IOException ("File aready exists");
}
- bool ShowErrorDialog (string error_text)
- {
- var dialog = new FileErrorDialog (guiStrings.TextExtractionError, error_text);
- var progress_dialog_hwnd = m_progress_dialog.GetWindowHandle();
- if (progress_dialog_hwnd != IntPtr.Zero)
- {
- var native_dialog = new WindowInteropHelper (dialog);
- native_dialog.Owner = progress_dialog_hwnd;
- NativeMethods.EnableWindow (progress_dialog_hwnd, false);
- EventHandler on_closed = null;
- on_closed = (s, e) => {
- NativeMethods.EnableWindow (progress_dialog_hwnd, true);
- dialog.Closed -= on_closed;
- };
- dialog.Closed += on_closed;
- }
- else
- {
- dialog.Owner = m_main;
- }
- bool dialog_result = dialog.ShowDialog() ?? false;
- m_ignore_errors = dialog.IgnoreErrors.IsChecked ?? false;
- return dialog_result;
- }
-
void OnExtractComplete (object sender, RunWorkerCompletedEventArgs e)
{
m_extract_in_progress = false;
diff --git a/GUI/MainWindow.xaml.cs b/GUI/MainWindow.xaml.cs
index 6adab05c..3d45960e 100644
--- a/GUI/MainWindow.xaml.cs
+++ b/GUI/MainWindow.xaml.cs
@@ -1,6 +1,6 @@
// Game Resource Browser
//
-// Copyright (C) 2014-2015 by morkt
+// Copyright (C) 2014-2017 by morkt
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
@@ -35,6 +35,7 @@ using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Input;
+using System.Windows.Interop;
using System.Windows.Threading;
using Microsoft.VisualBasic.FileIO;
using GARbro.GUI.Properties;
@@ -195,6 +196,40 @@ namespace GARbro.GUI
Dispatcher.Invoke (() => MessageBox.Show (this, message, title, MessageBoxButton.OK, MessageBoxImage.Error));
}
+ internal FileErrorDialogResult ShowErrorDialog (string error_title, string error_text, IntPtr parent_hwnd)
+ {
+ var dialog = new FileErrorDialog (error_title, error_text);
+ SetModalWindowParent (dialog, parent_hwnd);
+ return dialog.ShowDialog();
+ }
+
+ internal FileExistsDialogResult ShowFileExistsDialog (string title, string text, IntPtr parent_hwnd)
+ {
+ var dialog = new FileExistsDialog (title, text);
+ SetModalWindowParent (dialog, parent_hwnd);
+ return dialog.ShowDialog();
+ }
+
+ private void SetModalWindowParent (Window dialog, IntPtr parent_hwnd)
+ {
+ if (parent_hwnd != IntPtr.Zero)
+ {
+ var native_dialog = new WindowInteropHelper (dialog);
+ native_dialog.Owner = parent_hwnd;
+ NativeMethods.EnableWindow (parent_hwnd, false);
+ EventHandler on_closed = null;
+ on_closed = (s, e) => {
+ NativeMethods.EnableWindow (parent_hwnd, true);
+ dialog.Closed -= on_closed;
+ };
+ dialog.Closed += on_closed;
+ }
+ else
+ {
+ dialog.Owner = this;
+ }
+ }
+
const int MaxRecentFiles = 9;
LinkedList m_recent_files;
diff --git a/GUI/Strings/guiStrings.Designer.cs b/GUI/Strings/guiStrings.Designer.cs
index b03f1416..cd3ff941 100644
--- a/GUI/Strings/guiStrings.Designer.cs
+++ b/GUI/Strings/guiStrings.Designer.cs
@@ -114,6 +114,33 @@ namespace GARbro.GUI.Strings {
}
}
+ ///
+ /// Looks up a localized string similar to _Overwrite.
+ ///
+ public static string ButtonOverwrite {
+ get {
+ return ResourceManager.GetString("ButtonOverwrite", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to _Rename.
+ ///
+ public static string ButtonRename {
+ get {
+ return ResourceManager.GetString("ButtonRename", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to _Skip.
+ ///
+ public static string ButtonSkip {
+ get {
+ return ResourceManager.GetString("ButtonSkip", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to _Close.
///
@@ -312,6 +339,15 @@ namespace GARbro.GUI.Strings {
}
}
+ ///
+ /// Looks up a localized string similar to A_pply to all duplicate files.
+ ///
+ public static string LabelApplyToAll {
+ get {
+ return ResourceManager.GetString("LabelApplyToAll", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Archive format.
///
@@ -366,6 +402,15 @@ namespace GARbro.GUI.Strings {
}
}
+ ///
+ /// Looks up a localized string similar to What should be done?.
+ ///
+ public static string LabelDuplicateFileQuestion {
+ get {
+ return ResourceManager.GetString("LabelDuplicateFileQuestion", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Encoding.
///
@@ -963,6 +1008,17 @@ namespace GARbro.GUI.Strings {
}
}
+ ///
+ /// Looks up a localized string similar to Error occured while converting file
+ ///{0}
+ ///{1}.
+ ///
+ public static string TextErrorConverting {
+ get {
+ return ResourceManager.GetString("TextErrorConverting", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Error occured while extracting file
///{0}
diff --git a/GUI/Strings/guiStrings.ko-KR.resx b/GUI/Strings/guiStrings.ko-KR.resx
index b3009ef5..7047b2fb 100644
--- a/GUI/Strings/guiStrings.ko-KR.resx
+++ b/GUI/Strings/guiStrings.ko-KR.resx
@@ -474,4 +474,30 @@
File extraction error
translation pending
+
+ Overwrite
+ translation pending
+
+
+ Rename
+ translation pending
+
+
+ Skip
+ translation pending
+
+
+ Apply to all duplicate files
+ translation pending
+
+
+ What should be done?
+ translation pending
+
+
+ Error occured while converting file
+{0}
+{1}
+ translation pending
+
\ No newline at end of file
diff --git a/GUI/Strings/guiStrings.resx b/GUI/Strings/guiStrings.resx
index f08e7fab..59310985 100644
--- a/GUI/Strings/guiStrings.resx
+++ b/GUI/Strings/guiStrings.resx
@@ -474,4 +474,24 @@ Overwrite?
File extraction error
+
+ _Overwrite
+
+
+ _Rename
+
+
+ _Skip
+
+
+ A_pply to all duplicate files
+
+
+ What should be done?
+
+
+ Error occured while converting file
+{0}
+{1}
+
\ No newline at end of file
diff --git a/GUI/Strings/guiStrings.ru-RU.resx b/GUI/Strings/guiStrings.ru-RU.resx
index 83b3bed3..5103adff 100644
--- a/GUI/Strings/guiStrings.ru-RU.resx
+++ b/GUI/Strings/guiStrings.ru-RU.resx
@@ -495,4 +495,24 @@
Ошибка извлечения файла
+
+ Заменить
+
+
+ Переименовать
+
+
+ Пропустить
+
+
+ Применить ко всем совпадающим файлам
+
+
+ Что делать?
+
+
+ Не удадось конвертировать файл
+{0}
+{1}
+
\ No newline at end of file
diff --git a/GUI/Strings/guiStrings.zh-Hans.resx b/GUI/Strings/guiStrings.zh-Hans.resx
index beefb52d..7f6e2c00 100644
--- a/GUI/Strings/guiStrings.zh-Hans.resx
+++ b/GUI/Strings/guiStrings.zh-Hans.resx
@@ -476,4 +476,30 @@
File extraction error
translation pending
+
+ Overwrite
+ translation pending
+
+
+ Rename
+ translation pending
+
+
+ Skip
+ translation pending
+
+
+ Apply to all duplicate files
+ translation pending
+
+
+ What should be done?
+ translation pending
+
+
+ Error occured while converting file
+{0}
+{1}
+ translation pending
+
\ No newline at end of file