summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrake.Interop
diff options
context:
space:
mode:
authorsr55 <[email protected]>2019-04-20 22:51:01 +0100
committersr55 <[email protected]>2019-04-20 22:51:42 +0100
commit8ae989f31db31c43c069efc2c1fd8b1c2b65ef8f (patch)
tree269238f808d78c4b83d3a203f27839c3619230e5 /win/CS/HandBrake.Interop
parent4e0cf3ef3d5decfe30f26306bbc969c00b3c0861 (diff)
WinGui: New option to control the file overwrite default behaviour. Overwrite or Ask.
Diffstat (limited to 'win/CS/HandBrake.Interop')
-rw-r--r--win/CS/HandBrake.Interop/Attributes/DisplayName.cs34
-rw-r--r--win/CS/HandBrake.Interop/Attributes/DisplayNameLocalized.cs38
-rw-r--r--win/CS/HandBrake.Interop/HandBrake.Interop.csproj1
-rw-r--r--win/CS/HandBrake.Interop/Properties/Resources.Designer.cs2
4 files changed, 61 insertions, 14 deletions
diff --git a/win/CS/HandBrake.Interop/Attributes/DisplayName.cs b/win/CS/HandBrake.Interop/Attributes/DisplayName.cs
index a890d97f1..07512fc3a 100644
--- a/win/CS/HandBrake.Interop/Attributes/DisplayName.cs
+++ b/win/CS/HandBrake.Interop/Attributes/DisplayName.cs
@@ -10,26 +10,34 @@
namespace HandBrake.Interop.Attributes
{
using System;
+ using System.Reflection;
- /// <summary>
- /// A Short Name for an enum value
- /// </summary>
public class DisplayName : Attribute
{
- /// <summary>
- /// Initializes a new instance of the <see cref="DisplayName"/> class.
- /// </summary>
- /// <param name="displayName">
- /// The name name.
- /// </param>
public DisplayName(string displayName)
{
this.Name = displayName;
}
- /// <summary>
- /// Gets the short name.
- /// </summary>
- public string Name { get; private set; }
+ public DisplayName(Type resourceManagerProvider, string resourceKey)
+ {
+ this.Name = LookupResource(resourceManagerProvider, resourceKey);
+ }
+
+ public string Name { get; }
+
+ internal static string LookupResource(Type resourceManagerProvider, string resourceKey)
+ {
+ foreach (PropertyInfo staticProperty in resourceManagerProvider.GetProperties(BindingFlags.Static | BindingFlags.Public))
+ {
+ if (staticProperty.PropertyType == typeof(System.Resources.ResourceManager))
+ {
+ System.Resources.ResourceManager resourceManager = (System.Resources.ResourceManager)staticProperty.GetValue(null, null);
+ return resourceManager.GetString(resourceKey);
+ }
+ }
+
+ return resourceKey;
+ }
}
}
diff --git a/win/CS/HandBrake.Interop/Attributes/DisplayNameLocalized.cs b/win/CS/HandBrake.Interop/Attributes/DisplayNameLocalized.cs
new file mode 100644
index 000000000..849aff069
--- /dev/null
+++ b/win/CS/HandBrake.Interop/Attributes/DisplayNameLocalized.cs
@@ -0,0 +1,38 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="DisplayNameLocalized.cs" company="HandBrake Project (http://handbrake.fr)">
+// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
+// </copyright>
+// <summary>
+// Localised version of teh DisplayName attribute.
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrake.Interop.Attributes
+{
+ using System;
+ using System.ComponentModel;
+ using System.Reflection;
+
+ [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Event | AttributeTargets.All)]
+ public class DisplayNameLocalized : DisplayNameAttribute
+ {
+ public DisplayNameLocalized(Type resourceManagerProvider, string resourceKey)
+ : base(LookupResource(resourceManagerProvider, resourceKey))
+ {
+ }
+
+ internal static string LookupResource(Type resourceManagerProvider, string resourceKey)
+ {
+ foreach (PropertyInfo staticProperty in resourceManagerProvider.GetProperties(BindingFlags.Static | BindingFlags.NonPublic))
+ {
+ if (staticProperty.PropertyType == typeof(System.Resources.ResourceManager))
+ {
+ System.Resources.ResourceManager resourceManager = (System.Resources.ResourceManager)staticProperty.GetValue(null, null);
+ return resourceManager.GetString(resourceKey);
+ }
+ }
+
+ return resourceKey;
+ }
+ }
+}
diff --git a/win/CS/HandBrake.Interop/HandBrake.Interop.csproj b/win/CS/HandBrake.Interop/HandBrake.Interop.csproj
index 5bf710caa..d73d4dcbc 100644
--- a/win/CS/HandBrake.Interop/HandBrake.Interop.csproj
+++ b/win/CS/HandBrake.Interop/HandBrake.Interop.csproj
@@ -50,6 +50,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Attributes\DisplayName.cs" />
+ <Compile Include="Attributes\DisplayNameLocalized.cs" />
<Compile Include="Attributes\ShortName.cs" />
<Compile Include="Interop\EventArgs\EncodeCompletedEventArgs.cs" />
<Compile Include="Interop\EventArgs\EncodeProgressEventArgs.cs" />
diff --git a/win/CS/HandBrake.Interop/Properties/Resources.Designer.cs b/win/CS/HandBrake.Interop/Properties/Resources.Designer.cs
index c288971f6..bb3488fae 100644
--- a/win/CS/HandBrake.Interop/Properties/Resources.Designer.cs
+++ b/win/CS/HandBrake.Interop/Properties/Resources.Designer.cs
@@ -19,7 +19,7 @@ namespace HandBrake.Interop.Properties {
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {