From a9ffd7cccca1aa20b6757b1f8a304f799fb3dbf2 Mon Sep 17 00:00:00 2001 From: morkt Date: Fri, 14 Aug 2015 06:05:15 +0400 Subject: [PATCH] added shortcuts to standard formats as static properties of ImageFormat and AudioFormat. namely, ImageFormat.Jpeg ImageFormat.Png ImageFormat.Bmp AudioFormat.Wav --- GameRes/Audio.cs | 6 ++++++ GameRes/Image.cs | 13 +++++++++++++ GameRes/Properties/AssemblyInfo.cs | 4 ++-- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/GameRes/Audio.cs b/GameRes/Audio.cs index c000622a..88924082 100644 --- a/GameRes/Audio.cs +++ b/GameRes/Audio.cs @@ -23,7 +23,9 @@ // IN THE SOFTWARE. // +using System; using System.IO; +using System.Linq; namespace GameRes { @@ -167,5 +169,9 @@ namespace GameRes } return null; } + + public static AudioFormat Wav { get { return s_WavFormat.Value; } } + + static readonly Lazy s_WavFormat = new Lazy (() => FormatCatalog.Instance.AudioFormats.FirstOrDefault (x => x.Tag == "WAV")); } } diff --git a/GameRes/Image.cs b/GameRes/Image.cs index 4cd023f0..befad755 100644 --- a/GameRes/Image.cs +++ b/GameRes/Image.cs @@ -178,5 +178,18 @@ namespace GameRes { get { return this.GetType().Assembly == typeof(ImageFormat).Assembly; } } + + public static ImageFormat FindByTag (string tag) + { + return FormatCatalog.Instance.ImageFormats.FirstOrDefault (x => x.Tag == tag); + } + + static readonly Lazy s_JpegFormat = new Lazy (() => FindByTag ("JPEG")); + static readonly Lazy s_PngFormat = new Lazy (() => FindByTag ("PNG")); + static readonly Lazy s_BmpFormat = new Lazy (() => FindByTag ("BMP")); + + public static ImageFormat Jpeg { get { return s_JpegFormat.Value; } } + public static ImageFormat Png { get { return s_PngFormat.Value; } } + public static ImageFormat Bmp { get { return s_BmpFormat.Value; } } } } diff --git a/GameRes/Properties/AssemblyInfo.cs b/GameRes/Properties/AssemblyInfo.cs index 1ad17f04..664528c8 100644 --- a/GameRes/Properties/AssemblyInfo.cs +++ b/GameRes/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion ("1.1.4.8")] -[assembly: AssemblyFileVersion ("1.1.4.8")] +[assembly: AssemblyVersion ("1.1.5.8")] +[assembly: AssemblyFileVersion ("1.1.5.8")]