Skip to content

Commit

Permalink
[#25] Add view for Output settings
Browse files Browse the repository at this point in the history
  • Loading branch information
bassterror committed Feb 22, 2022
1 parent 6a1da80 commit 1daa742
Show file tree
Hide file tree
Showing 9 changed files with 327 additions and 4 deletions.
3 changes: 3 additions & 0 deletions MKVStudio/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
<DataTemplate DataType="{x:Type vm:PreferedLanguagesVM}">
<v:PreferedLanguagesV />
</DataTemplate>
<DataTemplate DataType="{x:Type vm:OutputNameVM}">
<v:OutputNameV />
</DataTemplate>

<!--Multiplexer-->
<DataTemplate DataType="{x:Type vm:BatchEditVM}">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ public class UpdateSelectedPreferencesTabCommand : BaseCommand
{
private readonly PreferencesVM _preferences;
private readonly OftenUsedVM _oftenUsed;
private readonly OutputNameVM _outputName;

public UpdateSelectedPreferencesTabCommand(PreferencesVM preferences, OftenUsedVM oftenUsed)
public UpdateSelectedPreferencesTabCommand(PreferencesVM preferences, OftenUsedVM oftenUsed, OutputNameVM outputName)
{
_preferences = preferences;
_oftenUsed = oftenUsed;
_outputName = outputName;
}

public override void Execute(object parameter)
Expand All @@ -28,6 +30,9 @@ private void SelectPreferencesTab(ViewModelTypes viewModel)
case ViewModelTypes.OftenUsed:
_preferences.SelectedPreferencesTab = _oftenUsed;
break;
case ViewModelTypes.OutputName:
_preferences.SelectedPreferencesTab = _outputName;
break;
}
}
}
16 changes: 15 additions & 1 deletion MKVStudio/Models/Objects/Settings/Settings.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using Microsoft.Win32;
using Microsoft.VisualBasic.ApplicationServices;
using Microsoft.Win32;
using MKVStudio.Services;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;

Expand All @@ -17,6 +19,18 @@ public class Settings
public SupportedFileTypesCollections SupportedFileTypes { get; set; } = new();
public MIMETypeCollection MIMETypes { get; set; } = new();

#region OutputName
public bool AutomaticallySetTheDestinationFileName { get; set; } //TODO
public bool OnlyUseTheFirstSourceFileWithAVideoTrack { get; set; } //TODO
public bool UseTheTitleAsTheBaseFileNameIfATitleIsSet { get; set; } //TODO
public bool SameDirectoryAsTheFirstSourceFile { get; set; } //TODO
public bool PreviouslyUsedDestinationDirectory { get; set; } //TODO
public bool DirectoryRelativeToFirstSourceFileDirectory { get; set; } //TODO
public bool UseFixedDirectory { get; set; } //TODO
public bool EnsureTheFileNameIsUnique { get; set; } //TODO
public bool AutomaticallyClearTheDestinationFileNameWhenTheLastFileIsRemoved { get; set; } //TODO
#endregion

