mirror of
https://github.com/Tichau/FileConverter.git
synced 2026-11-20 17:42:20 +01:00
Migration of classes that were implementing INotifyPropertyChanged to ObservableObject.
This commit is contained in:
1 parent
4d5a3e03be
commit
845ea763f0
2 files changed
+19
-38
No files matched your search
@@ -7,18 +7,17 @@ namespace FileConverter
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
using FileConverter.Annotations;
|
||||
using FileConverter.Controls;
|
||||
using FileConverter.Services;
|
||||
|
||||
using GalaSoft.MvvmLight;
|
||||
using GalaSoft.MvvmLight.Ioc;
|
||||
|
||||
[XmlRoot]
|
||||
[XmlType]
|
||||
public class ConversionPreset : INotifyPropertyChanged, IDataErrorInfo, IXmlSerializable
|
||||
public class ConversionPreset : ObservableObject, IDataErrorInfo, IXmlSerializable
|
||||
{
|
||||
private string name;
|
||||
private OutputType outputType;
|
||||
@@ -68,7 +67,6 @@ namespace FileConverter
|
||||
}
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
[XmlAttribute]
|
||||
public string Name
|
||||
@@ -81,7 +79,7 @@ namespace FileConverter
|
||||
set
|
||||
{
|
||||
this.name = value;
|
||||
this.OnPropertyChanged();
|
||||
this.RaisePropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,7 +95,7 @@ namespace FileConverter
|
||||
{
|
||||
this.outputType = value;
|
||||
this.InitializeDefaultSettings(this.outputType);
|
||||
this.OnPropertyChanged();
|
||||
this.RaisePropertyChanged();
|
||||
this.CoerceInputTypes();
|
||||
}
|
||||
}
|
||||
@@ -125,7 +123,7 @@ namespace FileConverter
|
||||
this.inputTypes[index] = this.inputTypes[index].ToLowerInvariant();
|
||||
}
|
||||
|
||||
this.OnPropertyChanged();
|
||||
this.RaisePropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,7 +138,7 @@ namespace FileConverter
|
||||
set
|
||||
{
|
||||
this.inputPostConversionAction = value;
|
||||
this.OnPropertyChanged();
|
||||
this.RaisePropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,7 +182,7 @@ namespace FileConverter
|
||||
}
|
||||
}
|
||||
|
||||
this.OnPropertyChanged(nameof(this.Settings));
|
||||
this.RaisePropertyChanged(nameof(this.Settings));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,7 +197,7 @@ namespace FileConverter
|
||||
set
|
||||
{
|
||||
this.outputFileNameTemplate = value;
|
||||
this.OnPropertyChanged();
|
||||
this.RaisePropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -239,7 +237,7 @@ namespace FileConverter
|
||||
}
|
||||
}
|
||||
|
||||
this.OnPropertyChanged();
|
||||
this.RaisePropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -247,7 +245,7 @@ namespace FileConverter
|
||||
{
|
||||
get
|
||||
{
|
||||
string errorString = this.Validate("Name");
|
||||
string errorString = this.Validate("ShortName");
|
||||
if (!string.IsNullOrEmpty(errorString))
|
||||
{
|
||||
return errorString;
|
||||
@@ -307,14 +305,14 @@ namespace FileConverter
|
||||
}
|
||||
|
||||
this.inputTypes.Add(inputType);
|
||||
this.OnPropertyChanged(nameof(this.InputTypes));
|
||||
this.RaisePropertyChanged(nameof(this.InputTypes));
|
||||
}
|
||||
|
||||
public void RemoveInputType(string inputType)
|
||||
{
|
||||
if (this.inputTypes.Remove(inputType))
|
||||
{
|
||||
this.OnPropertyChanged(nameof(this.InputTypes));
|
||||
this.RaisePropertyChanged(nameof(this.InputTypes));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -347,7 +345,7 @@ namespace FileConverter
|
||||
|
||||
this.settings[settingsKey] = value;
|
||||
|
||||
this.OnPropertyChanged(nameof(this.Settings));
|
||||
this.RaisePropertyChanged(nameof(this.Settings));
|
||||
}
|
||||
|
||||
public string GetSettingsValue(string settingsKey)
|
||||
@@ -388,12 +386,6 @@ namespace FileConverter
|
||||
return this.Settings.ContainsKey(settingsKey);
|
||||
}
|
||||
|
||||
[NotifyPropertyChangedInvocator]
|
||||
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
||||
{
|
||||
this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
|
||||
private void CoerceInputTypes()
|
||||
{
|
||||
if (this.inputTypes == null)
|
||||
@@ -529,7 +521,7 @@ namespace FileConverter
|
||||
throw new System.Exception("Missing default settings for type " + outputType);
|
||||
}
|
||||
|
||||
this.OnPropertyChanged(nameof(this.Settings));
|
||||
this.RaisePropertyChanged(nameof(this.Settings));
|
||||
}
|
||||
|
||||
private void InitializeSettingsValue(string settingsKey, string value, bool force = false)
|
||||
|
||||
@@ -3,12 +3,9 @@
|
||||
namespace FileConverter.ViewModels
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
using GalaSoft.MvvmLight;
|
||||
|
||||
using FileConverter.Annotations;
|
||||
|
||||
public class InputExtensionCategory : INotifyPropertyChanged
|
||||
public class InputExtensionCategory : ObservableObject
|
||||
{
|
||||
private string name;
|
||||
private List<InputExtension> inputExtensions = new List<InputExtension>();
|
||||
@@ -18,8 +15,6 @@ namespace FileConverter.ViewModels
|
||||
this.Name = name;
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
@@ -30,7 +25,7 @@ namespace FileConverter.ViewModels
|
||||
set
|
||||
{
|
||||
this.name = value;
|
||||
this.OnPropertyChanged();
|
||||
this.RaisePropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,15 +55,9 @@ namespace FileConverter.ViewModels
|
||||
{
|
||||
inputExtension = new InputExtension(extension);
|
||||
this.inputExtensions.Add(inputExtension);
|
||||
this.OnPropertyChanged("InputExtensions");
|
||||
this.OnPropertyChanged("InputExtensionNames");
|
||||
this.RaisePropertyChanged("InputExtensions");
|
||||
this.RaisePropertyChanged("InputExtensionNames");
|
||||
}
|
||||
}
|
||||
|
||||
[NotifyPropertyChangedInvocator]
|
||||
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
||||
{
|
||||
this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user