mirror of
https://github.com/crskycode/GARbro.git
synced 2024-12-24 03:44:13 +08:00
added progress window to archive creation process.
This commit is contained in:
parent
08b8e8a46b
commit
58f97183ac
@ -40,6 +40,11 @@ namespace GARbro.GUI
|
|||||||
if (MessageBoxResult.Yes != rc)
|
if (MessageBoxResult.Yes != rc)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
var format = this.ArchiveFormat.SelectedItem as ArchiveFormat;
|
||||||
|
if (null != format)
|
||||||
|
{
|
||||||
|
ArchiveOptions = format.GetOptions (OptionsWidget.Content);
|
||||||
|
}
|
||||||
DialogResult = true;
|
DialogResult = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,17 +102,10 @@ namespace GARbro.GUI
|
|||||||
void OnFormatSelect (object sender, SelectionChangedEventArgs e)
|
void OnFormatSelect (object sender, SelectionChangedEventArgs e)
|
||||||
{
|
{
|
||||||
var format = this.ArchiveFormat.SelectedItem as ArchiveFormat;
|
var format = this.ArchiveFormat.SelectedItem as ArchiveFormat;
|
||||||
UIElement widget = null;
|
object widget = null;
|
||||||
if (null != format)
|
if (null != format)
|
||||||
{
|
{
|
||||||
var options = format.GetOptions();
|
widget = format.GetCreationWidget();
|
||||||
ArchiveOptions = options;
|
|
||||||
if (null != options)
|
|
||||||
widget = options.Widget as UIElement;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ArchiveOptions = null;
|
|
||||||
}
|
}
|
||||||
OptionsWidget.Content = widget;
|
OptionsWidget.Content = widget;
|
||||||
OptionsWidget.Visibility = null != widget ? Visibility.Visible : Visibility.Hidden;
|
OptionsWidget.Visibility = null != widget ? Visibility.Visible : Visibility.Hidden;
|
||||||
|
59
GarCreate.cs
59
GarCreate.cs
@ -32,12 +32,13 @@ using System.Windows;
|
|||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using GameRes;
|
using GameRes;
|
||||||
using GARbro.GUI.Strings;
|
using GARbro.GUI.Strings;
|
||||||
|
using Ookii.Dialogs.Wpf;
|
||||||
|
|
||||||
namespace GARbro.GUI
|
namespace GARbro.GUI
|
||||||
{
|
{
|
||||||
public partial class MainWindow : Window
|
public partial class MainWindow : Window
|
||||||
{
|
{
|
||||||
private void CreateArchiveExec (object sender, ExecutedRoutedEventArgs e)
|
private void CreateArchiveExec (object sender, ExecutedRoutedEventArgs args)
|
||||||
{
|
{
|
||||||
StopWatchDirectoryChanges();
|
StopWatchDirectoryChanges();
|
||||||
try
|
try
|
||||||
@ -75,14 +76,60 @@ namespace GARbro.GUI
|
|||||||
file_list = BuildFileList (items, AddFilesFromDir);
|
file_list = BuildFileList (items, AddFilesFromDir);
|
||||||
|
|
||||||
arc_name = Path.GetFullPath (dialog.ArchiveName.Text);
|
arc_name = Path.GetFullPath (dialog.ArchiveName.Text);
|
||||||
using (var tmp_file = new GARbro.Shell.TemporaryFile (Path.GetDirectoryName (arc_name),
|
|
||||||
Path.GetRandomFileName()))
|
var createProgressDialog = new ProgressDialog ()
|
||||||
{
|
{
|
||||||
|
WindowTitle = guiStrings.TextTitle,
|
||||||
|
Text = string.Format (guiStrings.MsgCreatingArchive, Path.GetFileName (arc_name)),
|
||||||
|
Description = "",
|
||||||
|
MinimizeBox = true,
|
||||||
|
};
|
||||||
|
createProgressDialog.DoWork += (s, e) =>
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using (var tmp_file = new GARbro.Shell.TemporaryFile (Path.GetDirectoryName (arc_name),
|
||||||
|
Path.GetRandomFileName ()))
|
||||||
|
{
|
||||||
|
int total = file_list.Count() + 1;
|
||||||
using (var file = File.Create (tmp_file.Name))
|
using (var file = File.Create (tmp_file.Name))
|
||||||
format.Create (file, file_list, dialog.ArchiveOptions);
|
{
|
||||||
GARbro.Shell.File.Rename (tmp_file.Name, arc_name);
|
format.Create (file, file_list, dialog.ArchiveOptions, (i, entry, msg) =>
|
||||||
SetCurrentPosition (new DirectoryPosition (arc_name));
|
{
|
||||||
|
if (createProgressDialog.CancellationPending)
|
||||||
|
throw new OperationCanceledException();
|
||||||
|
int progress = i*100/total;
|
||||||
|
string notice = msg;
|
||||||
|
if (null != entry)
|
||||||
|
{
|
||||||
|
if (null != msg)
|
||||||
|
notice = string.Format ("{0} {1}", msg, entry.Name);
|
||||||
|
else
|
||||||
|
notice = entry.Name;
|
||||||
}
|
}
|
||||||
|
createProgressDialog.ReportProgress (progress, null, notice);
|
||||||
|
return ArchiveOperation.Continue;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
GARbro.Shell.File.Rename (tmp_file.Name, arc_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (OperationCanceledException X)
|
||||||
|
{
|
||||||
|
m_watcher.EnableRaisingEvents = true;
|
||||||
|
SetStatusText (X.Message);
|
||||||
|
}
|
||||||
|
catch (Exception X)
|
||||||
|
{
|
||||||
|
m_watcher.EnableRaisingEvents = true;
|
||||||
|
PopupError (X.Message, guiStrings.TextCreateArchiveError);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
createProgressDialog.RunWorkerCompleted += (s, e) => {
|
||||||
|
createProgressDialog.Dispose();
|
||||||
|
Dispatcher.Invoke (() => SetCurrentPosition (new DirectoryPosition (arc_name)));
|
||||||
|
};
|
||||||
|
createProgressDialog.ShowDialog (this);
|
||||||
}
|
}
|
||||||
catch (Exception X)
|
catch (Exception X)
|
||||||
{
|
{
|
||||||
|
9
Strings/guiStrings.Designer.cs
generated
9
Strings/guiStrings.Designer.cs
generated
@ -330,6 +330,15 @@ namespace GARbro.GUI.Strings {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Creating archive {0}.
|
||||||
|
/// </summary>
|
||||||
|
public static string MsgCreatingArchive {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("MsgCreatingArchive", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Deleted {0}.
|
/// Looks up a localized string similar to Deleted {0}.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -327,4 +327,7 @@ Overwrite?</value>
|
|||||||
<data name="TextConfirmOverwrite" xml:space="preserve">
|
<data name="TextConfirmOverwrite" xml:space="preserve">
|
||||||
<value>Confirm overwrite</value>
|
<value>Confirm overwrite</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="MsgCreatingArchive" xml:space="preserve">
|
||||||
|
<value>Creating archive {0}</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
@ -330,4 +330,7 @@
|
|||||||
<data name="TextConfirmOverwrite" xml:space="preserve">
|
<data name="TextConfirmOverwrite" xml:space="preserve">
|
||||||
<value>Подтвердите перезапись</value>
|
<value>Подтвердите перезапись</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="MsgCreatingArchive" xml:space="preserve">
|
||||||
|
<value>Создание архива {0}</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
Loading…
x
Reference in New Issue
Block a user