public Settings(IUtilitiesService util)
{
_util = util;
Expand Down
13 changes: 13 additions & 0 deletions MKVStudio/ViewModels/Main/Preferences/OutputNameVM.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using MKVStudio.Services;

namespace MKVStudio.ViewModels;

public class OutputNameVM : BaseViewModel
{
public IUtilitiesService Util { get; }

public OutputNameVM(IUtilitiesService util)
{
Util = util;
}
}
3 changes: 2 additions & 1 deletion MKVStudio/ViewModels/Main/Preferences/PreferencesVM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ public class PreferencesVM : BaseViewModel
#region Navigation
public BaseViewModel SelectedPreferencesTab { get; set; }
private OftenUsedVM OftenUsed => new(Util);
public ICommand UpdateSelectedPreferencesTab => new UpdateSelectedPreferencesTabCommand(this, OftenUsed);
private OutputNameVM OutputName => new(Util);
public ICommand UpdateSelectedPreferencesTab => new UpdateSelectedPreferencesTabCommand(this, OftenUsed, OutputName);
#endregion

public PreferencesVM(MainVM main, IUtilitiesService util, PreferencesV preferencesV)
Expand Down
1 change: 1 addition & 0 deletions MKVStudio/ViewModels/ViewModelTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public enum ViewModelTypes
//Preferences
OftenUsed,
PreferedLanguages,
OutputName,

//Multiplex
Input,
Expand Down
267 changes: 267 additions & 0 deletions MKVStudio/Views/Main/Preferences/OutputNameV.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,267 @@
<UserControl x:Class="MKVStudio.Views.OutputNameV"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:vm="clr-namespace:MKVStudio.ViewModels"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance Type=vm:PreferencesVM}"
d:DesignHeight="550"
d:DesignWidth="450">
<UserControl.Resources>
<Style x:Key="SettingsRadio"
TargetType="RadioButton" />
</UserControl.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<GroupBox Grid.Row="0"
Margin="5">
<GroupBox.Header>
<TextBlock Text="Destination file name"
Foreground="{StaticResource ControlDisabledGlythColour}" />
</GroupBox.Header>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<CheckBox Grid.Row="0"
Margin="5"
IsChecked="{Binding Util.Settings.AutomaticallySetTheDestinationFileName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
VerticalContentAlignment="Center">
<TextBlock>
<TextBlock.Resources>
<Style TargetType="{x:Type TextBlock}">
<Style.Triggers>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type CheckBox}}, Path=IsChecked}"
Value="False">
<Setter Property="Foreground"
Value="{StaticResource ControlDisabledGlythColour}" />
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Resources>
Automatically set the destination file name
</TextBlock>
</CheckBox>
<CheckBox Grid.Row="1"
Margin="5"
IsChecked="{Binding Util.Settings.OnlyUseTheFirstSourceFileWithAVideoTrack, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
VerticalContentAlignment="Center">
<TextBlock>
<TextBlock.Resources>
<Style TargetType="{x:Type TextBlock}">
<Style.Triggers>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type CheckBox}}, Path=IsChecked}"
Value="False">
<Setter Property="Foreground"
Value="{StaticResource ControlDisabledGlythColour}" />
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Resources>
Only use the first source file with a video track
</TextBlock>
</CheckBox>
<CheckBox Grid.Row="2"
Margin="5"
IsChecked="{Binding Util.Settings.UseTheTitleAsTheBaseFileNameIfATitleIsSet, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
VerticalContentAlignment="Center">
<TextBlock>
<TextBlock.Resources>
<Style TargetType="{x:Type TextBlock}">
<Style.Triggers>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type CheckBox}}, Path=IsChecked}"
Value="False">
<Setter Property="Foreground"
Value="{StaticResource ControlDisabledGlythColour}" />
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Resources>
Use the title as the base file name if a title is set
</TextBlock>
</CheckBox>
<GroupBox Grid.Row="3"
Margin="5">
<GroupBox.Header>
<TextBlock Text="Destination directory"
Foreground="{StaticResource ControlDisabledGlythColour}" />
</GroupBox.Header>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<RadioButton Grid.Row="0"
Margin="5"
IsChecked="{Binding Util.Settings.SameDirectoryAsTheFirstSourceFile, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
<TextBlock>
<TextBlock.Resources>
<Style TargetType="TextBlock">
<Style.Triggers>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type RadioButton}}, Path=IsChecked}"
Value="False">
<Setter Property="Foreground"
Value="{StaticResource ControlDisabledGlythColour}" />
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Resources>
Same directory as the first source file
</TextBlock>
</RadioButton>
<RadioButton Grid.Row="1"
Margin="5"
IsChecked="{Binding Util.Settings.PreviouslyUsedDestinationDirectory, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
<TextBlock>
<TextBlock.Resources>
<Style TargetType="TextBlock">
<Style.Triggers>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type RadioButton}}, Path=IsChecked}"
Value="False">
<Setter Property="Foreground"
Value="{StaticResource ControlDisabledGlythColour}" />
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Resources>
Previously used destination directory
</TextBlock>
</RadioButton>
<RadioButton Grid.Row="2"
Margin="5"
x:Name="DR"
IsChecked="{Binding Util.Settings.DirectoryRelativeToFirstSourceFileDirectory, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
<TextBlock>
<TextBlock.Resources>
<Style TargetType="TextBlock">
<Style.Triggers>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type RadioButton}}, Path=IsChecked}"
Value="False">
<Setter Property="Foreground"
Value="{StaticResource ControlDisabledGlythColour}" />
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Resources>
Directory relative to first source file's directory:
</TextBlock>
</RadioButton>
<TextBox Grid.Row="3"
Margin="25 5 5 5"
IsEnabled="{Binding IsChecked, ElementName=DR}"/>
<RadioButton Grid.Row="4"
Margin="5"
x:Name="UF"
IsChecked="{Binding Util.Settings.UseFixedDirectory, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
<TextBlock>
<TextBlock.Resources>
<Style TargetType="TextBlock">
<Style.Triggers>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type RadioButton}}, Path=IsChecked}"
Value="False">
<Setter Property="Foreground"
Value="{StaticResource ControlDisabledGlythColour}" />
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Resources>
Use fixed directory:
</TextBlock>
</RadioButton>
<Grid Grid.Row="5"
IsEnabled="{Binding IsChecked, ElementName=UF}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="6*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBox Grid.Column="0"
Margin="25 5 5 5" />
<Button Grid.Column="1"
Margin="0 5 5 5"
Content="Browse" />
</Grid>
</Grid>
</GroupBox>
<CheckBox Grid.Row="4"
IsChecked="{Binding Util.Settings.EnsureTheFileNameIsUnique, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
VerticalContentAlignment="Center"
Margin="5">
<TextBlock>
<TextBlock.Resources>
<Style TargetType="{x:Type TextBlock}">
<Style.Triggers>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type CheckBox}}, Path=IsChecked}"
Value="False">
<Setter Property="Foreground"
Value="{StaticResource ControlDisabledGlythColour}" />
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Resources>
Ensure the file name is unique
</TextBlock>
</CheckBox>
<CheckBox Grid.Row="5"
IsChecked="{Binding Util.Settings.AutomaticallyClearTheDestinationFileNameWhenTheLastFileIsRemoved, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
VerticalContentAlignment="Center"
Margin="5">
<TextBlock>
<TextBlock.Resources>
<Style TargetType="{x:Type TextBlock}">
<Style.Triggers>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type CheckBox}}, Path=IsChecked}"
Value="False">
<Setter Property="Foreground"
Value="{StaticResource ControlDisabledGlythColour}" />
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Resources>
Automatically clear the destination file name when the last file is removed
</TextBlock>
</CheckBox>
</Grid>
</GroupBox>
<GroupBox Grid.Row="1"
Margin="5 0 5 5">
<GroupBox.Header>
<TextBlock Text="Recent destination directories"
Foreground="{StaticResource ControlDisabledGlythColour}" />
</GroupBox.Header>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="10*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<ListView Grid.Column="0"
Margin="5"/>
<Grid Grid.Column="1">
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Button Grid.Row="0"
Margin="5"
Content="+" />
<Button Grid.Row="1"
Margin="5"
Content="-" />
</Grid>
</Grid>
</GroupBox>
</Grid>
</UserControl>
14 changes: 14 additions & 0 deletions MKVStudio/Views/Main/Preferences/OutputNameV.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System.Windows.Controls;

namespace MKVStudio.Views;

/// <summary>
/// Interaction logic for OutputNameV.xaml
/// </summary>
public partial class OutputNameV : UserControl
{
public OutputNameV()
{
InitializeComponent();
}
}
Loading

0 comments on commit 1daa742

Please sign in to comment.