added new key binding '+' that includes into selection files that match specified mask.

This commit is contained in:
morkt 2015-08-03 22:45:59 +04:00
parent 81773a8137
commit bd01f8860c
6 changed files with 162 additions and 8 deletions

View File

@ -133,6 +133,9 @@
<DependentUpon>CreateArchive.xaml</DependentUpon>
</Compile>
<Compile Include="DragScroll.cs" />
<Compile Include="EnterMaskDialog.xaml.cs">
<DependentUpon>EnterMaskDialog.xaml</DependentUpon>
</Compile>
<Compile Include="ExtractArchive.xaml.cs">
<DependentUpon>ExtractArchive.xaml</DependentUpon>
</Compile>
@ -176,6 +179,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="EnterMaskDialog.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="ExtractArchive.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>

View File

@ -255,6 +255,7 @@
SelectionMode="Extended" Foreground="Black" AlternationCount="2"
ContextMenu="{StaticResource lvDirContextMenu}"
PreviewTextInput="lv_TextInput" IsSynchronizedWithCurrentItem="True"
SelectionChanged="lv_SelectionChanged"
GridViewColumnHeader.Click="lv_ColumnHeaderClicked">
<ListView.Resources>
<SolidColorBrush x:Key="ItemInactiveBackground" Color="#ffcbcbcb" />
@ -263,18 +264,11 @@
<KeyBinding Key="Enter" Command="{x:Static local:Commands.OpenItem}"/>
<KeyBinding Gesture="Ctrl+E" Command="{x:Static local:Commands.ExploreItem}"/>
<KeyBinding Gesture="F2" Command="{x:Static local:Commands.RenameItem}"/>
<KeyBinding Gesture="F3" Command="{x:Static local:Commands.CreateArchive}"/>
<KeyBinding Gesture="F4" Command="{x:Static local:Commands.ExtractItem}"/>
<KeyBinding Gesture="F5" Command="{x:Static local:Commands.Refresh}"/>
<KeyBinding Gesture="F6" Command="{x:Static local:Commands.ConvertMedia}"/>
<KeyBinding Gesture="Delete" Command="{x:Static local:Commands.DeleteItem}"/>
<KeyBinding Gesture="Backspace" Command="{x:Static local:Commands.GoBack}"/>
<MouseBinding Gesture="LeftDoubleClick" Command="{x:Static local:Commands.OpenItem}" />
</ListView.InputBindings>
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<EventSetter Event="Selected" Handler="lvi_Selected"/>
<EventSetter Event="ListViewItem.MouseDoubleClick" Handler="lvi_DoubleClick" />
<Style.Triggers>
<!-- BEGIN alternate row color -->
@ -351,17 +345,26 @@
<KeyBinding Gesture="Ctrl+O" Command="{x:Static local:Commands.OpenFile}"/>
<KeyBinding Gesture="Ctrl+Q" Command="{x:Static local:Commands.Exit}"/>
<KeyBinding Gesture="Ctrl+H" Command="{x:Static local:Commands.FitWindow}"/>
<KeyBinding Gesture="Ctrl+A" Command="{x:Static local:Commands.SelectAll}"/>
<KeyBinding Gesture="Backspace" Command="{x:Static local:Commands.GoBack}"/>
<KeyBinding Gesture="Alt+Left" Command="{x:Static local:Commands.GoBack}"/>
<KeyBinding Gesture="Alt+Right" Command="{x:Static local:Commands.GoForward}"/>
<KeyBinding Gesture="Alt+Shift+M" Command="{x:Static local:Commands.HideMenuBar}"/>
<KeyBinding Gesture="Alt+Shift+T" Command="{x:Static local:Commands.HideToolBar}"/>
<KeyBinding Gesture="Alt+Shift+S" Command="{x:Static local:Commands.HideStatusBar}"/>
<KeyBinding Gesture="F3" Command="{x:Static local:Commands.CreateArchive}"/>
<KeyBinding Gesture="F4" Command="{x:Static local:Commands.ExtractItem}"/>
<KeyBinding Gesture="F5" Command="{x:Static local:Commands.Refresh}"/>
<KeyBinding Gesture="F6" Command="{x:Static local:Commands.ConvertMedia}"/>
<KeyBinding Gesture="Delete" Command="{x:Static local:Commands.DeleteItem}"/>
<KeyBinding Gesture="Add" Command="{x:Static local:Commands.AddSelection}"/>
</Window.InputBindings>
<Window.CommandBindings>
<CommandBinding Command="{x:Static local:Commands.OpenItem}" Executed="OpenItemExec" CanExecute="CanExecuteOnSelected"/>
<CommandBinding Command="{x:Static local:Commands.OpenFile}" Executed="OpenFileExec" CanExecute="CanExecuteAlways"/>
<CommandBinding Command="{x:Static local:Commands.OpenRecent}" Executed="OpenRecentExec" CanExecute="CanExecuteAlways"/>
<CommandBinding Command="{x:Static local:Commands.AddSelection}" Executed="AddSelectionExec" CanExecute="CanExecuteAlways"/>
<CommandBinding Command="{x:Static local:Commands.SelectAll}" Executed="SelectAllExec" CanExecute="CanExecuteAlways"/>
<CommandBinding Command="{x:Static local:Commands.ExtractItem}" Executed="ExtractItemExec" CanExecute="CanExecuteExtract"/>
<CommandBinding Command="{x:Static local:Commands.CreateArchive}" Executed="CreateArchiveExec" CanExecute="CanExecuteCreateArchive"/>
<CommandBinding Command="{x:Static local:Commands.DeleteItem}" Executed="DeleteItemExec" CanExecute="CanExecuteOnPhysicalFile" />

