mirror of
https://github.com/Tichau/FileConverter.git
synced 2026-11-20 01:22:16 +01:00
Add context menu for presets operation instead the dockpanel.
This commit is contained in:
1 parent
3871b74a20
commit
f92c9e25bd
5 files changed
+86
-189
No files matched your search
+14
-5
@@ -88,7 +88,7 @@ namespace FileConverter.Properties {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Add new preset (duplicate selected preset).
|
||||
/// Looks up a localized string similar to New preset.
|
||||
/// </summary>
|
||||
public static string AddNewPreset {
|
||||
get {
|
||||
@@ -313,7 +313,7 @@ namespace FileConverter.Properties {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Create a new folder..
|
||||
/// Looks up a localized string similar to New folder.
|
||||
/// </summary>
|
||||
public static string CreateANewFolder {
|
||||
get {
|
||||
@@ -411,6 +411,15 @@ namespace FileConverter.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Duplicate preset.
|
||||
/// </summary>
|
||||
public static string DuplicatePreset {
|
||||
get {
|
||||
return ResourceManager.GetString("DuplicatePreset", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Encoding :.
|
||||
/// </summary>
|
||||
@@ -637,7 +646,7 @@ namespace FileConverter.Properties {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Export selected presets.
|
||||
/// Looks up a localized string similar to Export.
|
||||
/// </summary>
|
||||
public static string ExportSelectedPresets {
|
||||
get {
|
||||
@@ -727,7 +736,7 @@ namespace FileConverter.Properties {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Import new presets.
|
||||
/// Looks up a localized string similar to Import.
|
||||
/// </summary>
|
||||
public static string ImportPresets {
|
||||
get {
|
||||
@@ -1058,7 +1067,7 @@ namespace FileConverter.Properties {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Remove selected preset.
|
||||
/// Looks up a localized string similar to Delete.
|
||||
/// </summary>
|
||||
public static string RemoveSelectedPreset {
|
||||
get {
|
||||
|
||||
@@ -127,7 +127,7 @@
|
||||
<value>Action when conversion succeed</value>
|
||||
</data>
|
||||
<data name="AddNewPreset" xml:space="preserve">
|
||||
<value>Add new preset (duplicate selected preset)</value>
|
||||
<value>New preset</value>
|
||||
</data>
|
||||
<data name="Application" xml:space="preserve">
|
||||
<value>Application</value>
|
||||
@@ -293,7 +293,7 @@ use maj for uppercase version</value>
|
||||
<value>Recommended bitrate range in blue</value>
|
||||
</data>
|
||||
<data name="RemoveSelectedPreset" xml:space="preserve">
|
||||
<value>Remove selected preset</value>
|
||||
<value>Delete</value>
|
||||
</data>
|
||||
<data name="Rotate" xml:space="preserve">
|
||||
<value>Rotate :</value>
|
||||
@@ -551,9 +551,12 @@ use maj for uppercase version</value>
|
||||
<value>Error during conversion job initialization.</value>
|
||||
</data>
|
||||
<data name="ExportSelectedPresets" xml:space="preserve">
|
||||
<value>Export selected presets</value>
|
||||
<value>Export</value>
|
||||
</data>
|
||||
<data name="ImportPresets" xml:space="preserve">
|
||||
<value>Import new presets</value>
|
||||
<value>Import</value>
|
||||
</data>
|
||||
<data name="DuplicatePreset" xml:space="preserve">
|
||||
<value>Duplicate preset</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -127,7 +127,7 @@
|
||||
<value>Action when conversion succeed</value>
|
||||
</data>
|
||||
<data name="AddNewPreset" xml:space="preserve">
|
||||
<value>Add new preset (duplicate selected preset)</value>
|
||||
<value>New preset</value>
|
||||
</data>
|
||||
<data name="Application" xml:space="preserve">
|
||||
<value>Application</value>
|
||||
@@ -296,7 +296,7 @@ use maj for uppercase version</value>
|
||||
<value>Recommended bitrate range in blue</value>
|
||||
</data>
|
||||
<data name="RemoveSelectedPreset" xml:space="preserve">
|
||||
<value>Remove selected preset</value>
|
||||
<value>Delete</value>
|
||||
</data>
|
||||
<data name="Rotate" xml:space="preserve">
|
||||
<value>Rotate :</value>
|
||||
@@ -551,7 +551,7 @@ use maj for uppercase version</value>
|
||||
<value>Error during conversion job initialization.</value>
|
||||
</data>
|
||||
<data name="CreateANewFolder" xml:space="preserve">
|
||||
<value>Create a new folder.</value>
|
||||
<value>New folder</value>
|
||||
</data>
|
||||
<data name="DefaultFolderName" xml:space="preserve">
|
||||
<value>New folder</value>
|
||||
@@ -575,9 +575,12 @@ use maj for uppercase version</value>
|
||||
<value>No preset selected</value>
|
||||
</data>
|
||||
<data name="ExportSelectedPresets" xml:space="preserve">
|
||||
<value>Export selected presets</value>
|
||||
<value>Export</value>
|
||||
</data>
|
||||
<data name="ImportPresets" xml:space="preserve">
|
||||
<value>Import new presets</value>
|
||||
<value>Import</value>
|
||||
</data>
|
||||
<data name="DuplicatePreset" xml:space="preserve">
|
||||
<value>Duplicate preset</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -48,9 +48,8 @@ namespace FileConverter.ViewModels
|
||||
private RelayCommand<string> openUrlCommand;
|
||||
private RelayCommand getChangeLogContentCommand;
|
||||
private RelayCommand createFolderCommand;
|
||||
private RelayCommand movePresetUpCommand;
|
||||
private RelayCommand movePresetDownCommand;
|
||||
private RelayCommand addNewPresetCommand;
|
||||
private RelayCommand newPresetCommand;
|
||||
private RelayCommand duplicatePresetCommand;
|
||||
private RelayCommand importPresetCommand;
|
||||
private RelayCommand exportPresetCommand;
|
||||
private RelayCommand removePresetCommand;
|
||||
@@ -68,9 +67,8 @@ namespace FileConverter.ViewModels
|
||||
this.getChangeLogContentCommand = new RelayCommand(this.DownloadChangeLogAction);
|
||||
this.openUrlCommand = new RelayCommand<string>((url) => Process.Start(url));
|
||||
this.createFolderCommand = new RelayCommand(this.CreateFolder);
|
||||
this.movePresetUpCommand = new RelayCommand(this.MoveSelectedPresetUp, this.CanMoveSelectedPresetUp);
|
||||
this.movePresetDownCommand = new RelayCommand(this.MoveSelectedPresetDown, this.CanMoveSelectedPresetDown);
|
||||
this.addNewPresetCommand = new RelayCommand(this.AddNewPreset);
|
||||
this.newPresetCommand = new RelayCommand(() => this.AddNewPreset(false));
|
||||
this.duplicatePresetCommand = new RelayCommand(() => this.AddNewPreset(true), this.CanDuplicateSelectedPreset);
|
||||
this.importPresetCommand = new RelayCommand(this.ImportPreset);
|
||||
this.exportPresetCommand = new RelayCommand(this.ExportSelectedPreset, this.CanExportSelectedPreset);
|
||||
this.removePresetCommand = new RelayCommand(this.RemoveSelectedPreset, this.CanRemoveSelectedPreset);
|
||||
@@ -197,9 +195,9 @@ namespace FileConverter.ViewModels
|
||||
|
||||
this.RaisePropertyChanged();
|
||||
this.RaisePropertyChanged(nameof(this.SelectedItem));
|
||||
this.movePresetUpCommand?.RaiseCanExecuteChanged();
|
||||
this.movePresetDownCommand?.RaiseCanExecuteChanged();
|
||||
this.removePresetCommand?.RaiseCanExecuteChanged();
|
||||
this.exportPresetCommand?.RaiseCanExecuteChanged();
|
||||
this.duplicatePresetCommand?.RaiseCanExecuteChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -224,10 +222,9 @@ namespace FileConverter.ViewModels
|
||||
this.RaisePropertyChanged();
|
||||
this.RaisePropertyChanged(nameof(this.SelectedItem));
|
||||
this.RaisePropertyChanged(nameof(this.InputCategories));
|
||||
this.movePresetUpCommand?.RaiseCanExecuteChanged();
|
||||
this.movePresetDownCommand?.RaiseCanExecuteChanged();
|
||||
this.removePresetCommand?.RaiseCanExecuteChanged();
|
||||
this.exportPresetCommand?.RaiseCanExecuteChanged();
|
||||
this.duplicatePresetCommand?.RaiseCanExecuteChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -283,11 +280,9 @@ namespace FileConverter.ViewModels
|
||||
|
||||
public ICommand CreateFolderCommand => this.createFolderCommand;
|
||||
|
||||
public ICommand MovePresetUpCommand => this.movePresetUpCommand;
|
||||
public ICommand NewPresetCommand => this.newPresetCommand;
|
||||
|
||||
public ICommand MovePresetDownCommand => this.movePresetDownCommand;
|
||||
|
||||
public ICommand AddNewPresetCommand => this.addNewPresetCommand;
|
||||
public ICommand DuplicatePresetCommand => this.duplicatePresetCommand;
|
||||
|
||||
public ICommand ImportPresetCommand => this.importPresetCommand;
|
||||
|
||||
@@ -556,120 +551,12 @@ namespace FileConverter.ViewModels
|
||||
Messenger.Default.Send<string>("FolderName", "DoFocus");
|
||||
}
|
||||
|
||||
private bool CanMoveSelectedPresetUp()
|
||||
private bool CanDuplicateSelectedPreset()
|
||||
{
|
||||
if (this.SelectedItem == null)
|
||||
{
|
||||
// no preset selected.
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.SelectedItem.Parent != this.presetsRootFolder)
|
||||
{
|
||||
// The parent is not the root, we can move the preset up.
|
||||
return true;
|
||||
}
|
||||
|
||||
int indexOfSelectedPreset = this.SelectedItem.Parent.Children.IndexOf(this.SelectedItem);
|
||||
return indexOfSelectedPreset > 0;
|
||||
return this.SelectedPreset != null;
|
||||
}
|
||||
|
||||
private void MoveSelectedPresetUp()
|
||||
{
|
||||
Diagnostics.Debug.Assert(this.SelectedItem != null, "this.SelectedItem != null");
|
||||
|
||||
AbstractTreeNode itemToMoveUp = this.SelectedItem;
|
||||
PresetFolderNode currentParent = itemToMoveUp.Parent;
|
||||
int indexOfSelectedPreset = currentParent.Children.IndexOf(itemToMoveUp);
|
||||
if (indexOfSelectedPreset == 0)
|
||||
{
|
||||
// Move to the parent folder.
|
||||
int indexOfFolder = currentParent.Parent.Children.IndexOf(currentParent);
|
||||
currentParent.Children.RemoveAt(indexOfSelectedPreset);
|
||||
currentParent.Parent.Children.Insert(indexOfFolder, itemToMoveUp);
|
||||
itemToMoveUp.Parent = currentParent.Parent;
|
||||
}
|
||||
else
|
||||
{
|
||||
int newIndexOfSelectedPreset = System.Math.Max(0, indexOfSelectedPreset - 1);
|
||||
if (currentParent.Children[newIndexOfSelectedPreset] is PresetFolderNode newParent)
|
||||
{
|
||||
// Move to child folder.
|
||||
currentParent.Children.RemoveAt(indexOfSelectedPreset);
|
||||
newParent.Children.Add(itemToMoveUp);
|
||||
itemToMoveUp.Parent = newParent;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Swap nodes.
|
||||
currentParent.Children.Move(indexOfSelectedPreset, newIndexOfSelectedPreset);
|
||||
}
|
||||
}
|
||||
|
||||
this.SelectedItem = itemToMoveUp;
|
||||
this.movePresetUpCommand.RaiseCanExecuteChanged();
|
||||
this.movePresetDownCommand.RaiseCanExecuteChanged();
|
||||
this.saveCommand.RaiseCanExecuteChanged();
|
||||
}
|
||||
|
||||
private bool CanMoveSelectedPresetDown()
|
||||
{
|
||||
if (this.SelectedItem == null)
|
||||
{
|
||||
// no preset selected.
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.SelectedItem.Parent != this.presetsRootFolder)
|
||||
{
|
||||
// The parent is not the root, we can move the preset down.
|
||||
return true;
|
||||
}
|
||||
|
||||
int indexOfSelectedPreset = this.SelectedItem.Parent.Children.IndexOf(this.SelectedItem);
|
||||
return indexOfSelectedPreset < this.SelectedItem.Parent.Children.Count - 1;
|
||||
}
|
||||
|
||||
private void MoveSelectedPresetDown()
|
||||
{
|
||||
Diagnostics.Debug.Assert(this.SelectedItem != null, "this.SelectedItem != null");
|
||||
|
||||
AbstractTreeNode itemToMoveDown = this.SelectedItem;
|
||||
PresetFolderNode currentParent = itemToMoveDown.Parent;
|
||||
int indexOfSelectedPreset = currentParent.Children.IndexOf(itemToMoveDown);
|
||||
if (indexOfSelectedPreset == currentParent.Children.Count - 1)
|
||||
{
|
||||
// Move to the parent folder.
|
||||
int indexOfFolder = currentParent.Parent.Children.IndexOf(currentParent);
|
||||
currentParent.Children.RemoveAt(indexOfSelectedPreset);
|
||||
currentParent.Parent.Children.Insert(indexOfFolder + 1, itemToMoveDown);
|
||||
itemToMoveDown.Parent = currentParent.Parent;
|
||||
}
|
||||
else
|
||||
{
|
||||
int newIndexOfSelectedPreset = System.Math.Min(this.SelectedItem.Parent.Children.Count - 1, indexOfSelectedPreset + 1);
|
||||
if (currentParent.Children[newIndexOfSelectedPreset] is PresetFolderNode newParent)
|
||||
{
|
||||
// Move to child folder.
|
||||
currentParent.Children.RemoveAt(indexOfSelectedPreset);
|
||||
newParent.Children.Insert(0, itemToMoveDown);
|
||||
itemToMoveDown.Parent = newParent;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Swap nodes.
|
||||
currentParent.Children.Move(indexOfSelectedPreset, newIndexOfSelectedPreset);
|
||||
}
|
||||
}
|
||||
|
||||
this.SelectedItem = itemToMoveDown;
|
||||
|
||||
this.movePresetUpCommand.RaiseCanExecuteChanged();
|
||||
this.movePresetDownCommand.RaiseCanExecuteChanged();
|
||||
this.saveCommand.RaiseCanExecuteChanged();
|
||||
}
|
||||
|
||||
private void AddNewPreset()
|
||||
private void AddNewPreset(bool duplicate)
|
||||
{
|
||||
PresetFolderNode parent;
|
||||
if (this.SelectedFolder != null)
|
||||
@@ -702,7 +589,7 @@ namespace FileConverter.ViewModels
|
||||
|
||||
// Create preset by copying the selected one.
|
||||
ConversionPreset newPreset = null;
|
||||
if (this.SelectedPreset != null)
|
||||
if (this.SelectedPreset != null && duplicate)
|
||||
{
|
||||
newPreset = new ConversionPreset(presetName, this.SelectedPreset.Preset);
|
||||
}
|
||||
@@ -732,7 +619,7 @@ namespace FileConverter.ViewModels
|
||||
Title = "Import presets",
|
||||
Filter = "Preset file (*.xml)|*.xml",
|
||||
InitialDirectory = this.ImportDirectoryPath,
|
||||
};
|
||||
};
|
||||
|
||||
if (openFileDialog.ShowDialog() == true)
|
||||
{
|
||||
|
||||
@@ -254,7 +254,7 @@
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="30"/>
|
||||
<RowDefinition Height="25"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<TreeView Name="PresetTreeView" Grid.Row="0"
|
||||
@@ -304,55 +304,50 @@
|
||||
HierarchyPredicate="{Binding PresetsHierarchyPredicate}"
|
||||
ExpandSelected="False"/>
|
||||
</i:Interaction.Behaviors>
|
||||
<TreeView.ContextMenu>
|
||||
<ContextMenu>
|
||||
<MenuItem Header="{x:Static project:Resources.CreateANewFolder}"
|
||||
Command="{Binding CreateFolderCommand}">
|
||||
<MenuItem.Icon>
|
||||
<Image Source="{Binding Source=/FileConverter;component/Resources/FolderIcon.ico, Converter={StaticResource IcoFileSizeSelector}, ConverterParameter=48}"
|
||||
Style="{StaticResource EnableDisableImageStyle}"/>
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Header="{x:Static project:Resources.AddNewPreset}"
|
||||
Command="{Binding AddNewPresetCommand}">
|
||||
</MenuItem>
|
||||
<MenuItem Header="{x:Static project:Resources.DuplicatePreset}"
|
||||
Command="{Binding DuplicatePresetCommand}">
|
||||
<MenuItem.Icon>
|
||||
<Image Source="{Binding Source=/FileConverter;component/Resources/PresetIcon.ico, Converter={StaticResource IcoFileSizeSelector}, ConverterParameter=48}"
|
||||
Style="{StaticResource EnableDisableImageStyle}"/>
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<Separator />
|
||||
<MenuItem Header="{x:Static project:Resources.ImportPresets}"
|
||||
Command="{Binding ImportPresetCommand}">
|
||||
</MenuItem>
|
||||
<MenuItem Header="{x:Static project:Resources.ExportSelectedPresets}"
|
||||
Command="{Binding ExportPresetCommand}">
|
||||
</MenuItem>
|
||||
<Separator />
|
||||
<MenuItem Header="{x:Static project:Resources.RemoveSelectedPreset}"
|
||||
Command="{Binding RemoveSelectedPresetCommand}">
|
||||
<MenuItem.Icon>
|
||||
<Image Source="{Binding Source=/FileConverter;component/Resources/DeleteIcon.ico, Converter={StaticResource IcoFileSizeSelector}, ConverterParameter=48}"
|
||||
Style="{StaticResource EnableDisableImageStyle}"/>
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
</ContextMenu>
|
||||
</TreeView.ContextMenu>
|
||||
<TreeView.InputBindings>
|
||||
<KeyBinding Key="Delete" Command="{Binding RemoveSelectedPresetCommand}"/>
|
||||
</TreeView.InputBindings>
|
||||
</TreeView>
|
||||
|
||||
<DockPanel Grid.Row="1" Margin="0,5,0,0" HorizontalAlignment="Center">
|
||||
<Button Width="25" Margin="0,0,2,0"
|
||||
ToolTip="{x:Static project:Resources.MoveUpSelectedPreset}"
|
||||
Command="{Binding MovePresetUpCommand}">
|
||||
<Image Source="{Binding Source=/FileConverter;component/Resources/UpIcon.ico, Converter={StaticResource IcoFileSizeSelector}, ConverterParameter=48}"
|
||||
Style="{StaticResource EnableDisableImageStyle}"/>
|
||||
</Button>
|
||||
<Button Width="25" Margin="2,0"
|
||||
ToolTip="{x:Static project:Resources.MoveDownSelectedPreset}"
|
||||
Command="{Binding MovePresetDownCommand}">
|
||||
<Image Source="{Binding Source=/FileConverter;component/Resources/DownIcon.ico, Converter={StaticResource IcoFileSizeSelector}, ConverterParameter=48}"
|
||||
Style="{StaticResource EnableDisableImageStyle}"/>
|
||||
</Button>
|
||||
<Button Width="25" Margin="2,0"
|
||||
ToolTip="{x:Static project:Resources.CreateANewFolder}"
|
||||
Command="{Binding CreateFolderCommand}">
|
||||
<Image Source="{Binding Source=/FileConverter;component/Resources/FolderIcon.ico, Converter={StaticResource IcoFileSizeSelector}, ConverterParameter=48}"
|
||||
Style="{StaticResource EnableDisableImageStyle}"/>
|
||||
</Button>
|
||||
<Button Width="25" Margin="2,0"
|
||||
ToolTip="{x:Static project:Resources.AddNewPreset}"
|
||||
Command="{Binding AddNewPresetCommand}">
|
||||
<Image Source="{Binding Source=/FileConverter;component/Resources/PresetIcon.ico, Converter={StaticResource IcoFileSizeSelector}, ConverterParameter=48}"
|
||||
Style="{StaticResource EnableDisableImageStyle}"/>
|
||||
</Button>
|
||||
<Button Width="25" Margin="2,0"
|
||||
ToolTip="{x:Static project:Resources.ImportPresets}"
|
||||
Command="{Binding ImportPresetCommand}">
|
||||
<Image Source="{Binding Source=/FileConverter;component/Resources/PresetIcon.ico, Converter={StaticResource IcoFileSizeSelector}, ConverterParameter=48}"
|
||||
Style="{StaticResource EnableDisableImageStyle}"/>
|
||||
</Button>
|
||||
<Button Width="25" Margin="2,0"
|
||||
ToolTip="{x:Static project:Resources.ExportSelectedPresets}"
|
||||
Command="{Binding ExportPresetCommand}">
|
||||
<Image Source="{Binding Source=/FileConverter;component/Resources/PresetIcon.ico, Converter={StaticResource IcoFileSizeSelector}, ConverterParameter=48}"
|
||||
Style="{StaticResource EnableDisableImageStyle}"/>
|
||||
</Button>
|
||||
<Button Width="25" Margin="2,0,0,0"
|
||||
ToolTip="{x:Static project:Resources.RemoveSelectedPreset}"
|
||||
Command="{Binding RemoveSelectedPresetCommand}">
|
||||
<Image Source="{Binding Source=/FileConverter;component/Resources/DeleteIcon.ico, Converter={StaticResource IcoFileSizeSelector}, ConverterParameter=48}"
|
||||
Style="{StaticResource EnableDisableImageStyle}"/>
|
||||
</Button>
|
||||
<TextBlock Margin="5,5,0,0">
|
||||
<Hyperlink CommandParameter="https://github.com/Tichau/FileConverter/wiki/How-to-create-a-new-custom-preset%3F" Command="{Binding OpenUrlCommand, Mode=OneWay}" Foreground="#1E6BB8"><x:Static Member="project:Resources.Help" /></Hyperlink>
|
||||
</TextBlock>
|
||||
</DockPanel>
|
||||
<TextBlock Margin="4" Grid.Row="1">
|
||||
<Hyperlink CommandParameter="https://github.com/Tichau/FileConverter/wiki/How-to-create-a-new-custom-preset%3F" Command="{Binding OpenUrlCommand, Mode=OneWay}" Foreground="#1E6BB8"><x:Static Member="project:Resources.Help" /></Hyperlink>
|
||||
</TextBlock>
|
||||
</Grid>
|
||||
|
||||
<!-- Selected item settings -->
|
||||
|
||||
Reference in new issue
Block a user