diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs index 42163e1a..6d1614d2 100644 --- a/MainWindow.xaml.cs +++ b/MainWindow.xaml.cs @@ -650,13 +650,12 @@ namespace GARbro.GUI /// private void OpenItemExec (object control, ExecutedRoutedEventArgs e) { - EntryViewModel entry = CurrentDirectory.SelectedItem as EntryViewModel; + EntryViewModel entry = null; + var lvi = e.OriginalSource as ListViewItem; + if (lvi != null) + entry = lvi.Content as EntryViewModel; if (null == entry) - { - var lvi = e.OriginalSource as ListViewItem; - if (lvi != null) - entry = lvi.Content as EntryViewModel; - } + entry = CurrentDirectory.SelectedItem as EntryViewModel; if (null == entry) return; @@ -784,19 +783,48 @@ namespace GARbro.GUI /// private void DeleteItemExec (object sender, ExecutedRoutedEventArgs e) { - var entry = CurrentDirectory.SelectedItem as EntryViewModel; - if (entry == null) + var items = CurrentDirectory.SelectedItems.Cast().Where (f => !f.IsDirectory); + if (!items.Any()) return; this.IsEnabled = false; try { m_app.ResetCache(); - string item_name = Path.Combine (CurrentPath, entry.Name); - Trace.WriteLine (item_name, "DeleteItemExec"); - FileSystem.DeleteFile (item_name, UIOption.AllDialogs, RecycleOption.SendToRecycleBin); - DeleteItem (lv_GetCurrentContainer()); - SetStatusText (string.Format(guiStrings.MsgDeletedItem, item_name)); + if (!items.Skip (1).Any()) // items.Count() == 1 + { + string item_name = Path.Combine (CurrentPath, items.First().Name); + Trace.WriteLine (item_name, "DeleteItemExec"); + FileSystem.DeleteFile (item_name, UIOption.AllDialogs, RecycleOption.SendToRecycleBin); + DeleteItem (lv_GetCurrentContainer()); + 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) { @@ -964,6 +992,11 @@ namespace GARbro.GUI } } } + + private void CanExecuteFitWindow (object sender, CanExecuteRoutedEventArgs e) + { + e.CanExecute = PreviewPane.Source != null; + } } /// @@ -1059,5 +1092,6 @@ namespace GARbro.GUI public static readonly RoutedCommand ExploreItem = new RoutedCommand(); public static readonly RoutedCommand Refresh = new RoutedCommand(); public static readonly RoutedCommand Browse = new RoutedCommand(); + public static readonly RoutedCommand FitWindow = new RoutedCommand(); } } diff --git a/Strings/guiStrings.Designer.cs b/Strings/guiStrings.Designer.cs index ac24d841..2219801b 100644 --- a/Strings/guiStrings.Designer.cs +++ b/Strings/guiStrings.Designer.cs @@ -366,6 +366,15 @@ namespace GARbro.GUI.Strings { } } + /// + /// Looks up a localized string similar to Are you sure you want to delete these files?. + /// + public static string MsgConfirmDeleteFiles { + get { + return ResourceManager.GetString("MsgConfirmDeleteFiles", resourceCulture); + } + } + /// /// Looks up a localized string similar to Creating archive {0}. /// @@ -384,6 +393,24 @@ namespace GARbro.GUI.Strings { } } + /// + /// Looks up a localized string similar to Deleted {0} file. + /// + public static string MsgDeletedItems1 { + get { + return ResourceManager.GetString("MsgDeletedItems1", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Deleted {0} files. + /// + public static string MsgDeletedItems2 { + get { + return ResourceManager.GetString("MsgDeletedItems2", resourceCulture); + } + } + /// /// Looks up a localized string similar to directory not found. /// @@ -657,6 +684,15 @@ namespace GARbro.GUI.Strings { } } + /// + /// Looks up a localized string similar to Delete files. + /// + public static string TextDeleteFiles { + get { + return ResourceManager.GetString("TextDeleteFiles", resourceCulture); + } + } + /// /// Looks up a localized string similar to Text encoding. /// diff --git a/Strings/guiStrings.resx b/Strings/guiStrings.resx index bfe5a215..d84c4031 100644 --- a/Strings/guiStrings.resx +++ b/Strings/guiStrings.resx @@ -351,4 +351,16 @@ Overwrite? {0} files + + Are you sure you want to delete these files? + + + Delete files + + + Deleted {0} file + + + Deleted {0} files + \ No newline at end of file diff --git a/Strings/guiStrings.ru-RU.resx b/Strings/guiStrings.ru-RU.resx index dc9dc76f..6b82b020 100644 --- a/Strings/guiStrings.ru-RU.resx +++ b/Strings/guiStrings.ru-RU.resx @@ -366,4 +366,19 @@ {0} файлов + + Вы действительно хотите удалить эти файлы? + + + Удалить файлы + + + Удалён {0} файл + + + Удалено {0} файла + + + Удалено {0} файлов + \ No newline at end of file