View File

@ -45,6 +45,7 @@ using System.Collections.Specialized;
using System.Collections.ObjectModel;
using Microsoft.Win32;
using NAudio.Wave;
using System.Text.RegularExpressions;
namespace GARbro.GUI
{
@ -396,6 +397,21 @@ namespace GARbro.GUI
PreviewEntry (entry.Source);
}
EntryViewModel m_last_selected = null;
void lv_SelectionChanged (object sender, SelectionChangedEventArgs args)
{
var lv = sender as ListView;
if (null == lv)
return;
var item = lv.SelectedItem as EntryViewModel;
if (item != null && m_last_selected != item)
{
m_last_selected = item;
PreviewEntry (item.Source);
}
}
void lvi_DoubleClick (object sender, MouseButtonEventArgs args)
{
var lvi = sender as ListViewItem;
@ -1043,6 +1059,54 @@ namespace GARbro.GUI
*/
}
/// <summary>
/// Select files matching mask.
/// </summary>
void AddSelectionExec (object sender, ExecutedRoutedEventArgs e)
{
var mask_list = new SortedSet<string>();
foreach (var entry in ViewModel)
{
var ext = Path.GetExtension (entry.Name).ToLowerInvariant();
if (!string.IsNullOrEmpty (ext))
mask_list.Add ("*" + ext);
}
var selection = new EnterMaskDialog (mask_list);
selection.Owner = this;
var result = selection.ShowDialog();
if (!result.Value)
return;
if ("*.*" == selection.Mask.Text)
{
CurrentDirectory.SelectAll();
return;
}
var mask = Regex.Escape (selection.Mask.Text).Replace (@"\*", ".*").Replace (@"\?", ".");
var glob = new Regex ("^"+mask+"$", RegexOptions.IgnoreCase);
var matching = ViewModel.Where (entry => glob.IsMatch (entry.Name));
if (!matching.Any())
{
SetStatusText (string.Format (guiStrings.MsgNoMatching, selection.Mask.Text));
return;
}
int count = 0;
foreach (var item in matching)
{
if (!CurrentDirectory.SelectedItems.Contains (item))
{
CurrentDirectory.SelectedItems.Add (item);
++count;
}
}
if (count != 0)
SetStatusText (Localization.Format ("MsgSelectedFiles", count));
}
void SelectAllExec (object sender, ExecutedRoutedEventArgs e)
{
CurrentDirectory.SelectAll();
}
/// <summary>
/// Handle "Exit" command.
/// </summary>
@ -1228,7 +1292,7 @@ namespace GARbro.GUI
try
{
string dirname = Path.GetDirectoryName (this.Text);
if (!string.IsNullOrEmpty (this.Text) && Directory.Exists (dirname))
if (!string.IsNullOrEmpty (dirname) && Directory.Exists (dirname))
{
foreach (var dir in Directory.GetDirectories (dirname))
{
@ -1304,5 +1368,7 @@ namespace GARbro.GUI
public static readonly RoutedCommand HideStatusBar = new RoutedCommand();
public static readonly RoutedCommand HideMenuBar = new RoutedCommand();
public static readonly RoutedCommand HideToolBar = new RoutedCommand();
public static readonly RoutedCommand AddSelection = new RoutedCommand();
public static readonly RoutedCommand SelectAll = new RoutedCommand();
}
}

View File

@ -321,6 +321,15 @@ namespace GARbro.GUI.Strings {
}
}
/// <summary>
/// Looks up a localized string similar to Enter wildcard mask.
/// </summary>
public static string LabelEnterMask {
get {
return ResourceManager.GetString("LabelEnterMask", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Extract files from {0} to.
/// </summary>
@ -636,6 +645,15 @@ namespace GARbro.GUI.Strings {
}
}
/// <summary>
/// Looks up a localized string similar to No entries matching &quot;{0}&quot;.
/// </summary>
public static string MsgNoMatching {
get {
return ResourceManager.GetString("MsgNoMatching", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to No media files selected..
/// </summary>
@ -666,6 +684,24 @@ namespace GARbro.GUI.Strings {
}
}
/// <summary>
/// Looks up a localized string similar to {0} file added to selection.
/// </summary>
public static string MsgSelectedFiles1 {
get {
return ResourceManager.GetString("MsgSelectedFiles1", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to {0} files added to selection.
/// </summary>
public static string MsgSelectedFiles2 {
get {
return ResourceManager.GetString("MsgSelectedFiles2", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to unable to interpret audio format.
/// </summary>
@ -936,6 +972,15 @@ namespace GARbro.GUI.Strings {
}
}
/// <summary>
/// Looks up a localized string similar to Select files.
/// </summary>
public static string TextSelectFiles {
get {
return ResourceManager.GetString("TextSelectFiles", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Game Resource browser.
/// </summary>

View File

@ -426,4 +426,19 @@ Overwrite?</value>
<data name="LabelSkipFailures" xml:space="preserve">
<value>Skip incovertible files.</value>
</data>
<data name="MsgNoMatching" xml:space="preserve">
<value>No entries matching "{0}"</value>
</data>
<data name="MsgSelectedFiles1" xml:space="preserve">
<value>{0} file added to selection</value>
</data>
<data name="MsgSelectedFiles2" xml:space="preserve">
<value>{0} files added to selection</value>
</data>
<data name="LabelEnterMask" xml:space="preserve">
<value>Enter wildcard mask</value>
</data>
<data name="TextSelectFiles" xml:space="preserve">
<value>Select files</value>
</data>
</root>

View File

@ -444,4 +444,22 @@
<data name="TextAudioConversion" xml:space="preserve">
<value>Аудио-файлы будут преобразованы в WAV, MP3 или OGG.</value>
</data>
<data name="MsgNoMatching" xml:space="preserve">
<value>Нет файлов, подходящих под маску "{0}"</value>
</data>
<data name="MsgSelectedFiles1" xml:space="preserve">
<value>{0} файл добавлен к выбранным</value>
</data>
<data name="MsgSelectedFiles2" xml:space="preserve">
<value>{0} файла добавлено к выбранным</value>
</data>
<data name="MsgSelectedFiles3" xml:space="preserve">
<value>{0} файлов добавлено к выбранным</value>
</data>
<data name="LabelEnterMask" xml:space="preserve">
<value>Маска для имён файлов</value>
</data>
<data name="TextSelectFiles" xml:space="preserve">
<value>Выбрать файлы</value>
</data>
</root>