mirror of
https://github.com/claunia/cuetools.net.git
synced 2025-12-16 18:14:25 +00:00
Removed AudioEncoderSettings/AudioDecoderSettings classes, all of their functionality is now in IAudioEncoderSettings/IAudioDecoderSettings interfaces.
This commit is contained in:
@@ -8,7 +8,7 @@ namespace CUETools.Codecs
|
||||
public class AudioDecoderSettingsViewModel : INotifyPropertyChanged
|
||||
{
|
||||
[JsonProperty]
|
||||
public AudioDecoderSettings Settings = null;
|
||||
public IAudioDecoderSettings Settings = null;
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace CUETools.Codecs
|
||||
{
|
||||
}
|
||||
|
||||
public AudioDecoderSettingsViewModel(AudioDecoderSettings settings)
|
||||
public AudioDecoderSettingsViewModel(IAudioDecoderSettings settings)
|
||||
{
|
||||
this.Settings = settings;
|
||||
}
|
||||
@@ -62,21 +62,13 @@ namespace CUETools.Codecs
|
||||
}
|
||||
}
|
||||
|
||||
public bool Lossless
|
||||
{
|
||||
get => true;
|
||||
set {
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get => Settings.Name;
|
||||
set
|
||||
{
|
||||
if (Settings is CommandLine.DecoderSettings)
|
||||
(Settings as CommandLine.DecoderSettings).name = value;
|
||||
(Settings as CommandLine.DecoderSettings).Name = value;
|
||||
else throw new InvalidOperationException();
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Name"));
|
||||
}
|
||||
@@ -88,7 +80,7 @@ namespace CUETools.Codecs
|
||||
set
|
||||
{
|
||||
if (Settings is CommandLine.DecoderSettings)
|
||||
(Settings as CommandLine.DecoderSettings).extension = value;
|
||||
(Settings as CommandLine.DecoderSettings).Extension = value;
|
||||
else throw new InvalidOperationException();
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Extension"));
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace CUETools.Codecs
|
||||
public class AudioEncoderSettingsViewModel : INotifyPropertyChanged
|
||||
{
|
||||
[JsonProperty]
|
||||
public AudioEncoderSettings Settings = null;
|
||||
public IAudioEncoderSettings Settings = null;
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace CUETools.Codecs
|
||||
{
|
||||
}
|
||||
|
||||
public AudioEncoderSettingsViewModel(AudioEncoderSettings settings)
|
||||
public AudioEncoderSettingsViewModel(IAudioEncoderSettings settings)
|
||||
{
|
||||
this.Settings = settings;
|
||||
}
|
||||
@@ -70,7 +70,7 @@ namespace CUETools.Codecs
|
||||
{
|
||||
var settings = this.Settings as CommandLine.EncoderSettings;
|
||||
if (settings == null) throw new InvalidOperationException();
|
||||
settings.lossless = value;
|
||||
settings.Lossless = value;
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Lossless"));
|
||||
}
|
||||
}
|
||||
@@ -83,7 +83,7 @@ namespace CUETools.Codecs
|
||||
{
|
||||
var settings = this.Settings as CommandLine.EncoderSettings;
|
||||
if (settings == null) throw new InvalidOperationException();
|
||||
settings.name = value;
|
||||
settings.Name = value;
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Name"));
|
||||
}
|
||||
}
|
||||
@@ -95,36 +95,30 @@ namespace CUETools.Codecs
|
||||
{
|
||||
var settings = this.Settings as CommandLine.EncoderSettings;
|
||||
if (settings == null) throw new InvalidOperationException();
|
||||
settings.extension = value;
|
||||
settings.Extension = value;
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Extension"));
|
||||
}
|
||||
}
|
||||
|
||||
public string DotExtension => "." + Extension;
|
||||
|
||||
public string SupportedModesStr
|
||||
public string SupportedModes
|
||||
{
|
||||
get
|
||||
{
|
||||
string defaultMode;
|
||||
return this.Settings.GetSupportedModes(out defaultMode);
|
||||
}
|
||||
get => Settings.SupportedModes;
|
||||
set
|
||||
{
|
||||
var settings = this.Settings as CommandLine.EncoderSettings;
|
||||
if (settings == null) throw new InvalidOperationException();
|
||||
settings.SupportedModes = value;
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("SupportedModesStr"));
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("SupportedModes"));
|
||||
}
|
||||
}
|
||||
|
||||
public string[] SupportedModes => this.SupportedModesStr.Split(' ');
|
||||
|
||||
public int EncoderModeIndex
|
||||
{
|
||||
get
|
||||
{
|
||||
string[] modes = this.SupportedModes;
|
||||
string[] modes = this.SupportedModes.Split(' ');
|
||||
if (modes == null || modes.Length < 2)
|
||||
return -1;
|
||||
for (int i = 0; i < modes.Length; i++)
|
||||
|
||||
@@ -6,9 +6,9 @@ namespace CUETools.Codecs
|
||||
{
|
||||
public class DecoderListViewModel : BindingList<AudioDecoderSettingsViewModel>
|
||||
{
|
||||
private List<AudioDecoderSettings> model;
|
||||
private List<IAudioDecoderSettings> model;
|
||||
|
||||
public DecoderListViewModel(List<AudioDecoderSettings> model)
|
||||
public DecoderListViewModel(List<IAudioDecoderSettings> model)
|
||||
: base()
|
||||
{
|
||||
this.model = model;
|
||||
@@ -23,11 +23,11 @@ namespace CUETools.Codecs
|
||||
e.NewObject = new AudioDecoderSettingsViewModel(item);
|
||||
}
|
||||
|
||||
public bool TryGetValue(string extension, bool lossless, string name, out AudioDecoderSettingsViewModel result)
|
||||
public bool TryGetValue(string extension, string name, out AudioDecoderSettingsViewModel result)
|
||||
{
|
||||
foreach (AudioDecoderSettingsViewModel udc in this)
|
||||
{
|
||||
if (udc.Settings.Extension == extension && udc.Settings.Lossless == lossless && udc.Settings.Name == name)
|
||||
if (udc.Settings.Extension == extension && udc.Settings.Name == name)
|
||||
{
|
||||
result = udc;
|
||||
return true;
|
||||
@@ -37,12 +37,12 @@ namespace CUETools.Codecs
|
||||
return false;
|
||||
}
|
||||
|
||||
public AudioDecoderSettingsViewModel GetDefault(string extension, bool lossless)
|
||||
public AudioDecoderSettingsViewModel GetDefault(string extension)
|
||||
{
|
||||
AudioDecoderSettingsViewModel result = null;
|
||||
foreach (AudioDecoderSettingsViewModel udc in this)
|
||||
{
|
||||
if (udc.Settings.Extension == extension && udc.Settings.Lossless == lossless && (result == null || result.Settings.Priority < udc.Settings.Priority))
|
||||
if (udc.Settings.Extension == extension && (result == null || result.Settings.Priority < udc.Settings.Priority))
|
||||
{
|
||||
result = udc;
|
||||
}
|
||||
|
||||
@@ -6,9 +6,9 @@ namespace CUETools.Codecs
|
||||
{
|
||||
public class EncoderListViewModel : BindingList<AudioEncoderSettingsViewModel>
|
||||
{
|
||||
private List<AudioEncoderSettings> model;
|
||||
private List<IAudioEncoderSettings> model;
|
||||
|
||||
public EncoderListViewModel(List<AudioEncoderSettings> model)
|
||||
public EncoderListViewModel(List<IAudioEncoderSettings> model)
|
||||
: base()
|
||||
{
|
||||
this.model = model;
|
||||
|
||||
Reference in New Issue
Block a user