From 0b14b5646566aa90026466dd7c4b3430dec7c093 Mon Sep 17 00:00:00 2001 From: sr55 Date: Sat, 14 Mar 2015 17:16:58 +0000 Subject: WinGui: Remove the Caliburn Micro / Castle dependency in The services library, and make the low-level json api public. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6986 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- .../HandBrake.ApplicationServices.csproj | 14 +--- .../Interop/HandBrakeInstance.cs | 2 +- .../Interop/Json/Encode/JsonEncodeObject.cs | 2 +- .../Interop/Json/Scan/AudioList.cs | 2 +- .../Interop/Json/Scan/ChapterList.cs | 2 +- .../Interop/Json/Scan/Color.cs | 2 +- .../Interop/Json/Scan/Duration.cs | 2 +- .../Interop/Json/Scan/Duration2.cs | 2 +- .../Interop/Json/Scan/FrameRate.cs | 3 +- .../Interop/Json/Scan/Geometry.cs | 2 +- .../Interop/Json/Scan/JsonScanObject.cs | 2 +- .../Interop/Json/Scan/MetaData.cs | 2 +- .../Interop/Json/Scan/PAR.cs | 2 +- .../Interop/Json/Scan/SubtitleList.cs | 2 +- .../Interop/Json/Scan/TitleList.cs | 2 +- .../Model/QueueTask.cs | 3 +- .../Services/Encode/Model/EncodeTask.cs | 2 +- .../Services/Encode/Model/Models/AudioTrack.cs | 2 - .../Services/Encode/Model/Models/ChapterMarker.cs | 2 +- .../Services/Encode/Model/Models/SubtitleTrack.cs | 3 +- .../Utilities/ExtensionMethods.cs | 35 +++++++++ .../Utilities/PropertyChangedBase.cs | 86 ++++++++++++++++++++++ 22 files changed, 141 insertions(+), 35 deletions(-) create mode 100644 win/CS/HandBrake.ApplicationServices/Utilities/ExtensionMethods.cs create mode 100644 win/CS/HandBrake.ApplicationServices/Utilities/PropertyChangedBase.cs (limited to 'win') diff --git a/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj b/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj index 91228fdae..a507cfdc8 100644 --- a/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj +++ b/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj @@ -46,18 +46,6 @@ true - - False - ..\libraries\caliburn\Caliburn.Micro.dll - - - False - ..\libraries\caliburn\Castle.Core.dll - - - False - ..\libraries\caliburn\Castle.Windsor.dll - False @@ -202,6 +190,8 @@ + + diff --git a/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeInstance.cs b/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeInstance.cs index 379e461c3..9c99087f2 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeInstance.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeInstance.cs @@ -41,7 +41,7 @@ namespace HandBrake.ApplicationServices.Interop /// /// A wrapper for a HandBrake instance. /// - internal class HandBrakeInstance : IHandBrakeInstance, IDisposable + public class HandBrakeInstance : IHandBrakeInstance, IDisposable { /// /// The number of MS between status polls when scanning. diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/JsonEncodeObject.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/JsonEncodeObject.cs index 7b9a1f953..0accd19cf 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/JsonEncodeObject.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/JsonEncodeObject.cs @@ -14,7 +14,7 @@ namespace HandBrake.ApplicationServices.Interop.Json.Encode /// /// The root object. /// - internal class JsonEncodeObject + public class JsonEncodeObject { /// /// Gets or sets the audio. diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/AudioList.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/AudioList.cs index 18ad084f3..544f49226 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/AudioList.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/AudioList.cs @@ -12,7 +12,7 @@ namespace HandBrake.ApplicationServices.Interop.Json.Scan /// /// The audio list. /// - internal class AudioList + public class AudioList { /// /// Gets or sets the bit rate. diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/ChapterList.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/ChapterList.cs index c4da099e5..01a0068fc 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/ChapterList.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/ChapterList.cs @@ -12,7 +12,7 @@ namespace HandBrake.ApplicationServices.Interop.Json.Scan /// /// The chapter list. /// - internal class ChapterList + public class ChapterList { /// /// Gets or sets the duration. diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/Color.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/Color.cs index 8709dcbdd..b99495440 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/Color.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/Color.cs @@ -12,7 +12,7 @@ namespace HandBrake.ApplicationServices.Interop.Json.Scan /// /// The color. /// - internal class Color + public class Color { /// /// Gets or sets the matrix. diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/Duration.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/Duration.cs index 7785fff05..4eea32e12 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/Duration.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/Duration.cs @@ -12,7 +12,7 @@ namespace HandBrake.ApplicationServices.Interop.Json.Scan /// /// The duration. /// - internal class Duration + public class Duration { /// /// Gets or sets the hours. diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/Duration2.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/Duration2.cs index 444ea3e2f..3bf6827f5 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/Duration2.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/Duration2.cs @@ -12,7 +12,7 @@ namespace HandBrake.ApplicationServices.Interop.Json.Scan /// /// The duration 2. /// - internal class Duration2 + public class Duration2 { /// /// Gets or sets the hours. diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/FrameRate.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/FrameRate.cs index 937738076..a85042320 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/FrameRate.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/FrameRate.cs @@ -12,9 +12,8 @@ namespace HandBrake.ApplicationServices.Interop.Json.Scan /// /// The frame rate. /// - internal class FrameRate + public class FrameRate { - /// /// Gets or sets the den. /// diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/Geometry.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/Geometry.cs index 9f7bc95d4..0f7f35ee8 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/Geometry.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/Geometry.cs @@ -12,7 +12,7 @@ namespace HandBrake.ApplicationServices.Interop.Json.Scan /// /// The geometry. /// - internal class Geometry + public class Geometry { /// /// Gets or sets the height. diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/JsonScanObject.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/JsonScanObject.cs index 397e5ce9e..8d38c51a1 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/JsonScanObject.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/JsonScanObject.cs @@ -14,7 +14,7 @@ namespace HandBrake.ApplicationServices.Interop.Json.Scan /// /// The root object. /// - internal class JsonScanObject + public class JsonScanObject { /// /// Gets or sets the main feature. diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/MetaData.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/MetaData.cs index 46b312a5a..ecd26bd8f 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/MetaData.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/MetaData.cs @@ -12,7 +12,7 @@ namespace HandBrake.ApplicationServices.Interop.Json.Scan /// /// The meta data. /// - internal class MetaData + public class MetaData { } } \ No newline at end of file diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/PAR.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/PAR.cs index 2eca81fc6..9149604d9 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/PAR.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/PAR.cs @@ -12,7 +12,7 @@ namespace HandBrake.ApplicationServices.Interop.Json.Scan /// /// The par. /// - internal class PAR + public class PAR { /// /// Gets or sets the width. diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SubtitleList.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SubtitleList.cs index f727fd15e..a6ec067e8 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SubtitleList.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SubtitleList.cs @@ -12,7 +12,7 @@ namespace HandBrake.ApplicationServices.Interop.Json.Scan /// /// The subtitle list. /// - internal class SubtitleList + public class SubtitleList { /// /// Gets or sets the format. diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/TitleList.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/TitleList.cs index f6668eb24..731d715c2 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/TitleList.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/TitleList.cs @@ -14,7 +14,7 @@ namespace HandBrake.ApplicationServices.Interop.Json.Scan /// /// The title list. /// - internal class TitleList + public class TitleList { /// /// Gets or sets the angle count. diff --git a/win/CS/HandBrake.ApplicationServices/Model/QueueTask.cs b/win/CS/HandBrake.ApplicationServices/Model/QueueTask.cs index 366f5b4e6..42f55d02d 100644 --- a/win/CS/HandBrake.ApplicationServices/Model/QueueTask.cs +++ b/win/CS/HandBrake.ApplicationServices/Model/QueueTask.cs @@ -9,10 +9,9 @@ namespace HandBrake.ApplicationServices.Model { - using Caliburn.Micro; using HandBrake.ApplicationServices.Services.Encode.Model; - using HandBrake.ApplicationServices.Services.Scan.Model; + using HandBrake.ApplicationServices.Utilities; /// /// The QueueTask. diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/EncodeTask.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/EncodeTask.cs index 67d81facf..2117565e5 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/EncodeTask.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/EncodeTask.cs @@ -13,12 +13,12 @@ namespace HandBrake.ApplicationServices.Services.Encode.Model using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; - using Caliburn.Micro; using HandBrake.ApplicationServices.Services.Encode.Model.Models; using HandBrake.ApplicationServices.Services.Encode.Model.Models.Video; using HandBrake.ApplicationServices.Interop.Model; using HandBrake.ApplicationServices.Interop.Model.Encoding; + using HandBrake.ApplicationServices.Utilities; /// /// An Encode Task diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/AudioTrack.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/AudioTrack.cs index 9887275bb..34a81a27f 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/AudioTrack.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/AudioTrack.cs @@ -13,8 +13,6 @@ namespace HandBrake.ApplicationServices.Services.Encode.Model.Models using System.ComponentModel; using System.Globalization; - using Caliburn.Micro; - using HandBrake.ApplicationServices.Services.Scan.Model; using HandBrake.ApplicationServices.Utilities; using HandBrake.ApplicationServices.Interop.Model.Encoding; diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/ChapterMarker.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/ChapterMarker.cs index 7f20ac6da..6792a1394 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/ChapterMarker.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/ChapterMarker.cs @@ -11,7 +11,7 @@ namespace HandBrake.ApplicationServices.Services.Encode.Model.Models { using System; - using Caliburn.Micro; + using HandBrake.ApplicationServices.Utilities; /// /// A Movie Chapter diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/SubtitleTrack.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/SubtitleTrack.cs index e37bf26c5..a7d11c670 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/SubtitleTrack.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/Models/SubtitleTrack.cs @@ -11,9 +11,8 @@ namespace HandBrake.ApplicationServices.Services.Encode.Model.Models { using System; - using Caliburn.Micro; - using HandBrake.ApplicationServices.Services.Scan.Model; + using HandBrake.ApplicationServices.Utilities; /// /// Subtitle Information diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/ExtensionMethods.cs b/win/CS/HandBrake.ApplicationServices/Utilities/ExtensionMethods.cs new file mode 100644 index 000000000..53db9e23f --- /dev/null +++ b/win/CS/HandBrake.ApplicationServices/Utilities/ExtensionMethods.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace HandBrake.ApplicationServices.Utilities +{ + using System.Linq.Expressions; + using System.Reflection; + + public static class ExtensionMethods + { + /// + /// Converts an expression into a . + /// + /// The expression to convert. + /// The member info. + public static MemberInfo GetMemberInfo(this Expression expression) + { + var lambda = (LambdaExpression)expression; + + MemberExpression memberExpression; + if (lambda.Body is UnaryExpression) + { + var unaryExpression = (UnaryExpression)lambda.Body; + memberExpression = (MemberExpression)unaryExpression.Operand; + } + else + memberExpression = (MemberExpression)lambda.Body; + + return memberExpression.Member; + } + + } +} diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/PropertyChangedBase.cs b/win/CS/HandBrake.ApplicationServices/Utilities/PropertyChangedBase.cs new file mode 100644 index 000000000..9809def57 --- /dev/null +++ b/win/CS/HandBrake.ApplicationServices/Utilities/PropertyChangedBase.cs @@ -0,0 +1,86 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// A base class that implements the infrastructure for property change notification and automatically performs UI thread marshalling. +// This class is a modified version of the caliburn micro +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrake.ApplicationServices.Utilities +{ + using System; + using System.ComponentModel; + using System.Linq.Expressions; + using System.Runtime.Serialization; + + /// + /// Property Changed Base implimentation. + /// + [DataContract] + public class PropertyChangedBase : INotifyPropertyChanged + { + /// + /// Creates an instance of . + /// + public PropertyChangedBase() + { + IsNotifying = true; + } + + /// + /// Occurs when a property value changes. + /// + public event PropertyChangedEventHandler PropertyChanged = delegate { }; + + /// + /// Enables/Disables property change notification. + /// + public bool IsNotifying { get; set; } + + /// + /// Raises a change notification indicating that all bindings should be refreshed. + /// + public virtual void Refresh() + { + NotifyOfPropertyChange(string.Empty); + } + + /// + /// Notifies subscribers of the property change. + /// + /// Name of the property. + public virtual void NotifyOfPropertyChange(string propertyName = null) + { + if (IsNotifying) + { + OnPropertyChanged(new PropertyChangedEventArgs(propertyName)); + } + } + + /// + /// Notifies subscribers of the property change. + /// + /// The type of the property. + /// The property expression. + public void NotifyOfPropertyChange(Expression> property) + { + NotifyOfPropertyChange(property.GetMemberInfo().Name); + } + + /// + /// Raises the event directly. + /// + /// The instance containing the event data. + [EditorBrowsable(EditorBrowsableState.Never)] + protected void OnPropertyChanged(PropertyChangedEventArgs e) + { + var handler = PropertyChanged; + if (handler != null) + { + handler(this, e); + } + } + } +} -- cgit v1.2.3