mirror of
https://github.com/crskycode/GARbro.git
synced 2024-12-24 03:44:13 +08:00
(DeleteItemExec): multiple files deletion.
This commit is contained in:
parent
13674f2e11
commit
407d394c2c
@ -650,13 +650,12 @@ namespace GARbro.GUI
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void OpenItemExec (object control, ExecutedRoutedEventArgs e)
|
private void OpenItemExec (object control, ExecutedRoutedEventArgs e)
|
||||||
{
|
{
|
||||||
EntryViewModel entry = CurrentDirectory.SelectedItem as EntryViewModel;
|
EntryViewModel entry = null;
|
||||||
if (null == entry)
|
|
||||||
{
|
|
||||||
var lvi = e.OriginalSource as ListViewItem;
|
var lvi = e.OriginalSource as ListViewItem;
|
||||||
if (lvi != null)
|
if (lvi != null)
|
||||||
entry = lvi.Content as EntryViewModel;
|
entry = lvi.Content as EntryViewModel;
|
||||||
}
|
if (null == entry)
|
||||||
|
entry = CurrentDirectory.SelectedItem as EntryViewModel;
|
||||||
if (null == entry)
|
if (null == entry)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -784,20 +783,49 @@ namespace GARbro.GUI
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void DeleteItemExec (object sender, ExecutedRoutedEventArgs e)
|
private void DeleteItemExec (object sender, ExecutedRoutedEventArgs e)
|
||||||
{
|
{
|
||||||
var entry = CurrentDirectory.SelectedItem as EntryViewModel;
|
var items = CurrentDirectory.SelectedItems.Cast<EntryViewModel>().Where (f => !f.IsDirectory);
|
||||||
if (entry == null)
|
if (!items.Any())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
this.IsEnabled = false;
|
this.IsEnabled = false;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
m_app.ResetCache();
|
m_app.ResetCache();
|
||||||
string item_name = Path.Combine (CurrentPath, entry.Name);
|
if (!items.Skip (1).Any()) // items.Count() == 1
|
||||||
|
{
|
||||||
|
string item_name = Path.Combine (CurrentPath, items.First().Name);
|
||||||
Trace.WriteLine (item_name, "DeleteItemExec");
|
Trace.WriteLine (item_name, "DeleteItemExec");
|
||||||
FileSystem.DeleteFile (item_name, UIOption.AllDialogs, RecycleOption.SendToRecycleBin);
|
FileSystem.DeleteFile (item_name, UIOption.AllDialogs, RecycleOption.SendToRecycleBin);
|
||||||
DeleteItem (lv_GetCurrentContainer());
|
DeleteItem (lv_GetCurrentContainer());
|
||||||
SetStatusText (string.Format(guiStrings.MsgDeletedItem, item_name));
|
SetStatusText (string.Format(guiStrings.MsgDeletedItem, item_name));
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var rc = MessageBox.Show (this, guiStrings.MsgConfirmDeleteFiles, guiStrings.TextDeleteFiles,
|
||||||
|
MessageBoxButton.YesNo, MessageBoxImage.Question);
|
||||||
|
if (MessageBoxResult.Yes != rc)
|
||||||
|
return;
|
||||||
|
int count = 0;
|
||||||
|
StopWatchDirectoryChanges ();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Trace.WriteLine (string.Format ("deleting multiple files in {0}", CurrentPath), "DeleteItemExec");
|
||||||
|
foreach (var entry in items)
|
||||||
|
{
|
||||||
|
string item_name = Path.Combine (CurrentPath, entry.Name);
|
||||||
|
FileSystem.DeleteFile (item_name);
|
||||||
|
++count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
ResumeWatchDirectoryChanges();
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
RefreshView();
|
||||||
|
SetStatusText (Localization.Format ("MsgDeletedItems", count));
|
||||||
|
}
|
||||||
|
}
|
||||||
catch (OperationCanceledException)
|
catch (OperationCanceledException)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -964,6 +992,11 @@ namespace GARbro.GUI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void CanExecuteFitWindow (object sender, CanExecuteRoutedEventArgs e)
|
||||||
|
{
|
||||||
|
e.CanExecute = PreviewPane.Source != null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -1059,5 +1092,6 @@ namespace GARbro.GUI
|
|||||||
public static readonly RoutedCommand ExploreItem = new RoutedCommand();
|
public static readonly RoutedCommand ExploreItem = new RoutedCommand();
|
||||||
public static readonly RoutedCommand Refresh = new RoutedCommand();
|
public static readonly RoutedCommand Refresh = new RoutedCommand();
|
||||||
public static readonly RoutedCommand Browse = new RoutedCommand();
|
public static readonly RoutedCommand Browse = new RoutedCommand();
|
||||||
|
public static readonly RoutedCommand FitWindow = new RoutedCommand();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
36
Strings/guiStrings.Designer.cs
generated
36
Strings/guiStrings.Designer.cs
generated
@ -366,6 +366,15 @@ namespace GARbro.GUI.Strings {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Are you sure you want to delete these files?.
|
||||||
|
/// </summary>
|
||||||
|
public static string MsgConfirmDeleteFiles {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("MsgConfirmDeleteFiles", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Creating archive {0}.
|
/// Looks up a localized string similar to Creating archive {0}.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -384,6 +393,24 @@ namespace GARbro.GUI.Strings {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Deleted {0} file.
|
||||||
|
/// </summary>
|
||||||
|
public static string MsgDeletedItems1 {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("MsgDeletedItems1", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Deleted {0} files.
|
||||||
|
/// </summary>
|
||||||
|
public static string MsgDeletedItems2 {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("MsgDeletedItems2", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to directory not found.
|
/// Looks up a localized string similar to directory not found.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -657,6 +684,15 @@ namespace GARbro.GUI.Strings {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Delete files.
|
||||||
|
/// </summary>
|
||||||
|
public static string TextDeleteFiles {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("TextDeleteFiles", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Text encoding.
|
/// Looks up a localized string similar to Text encoding.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -351,4 +351,16 @@ Overwrite?</value>
|
|||||||
<data name="MsgFiles2" xml:space="preserve">
|
<data name="MsgFiles2" xml:space="preserve">
|
||||||
<value>{0} files</value>
|
<value>{0} files</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="MsgConfirmDeleteFiles" xml:space="preserve">
|
||||||
|
<value>Are you sure you want to delete these files?</value>
|
||||||
|
</data>
|
||||||
|
<data name="TextDeleteFiles" xml:space="preserve">
|
||||||
|
<value>Delete files</value>
|
||||||
|
</data>
|
||||||
|
<data name="MsgDeletedItems1" xml:space="preserve">
|
||||||
|
<value>Deleted {0} file</value>
|
||||||
|
</data>
|
||||||
|
<data name="MsgDeletedItems2" xml:space="preserve">
|
||||||
|
<value>Deleted {0} files</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
@ -366,4 +366,19 @@
|
|||||||
<data name="MsgFiles3" xml:space="preserve">
|
<data name="MsgFiles3" xml:space="preserve">
|
||||||
<value>{0} файлов</value>
|
<value>{0} файлов</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="MsgConfirmDeleteFiles" xml:space="preserve">
|
||||||
|
<value>Вы действительно хотите удалить эти файлы?</value>
|
||||||
|
</data>
|
||||||
|
<data name="TextDeleteFiles" xml:space="preserve">
|
||||||
|
<value>Удалить файлы</value>
|
||||||
|
</data>
|
||||||
|
<data name="MsgDeletedItems1" xml:space="preserve">
|
||||||
|
<value>Удалён {0} файл</value>
|
||||||
|
</data>
|
||||||
|
<data name="MsgDeletedItems2" xml:space="preserve">
|
||||||
|
<value>Удалено {0} файла</value>
|
||||||
|
</data>
|
||||||
|
<data name="MsgDeletedItems3" xml:space="preserve">
|
||||||
|
<value>Удалено {0} файлов</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
Loading…
x
Reference in New Issue
Block a user