diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2015-04-08 08:37:07 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2015-04-08 08:37:07 -0400 |
| commit | 78e96917e12abb963301957607da4a738f27df58 (patch) | |
| tree | 5d46b69b5ea4d034c778ba0339d006cbd654a461 /MediaBrowser.Server.Implementations/Drawing/PlayedIndicatorDrawer.cs | |
| parent | d6b2bf89f58f4bf9df6bc1c3578c0ee1cc152210 (diff) | |
move drawing code
Diffstat (limited to 'MediaBrowser.Server.Implementations/Drawing/PlayedIndicatorDrawer.cs')
| -rw-r--r-- | MediaBrowser.Server.Implementations/Drawing/PlayedIndicatorDrawer.cs | 86 |
1 files changed, 0 insertions, 86 deletions
diff --git a/MediaBrowser.Server.Implementations/Drawing/PlayedIndicatorDrawer.cs b/MediaBrowser.Server.Implementations/Drawing/PlayedIndicatorDrawer.cs deleted file mode 100644 index 359065cc2..000000000 --- a/MediaBrowser.Server.Implementations/Drawing/PlayedIndicatorDrawer.cs +++ /dev/null @@ -1,86 +0,0 @@ -using ImageMagickSharp; -using MediaBrowser.Common.Configuration; -using MediaBrowser.Model.Drawing; -using System; -using System.IO; - -namespace MediaBrowser.Server.Implementations.Drawing -{ - public class PlayedIndicatorDrawer - { - private const int FontSize = 52; - private const int OffsetFromTopRightCorner = 38; - - private readonly IApplicationPaths _appPaths; - - public PlayedIndicatorDrawer(IApplicationPaths appPaths) - { - _appPaths = appPaths; - } - - public void DrawPlayedIndicator(MagickWand wand, ImageSize imageSize) - { - var x = imageSize.Width - OffsetFromTopRightCorner; - - using (var draw = new DrawingWand()) - { - using (PixelWand pixel = new PixelWand()) - { - pixel.Color = "#52B54B"; - pixel.Opacity = 0.2; - draw.FillColor = pixel; - draw.DrawCircle(x, OffsetFromTopRightCorner, x - 20, OffsetFromTopRightCorner - 20); - - pixel.Opacity = 0; - pixel.Color = "white"; - draw.FillColor = pixel; - draw.Font = ExtractFont("webdings.ttf", _appPaths); - draw.FontSize = FontSize; - draw.FontStyle = FontStyleType.NormalStyle; - draw.TextAlignment = TextAlignType.CenterAlign; - draw.FontWeight = FontWeightType.RegularStyle; - draw.TextAntialias = true; - draw.DrawAnnotation(x + 4, OffsetFromTopRightCorner + 14, "a"); - - draw.FillColor = pixel; - wand.CurrentImage.DrawImage(draw); - } - } - } - - internal static string ExtractFont(string name, IApplicationPaths paths) - { - var filePath = Path.Combine(paths.ProgramDataPath, "fonts", name); - - if (File.Exists(filePath)) - { - return filePath; - } - - var namespacePath = typeof(PlayedIndicatorDrawer).Namespace + ".fonts." + name; - var tempPath = Path.Combine(paths.TempDirectory, Guid.NewGuid().ToString("N") + ".ttf"); - Directory.CreateDirectory(Path.GetDirectoryName(tempPath)); - - using (var stream = typeof(PlayedIndicatorDrawer).Assembly.GetManifestResourceStream(namespacePath)) - { - using (var fileStream = new FileStream(tempPath, FileMode.Create, FileAccess.Write, FileShare.Read)) - { - stream.CopyTo(fileStream); - } - } - - Directory.CreateDirectory(Path.GetDirectoryName(filePath)); - - try - { - File.Copy(tempPath, filePath, false); - } - catch (IOException) - { - - } - - return tempPath; - } - } -} |
