PageRenderTime 20ms CodeModel.GetById 9ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/CBR/CBR.Core/Files/Conversion/XPS/XPSImageWriter.cs

#
C# | 43 lines | 40 code | 3 blank | 0 comment | 4 complexity | 0fb7482d54b1f942ffd03f794e6d1010 MD5 | raw file
 1using System;
 2using System.Collections.Generic;
 3using System.Linq;
 4using System.Text;
 5using System.IO;
 6using CBR.Core.Helpers;
 7using CBR.Core.Helpers.Localization;
 8
 9namespace CBR.Core.Files.Conversion
10{
11    internal class XPSImageWriter : IWriterContract
12    {
13        public void Write(string inputFileorFolder, string inputFolder, string outputFolder, List<byte[]> imageBytes, List<string> imageNames, ContractParameters settings, ProgressDelegate progress)
14        {
15			if (LogHelper.CanDebug())
16				LogHelper.Begin("XPSImageWriter.Write");
17			try
18			{
19                string file_out = Path.Combine(outputFolder, inputFileorFolder) + ".xps";
20
21                if (File.Exists(file_out))
22                    File.Delete(file_out);
23
24				if (new XpsHelper().WriteDocument(imageBytes, file_out))
25				{
26					string msg = CultureManager.Instance.GetLocalization("ByCode", "Convert.Output", "Output file written !");
27					progress(msg);
28				}
29                if (settings.ResfreshLibrary)
30                    settings.ResultFiles.Add(file_out);
31			}
32			catch (Exception err)
33			{
34				LogHelper.Manage("XPSImageWriter.Write", err);
35				settings.Result = false;
36			}
37			finally
38			{
39				LogHelper.End("XPSImageWriter.Write");
40			}  
41        }
42    }
43}