From 3aace687893ab7355b41f779daa3bb93e6bf7d52 Mon Sep 17 00:00:00 2001 From: hzhuangxin01 Date: Tue, 19 Feb 2019 12:02:14 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E5=A2=9E=E5=8A=A0UDP=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E9=80=9A=E9=81=93=202.=20=E5=A2=9E=E5=8A=A0=E4=B8=BB=E7=A8=8B?= =?UTF-8?q?=E5=BA=8F=E9=85=8D=E7=BD=AE=E9=A1=B9=203.=20=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- GeneratorCode/App.config | 9 +- GeneratorCode/Configure/NConfig.cs | 25 +- GeneratorCode/GeneratorCode.csproj | 2 +- GeneratorCode/Logs/NLog.cs | 164 +- GeneratorCode/{Program.cs => MainCode.cs} | 553 ++- .../OIDPublishImageGenerator/PluginEntry.xml | 14 +- GeneratorCode/Properties/Annotations.cs | 841 ++-- GeneratorCode/Properties/AssemblyInfo.cs | 1 - .../TmatrixSDK/OIDPublishImageGenerator.cs | 82 +- GeneratorCode/TmatrixSDK/TmatrixClass.cs | 4113 ++++++++--------- GeneratorCode/config.ini | 11 + GeneratorCode/packages.config | 1 + 12 files changed, 2970 insertions(+), 2846 deletions(-) rename GeneratorCode/{Program.cs => MainCode.cs} (68%) diff --git a/GeneratorCode/App.config b/GeneratorCode/App.config index 4543795..3a18ba6 100644 --- a/GeneratorCode/App.config +++ b/GeneratorCode/App.config @@ -1,6 +1,7 @@ + - - - - + + + + \ No newline at end of file diff --git a/GeneratorCode/Configure/NConfig.cs b/GeneratorCode/Configure/NConfig.cs index 16ec06c..5ebb1e7 100644 --- a/GeneratorCode/Configure/NConfig.cs +++ b/GeneratorCode/Configure/NConfig.cs @@ -11,12 +11,12 @@ namespace GeneratorCode.Configure { public static class NConfig { - private static string _cfgFileName = @".\config.ini"; - - private static IniData _cfgData = null; - public delegate void ConfigChangedHandle(); + private static readonly string _cfgFileName = @".\config.ini"; + + private static IniData _cfgData; + public static event ConfigChangedHandle OnConfigChanged; private static void ConfigChanged() @@ -35,7 +35,7 @@ namespace GeneratorCode.Configure ws.WriteLine("; 应用程序配置文件\n"); } - FileIniDataParser iniPraser = new FileIniDataParser(); + var iniPraser = new FileIniDataParser(); iniPraser.Parser.Configuration.CommentString = ";"; _cfgData = iniPraser.ReadFile(_cfgFileName); //Trace.WriteLine(_cfgData); @@ -50,17 +50,17 @@ namespace GeneratorCode.Configure { var cfgTask = new List(); var appPath = Process.GetCurrentProcess().MainModule.FileName; - + //Trace.WriteLine("Application: " + appPath); //Trace.WriteLine("Directory: " + Path.GetDirectoryName(appPath)); //Trace.WriteLine("File: " + Path.GetFileName(appPath)); - var fw = new FileSystemWatcher() + var fw = new FileSystemWatcher { NotifyFilter = NotifyFilters.FileName | NotifyFilters.LastWrite, Filter = _cfgFileName, Path = Path.GetDirectoryName(appPath), - IncludeSubdirectories = false, + IncludeSubdirectories = false }; fw.Changed += (sender, e) => @@ -99,20 +99,17 @@ namespace GeneratorCode.Configure { var ret = defValue; - if (_cfgData.Equals(null)) - { - return ret; - } + if (_cfgData.Equals(null)) return ret; try { ret = (T) Convert.ChangeType(_cfgData[secName][keyName], typeof(T)); } - catch(Exception e) + catch (Exception e) { Trace.WriteLine("[" + _cfgData[secName][keyName] + "] :" + e.Message); ret = defValue; - throw(e); + throw e; } return ret; diff --git a/GeneratorCode/GeneratorCode.csproj b/GeneratorCode/GeneratorCode.csproj index ef361c9..e8483dd 100644 --- a/GeneratorCode/GeneratorCode.csproj +++ b/GeneratorCode/GeneratorCode.csproj @@ -58,7 +58,7 @@ - + diff --git a/GeneratorCode/Logs/NLog.cs b/GeneratorCode/Logs/NLog.cs index d689c5c..f2fd45b 100644 --- a/GeneratorCode/Logs/NLog.cs +++ b/GeneratorCode/Logs/NLog.cs @@ -29,10 +29,9 @@ namespace GeneratorCode.Logs public class NLogConfig { - private object _cfgLock = new object(); public delegate void LogCfgChangedHandle(); - public static event LogCfgChangedHandle OnLogCfgChanged; + private readonly object _cfgLock = new object(); public NLogConfig() { @@ -40,11 +39,6 @@ namespace GeneratorCode.Logs NConfig.OnConfigChanged += () => { LogCfgChanged(); }; } - protected static void LogCfgChanged() - { - OnLogCfgChanged?.Invoke(); - } - public bool LogEnable { get; set; } public NLogLevel LogLevel { get; set; } public NLogLevel DefaultLevel { get; set; } @@ -78,13 +72,20 @@ namespace GeneratorCode.Logs public bool RoolbackFile { get; set; } public int MaxFileNum { get; set; } + public static event LogCfgChangedHandle OnLogCfgChanged; + + protected static void LogCfgChanged() + { + OnLogCfgChanged?.Invoke(); + } + public void LogConfig() { lock (_cfgLock) { LogEnable = NConfig.GetCfgValue("LogGlobal", "LogEnable", false); - LogLevel = (NLogLevel)NConfig.GetCfgValue("LogGlobal", "LogLevel", (int)NLogLevel.MaxLevel); - DefaultLevel = (NLogLevel)NConfig.GetCfgValue("LogGlobal", "DefaultLogLevel", (int)NLogLevel.Info); + LogLevel = (NLogLevel) NConfig.GetCfgValue("LogGlobal", "LogLevel", (int) NLogLevel.MaxLevel); + DefaultLevel = (NLogLevel) NConfig.GetCfgValue("LogGlobal", "DefaultLogLevel", (int) NLogLevel.Info); AsyncMode = NConfig.GetCfgValue("LogGlobal", "AsyncMode", false); ForceNewLine = NConfig.GetCfgValue("LogGlobal", "AutoForceNewLine", false); @@ -107,7 +108,8 @@ namespace GeneratorCode.Logs if (MaxItemsCache == 0) MaxItemsCache = int.MaxValue; - CacheMode = (CacheOptMode)NConfig.GetCfgValue("AsyncLogSetting", "CacheFullOpts", (int)CacheOptMode.Drop); + CacheMode = (CacheOptMode) NConfig.GetCfgValue("AsyncLogSetting", "CacheFullOpts", + (int) CacheOptMode.Drop); NumOutItems = NConfig.GetCfgValue("AsyncLogSetting", "NumItemsOutEachTime", 10); } @@ -118,14 +120,9 @@ namespace GeneratorCode.Logs DirPath = NConfig.GetCfgValue("FileLogSetting", "Path", @""); if (DirPath == "" || !Directory.Exists(DirPath) || DirPath == @".\") - { DirPath = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName) + @"\"; - } - if (!Directory.Exists(DirPath)) - { - Directory.CreateDirectory(DirPath); - } + if (!Directory.Exists(DirPath)) Directory.CreateDirectory(DirPath); FileNamePre = NConfig.GetCfgValue("FileLogSetting", "FileNamePrefix", ""); EnSplitLog = NConfig.GetCfgValue("FileLogSetting", "AutoSplitFile", true); @@ -152,13 +149,9 @@ namespace GeneratorCode.Logs DateTime? dt = null) { if (dt == null) - { LogStamp = DateTime.Now; - } else - { - LogStamp = (DateTime)dt; - } + LogStamp = (DateTime) dt; LogLevel = level; LogContent = logContent; @@ -181,8 +174,8 @@ namespace GeneratorCode.Logs private static readonly ConcurrentQueue _logItemCollection = new ConcurrentQueue(); private static readonly object _logOutputLock = new object(); private static string _logFileName = ""; - private static uint _logFileNum = 0; - private static StreamWriter _logSw = null; + private static uint _logFileNum; + private static StreamWriter _logSw; private static void CreateLogFileHead() { @@ -190,7 +183,7 @@ namespace GeneratorCode.Logs _logSw?.WriteLine("CreateTime: " + string.Format("{0:yyyy-MM-dd HH:mm:ss}", DateTime.Now)); _logSw?.WriteLine("Program: " + Process.GetCurrentProcess().MainModule.FileName); _logSw?.WriteLine("PID: " + Process.GetCurrentProcess().Id); - _logSw?.WriteLine("Split Count: " + (_logFileNum - 1).ToString()); + _logSw?.WriteLine("Split Count: " + (_logFileNum - 1)); _logSw?.WriteLine("--------------------------------------------------"); _logSw?.Flush(); } @@ -215,12 +208,8 @@ namespace GeneratorCode.Logs _logFileName += ".log"; if (File.Exists(_logFileName)) - { if (_logCfg.EnSplitLog) - { File.Delete(_logFileName); - } - } _logSw = new StreamWriter(_logFileName, true); CreateLogFileHead(); @@ -261,43 +250,33 @@ namespace GeneratorCode.Logs var tolOut = Math.Min(_logCfg.NumOutItems, _logItemCollection.Count); foreach (var val in Enumerable.Range(1, tolOut)) - { if (_logItemCollection.TryDequeue(out var logItem)) - { LogOutput(logItem); - } - } - + Thread.Sleep(_logCfg.SleepTime); // 每秒执行一次维护工作 - if ((++cnt % (1000 / _logCfg.SleepTime)) != 0) - { - continue; - } + if (++cnt % (1000 / _logCfg.SleepTime) != 0) continue; _logSw?.Flush(); if (_logCfg.EnSplitLog) { - bool isNeedSplit = false; + var isNeedSplit = false; if (_logCfg.SplitByData && lastDt.Day != DateTime.Now.Day) - { isNeedSplit = true; - } - else if (_logCfg.SplitBySize > 0 && (new FileInfo(_logFileName)).Length > _logCfg.SplitBySize * (1024 * 1024)) - { + else if (_logCfg.SplitBySize > 0 && + new FileInfo(_logFileName).Length > _logCfg.SplitBySize * 1024 * 1024) isNeedSplit = true; - } if (isNeedSplit) { _logSw?.Close(); _logSw?.Dispose(); _logSw = null; - - string parttn = string.Format("*[{0:d3}]_{1}", + + var parttn = string.Format("*[{0:d3}]_{1}", Process.GetCurrentProcess().Id, Path.GetFileNameWithoutExtension(Process.GetCurrentProcess().MainModule.FileName)); @@ -314,16 +293,17 @@ namespace GeneratorCode.Logs parttn += $"_{_logFileNum:d3}"; _logFileNum = Convert.ToUInt32((_logFileNum + 1) % _logCfg.MaxFileNum); } - + _logFileName += ".log"; parttn += ".log"; - - foreach (var f in Directory.GetFiles(_logCfg.DirPath, parttn, SearchOption.TopDirectoryOnly)) + + foreach (var f in Directory.GetFiles(_logCfg.DirPath, parttn, + SearchOption.TopDirectoryOnly)) { File.Delete(f); Trace.WriteLine("Delect Rollback log: " + f); } - + _logSw = new StreamWriter(_logFileName, true); CreateLogFileHead(); } @@ -352,58 +332,33 @@ namespace GeneratorCode.Logs { var msg = ""; - if (_logCfg.ShowDate || _logCfg.ShowTime) - { - msg += "["; - } + if (_logCfg.ShowDate || _logCfg.ShowTime) msg += "["; if (_logCfg.ShowDate) { msg += dt.ToString("yyyy-MM-dd"); - if (_logCfg.ShowTime) - { - msg += " "; - } + if (_logCfg.ShowTime) msg += " "; } if (_logCfg.ShowTime) { msg += dt.ToString("HH:mm:ss"); - if (_logCfg.ShowMSec) - { - msg += "." + dt.ToString("fff"); - } + if (_logCfg.ShowMSec) msg += "." + dt.ToString("fff"); } - if (_logCfg.ShowDate || _logCfg.ShowTime) - { - msg += "]"; - } + if (_logCfg.ShowDate || _logCfg.ShowTime) msg += "]"; - if (_logCfg.ShowLevel) - { - msg += " [" + LogLevelToString(logLevel) + "] "; - } + if (_logCfg.ShowLevel) msg += " [" + LogLevelToString(logLevel) + "] "; - if (_logCfg.ShowCodeFile) - { - msg += "[" + Path.GetFileName(fileName) + "] "; - } + if (_logCfg.ShowCodeFile) msg += "[" + Path.GetFileName(fileName) + "] "; - if (_logCfg.ShowFunction) - { - msg += "- " + funName; - } + if (_logCfg.ShowFunction) msg += "- " + funName; if (_logCfg.ShowCodeFile || _logCfg.ShowFunction) - { if (_logCfg.ShowCodeLine) - { - msg += "(" + lineNo.ToString() + ")"; - } - } + msg += "(" + lineNo + ")"; msg += ": " + logMsg; @@ -419,11 +374,8 @@ namespace GeneratorCode.Logs logItem.CodeLine, logItem.LogStamp); - if (_logCfg.ForceNewLine) - { - msg += Environment.NewLine; - } - + if (_logCfg.ForceNewLine) msg += Environment.NewLine; + lock (_logOutputLock) { if (_logCfg.EnConsole) Console.Write(msg); @@ -436,10 +388,7 @@ namespace GeneratorCode.Logs System.Diagnostics.Debug.WriteLine(msg); } - if (_logCfg.EnFile) - { - _logSw?.Write(msg); - } + if (_logCfg.EnFile) _logSw?.Write(msg); } } @@ -457,10 +406,7 @@ namespace GeneratorCode.Logs System.Diagnostics.Debug.WriteLine(logMsg); } - if (_logCfg.EnFile) - { - _logSw?.Write(logMsg); - } + if (_logCfg.EnFile) _logSw?.Write(logMsg); } } @@ -475,15 +421,10 @@ namespace GeneratorCode.Logs { if (_logItemCollection.Count >= _logCfg.MaxItemsCache) { - if (_logCfg.CacheMode == CacheOptMode.Drop) - { - return; - } - else - { - NLogItem val; - _logItemCollection.TryDequeue(out val); - } + if (_logCfg.CacheMode == CacheOptMode.Drop) return; + + NLogItem val; + _logItemCollection.TryDequeue(out val); } var logItem = new NLogItem(_logCfg.DefaultLevel, logMsg, fileName, funName, lineNo, DateTime.Now); @@ -508,17 +449,12 @@ namespace GeneratorCode.Logs { if (_logItemCollection.Count >= _logCfg.MaxItemsCache) { - if (_logCfg.CacheMode == CacheOptMode.Drop) - { - return; - } - else - { - NLogItem val; - _logItemCollection.TryDequeue(out val); - } + if (_logCfg.CacheMode == CacheOptMode.Drop) return; + + NLogItem val; + _logItemCollection.TryDequeue(out val); } - + var logItem = new NLogItem(NLogLevel.Debug, logMsg, fileName, funName, lineNo, DateTime.Now); _logItemCollection.Enqueue(logItem); } diff --git a/GeneratorCode/Program.cs b/GeneratorCode/MainCode.cs similarity index 68% rename from GeneratorCode/Program.cs rename to GeneratorCode/MainCode.cs index e51143b..4a488a0 100644 --- a/GeneratorCode/Program.cs +++ b/GeneratorCode/MainCode.cs @@ -1,250 +1,303 @@ -using System; -using System.Diagnostics; -using System.IO; -using System.Text; -using System.Threading; -using GeneratorCode.Configure; -using GeneratorCode.Logs; -using Newtonsoft.Json; -using TmatrixLibrary; - -namespace GeneratorCode -{ - public class GeneratorParams - { - public GeneratorParams() - { - dpi = new[] { 0, 0, 0, 0 }; - point_type = new[] { 0, 0, 0, 0 }; - image_type = new[] { false, false, false, true }; - StartPageID = 0; - key = "S0,O000,B0000,P000-255,D2018/12/31;CCAFBQMXYPOAOCIRK52S8QC8SO4A0AGA8Y"; - //filePath = "E:\\NetEase\\轨迹笔\\Sample\\123.pdf"; //"C:\\Works\\pdf\\123.pdf"; - filePath = "C:\\Works\\pdf\\123.pdf"; - sessionId = "4BD5D923-47EA-4DEF-A1CD-9B85B515B191"; - } - - public int[] dpi { get; set; } - - public int[] point_type { get; set; } - - public bool[] image_type { get; set; } - - public string key { get; set; } - - public string filePath { get; set; } - - public int StartPageID { get; set; } - - public string sessionId { get; set; } - } - - public class GenerCodeRet - { - public GenerCodeRet(string sId, int prg) - { - sessionId = sId; - progress = prg; - } - - public string sessionId { get; set; } - - public int progress { get; set; } - } - - public class RspMessage - { - public RspMessage(string sId) - { - err = 0; - msg = ""; - data = new GenerCodeRet(sId, 0); - } - - public RspMessage(string sId, int prg) - { - err = 0; - msg = ""; - data = new GenerCodeRet(sId, prg); - } - - public int err { get; set; } - - public string msg { get; set; } - - public GenerCodeRet data { get; set; } - - public string FormatRspMessage(int errCode, string readme, int prg) - { - var rsp = new RspMessage(data.sessionId, prg); - rsp.err = errCode; - rsp.msg = (Convert.ToBase64String(Encoding.Default.GetBytes(readme))); - - return JsonConvert.SerializeObject(rsp); - } - - public static int SendRspMessage(string msg) - { - NLog.Debug("Send: " + msg + Environment.NewLine); - Console.WriteLine(msg); - return 0; - } - - public void ProgressMessage(int step) - { - var msgContent = FormatRspMessage(0, "Progress", step); - - msg = JsonConvert.SerializeObject(msgContent); - - SendRspMessage(msg); - } - } - - internal class Program - { - private static int Main(string[] args) - { - NConfig.InitConfigure(); - NLog.NLog_Init(); - GeneratorParams inParams = null; - RspMessage rspMsg; - var tmObj = new TmatrixClass(); - - AppDomain.CurrentDomain.UnhandledException += (sender, e) => - { - //Trace.WriteLine("+++++++++++++++++++++++++++++++++++++++++++xajhuang1\n"); - }; - - AppDomain.CurrentDomain.DomainUnload += (sender, e) => - { - //Trace.WriteLine("+++++++++++++++++++++++++++++++++++++++++++xajhuang2\n"); - }; - - AppDomain.CurrentDomain.ProcessExit += (sender, ev) => - { - try - { - tmObj.TmatrixUninitialize(); - } - catch (Exception e) - { - //var msg = rspMsg.FormatRspMessage(9, e.Message, 0); - //RspMessage.SendRspMessage(msg); - NLog.Crash(e.ToString()); - } - - NLog.NLog_Finish(); - }; - - //string inputArg = - // "eyJkcGkiOlswLDAsMCwwXSwicG9pbnRfdHlwZSI6WzAsMCwwLDBdLCJpbWFnZV90eXBlI" + - // "jpbZmFsc2UsZmFsc2UsZmFsc2UsdHJ1ZV0sImtleSI6IlMwLE8wMDAsQjAwMDAsUDAwMC0" + - // "yNTUsRDIwMTgvMTIvMzE7Q0NBRkJRTVhZUE9BT0NJUks1MlM4UUM4U080QTBBR0E4WSIsIm" + - // "ZpbGVQYXRoIjoiRTpcXE5ldEVhc2VcXLnsvKOxylxcU2FtcGxlXFwxMjMucGRmIiwiU3Rhcn" + - // "RQYWdlSUQiOjAsInNlc3Npb25JZCI6IjRCRDVEOTIzLTQ3RUEtNERFRi1BMUNELTlCODVCNT" + - // "E1QjE5MSJ9"; - //string inputArg2 = "eyJkcGkiOlswLDAsMCwwXSwicG9pbnRfdHlwZSI6WzAsMCwwLDBdLCJpb" + - // "WFnZV90eXBlIjpbZmFsc2UsZmFsc2UsZmFsc2UsdHJ1ZV0sImtleSI6Il" + - // "MwLE8wMDAsQjAwMDAsUDAwMC0yNTUsRDIwMTgvMTIvMzE7Q0NBRkJRTVh" + - // "ZUE9BT0NJUks1MlM4UUM4U080QTBBR0E4WSIsImZpbGVQYXRoIjoiQzpc" + - // "XFdvcmtzXFxwZGZcXDEyMy5wZGYiLCJTdGFydFBhZ2VJRCI6MCwic2Vzc" + - // "2lvbklkIjoiNEJENUQ5MjMtNDdFQS00REVGLUExQ0QtOUI4NUI1MTVCMTkxIn0="; - - try - { - if (args.Length == 1) - { - var deCode = Convert.FromBase64String(args[0]); - var strParams = Encoding.Default.GetString(deCode); - inParams = JsonConvert.DeserializeObject(strParams); - } - else if (args.Length == 2) - { - var deCode = Convert.FromBase64String(args[1]); - var strParams = Encoding.Default.GetString(deCode); - inParams = JsonConvert.DeserializeObject(strParams); - inParams.sessionId = args[0]; - } - else - { - inParams = new GeneratorParams(); - } - } - catch (Exception e) - { - rspMsg = new RspMessage(""); - var msg = rspMsg.FormatRspMessage(10, e.Message, 0); - RspMessage.SendRspMessage(msg); - NLog.Crash(string.Format("[{0}]: ", (inParams == null) ? inParams.sessionId : "UnInit") + e.Message); - return -(int) ErrCode.ERR_JSON_DECODE; - } - - rspMsg = new RspMessage(inParams.sessionId); - - tmObj.ProgressChange += rspMsg.ProgressMessage; - - var jsInput = JsonConvert.SerializeObject(inParams); - - NLog.Debug("Input:" + jsInput + Environment.NewLine); - - if (!File.Exists(inParams.filePath)) - { - NLog.Error("File Not Exists: " + inParams.filePath + Environment.NewLine); - return -(int) ErrCode.ERR_FILE_NOTEXISTS; - } - - try - { - tmObj.TmatrixInitialize(); - } - catch (Exception e) - { - var msg = rspMsg.FormatRspMessage(7, e.Message, 0); - RspMessage.SendRspMessage(msg); - NLog.Crash(e.ToString()); - return -(int) ErrCode.ERR_EXCEPT_THROW; - } - - try - { - var ret = tmObj.GenerateTmatrixCode_OID4(inParams.key, - inParams.filePath, inParams.StartPageID, inParams.point_type, - inParams.image_type, inParams.dpi); - - if (ret.Substring(0, 1) != "0") - { - var msg = rspMsg.FormatRspMessage(int.Parse(ret.Substring(0, 1)), - ret.Substring(1, ret.Length - 1), tmObj.GetProgerss()); - - NLog.Error(msg + Environment.NewLine); - RspMessage.SendRspMessage(msg); - } - else - { - var msg = rspMsg.FormatRspMessage(int.Parse(ret.Substring(0, 1)), - ret.Substring(1, ret.Length - 1), 100); - - NLog.Debug(msg + Environment.NewLine); - RspMessage.SendRspMessage(msg); - } - } - catch (Exception e) - { - var msg = rspMsg.FormatRspMessage(8, e.Message, tmObj.GetProgerss()); - RspMessage.SendRspMessage(msg); - NLog.Crash(e.ToString()); - return -(int) ErrCode.ERR_EXCEPT_THROW; - } - - return 0; - } - - private enum ErrCode - { - ERR_INPUT_PARAMS = 1, - ERR_FILE_NOTEXISTS, - ERR_EXCEPT_THROW, - ERR_JSON_DECODE - } - } -} +using System; +using System.IO; +using System.Net; +using System.Net.Sockets; +using System.Text; +using GeneratorCode.Configure; +using GeneratorCode.Logs; +using JetBrains.Annotations; +using Newtonsoft.Json; +using TmatrixLibrary; + +namespace GeneratorCode +{ + public class GeneratorParams + { + public GeneratorParams() + { + dpi = new[] { 0, 0, 0, 0 }; + point_type = new[] { 0, 0, 0, 0 }; + image_type = new[] { false, false, false, true }; + StartPageID = 0; + key = "S0,O000,B0000,P000-255,D2018/12/31;CCAFBQMXYPOAOCIRK52S8QC8SO4A0AGA8Y"; + filePath = "E:\\NetEase\\轨迹笔\\Sample\\123.pdf"; //"C:\\Works\\pdf\\123.pdf"; + //filePath = "C:\\Works\\pdf\\123.pdf"; + sessionId = "4BD5D923-47EA-4DEF-A1CD-9B85B515B191"; + } + + public int[] dpi { get; set; } + + public int[] point_type { get; set; } + + public bool[] image_type { get; set; } + + public string key { get; set; } + + public string filePath { get; set; } + + public int StartPageID { get; set; } + + public string sessionId { get; set; } + } + + public class GenerCodeRet + { + public GenerCodeRet(string sId, int prg) + { + sessionId = sId; + progress = prg; + } + + public string sessionId { get; set; } + + public int progress { get; set; } + } + + public class MainConfig + { + public delegate void MainCfgChangedHandle(); + + private readonly object _cfgLock = new object(); + + public MainConfig() + { + LoadConfig(); + OnMainCfgChanged += MainCfgChanged; + } + + public bool Base64MsgContent { get; set; } + public int ServerPort { get; set; } + public string ServerAddr { get; set; } + + public static event MainCfgChangedHandle OnMainCfgChanged; + + protected static void MainCfgChanged() + { + OnMainCfgChanged?.Invoke(); + } + + public void LoadConfig() + { + lock (_cfgLock) + { + Base64MsgContent = NConfig.GetCfgValue("Main", "ProBase64Msg", true); + ServerPort = NConfig.GetCfgValue("Main", "ProServerPort", 10088); + ServerAddr = NConfig.GetCfgValue("Main", "ProServerAddr", "127.0.0.1"); + } + } + } + + public class MessageProcess + { + private readonly UdpClient _udp = new UdpClient(); + + public MessageProcess(MainConfig cfg) + { + var svrAddr = IPAddress.Parse(cfg.ServerAddr); + _server = new IPEndPoint(svrAddr, cfg.ServerPort); + } + + private IPEndPoint _server { get; } + + public void SendMessage([NotNull] string msg) + { + if (msg.Length > 0) + { + var sendData = Encoding.Default.GetBytes(msg); + _udp.Send(sendData, sendData.Length, _server); + NLog.Debug("Send: " + msg + Environment.NewLine); + } + } + } + + public class RspMessage + { + public RspMessage(string sId) + { + err = 0; + msg = ""; + data = new GenerCodeRet(sId, 0); + } + + public RspMessage(string sId, int prg) + { + err = 0; + msg = ""; + data = new GenerCodeRet(sId, prg); + } + + public int err { get; set; } + + public string msg { get; set; } + + public GenerCodeRet data { get; set; } + + public string FormatRspMessage(int errCode, string readme, int prg, bool enBase64 = true) + { + var rsp = new RspMessage(data.sessionId, prg); + rsp.err = errCode; + + if (enBase64) + rsp.msg = Convert.ToBase64String(Encoding.Default.GetBytes(readme)); + else + rsp.msg = readme; + + return JsonConvert.SerializeObject(rsp); + } + } + + internal class MainCode + { + private static int Main(string[] args) + { + NConfig.InitConfigure(); + NLog.NLog_Init(); + GeneratorParams inParams = null; + RspMessage rspMsg; + var mainCfg = new MainConfig(); + var msgProcess = new MessageProcess(mainCfg); + var tmObj = new TmatrixClass(); + + AppDomain.CurrentDomain.UnhandledException += (sender, e) => + { + NLog.Crash("UnHandled Exception: " + e.ToString()); + }; + + AppDomain.CurrentDomain.ProcessExit += (sender, ev) => + { + try + { + tmObj.TmatrixUninitialize(); + } + catch (Exception e) + { + //var msg = rspMsg.FormatRspMessage(9, e.Message, 0); + //RspMessage.SendRspMessage(msg); + NLog.Crash(e.ToString()); + } + + NLog.NLog_Finish(); + }; + + //string inputArg = + // "eyJkcGkiOlswLDAsMCwwXSwicG9pbnRfdHlwZSI6WzAsMCwwLDBdLCJpbWFnZV90eXBlI" + + // "jpbZmFsc2UsZmFsc2UsZmFsc2UsdHJ1ZV0sImtleSI6IlMwLE8wMDAsQjAwMDAsUDAwMC0" + + // "yNTUsRDIwMTgvMTIvMzE7Q0NBRkJRTVhZUE9BT0NJUks1MlM4UUM4U080QTBBR0E4WSIsIm" + + // "ZpbGVQYXRoIjoiRTpcXE5ldEVhc2VcXLnsvKOxylxcU2FtcGxlXFwxMjMucGRmIiwiU3Rhcn" + + // "RQYWdlSUQiOjAsInNlc3Npb25JZCI6IjRCRDVEOTIzLTQ3RUEtNERFRi1BMUNELTlCODVCNT" + + // "E1QjE5MSJ9"; + //string inputArg2 = "eyJkcGkiOlswLDAsMCwwXSwicG9pbnRfdHlwZSI6WzAsMCwwLDBdLCJpb" + + // "WFnZV90eXBlIjpbZmFsc2UsZmFsc2UsZmFsc2UsdHJ1ZV0sImtleSI6Il" + + // "MwLE8wMDAsQjAwMDAsUDAwMC0yNTUsRDIwMTgvMTIvMzE7Q0NBRkJRTVh" + + // "ZUE9BT0NJUks1MlM4UUM4U080QTBBR0E4WSIsImZpbGVQYXRoIjoiQzpc" + + // "XFdvcmtzXFxwZGZcXDEyMy5wZGYiLCJTdGFydFBhZ2VJRCI6MCwic2Vzc" + + // "2lvbklkIjoiNEJENUQ5MjMtNDdFQS00REVGLUExQ0QtOUI4NUI1MTVCMTkxIn0="; + + try + { + if (args.Length == 1) + { + var deCode = Convert.FromBase64String(args[0]); + var strParams = Encoding.Default.GetString(deCode); + inParams = JsonConvert.DeserializeObject(strParams); + } + else if (args.Length == 2) + { + var deCode = Convert.FromBase64String(args[1]); + var strParams = Encoding.Default.GetString(deCode); + inParams = JsonConvert.DeserializeObject(strParams); + inParams.sessionId = args[0]; + } + else + { + inParams = new GeneratorParams(); + } + } + catch (Exception e) + { + rspMsg = new RspMessage(""); + var msg = rspMsg.FormatRspMessage(10, e.Message, 0, mainCfg.Base64MsgContent); + msgProcess.SendMessage(msg); + NLog.Crash(string.Format("[{0}]: ", inParams == null ? inParams.sessionId : "UnInit") + e.Message); + return -(int) ErrCode.ERR_JSON_DECODE; + } + + rspMsg = new RspMessage(inParams.sessionId); + + tmObj.ProgressChange += step => + { + var msgContent = rspMsg.FormatRspMessage(0, "Progress", step, mainCfg.Base64MsgContent); + + var msg = JsonConvert.SerializeObject(msgContent); + + msgProcess.SendMessage(msg); + }; + + var jsInput = JsonConvert.SerializeObject(inParams); + + NLog.Debug("Input:" + jsInput + Environment.NewLine); + + if (!File.Exists(inParams.filePath)) + { + NLog.Error("File Not Exists: " + inParams.filePath + Environment.NewLine); + return -(int) ErrCode.ERR_FILE_NOTEXISTS; + } + + try + { + tmObj.TmatrixInitialize(); + } + catch (Exception e) + { + var msg = rspMsg.FormatRspMessage(7, e.Message, 0, mainCfg.Base64MsgContent); + msgProcess.SendMessage(msg); + NLog.Crash(e.ToString()); + return -(int) ErrCode.ERR_EXCEPT_THROW; + } + + try + { + var ret = tmObj.GenerateTmatrixCode_OID4(inParams.key, + inParams.filePath, inParams.StartPageID, inParams.point_type, + inParams.image_type, inParams.dpi); + + if (ret.Substring(0, 1) != "0") + { + var msg = rspMsg.FormatRspMessage(int.Parse(ret.Substring(0, 1)), + ret.Substring(1, ret.Length - 1), + tmObj.GetProgerss(), + mainCfg.Base64MsgContent); + + NLog.Error(msg + Environment.NewLine); + msgProcess.SendMessage(msg); + } + else + { + var msg = rspMsg.FormatRspMessage(int.Parse(ret.Substring(0, 1)), + ret.Substring(1, ret.Length - 1), 100, + mainCfg.Base64MsgContent); + + NLog.Debug(msg + Environment.NewLine); + msgProcess.SendMessage(msg); + } + } + catch (Exception e) + { + var msg = rspMsg.FormatRspMessage(8, e.Message, tmObj.GetProgerss(), mainCfg.Base64MsgContent); + msgProcess.SendMessage(msg); + NLog.Crash(e.ToString()); + return -(int) ErrCode.ERR_EXCEPT_THROW; + } + + return 0; + } + + private enum ErrCode + { + ERR_INPUT_PARAMS = 1, + ERR_FILE_NOTEXISTS, + ERR_EXCEPT_THROW, + ERR_JSON_DECODE + } + } +} diff --git a/GeneratorCode/OIDPublishImageGenerator/PluginEntry.xml b/GeneratorCode/OIDPublishImageGenerator/PluginEntry.xml index 6ac1410..f8b435d 100644 --- a/GeneratorCode/OIDPublishImageGenerator/PluginEntry.xml +++ b/GeneratorCode/OIDPublishImageGenerator/PluginEntry.xml @@ -1,10 +1,10 @@  - - - - - - - + + + + + + + \ No newline at end of file diff --git a/GeneratorCode/Properties/Annotations.cs b/GeneratorCode/Properties/Annotations.cs index fca55e7..a9e7868 100644 --- a/GeneratorCode/Properties/Annotations.cs +++ b/GeneratorCode/Properties/Annotations.cs @@ -33,93 +33,107 @@ using System; namespace JetBrains.Annotations { /// - /// Indicates that the value of the marked element could be null sometimes, - /// so the check for null is necessary before its usage. + /// Indicates that the value of the marked element could be null sometimes, + /// so the check for null is necessary before its usage. /// - /// + /// + /// /// [CanBeNull] object Test() => null; /// /// void UseTest() { /// var p = Test(); /// var s = p.ToString(); // Warning: Possible 'System.NullReferenceException' /// } - /// + /// + /// [AttributeUsage( - AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property | - AttributeTargets.Delegate | AttributeTargets.Field | AttributeTargets.Event | - AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.GenericParameter)] - internal sealed class CanBeNullAttribute : Attribute { } + AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property | + AttributeTargets.Delegate | AttributeTargets.Field | AttributeTargets.Event | + AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.GenericParameter)] + internal sealed class CanBeNullAttribute : Attribute + { + } /// - /// Indicates that the value of the marked element could never be null. + /// Indicates that the value of the marked element could never be null. /// - /// + /// + /// /// [NotNull] object Foo() { /// return null; // Warning: Possible 'null' assignment /// } - /// + /// + /// [AttributeUsage( - AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property | - AttributeTargets.Delegate | AttributeTargets.Field | AttributeTargets.Event | - AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.GenericParameter)] - internal sealed class NotNullAttribute : Attribute { } + AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property | + AttributeTargets.Delegate | AttributeTargets.Field | AttributeTargets.Event | + AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.GenericParameter)] + internal sealed class NotNullAttribute : Attribute + { + } /// - /// Can be appplied to symbols of types derived from IEnumerable as well as to symbols of Task - /// and Lazy classes to indicate that the value of a collection item, of the Task.Result property - /// or of the Lazy.Value property can never be null. + /// Can be appplied to symbols of types derived from IEnumerable as well as to symbols of Task + /// and Lazy classes to indicate that the value of a collection item, of the Task.Result property + /// or of the Lazy.Value property can never be null. /// [AttributeUsage( - AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property | - AttributeTargets.Delegate | AttributeTargets.Field)] - internal sealed class ItemNotNullAttribute : Attribute { } + AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property | + AttributeTargets.Delegate | AttributeTargets.Field)] + internal sealed class ItemNotNullAttribute : Attribute + { + } /// - /// Can be appplied to symbols of types derived from IEnumerable as well as to symbols of Task - /// and Lazy classes to indicate that the value of a collection item, of the Task.Result property - /// or of the Lazy.Value property can be null. + /// Can be appplied to symbols of types derived from IEnumerable as well as to symbols of Task + /// and Lazy classes to indicate that the value of a collection item, of the Task.Result property + /// or of the Lazy.Value property can be null. /// [AttributeUsage( - AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property | - AttributeTargets.Delegate | AttributeTargets.Field)] - internal sealed class ItemCanBeNullAttribute : Attribute { } + AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property | + AttributeTargets.Delegate | AttributeTargets.Field)] + internal sealed class ItemCanBeNullAttribute : Attribute + { + } /// - /// Indicates that the marked method builds string by format pattern and (optional) arguments. - /// Parameter, which contains format string, should be given in constructor. The format string - /// should be in -like form. + /// Indicates that the marked method builds string by format pattern and (optional) arguments. + /// Parameter, which contains format string, should be given in constructor. The format string + /// should be in -like form. /// - /// + /// + /// /// [StringFormatMethod("message")] /// void ShowError(string message, params object[] args) { /* do something */ } /// /// void Foo() { /// ShowError("Failed: {0}"); // Warning: Non-existing argument in format string /// } - /// + /// + /// [AttributeUsage( - AttributeTargets.Constructor | AttributeTargets.Method | - AttributeTargets.Property | AttributeTargets.Delegate)] + AttributeTargets.Constructor | AttributeTargets.Method | + AttributeTargets.Property | AttributeTargets.Delegate)] internal sealed class StringFormatMethodAttribute : Attribute { /// - /// Specifies which parameter of an annotated method should be treated as format-string + /// Specifies which parameter of an annotated method should be treated as format-string /// public StringFormatMethodAttribute([NotNull] string formatParameterName) { FormatParameterName = formatParameterName; } - [NotNull] public string FormatParameterName { get; private set; } + [NotNull] public string FormatParameterName { get; } } /// - /// For a parameter that is expected to be one of the limited set of values. - /// Specify fields of which type should be used as values for this parameter. + /// For a parameter that is expected to be one of the limited set of values. + /// Specify fields of which type should be used as values for this parameter. /// [AttributeUsage( - AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.Field, - AllowMultiple = true)] + AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.Field, + AllowMultiple = true)] internal sealed class ValueProviderAttribute : Attribute { public ValueProviderAttribute([NotNull] string name) @@ -127,45 +141,60 @@ namespace JetBrains.Annotations Name = name; } - [NotNull] public string Name { get; private set; } + [NotNull] public string Name { get; } } /// - /// Indicates that the function argument should be string literal and match one - /// of the parameters of the caller function. For example, ReSharper annotates - /// the parameter of . + /// Indicates that the function argument should be string literal and match one + /// of the parameters of the caller function. For example, ReSharper annotates + /// the parameter of . /// - /// + /// + /// /// void Foo(string param) { /// if (param == null) /// throw new ArgumentNullException("par"); // Warning: Cannot resolve symbol /// } - /// + /// + /// [AttributeUsage(AttributeTargets.Parameter)] - internal sealed class InvokerParameterNameAttribute : Attribute { } + internal sealed class InvokerParameterNameAttribute : Attribute + { + } /// - /// Indicates that the method is contained in a type that implements - /// System.ComponentModel.INotifyPropertyChanged interface and this method - /// is used to notify that some property value changed. + /// Indicates that the method is contained in a type that implements + /// System.ComponentModel.INotifyPropertyChanged interface and this method + /// is used to notify that some property value changed. /// /// - /// The method should be non-static and conform to one of the supported signatures: - /// - /// NotifyChanged(string) - /// NotifyChanged(params string[]) - /// NotifyChanged{T}(Expression{Func{T}}) - /// NotifyChanged{T,U}(Expression{Func{T,U}}) - /// SetProperty{T}(ref T, T, string) - /// + /// The method should be non-static and conform to one of the supported signatures: + /// + /// + /// NotifyChanged(string) + /// + /// + /// NotifyChanged(params string[]) + /// + /// + /// NotifyChanged{T}(Expression{Func{T}}) + /// + /// + /// NotifyChanged{T,U}(Expression{Func{T,U}}) + /// + /// + /// SetProperty{T}(ref T, T, string) + /// + /// /// - /// + /// + /// /// public class Foo : INotifyPropertyChanged { /// public event PropertyChangedEventHandler PropertyChanged; /// /// [NotifyPropertyChangedInvocator] /// protected virtual void NotifyChanged(string propertyName) { ... } - /// + /// /// string _name; /// /// public string Name { @@ -174,75 +203,100 @@ namespace JetBrains.Annotations /// } /// } /// - /// Examples of generated notifications: - /// - /// NotifyChanged("Property") - /// NotifyChanged(() => Property) - /// NotifyChanged((VM x) => x.Property) - /// SetProperty(ref myField, value, "Property") - /// + /// Examples of generated notifications: + /// + /// + /// NotifyChanged("Property") + /// + /// + /// NotifyChanged(() => Property) + /// + /// + /// NotifyChanged((VM x) => x.Property) + /// + /// + /// SetProperty(ref myField, value, "Property") + /// + /// /// [AttributeUsage(AttributeTargets.Method)] internal sealed class NotifyPropertyChangedInvocatorAttribute : Attribute { - public NotifyPropertyChangedInvocatorAttribute() { } + public NotifyPropertyChangedInvocatorAttribute() + { + } + public NotifyPropertyChangedInvocatorAttribute([NotNull] string parameterName) { ParameterName = parameterName; } - [CanBeNull] public string ParameterName { get; private set; } + [CanBeNull] public string ParameterName { get; } } /// - /// Describes dependency between method input and output. + /// Describes dependency between method input and output. /// /// - ///

Function Definition Table syntax:

- /// - /// FDT ::= FDTRow [;FDTRow]* - /// FDTRow ::= Input => Output | Output <= Input - /// Input ::= ParameterName: Value [, Input]* - /// Output ::= [ParameterName: Value]* {halt|stop|void|nothing|Value} - /// Value ::= true | false | null | notnull | canbenull - /// - /// If method has single input parameter, it's name could be omitted.
- /// Using halt (or void/nothing, which is the same) for method output - /// means that the methos doesn't return normally (throws or terminates the process).
- /// Value canbenull is only applicable for output parameters.
- /// You can use multiple [ContractAnnotation] for each FDT row, or use single attribute - /// with rows separated by semicolon. There is no notion of order rows, all rows are checked - /// for applicability and applied per each program state tracked by R# analysis.
+ ///

Function Definition Table syntax:

+ /// + /// FDT ::= FDTRow [;FDTRow]* + /// FDTRow ::= Input => Output | Output <= Input + /// Input ::= ParameterName: Value [, Input]* + /// Output ::= [ParameterName: Value]* {halt|stop|void|nothing|Value} + /// Value ::= true | false | null | notnull | canbenull + /// + /// If method has single input parameter, it's name could be omitted.
+ /// Using halt (or void/nothing, which is the same) for method output + /// means that the methos doesn't return normally (throws or terminates the process).
+ /// Value canbenull is only applicable for output parameters.
+ /// You can use multiple [ContractAnnotation] for each FDT row, or use single attribute + /// with rows separated by semicolon. There is no notion of order rows, all rows are checked + /// for applicability and applied per each program state tracked by R# analysis.
///
- /// - /// + /// + /// + /// + /// /// [ContractAnnotation("=> halt")] /// public void TerminationMethod() - /// - /// + /// + /// + /// + /// /// [ContractAnnotation("halt <= condition: false")] /// public void Assert(bool condition, string text) // regular assertion method - /// - /// + /// + /// + /// + /// /// [ContractAnnotation("s:null => true")] /// public bool IsNullOrEmpty(string s) // string.IsNullOrEmpty() - /// - /// + /// + /// + /// + /// /// // A method that returns null if the parameter is null, /// // and not null if the parameter is not null /// [ContractAnnotation("null => null; notnull => notnull")] /// public object Transform(object data) - /// - /// + /// + /// + /// + /// /// [ContractAnnotation("=> true, result: notnull; => false, result: null")] /// public bool TryParse(string s, out Person result) - /// - /// + /// + /// + /// + /// [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)] internal sealed class ContractAnnotationAttribute : Attribute { public ContractAnnotationAttribute([NotNull] string contract) - : this(contract, false) { } + : this(contract, false) + { + } public ContractAnnotationAttribute([NotNull] string contract, bool forceFullStates) { @@ -250,40 +304,45 @@ namespace JetBrains.Annotations ForceFullStates = forceFullStates; } - [NotNull] public string Contract { get; private set; } + [NotNull] public string Contract { get; } - public bool ForceFullStates { get; private set; } + public bool ForceFullStates { get; } } /// - /// Indicates that marked element should be localized or not. + /// Indicates that marked element should be localized or not. /// - /// + /// + /// /// [LocalizationRequiredAttribute(true)] /// class Foo { /// string str = "my string"; // Warning: Localizable string /// } - /// + /// + /// [AttributeUsage(AttributeTargets.All)] internal sealed class LocalizationRequiredAttribute : Attribute { - public LocalizationRequiredAttribute() : this(true) { } + public LocalizationRequiredAttribute() : this(true) + { + } public LocalizationRequiredAttribute(bool required) { Required = required; } - public bool Required { get; private set; } + public bool Required { get; } } /// - /// Indicates that the value of the marked type (or its derivatives) - /// cannot be compared using '==' or '!=' operators and Equals() - /// should be used instead. However, using '==' or '!=' for comparison - /// with null is always permitted. + /// Indicates that the value of the marked type (or its derivatives) + /// cannot be compared using '==' or '!=' operators and Equals() + /// should be used instead. However, using '==' or '!=' for comparison + /// with null is always permitted. /// - /// + /// + /// /// [CannotApplyEqualityOperator] /// class NoEquality { } /// @@ -296,21 +355,26 @@ namespace JetBrains.Annotations /// } /// } /// } - /// + /// + /// [AttributeUsage(AttributeTargets.Interface | AttributeTargets.Class | AttributeTargets.Struct)] - internal sealed class CannotApplyEqualityOperatorAttribute : Attribute { } + internal sealed class CannotApplyEqualityOperatorAttribute : Attribute + { + } /// - /// When applied to a target attribute, specifies a requirement for any type marked - /// with the target attribute to implement or inherit specific type or types. + /// When applied to a target attribute, specifies a requirement for any type marked + /// with the target attribute to implement or inherit specific type or types. /// - /// + /// + /// /// [BaseTypeRequired(typeof(IComponent)] // Specify requirement /// class ComponentAttribute : Attribute { } /// /// [Component] // ComponentAttribute requires implementing IComponent interface /// class MyComponent : IComponent { } - /// + /// + /// [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] [BaseTypeRequired(typeof(Attribute))] internal sealed class BaseTypeRequiredAttribute : Attribute @@ -320,24 +384,30 @@ namespace JetBrains.Annotations BaseType = baseType; } - [NotNull] public Type BaseType { get; private set; } + [NotNull] public Type BaseType { get; } } /// - /// Indicates that the marked symbol is used implicitly (e.g. via reflection, in external library), - /// so this symbol will not be marked as unused (as well as by other usage inspections). + /// Indicates that the marked symbol is used implicitly (e.g. via reflection, in external library), + /// so this symbol will not be marked as unused (as well as by other usage inspections). /// [AttributeUsage(AttributeTargets.All)] internal sealed class UsedImplicitlyAttribute : Attribute { public UsedImplicitlyAttribute() - : this(ImplicitUseKindFlags.Default, ImplicitUseTargetFlags.Default) { } + : this(ImplicitUseKindFlags.Default, ImplicitUseTargetFlags.Default) + { + } public UsedImplicitlyAttribute(ImplicitUseKindFlags useKindFlags) - : this(useKindFlags, ImplicitUseTargetFlags.Default) { } + : this(useKindFlags, ImplicitUseTargetFlags.Default) + { + } public UsedImplicitlyAttribute(ImplicitUseTargetFlags targetFlags) - : this(ImplicitUseKindFlags.Default, targetFlags) { } + : this(ImplicitUseKindFlags.Default, targetFlags) + { + } public UsedImplicitlyAttribute(ImplicitUseKindFlags useKindFlags, ImplicitUseTargetFlags targetFlags) { @@ -345,26 +415,32 @@ namespace JetBrains.Annotations TargetFlags = targetFlags; } - public ImplicitUseKindFlags UseKindFlags { get; private set; } + public ImplicitUseKindFlags UseKindFlags { get; } - public ImplicitUseTargetFlags TargetFlags { get; private set; } + public ImplicitUseTargetFlags TargetFlags { get; } } /// - /// Should be used on attributes and causes ReSharper to not mark symbols marked with such attributes - /// as unused (as well as by other usage inspections) + /// Should be used on attributes and causes ReSharper to not mark symbols marked with such attributes + /// as unused (as well as by other usage inspections) /// [AttributeUsage(AttributeTargets.Class | AttributeTargets.GenericParameter)] internal sealed class MeansImplicitUseAttribute : Attribute { public MeansImplicitUseAttribute() - : this(ImplicitUseKindFlags.Default, ImplicitUseTargetFlags.Default) { } + : this(ImplicitUseKindFlags.Default, ImplicitUseTargetFlags.Default) + { + } public MeansImplicitUseAttribute(ImplicitUseKindFlags useKindFlags) - : this(useKindFlags, ImplicitUseTargetFlags.Default) { } + : this(useKindFlags, ImplicitUseTargetFlags.Default) + { + } public MeansImplicitUseAttribute(ImplicitUseTargetFlags targetFlags) - : this(ImplicitUseKindFlags.Default, targetFlags) { } + : this(ImplicitUseKindFlags.Default, targetFlags) + { + } public MeansImplicitUseAttribute(ImplicitUseKindFlags useKindFlags, ImplicitUseTargetFlags targetFlags) { @@ -381,95 +457,112 @@ namespace JetBrains.Annotations internal enum ImplicitUseKindFlags { Default = Access | Assign | InstantiatedWithFixedConstructorSignature, + /// Only entity marked with attribute considered used. Access = 1, + /// Indicates implicit assignment to a member. Assign = 2, + /// - /// Indicates implicit instantiation of a type with fixed constructor signature. - /// That means any unused constructor parameters won't be reported as such. + /// Indicates implicit instantiation of a type with fixed constructor signature. + /// That means any unused constructor parameters won't be reported as such. /// InstantiatedWithFixedConstructorSignature = 4, + /// Indicates implicit instantiation of a type. - InstantiatedNoFixedConstructorSignature = 8, + InstantiatedNoFixedConstructorSignature = 8 } /// - /// Specify what is considered used implicitly when marked - /// with or . + /// Specify what is considered used implicitly when marked + /// with or . /// [Flags] internal enum ImplicitUseTargetFlags { Default = Itself, Itself = 1, + /// Members of entity marked with attribute are considered used. Members = 2, + /// Entity marked with attribute and all its members considered used. WithMembers = Itself | Members } /// - /// This attribute is intended to mark publicly available API - /// which should not be removed and so is treated as used. + /// This attribute is intended to mark publicly available API + /// which should not be removed and so is treated as used. /// [MeansImplicitUse(ImplicitUseTargetFlags.WithMembers)] internal sealed class PublicAPIAttribute : Attribute { - public PublicAPIAttribute() { } + public PublicAPIAttribute() + { + } public PublicAPIAttribute([NotNull] string comment) { Comment = comment; } - [CanBeNull] public string Comment { get; private set; } + [CanBeNull] public string Comment { get; } } /// - /// Tells code analysis engine if the parameter is completely handled when the invoked method is on stack. - /// If the parameter is a delegate, indicates that delegate is executed while the method is executed. - /// If the parameter is an enumerable, indicates that it is enumerated while the method is executed. + /// Tells code analysis engine if the parameter is completely handled when the invoked method is on stack. + /// If the parameter is a delegate, indicates that delegate is executed while the method is executed. + /// If the parameter is an enumerable, indicates that it is enumerated while the method is executed. /// [AttributeUsage(AttributeTargets.Parameter)] - internal sealed class InstantHandleAttribute : Attribute { } + internal sealed class InstantHandleAttribute : Attribute + { + } /// - /// Indicates that a method does not make any observable state changes. - /// The same as System.Diagnostics.Contracts.PureAttribute. + /// Indicates that a method does not make any observable state changes. + /// The same as System.Diagnostics.Contracts.PureAttribute. /// - /// + /// + /// /// [Pure] int Multiply(int x, int y) => x * y; /// /// void M() { /// Multiply(123, 42); // Waring: Return value of pure method is not used /// } - /// + /// + /// [AttributeUsage(AttributeTargets.Method)] - internal sealed class PureAttribute : Attribute { } + internal sealed class PureAttribute : Attribute + { + } /// - /// Indicates that the return value of method invocation must be used. + /// Indicates that the return value of method invocation must be used. /// [AttributeUsage(AttributeTargets.Method)] internal sealed class MustUseReturnValueAttribute : Attribute { - public MustUseReturnValueAttribute() { } + public MustUseReturnValueAttribute() + { + } public MustUseReturnValueAttribute([NotNull] string justification) { Justification = justification; } - [CanBeNull] public string Justification { get; private set; } + [CanBeNull] public string Justification { get; } } /// - /// Indicates the type member or parameter of some type, that should be used instead of all other ways - /// to get the value that type. This annotation is useful when you have some "context" value evaluated - /// and stored somewhere, meaning that all other ways to get this value must be consolidated with existing one. + /// Indicates the type member or parameter of some type, that should be used instead of all other ways + /// to get the value that type. This annotation is useful when you have some "context" value evaluated + /// and stored somewhere, meaning that all other ways to get this value must be consolidated with existing one. /// - /// + /// + /// /// class Foo { /// [ProvidesContext] IBarService _barService = ...; /// @@ -478,44 +571,50 @@ namespace JetBrains.Annotations /// // ^ Warning: use value of '_barService' field /// } /// } - /// + /// + /// [AttributeUsage( - AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Parameter | AttributeTargets.Method | - AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.Struct | AttributeTargets.GenericParameter)] - internal sealed class ProvidesContextAttribute : Attribute { } + AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Parameter | AttributeTargets.Method | + AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.Struct | + AttributeTargets.GenericParameter)] + internal sealed class ProvidesContextAttribute : Attribute + { + } /// - /// Indicates that a parameter is a path to a file or a folder within a web project. - /// Path can be relative or absolute, starting from web root (~). + /// Indicates that a parameter is a path to a file or a folder within a web project. + /// Path can be relative or absolute, starting from web root (~). /// [AttributeUsage(AttributeTargets.Parameter)] internal sealed class PathReferenceAttribute : Attribute { - public PathReferenceAttribute() { } + public PathReferenceAttribute() + { + } - public PathReferenceAttribute([NotNull, PathReference] string basePath) + public PathReferenceAttribute([NotNull] [PathReference] string basePath) { BasePath = basePath; } - [CanBeNull] public string BasePath { get; private set; } + [CanBeNull] public string BasePath { get; } } /// - /// An extension method marked with this attribute is processed by ReSharper code completion - /// as a 'Source Template'. When extension method is completed over some expression, it's source code - /// is automatically expanded like a template at call site. + /// An extension method marked with this attribute is processed by ReSharper code completion + /// as a 'Source Template'. When extension method is completed over some expression, it's source code + /// is automatically expanded like a template at call site. /// /// - /// Template method body can contain valid source code and/or special comments starting with '$'. - /// Text inside these comments is added as source code when the template is applied. Template parameters - /// can be used either as additional method parameters or as identifiers wrapped in two '$' signs. - /// Use the attribute to specify macros for parameters. + /// Template method body can contain valid source code and/or special comments starting with '$'. + /// Text inside these comments is added as source code when the template is applied. Template parameters + /// can be used either as additional method parameters or as identifiers wrapped in two '$' signs. + /// Use the attribute to specify macros for parameters. /// /// - /// In this example, the 'forEach' method is a source template available over all values - /// of enumerable types, producing ordinary C# 'foreach' statement and placing caret inside block: - /// + /// In this example, the 'forEach' method is a source template available over all values + /// of enumerable types, producing ordinary C# 'foreach' statement and placing caret inside block: + /// /// [SourceTemplate] /// public static void forEach<T>(this IEnumerable<T> xs) { /// foreach (var x in xs) { @@ -525,20 +624,22 @@ namespace JetBrains.Annotations /// /// [AttributeUsage(AttributeTargets.Method)] - internal sealed class SourceTemplateAttribute : Attribute { } + internal sealed class SourceTemplateAttribute : Attribute + { + } /// - /// Allows specifying a macro for a parameter of a source template. + /// Allows specifying a macro for a parameter of a source template. /// /// - /// You can apply the attribute on the whole method or on any of its additional parameters. The macro expression - /// is defined in the property. When applied on a method, the target - /// template parameter is defined in the property. To apply the macro silently - /// for the parameter, set the property value = -1. + /// You can apply the attribute on the whole method or on any of its additional parameters. The macro expression + /// is defined in the property. When applied on a method, the target + /// template parameter is defined in the property. To apply the macro silently + /// for the parameter, set the property value = -1. /// /// - /// Applying the attribute on a source template method: - /// + /// Applying the attribute on a source template method: + /// /// [SourceTemplate, Macro(Target = "item", Expression = "suggestVariableName()")] /// public static void forEach<T>(this IEnumerable<T> collection) { /// foreach (var item in collection) { @@ -546,8 +647,8 @@ namespace JetBrains.Annotations /// } /// } /// - /// Applying the attribute on a template method parameter: - /// + /// Applying the attribute on a template method parameter: + /// /// [SourceTemplate] /// public static void something(this Entity x, [Macro(Expression = "guid()", Editable = -1)] string newguid) { /// /*$ var $x$Id = "$newguid$" + x.ToString(); @@ -559,29 +660,33 @@ namespace JetBrains.Annotations internal sealed class MacroAttribute : Attribute { /// - /// Allows specifying a macro that will be executed for a source template - /// parameter when the template is expanded. + /// Allows specifying a macro that will be executed for a source template + /// parameter when the template is expanded. /// - [CanBeNull] public string Expression { get; set; } + [CanBeNull] + public string Expression { get; set; } /// - /// Allows specifying which occurrence of the target parameter becomes editable when the template is deployed. + /// Allows specifying which occurrence of the target parameter becomes editable when the template is deployed. /// /// - /// If the target parameter is used several times in the template, only one occurrence becomes editable; - /// other occurrences are changed synchronously. To specify the zero-based index of the editable occurrence, - /// use values >= 0. To make the parameter non-editable when the template is expanded, use -1. - /// > + /// If the target parameter is used several times in the template, only one occurrence becomes editable; + /// other occurrences are changed synchronously. To specify the zero-based index of the editable occurrence, + /// use values >= 0. To make the parameter non-editable when the template is expanded, use -1. + /// + /// > public int Editable { get; set; } /// - /// Identifies the target parameter of a source template if the - /// is applied on a template method. + /// Identifies the target parameter of a source template if the + /// is applied on a template method. /// - [CanBeNull] public string Target { get; set; } + [CanBeNull] + public string Target { get; set; } } - [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = true)] + [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = + true)] internal sealed class AspMvcAreaMasterLocationFormatAttribute : Attribute { public AspMvcAreaMasterLocationFormatAttribute([NotNull] string format) @@ -589,10 +694,11 @@ namespace JetBrains.Annotations Format = format; } - [NotNull] public string Format { get; private set; } + [NotNull] public string Format { get; } } - [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = true)] + [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = + true)] internal sealed class AspMvcAreaPartialViewLocationFormatAttribute : Attribute { public AspMvcAreaPartialViewLocationFormatAttribute([NotNull] string format) @@ -600,10 +706,11 @@ namespace JetBrains.Annotations Format = format; } - [NotNull] public string Format { get; private set; } + [NotNull] public string Format { get; } } - [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = true)] + [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = + true)] internal sealed class AspMvcAreaViewLocationFormatAttribute : Attribute { public AspMvcAreaViewLocationFormatAttribute([NotNull] string format) @@ -611,10 +718,11 @@ namespace JetBrains.Annotations Format = format; } - [NotNull] public string Format { get; private set; } + [NotNull] public string Format { get; } } - [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = true)] + [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = + true)] internal sealed class AspMvcMasterLocationFormatAttribute : Attribute { public AspMvcMasterLocationFormatAttribute([NotNull] string format) @@ -622,10 +730,11 @@ namespace JetBrains.Annotations Format = format; } - [NotNull] public string Format { get; private set; } + [NotNull] public string Format { get; } } - [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = true)] + [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = + true)] internal sealed class AspMvcPartialViewLocationFormatAttribute : Attribute { public AspMvcPartialViewLocationFormatAttribute([NotNull] string format) @@ -633,10 +742,11 @@ namespace JetBrains.Annotations Format = format; } - [NotNull] public string Format { get; private set; } + [NotNull] public string Format { get; } } - [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = true)] + [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = + true)] internal sealed class AspMvcViewLocationFormatAttribute : Attribute { public AspMvcViewLocationFormatAttribute([NotNull] string format) @@ -644,166 +754,198 @@ namespace JetBrains.Annotations Format = format; } - [NotNull] public string Format { get; private set; } + [NotNull] public string Format { get; } } /// - /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter - /// is an MVC action. If applied to a method, the MVC action name is calculated - /// implicitly from the context. Use this attribute for custom wrappers similar to - /// System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String). + /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter + /// is an MVC action. If applied to a method, the MVC action name is calculated + /// implicitly from the context. Use this attribute for custom wrappers similar to + /// System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String). /// [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)] internal sealed class AspMvcActionAttribute : Attribute { - public AspMvcActionAttribute() { } + public AspMvcActionAttribute() + { + } public AspMvcActionAttribute([NotNull] string anonymousProperty) { AnonymousProperty = anonymousProperty; } - [CanBeNull] public string AnonymousProperty { get; private set; } + [CanBeNull] public string AnonymousProperty { get; } } /// - /// ASP.NET MVC attribute. Indicates that a parameter is an MVC area. - /// Use this attribute for custom wrappers similar to - /// System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String). + /// ASP.NET MVC attribute. Indicates that a parameter is an MVC area. + /// Use this attribute for custom wrappers similar to + /// System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String). /// [AttributeUsage(AttributeTargets.Parameter)] internal sealed class AspMvcAreaAttribute : Attribute { - public AspMvcAreaAttribute() { } + public AspMvcAreaAttribute() + { + } public AspMvcAreaAttribute([NotNull] string anonymousProperty) { AnonymousProperty = anonymousProperty; } - [CanBeNull] public string AnonymousProperty { get; private set; } + [CanBeNull] public string AnonymousProperty { get; } } /// - /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter is - /// an MVC controller. If applied to a method, the MVC controller name is calculated - /// implicitly from the context. Use this attribute for custom wrappers similar to - /// System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String, String). + /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter is + /// an MVC controller. If applied to a method, the MVC controller name is calculated + /// implicitly from the context. Use this attribute for custom wrappers similar to + /// System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String, String). /// [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)] internal sealed class AspMvcControllerAttribute : Attribute { - public AspMvcControllerAttribute() { } + public AspMvcControllerAttribute() + { + } public AspMvcControllerAttribute([NotNull] string anonymousProperty) { AnonymousProperty = anonymousProperty; } - [CanBeNull] public string AnonymousProperty { get; private set; } + [CanBeNull] public string AnonymousProperty { get; } } /// - /// ASP.NET MVC attribute. Indicates that a parameter is an MVC Master. Use this attribute - /// for custom wrappers similar to System.Web.Mvc.Controller.View(String, String). + /// ASP.NET MVC attribute. Indicates that a parameter is an MVC Master. Use this attribute + /// for custom wrappers similar to System.Web.Mvc.Controller.View(String, String). /// [AttributeUsage(AttributeTargets.Parameter)] - internal sealed class AspMvcMasterAttribute : Attribute { } + internal sealed class AspMvcMasterAttribute : Attribute + { + } /// - /// ASP.NET MVC attribute. Indicates that a parameter is an MVC model type. Use this attribute - /// for custom wrappers similar to System.Web.Mvc.Controller.View(String, Object). + /// ASP.NET MVC attribute. Indicates that a parameter is an MVC model type. Use this attribute + /// for custom wrappers similar to System.Web.Mvc.Controller.View(String, Object). /// [AttributeUsage(AttributeTargets.Parameter)] - internal sealed class AspMvcModelTypeAttribute : Attribute { } + internal sealed class AspMvcModelTypeAttribute : Attribute + { + } /// - /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter is an MVC - /// partial view. If applied to a method, the MVC partial view name is calculated implicitly - /// from the context. Use this attribute for custom wrappers similar to - /// System.Web.Mvc.Html.RenderPartialExtensions.RenderPartial(HtmlHelper, String). + /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter is an MVC + /// partial view. If applied to a method, the MVC partial view name is calculated implicitly + /// from the context. Use this attribute for custom wrappers similar to + /// System.Web.Mvc.Html.RenderPartialExtensions.RenderPartial(HtmlHelper, String). /// [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)] - internal sealed class AspMvcPartialViewAttribute : Attribute { } + internal sealed class AspMvcPartialViewAttribute : Attribute + { + } /// - /// ASP.NET MVC attribute. Allows disabling inspections for MVC views within a class or a method. + /// ASP.NET MVC attribute. Allows disabling inspections for MVC views within a class or a method. /// [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)] - internal sealed class AspMvcSuppressViewErrorAttribute : Attribute { } + internal sealed class AspMvcSuppressViewErrorAttribute : Attribute + { + } /// - /// ASP.NET MVC attribute. Indicates that a parameter is an MVC display template. - /// Use this attribute for custom wrappers similar to - /// System.Web.Mvc.Html.DisplayExtensions.DisplayForModel(HtmlHelper, String). + /// ASP.NET MVC attribute. Indicates that a parameter is an MVC display template. + /// Use this attribute for custom wrappers similar to + /// System.Web.Mvc.Html.DisplayExtensions.DisplayForModel(HtmlHelper, String). /// [AttributeUsage(AttributeTargets.Parameter)] - internal sealed class AspMvcDisplayTemplateAttribute : Attribute { } + internal sealed class AspMvcDisplayTemplateAttribute : Attribute + { + } /// - /// ASP.NET MVC attribute. Indicates that a parameter is an MVC editor template. - /// Use this attribute for custom wrappers similar to - /// System.Web.Mvc.Html.EditorExtensions.EditorForModel(HtmlHelper, String). + /// ASP.NET MVC attribute. Indicates that a parameter is an MVC editor template. + /// Use this attribute for custom wrappers similar to + /// System.Web.Mvc.Html.EditorExtensions.EditorForModel(HtmlHelper, String). /// [AttributeUsage(AttributeTargets.Parameter)] - internal sealed class AspMvcEditorTemplateAttribute : Attribute { } + internal sealed class AspMvcEditorTemplateAttribute : Attribute + { + } /// - /// ASP.NET MVC attribute. Indicates that a parameter is an MVC template. - /// Use this attribute for custom wrappers similar to - /// System.ComponentModel.DataAnnotations.UIHintAttribute(System.String). + /// ASP.NET MVC attribute. Indicates that a parameter is an MVC template. + /// Use this attribute for custom wrappers similar to + /// System.ComponentModel.DataAnnotations.UIHintAttribute(System.String). /// [AttributeUsage(AttributeTargets.Parameter)] - internal sealed class AspMvcTemplateAttribute : Attribute { } + internal sealed class AspMvcTemplateAttribute : Attribute + { + } /// - /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter - /// is an MVC view component. If applied to a method, the MVC view name is calculated implicitly - /// from the context. Use this attribute for custom wrappers similar to - /// System.Web.Mvc.Controller.View(Object). + /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter + /// is an MVC view component. If applied to a method, the MVC view name is calculated implicitly + /// from the context. Use this attribute for custom wrappers similar to + /// System.Web.Mvc.Controller.View(Object). /// [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)] - internal sealed class AspMvcViewAttribute : Attribute { } + internal sealed class AspMvcViewAttribute : Attribute + { + } /// - /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter - /// is an MVC view component name. + /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter + /// is an MVC view component name. /// [AttributeUsage(AttributeTargets.Parameter)] - internal sealed class AspMvcViewComponentAttribute : Attribute { } + internal sealed class AspMvcViewComponentAttribute : Attribute + { + } /// - /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter - /// is an MVC view component view. If applied to a method, the MVC view component view name is default. + /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter + /// is an MVC view component view. If applied to a method, the MVC view component view name is default. /// [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)] - internal sealed class AspMvcViewComponentViewAttribute : Attribute { } + internal sealed class AspMvcViewComponentViewAttribute : Attribute + { + } /// - /// ASP.NET MVC attribute. When applied to a parameter of an attribute, - /// indicates that this parameter is an MVC action name. + /// ASP.NET MVC attribute. When applied to a parameter of an attribute, + /// indicates that this parameter is an MVC action name. /// - /// + /// + /// /// [ActionName("Foo")] /// public ActionResult Login(string returnUrl) { /// ViewBag.ReturnUrl = Url.Action("Foo"); // OK /// return RedirectToAction("Bar"); // Error: Cannot resolve action /// } - /// + /// + /// [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property)] - internal sealed class AspMvcActionSelectorAttribute : Attribute { } + internal sealed class AspMvcActionSelectorAttribute : Attribute + { + } [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.Field)] internal sealed class HtmlElementAttributesAttribute : Attribute { - public HtmlElementAttributesAttribute() { } + public HtmlElementAttributesAttribute() + { + } public HtmlElementAttributesAttribute([NotNull] string name) { Name = name; } - [CanBeNull] public string Name { get; private set; } + [CanBeNull] public string Name { get; } } [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)] @@ -814,20 +956,22 @@ namespace JetBrains.Annotations Name = name; } - [NotNull] public string Name { get; private set; } + [NotNull] public string Name { get; } } /// - /// Razor attribute. Indicates that a parameter or a method is a Razor section. - /// Use this attribute for custom wrappers similar to - /// System.Web.WebPages.WebPageBase.RenderSection(String). + /// Razor attribute. Indicates that a parameter or a method is a Razor section. + /// Use this attribute for custom wrappers similar to + /// System.Web.WebPages.WebPageBase.RenderSection(String). /// [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)] - internal sealed class RazorSectionAttribute : Attribute { } + internal sealed class RazorSectionAttribute : Attribute + { + } /// - /// Indicates how method, constructor invocation or property access - /// over collection type affects content of the collection. + /// Indicates how method, constructor invocation or property access + /// over collection type affects content of the collection. /// [AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor | AttributeTargets.Property)] internal sealed class CollectionAccessAttribute : Attribute @@ -837,7 +981,7 @@ namespace JetBrains.Annotations CollectionAccessType = collectionAccessType; } - public CollectionAccessType CollectionAccessType { get; private set; } + public CollectionAccessType CollectionAccessType { get; } } [Flags] @@ -845,26 +989,31 @@ namespace JetBrains.Annotations { /// Method does not use or modify content of the collection. None = 0, + /// Method only reads content of the collection but does not modify it. Read = 1, + /// Method can change content of the collection but does not add new elements. ModifyExistingContent = 2, + /// Method can add new elements to the collection. UpdatedContent = ModifyExistingContent | 4 } /// - /// Indicates that the marked method is assertion method, i.e. it halts control flow if - /// one of the conditions is satisfied. To set the condition, mark one of the parameters with - /// attribute. + /// Indicates that the marked method is assertion method, i.e. it halts control flow if + /// one of the conditions is satisfied. To set the condition, mark one of the parameters with + /// attribute. /// [AttributeUsage(AttributeTargets.Method)] - internal sealed class AssertionMethodAttribute : Attribute { } + internal sealed class AssertionMethodAttribute : Attribute + { + } /// - /// Indicates the condition parameter of the assertion method. The method itself should be - /// marked by attribute. The mandatory argument of - /// the attribute is the assertion type. + /// Indicates the condition parameter of the assertion method. The method itself should be + /// marked by attribute. The mandatory argument of + /// the attribute is the assertion type. /// [AttributeUsage(AttributeTargets.Parameter)] internal sealed class AssertionConditionAttribute : Attribute @@ -874,81 +1023,98 @@ namespace JetBrains.Annotations ConditionType = conditionType; } - public AssertionConditionType ConditionType { get; private set; } + public AssertionConditionType ConditionType { get; } } /// - /// Specifies assertion type. If the assertion method argument satisfies the condition, - /// then the execution continues. Otherwise, execution is assumed to be halted. + /// Specifies assertion type. If the assertion method argument satisfies the condition, + /// then the execution continues. Otherwise, execution is assumed to be halted. /// internal enum AssertionConditionType { /// Marked parameter should be evaluated to true. IS_TRUE = 0, + /// Marked parameter should be evaluated to false. IS_FALSE = 1, + /// Marked parameter should be evaluated to null value. IS_NULL = 2, + /// Marked parameter should be evaluated to not null value. - IS_NOT_NULL = 3, + IS_NOT_NULL = 3 } /// - /// Indicates that the marked method unconditionally terminates control flow execution. - /// For example, it could unconditionally throw exception. + /// Indicates that the marked method unconditionally terminates control flow execution. + /// For example, it could unconditionally throw exception. /// [Obsolete("Use [ContractAnnotation('=> halt')] instead")] [AttributeUsage(AttributeTargets.Method)] - internal sealed class TerminatesProgramAttribute : Attribute { } + internal sealed class TerminatesProgramAttribute : Attribute + { + } /// - /// Indicates that method is pure LINQ method, with postponed enumeration (like Enumerable.Select, - /// .Where). This annotation allows inference of [InstantHandle] annotation for parameters - /// of delegate type by analyzing LINQ method chains. + /// Indicates that method is pure LINQ method, with postponed enumeration (like Enumerable.Select, + /// .Where). This annotation allows inference of [InstantHandle] annotation for parameters + /// of delegate type by analyzing LINQ method chains. /// [AttributeUsage(AttributeTargets.Method)] - internal sealed class LinqTunnelAttribute : Attribute { } + internal sealed class LinqTunnelAttribute : Attribute + { + } /// - /// Indicates that IEnumerable, passed as parameter, is not enumerated. + /// Indicates that IEnumerable, passed as parameter, is not enumerated. /// [AttributeUsage(AttributeTargets.Parameter)] - internal sealed class NoEnumerationAttribute : Attribute { } + internal sealed class NoEnumerationAttribute : Attribute + { + } /// - /// Indicates that parameter is regular expression pattern. + /// Indicates that parameter is regular expression pattern. /// [AttributeUsage(AttributeTargets.Parameter)] - internal sealed class RegexPatternAttribute : Attribute { } + internal sealed class RegexPatternAttribute : Attribute + { + } /// - /// Prevents the Member Reordering feature from tossing members of the marked class. + /// Prevents the Member Reordering feature from tossing members of the marked class. /// /// - /// The attribute must be mentioned in your member reordering patterns + /// The attribute must be mentioned in your member reordering patterns /// [AttributeUsage( - AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.Struct | AttributeTargets.Enum)] - internal sealed class NoReorderAttribute : Attribute { } + AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.Struct | AttributeTargets.Enum)] + internal sealed class NoReorderAttribute : Attribute + { + } /// - /// XAML attribute. Indicates the type that has ItemsSource property and should be treated - /// as ItemsControl-derived type, to enable inner items DataContext type resolve. + /// XAML attribute. Indicates the type that has ItemsSource property and should be treated + /// as ItemsControl-derived type, to enable inner items DataContext type resolve. /// [AttributeUsage(AttributeTargets.Class)] - internal sealed class XamlItemsControlAttribute : Attribute { } + internal sealed class XamlItemsControlAttribute : Attribute + { + } /// - /// XAML attribute. Indicates the property of some BindingBase-derived type, that - /// is used to bind some item of ItemsControl-derived type. This annotation will - /// enable the DataContext type resolve for XAML bindings for such properties. + /// XAML attribute. Indicates the property of some BindingBase-derived type, that + /// is used to bind some item of ItemsControl-derived type. This annotation will + /// enable the DataContext type resolve for XAML bindings for such properties. /// /// - /// Property should have the tree ancestor of the ItemsControl type or - /// marked with the attribute. + /// Property should have the tree ancestor of the ItemsControl type or + /// marked with the attribute. /// [AttributeUsage(AttributeTargets.Property)] - internal sealed class XamlItemBindingOfItemsControlAttribute : Attribute { } + internal sealed class XamlItemBindingOfItemsControlAttribute : Attribute + { + } [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] internal sealed class AspChildControlTypeAttribute : Attribute @@ -959,19 +1125,25 @@ namespace JetBrains.Annotations ControlType = controlType; } - [NotNull] public string TagName { get; private set; } + [NotNull] public string TagName { get; } - [NotNull] public Type ControlType { get; private set; } + [NotNull] public Type ControlType { get; } } [AttributeUsage(AttributeTargets.Property | AttributeTargets.Method)] - internal sealed class AspDataFieldAttribute : Attribute { } + internal sealed class AspDataFieldAttribute : Attribute + { + } [AttributeUsage(AttributeTargets.Property | AttributeTargets.Method)] - internal sealed class AspDataFieldsAttribute : Attribute { } + internal sealed class AspDataFieldsAttribute : Attribute + { + } [AttributeUsage(AttributeTargets.Property)] - internal sealed class AspMethodPropertyAttribute : Attribute { } + internal sealed class AspMethodPropertyAttribute : Attribute + { + } [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] internal sealed class AspRequiredAttributeAttribute : Attribute @@ -981,18 +1153,18 @@ namespace JetBrains.Annotations Attribute = attribute; } - [NotNull] public string Attribute { get; private set; } + [NotNull] public string Attribute { get; } } [AttributeUsage(AttributeTargets.Property)] internal sealed class AspTypePropertyAttribute : Attribute { - public bool CreateConstructorReferences { get; private set; } - public AspTypePropertyAttribute(bool createConstructorReferences) { CreateConstructorReferences = createConstructorReferences; } + + public bool CreateConstructorReferences { get; } } [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] @@ -1003,7 +1175,7 @@ namespace JetBrains.Annotations Name = name; } - [NotNull] public string Name { get; private set; } + [NotNull] public string Name { get; } } [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] @@ -1015,9 +1187,9 @@ namespace JetBrains.Annotations FieldName = fieldName; } - [NotNull] public string Type { get; private set; } + [NotNull] public string Type { get; } - [NotNull] public string FieldName { get; private set; } + [NotNull] public string FieldName { get; } } [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] @@ -1028,7 +1200,7 @@ namespace JetBrains.Annotations Directive = directive; } - [NotNull] public string Directive { get; private set; } + [NotNull] public string Directive { get; } } [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] @@ -1038,28 +1210,39 @@ namespace JetBrains.Annotations { BaseType = baseType; } + public RazorPageBaseTypeAttribute([NotNull] string baseType, string pageName) { BaseType = baseType; PageName = pageName; } - [NotNull] public string BaseType { get; private set; } - [CanBeNull] public string PageName { get; private set; } + [NotNull] public string BaseType { get; } + [CanBeNull] public string PageName { get; } } [AttributeUsage(AttributeTargets.Method)] - internal sealed class RazorHelperCommonAttribute : Attribute { } + internal sealed class RazorHelperCommonAttribute : Attribute + { + } [AttributeUsage(AttributeTargets.Property)] - internal sealed class RazorLayoutAttribute : Attribute { } + internal sealed class RazorLayoutAttribute : Attribute + { + } [AttributeUsage(AttributeTargets.Method)] - internal sealed class RazorWriteLiteralMethodAttribute : Attribute { } + internal sealed class RazorWriteLiteralMethodAttribute : Attribute + { + } [AttributeUsage(AttributeTargets.Method)] - internal sealed class RazorWriteMethodAttribute : Attribute { } + internal sealed class RazorWriteMethodAttribute : Attribute + { + } [AttributeUsage(AttributeTargets.Parameter)] - internal sealed class RazorWriteMethodParameterAttribute : Attribute { } -} \ No newline at end of file + internal sealed class RazorWriteMethodParameterAttribute : Attribute + { + } +} diff --git a/GeneratorCode/Properties/AssemblyInfo.cs b/GeneratorCode/Properties/AssemblyInfo.cs index 8e416cf..de2d561 100644 --- a/GeneratorCode/Properties/AssemblyInfo.cs +++ b/GeneratorCode/Properties/AssemblyInfo.cs @@ -1,5 +1,4 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // 有关程序集的一般信息由以下 diff --git a/GeneratorCode/TmatrixSDK/OIDPublishImageGenerator.cs b/GeneratorCode/TmatrixSDK/OIDPublishImageGenerator.cs index c2ce1c5..cd2a1c5 100644 --- a/GeneratorCode/TmatrixSDK/OIDPublishImageGenerator.cs +++ b/GeneratorCode/TmatrixSDK/OIDPublishImageGenerator.cs @@ -1,7 +1,7 @@ +using System.Runtime.InteropServices; + namespace OIDModule.Generator { - using System; - using System.Runtime.InteropServices; internal enum OIDBeginBuildState { eBBState_OK, @@ -9,17 +9,20 @@ namespace OIDModule.Generator eBBState_FailToOpenImageFile, eBBState_Unknown } + internal enum OIDPrintPointType { eOID_PrintPointType_2x2, eOID_PrintPointType_3x3, eOID_PrintPointType_4x4 } + internal enum OIDPublishImageDPIType { eOID_PublishImageDPI_600, eOID_PublishImageDPI_1200 } + internal enum OIDPublishImageType { eOID_PIT_Publish_Image, @@ -27,6 +30,7 @@ namespace OIDModule.Generator eOID_PIT_BG_Vertor_Image, eOID_PIT_Publish_BG_Image } + internal enum OIDPublishObjectType { eOID_OT_ElementCode, @@ -35,64 +39,90 @@ namespace OIDModule.Generator internal class OIDPublishImageGenerator { - public bool AddObjectInfo(int nPageIndex, ulong uiObjectIndex, uint[] arPointX, uint[] arPointY, int nPointsCount, int nZOrder, int nObjectType) + public bool AddObjectInfo(int nPageIndex, ulong uiObjectIndex, uint[] arPointX, uint[] arPointY, + int nPointsCount, int nZOrder, int nObjectType) { - return OID_PIG_AddObjectInfo(nPageIndex, uiObjectIndex, arPointX, arPointY, nPointsCount, nZOrder, nObjectType); + return OID_PIG_AddObjectInfo(nPageIndex, uiObjectIndex, arPointX, arPointY, nPointsCount, nZOrder, + nObjectType); } - + public int BeginBuildPublishImage(char[] szBGImage, bool bExportPDFImage, int nExportPDFImageDPI) { return OID_PIG_BeginBuildPublishImage(szBGImage, bExportPDFImage, nExportPDFImageDPI); } - + public int BeginBuildPublishImageByInfo(double dbCMWidth, double dbCMHeight) { return OID_PIG_BeginBuildPublishImageByInfo(dbCMWidth, dbCMHeight); } - - public bool BuildPublishImage(char[] szOutputFolderPath, bool bPrintIdleCode, bool bSplitBigImage, bool bMergeSplittedImages, int nPublishImageDPIType, int nPrintPointType, int nPublishImageType) + + public bool BuildPublishImage(char[] szOutputFolderPath, bool bPrintIdleCode, bool bSplitBigImage, + bool bMergeSplittedImages, int nPublishImageDPIType, int nPrintPointType, int nPublishImageType) { - return OID_PIG_BuildPublishImage(szOutputFolderPath, bPrintIdleCode, bSplitBigImage, bMergeSplittedImages, nPublishImageDPIType, nPrintPointType, nPublishImageType); + return OID_PIG_BuildPublishImage(szOutputFolderPath, bPrintIdleCode, bSplitBigImage, bMergeSplittedImages, + nPublishImageDPIType, nPrintPointType, nPublishImageType); } - + public void EndBuildPublishImage() { OID_PIG_EndBuildPublishImage(); } - + public bool Initialize() { return OID_PIG_Initialize(); } - - [DllImport(@".\OIDPublishImageGenerator\OIDPublishImageGenerator.dll", CallingConvention=CallingConvention.StdCall)] - private static extern bool OID_PIG_AddObjectInfo(int nPageIndex, ulong uiObjectIndex, uint[] arPointX, uint[] arPointY, int nPointsCount, int nZOrder, int nObjectType); - [DllImport(@".\OIDPublishImageGenerator\OIDPublishImageGenerator.dll", CallingConvention=CallingConvention.StdCall, CharSet=CharSet.Unicode)] - private static extern int OID_PIG_BeginBuildPublishImage(char[] szBGImage, bool bExportPDFImage, int nExportPDFImageDPI); - [DllImport(@".\OIDPublishImageGenerator\OIDPublishImageGenerator.dll", CallingConvention=CallingConvention.StdCall, CharSet=CharSet.Unicode)] + + [DllImport(@".\OIDPublishImageGenerator\OIDPublishImageGenerator.dll", CallingConvention = + CallingConvention.StdCall)] + private static extern bool OID_PIG_AddObjectInfo(int nPageIndex, ulong uiObjectIndex, uint[] arPointX, + uint[] arPointY, int nPointsCount, int nZOrder, int nObjectType); + + [DllImport(@".\OIDPublishImageGenerator\OIDPublishImageGenerator.dll", + CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Unicode)] + private static extern int OID_PIG_BeginBuildPublishImage(char[] szBGImage, bool bExportPDFImage, + int nExportPDFImageDPI); + + [DllImport(@".\OIDPublishImageGenerator\OIDPublishImageGenerator.dll", + CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Unicode)] private static extern int OID_PIG_BeginBuildPublishImageByInfo(double dbCMWidth, double dbCMHeight); - [DllImport(@".\OIDPublishImageGenerator\OIDPublishImageGenerator.dll", CallingConvention=CallingConvention.StdCall, CharSet=CharSet.Unicode)] - private static extern bool OID_PIG_BuildPublishImage(char[] szOutputFolderPath, bool bPrintIdleCode, bool bSplitBigImage, bool bMergeSplittedImages, int nPublishImageDPIType, int nPrintPointType, int nPublishImageType); - [DllImport(@".\OIDPublishImageGenerator\OIDPublishImageGenerator.dll", CallingConvention=CallingConvention.StdCall)] + + [DllImport(@".\OIDPublishImageGenerator\OIDPublishImageGenerator.dll", + CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Unicode)] + private static extern bool OID_PIG_BuildPublishImage(char[] szOutputFolderPath, bool bPrintIdleCode, + bool bSplitBigImage, bool bMergeSplittedImages, int nPublishImageDPIType, int nPrintPointType, + int nPublishImageType); + + [DllImport(@".\OIDPublishImageGenerator\OIDPublishImageGenerator.dll", CallingConvention = + CallingConvention.StdCall)] private static extern void OID_PIG_EndBuildPublishImage(); - [DllImport(@".\OIDPublishImageGenerator\OIDPublishImageGenerator.dll", CallingConvention=CallingConvention.StdCall)] + + [DllImport(@".\OIDPublishImageGenerator\OIDPublishImageGenerator.dll", CallingConvention = + CallingConvention.StdCall)] private static extern bool OID_PIG_Initialize(); - [DllImport(@".\OIDPublishImageGenerator\OIDPublishImageGenerator.dll", CallingConvention=CallingConvention.StdCall)] + + [DllImport(@".\OIDPublishImageGenerator\OIDPublishImageGenerator.dll", CallingConvention = + CallingConvention.StdCall)] private static extern bool OID_PIG_SetPublishPages(int[] arPageNumbers, int nPageCount); - [DllImport(@".\OIDPublishImageGenerator\OIDPublishImageGenerator.dll", CallingConvention=CallingConvention.StdCall)] + + [DllImport(@".\OIDPublishImageGenerator\OIDPublishImageGenerator.dll", CallingConvention = + CallingConvention.StdCall)] private static extern bool OID_PIG_SetStartPosition(int nPageIndex, int nXStart, int nYStart); - [DllImport(@".\OIDPublishImageGenerator\OIDPublishImageGenerator.dll", CallingConvention=CallingConvention.StdCall)] + + [DllImport(@".\OIDPublishImageGenerator\OIDPublishImageGenerator.dll", CallingConvention = + CallingConvention.StdCall)] private static extern void OID_PIG_Uninitialize(); + public bool SetPublishPages(int[] arPageNumbers, int nPageCount) { return OID_PIG_SetPublishPages(arPageNumbers, nPageCount); } - + public bool SetStartPosition(int nPageIndex, int nXStart, int nYStart) { return OID_PIG_SetStartPosition(nPageIndex, nXStart, nYStart); } - + public void Uninitialize() { OID_PIG_Uninitialize(); diff --git a/GeneratorCode/TmatrixSDK/TmatrixClass.cs b/GeneratorCode/TmatrixSDK/TmatrixClass.cs index fafd901..4dc06d7 100644 --- a/GeneratorCode/TmatrixSDK/TmatrixClass.cs +++ b/GeneratorCode/TmatrixSDK/TmatrixClass.cs @@ -1,43 +1,43 @@ +using System; using System.Collections.Generic; +using System.Drawing; +using System.IO; +using iTextSharp.text.pdf; +using OIDModule.Generator; namespace TmatrixLibrary { - using iTextSharp.text.pdf; - using OIDModule.Generator; - using System; - using System.Drawing; - using System.IO; - using System.Windows.Forms; - public class TmatrixClass { - private bool gbKeyValidate; - private string gsSize; - private string gsBID; - private string gsPID1; - private string gsPID2; - private string gsExpiration; - private string gsSID; - private string gsOID; - private int gSID; - private int gOID; + public delegate void ProgressChangedEvent(int step); + + private readonly int Default_DPI = 300; private int gBID; + private bool gbKeyValidate; + private int gCurPageIndex; + private int gCurrentPageID; + private int gOID; + private int gPageNum; private int gPID1; private int gPID2; - private int gTotalPageID; - private int gCurrentPageID; - private int gPageNum; - private string[] gTPDFName = new string[0x100]; - private string[] gTPDFVIName = new string[0x100]; - private string[] gTPDFWOVIName = new string[0x100]; - private string[] gTPDFBGIName = new string[0x100]; private string gPointType = ""; - private string[] gsPointType = new string[4]; - private string[] gsPointDPI = new string[4]; - private int gCurPageIndex; - private int Default_DPI = 300; - private OIDPublishImageGenerator oidPIGenerator = new OIDPublishImageGenerator(); + private string gsBID; + private string gsExpiration; + private int gSID; + private string gsOID; + private string gsPID1; + private string gsPID2; + private readonly string[] gsPointDPI = new string[4]; + private readonly string[] gsPointType = new string[4]; + private string gsSID; + private string gsSize; private int gStep; + private int gTotalPageID; + private readonly string[] gTPDFBGIName = new string[0x100]; + private readonly string[] gTPDFName = new string[0x100]; + private readonly string[] gTPDFVIName = new string[0x100]; + private readonly string[] gTPDFWOVIName = new string[0x100]; + private readonly OIDPublishImageGenerator oidPIGenerator = new OIDPublishImageGenerator(); public int GetProgerss() { @@ -52,40 +52,35 @@ namespace TmatrixLibrary OnProgressChanged(gStep); } } - - public delegate void ProgressChangedEvent(int step); public event ProgressChangedEvent ProgressChange; protected virtual void OnProgressChanged(int step) { if (ProgressChange != null) - { ProgressChange(step); - } else - { - ProgressChange (-1); - } + ProgressChange(-1); } private bool IsKeyValidate() { - return this.gbKeyValidate; + return gbKeyValidate; } private bool CheckExpirationValidate(string dstr) { - string[] strArray = dstr.Substring(1, dstr.Length - 1).Split(new char[] { '/' }); - int num = int.Parse(strArray[0]); - int num2 = int.Parse(strArray[1]); - int num3 = int.Parse(strArray[2]); - DateTime today = DateTime.Today; - int year = today.Year; - int month = today.Month; - int day = today.Day; - return ((year <= num) ? ((year != num) || ((month <= num2) ? ((month != num2) || (day <= num3)) : false)) : false); + var strArray = dstr.Substring(1, dstr.Length - 1).Split('/'); + var num = int.Parse(strArray[0]); + var num2 = int.Parse(strArray[1]); + var num3 = int.Parse(strArray[2]); + var today = DateTime.Today; + var year = today.Year; + var month = today.Month; + var day = today.Day; + return year <= num ? year != num || (month <= num2 ? month != num2 || day <= num3 : false) : false; } + private string CheckOidBuildState(OIDBeginBuildState eBeginBuildState) { switch (eBeginBuildState) @@ -113,236 +108,229 @@ namespace TmatrixLibrary public string DecodeLicense_TmatrixKey(string KeyStr) { - char[] chArray = new char[80]; - char[] chArray2 = new char[80]; - string str = ""; - long num5 = 1L; + var chArray = new char[80]; + var chArray2 = new char[80]; + var str = ""; + var num5 = 1L; chArray = KeyStr.ToCharArray(); - int length = KeyStr.Length; - long num4 = 0L; - for (long i = 0L; i < length; i += 1L) + var length = KeyStr.Length; + var num4 = 0L; + + for (var i = 0L; i < length; i += 1L) { - long num3 = Convert.ToByte(chArray[(int) ((IntPtr) i)]); - if (i > 1L) - { - num4 = Convert.ToByte(chArray[(int) ((IntPtr) ((length + 1) - i))]); - } - num3 = ((((((num3 * 2L) + (num5 * 2L)) + num4) * (i + num5)) + (num5 * i)) - 12) % ((long) 0x24); - if ((num3 < 0L) || (num3 > 9)) - { - chArray2[(int) ((IntPtr) i)] = Convert.ToChar((long) (num3 + 0x37)); - } + long num3 = Convert.ToByte(chArray[(int) (IntPtr) i]); + if (i > 1L) num4 = Convert.ToByte(chArray[(int) (IntPtr) (length + 1 - i)]); + num3 = ((num3 * 2L + num5 * 2L + num4) * (i + num5) + num5 * i - 12) % 0x24; + if (num3 < 0L || num3 > 9) + chArray2[(int) (IntPtr) i] = Convert.ToChar(num3 + 0x37); else - { - chArray2[(int) ((IntPtr) i)] = Convert.ToChar((long) (num3 + 0x30)); - } - num5 = (num3 * num3) * i; - str = str + chArray2[(int) ((IntPtr) i)].ToString(); + chArray2[(int) (IntPtr) i] = Convert.ToChar(num3 + 0x30); + num5 = num3 * num3 * i; + str = str + chArray2[(int) (IntPtr) i]; } + return str; } - - public string GenerateTmatrixBigAreaCode_OID4(string KeyStr, string sPath, int StartPageID, int[] PointType, bool[] bPublishImageType, int[] PointDPI, double dWidth, double dHeight) + + public string GenerateTmatrixBigAreaCode_OID4(string KeyStr, string sPath, int StartPageID, int[] PointType, + bool[] bPublishImageType, int[] PointDPI, double dWidth, double dHeight) { - string str = ""; - str = this.TmatrixKeyCheck_OID4(KeyStr); - if (str.Substring(0, 1) == "1") + var str = ""; + str = TmatrixKeyCheck_OID4(KeyStr); + if (str.Substring(0, 1) == "1") return str; + + if (StartPageID < int.Parse(gsPID1) || StartPageID > int.Parse(gsPID2)) + return "1Start page ID must be located between " + gsPID1 + " ~ " + gsPID2; + var flag1 = bPublishImageType[0]; + var bGenerateVImage = bPublishImageType[1]; + var flag6 = bPublishImageType[2]; + var bGenerateImage = bPublishImageType[3]; + gTotalPageID = StartPageID; + var nPageIndex = 0; + var nXStart = 0; + var nYStart = 0; + var bPrintIdleCode = false; + + for (var i = 0; i < 4; i++) { - return str; - } - if ((StartPageID < int.Parse(this.gsPID1)) || (StartPageID > int.Parse(this.gsPID2))) - { - return ("1Start page ID must be located between " + this.gsPID1 + " ~ " + this.gsPID2); - } - bool flag1 = bPublishImageType[0]; - bool bGenerateVImage = bPublishImageType[1]; - bool flag6 = bPublishImageType[2]; - bool bGenerateImage = bPublishImageType[3]; - this.gTotalPageID = StartPageID; - int nPageIndex = 0; - int nXStart = 0; - int nYStart = 0; - bool bPrintIdleCode = false; - for (int i = 0; i < 4; i++) - { - int num24 = PointType[i]; + var num24 = PointType[i]; + switch (num24) { case 0: - this.gsPointType[i] = "2"; + gsPointType[i] = "2"; break; - + case 1: - this.gsPointType[i] = "3"; + gsPointType[i] = "3"; break; - + case 2: - this.gsPointType[i] = "4"; - break; - - default: + gsPointType[i] = "4"; break; } + switch (PointDPI[i]) { case 0: - this.gsPointDPI[i] = "D600"; + gsPointDPI[i] = "D600"; break; - + case 1: - this.gsPointDPI[i] = "D1200"; - break; - - default: + gsPointDPI[i] = "D1200"; break; } } - this.gCurrentPageID = this.gTotalPageID; - this.gCurPageIndex = 0; - string str2 = sPath + @"\BA_.pdf"; - string str3 = sPath + @"\BA_VI_.pdf"; + + gCurrentPageID = gTotalPageID; + gCurPageIndex = 0; + var str2 = sPath + @"\BA_.pdf"; + var str3 = sPath + @"\BA_VI_.pdf"; sPath = sPath + @"\BA_WOVI_.pdf"; - string str4 = sPath + @"\BA_Im_.tif"; - OIDBeginBuildState eBeginBuildState = OIDBeginBuildState.eBBState_OK; - eBeginBuildState = (OIDBeginBuildState) this.oidPIGenerator.BeginBuildPublishImageByInfo(dWidth / 10.0, dHeight / 10.0); - this.CheckOidBuildState(eBeginBuildState); - if ((eBeginBuildState == OIDBeginBuildState.eBBState_OK) && (bGenerateVImage || bGenerateImage)) + var str4 = sPath + @"\BA_Im_.tif"; + var eBeginBuildState = OIDBeginBuildState.eBBState_OK; + eBeginBuildState = + (OIDBeginBuildState) oidPIGenerator.BeginBuildPublishImageByInfo(dWidth / 10.0, dHeight / 10.0); + CheckOidBuildState(eBeginBuildState); + + if (eBeginBuildState == OIDBeginBuildState.eBBState_OK && (bGenerateVImage || bGenerateImage)) { - int num4 = this.gSID % 2; - int num5 = this.gSID / 2; - int num6 = this.gOID % 0x10; - int num7 = this.gOID / 0x10; - int num10 = this.gCurrentPageID % 0x10; - int num11 = this.gCurrentPageID / 0x10; - int num12 = 0; - int num13 = 0; - int num14 = 0; - int num15 = 0; + var num4 = this.gSID % 2; + var num5 = this.gSID / 2; + var num6 = gOID % 0x10; + var num7 = gOID / 0x10; + var num10 = gCurrentPageID % 0x10; + var num11 = gCurrentPageID / 0x10; + var num12 = 0; + var num13 = 0; + var num14 = 0; + var num15 = 0; + switch (this.gSID) { case 0: case 1: case 2: - num12 = (this.gBID % 0x20) << 13; - num13 = (this.gBID / 0x20) << 13; + num12 = (gBID % 0x20) << 13; + num13 = (gBID / 0x20) << 13; num14 = num10 << 9; num15 = num11 << 9; break; - + case 3: - num12 = (this.gBID % 4) << 0x10; - num13 = (this.gBID / 4) << 0x10; + num12 = (gBID % 4) << 0x10; + num13 = (gBID / 4) << 0x10; num14 = num10 << 12; num15 = num11 << 12; break; - - default: - break; } - nXStart = (((num4 << 0x16) + (num6 << 0x12)) + num12) + num14; - nYStart = (((num5 << 0x16) + (num7 << 0x12)) + num13) + num15; + + nXStart = (num4 << 0x16) + (num6 << 0x12) + num12 + num14; + nYStart = (num5 << 0x16) + (num7 << 0x12) + num13 + num15; + while (true) { - if (!this.oidPIGenerator.SetStartPosition(nPageIndex, nXStart, nYStart)) + if (!oidPIGenerator.SetStartPosition(nPageIndex, nXStart, nYStart)) { string str5; + if (bGenerateVImage) { str5 = str3; - this.oidPIGenerator.BuildPublishImage(str5.ToCharArray(), bPrintIdleCode, true, true, PointDPI[1], PointType[1], 1); + oidPIGenerator.BuildPublishImage(str5.ToCharArray(), bPrintIdleCode, true, true, + PointDPI[1], PointType[1], 1); } + if (bGenerateImage) { str5 = str4; - this.gTPDFBGIName[0] = str4; - this.oidPIGenerator.BuildPublishImage(str5.ToCharArray(), bPrintIdleCode, true, true, PointDPI[3], PointType[3], 0); + gTPDFBGIName[0] = str4; + oidPIGenerator.BuildPublishImage(str5.ToCharArray(), bPrintIdleCode, true, true, + PointDPI[3], PointType[3], 0); } - this.gCurPageIndex++; - this.oidPIGenerator.EndBuildPublishImage(); + + gCurPageIndex++; + oidPIGenerator.EndBuildPublishImage(); break; } - uint num22 = (uint) ((dWidth * 75.0) / 25.4); - uint num23 = (uint) ((dHeight * 75.0) / 25.4); - int gSID = this.gSID; + + var num22 = (uint) (dWidth * 75.0 / 25.4); + var num23 = (uint) (dHeight * 75.0 / 25.4); + var gSID = this.gSID; + switch (gSID) { case 0: case 1: case 2: - if ((dWidth <= 780.0) && (dHeight <= 780.0)) - { - break; - } + if (dWidth <= 780.0 && dHeight <= 780.0) break; return "1PDF page size's width or height > 780mm !"; - + case 3: - if ((dWidth <= 6242.0) && (dHeight <= 6242.0)) - { - break; - } + if (dWidth <= 6242.0 && dHeight <= 6242.0) break; return "1PDF page size's width or height > 6242mm !"; - - default: - break; } - uint[] numArray3 = new uint[5]; + + var numArray3 = new uint[5]; numArray3[1] = 0x1372; numArray3[2] = 0x1372; - uint[] arPointX = numArray3; - uint[] numArray4 = new uint[5]; + var arPointX = numArray3; + var numArray4 = new uint[5]; numArray4[2] = 0x1a5d; numArray4[3] = 0x1a5d; - uint[] arPointY = numArray4; + var arPointY = numArray4; arPointX[1] = num22; arPointX[2] = num22; arPointY[2] = num23; arPointY[3] = num23; - this.oidPIGenerator.AddObjectInfo(nPageIndex, 0xffffffffUL, arPointX, arPointY, 4, 0, 1); - this.gTPDFName[nPageIndex] = str2; - this.gTPDFVIName[nPageIndex] = str3; - this.gTPDFBGIName[nPageIndex] = str4; + oidPIGenerator.AddObjectInfo(nPageIndex, 0xffffffffUL, arPointX, arPointY, 4, 0, 1); + gTPDFName[nPageIndex] = str2; + gTPDFVIName[nPageIndex] = str3; + gTPDFBGIName[nPageIndex] = str4; nPageIndex++; - this.gCurrentPageID++; + gCurrentPageID++; num4 = this.gSID % 2; num5 = this.gSID / 2; - num6 = this.gOID % 0x10; - num7 = this.gOID / 0x10; - num10 = this.gCurrentPageID % 0x10; - num11 = this.gCurrentPageID / 0x10; + num6 = gOID % 0x10; + num7 = gOID / 0x10; + num10 = gCurrentPageID % 0x10; + num11 = gCurrentPageID / 0x10; num12 = 0; num13 = 0; num14 = 0; num15 = 0; + switch (this.gSID) { case 0: case 1: case 2: - num12 = (this.gBID % 0x20) << 13; - num13 = (this.gBID / 0x20) << 13; + num12 = (gBID % 0x20) << 13; + num13 = (gBID / 0x20) << 13; num14 = num10 << 9; num15 = num11 << 9; break; - + case 3: - num12 = (this.gBID % 4) << 0x10; - num13 = (this.gBID / 4) << 0x10; + num12 = (gBID % 4) << 0x10; + num13 = (gBID / 4) << 0x10; num14 = num10 << 12; num15 = num11 << 12; break; - - default: - break; } - nXStart = (((num4 << 0x16) + (num6 << 0x12)) + num12) + num14; - nYStart = (((num5 << 0x16) + (num7 << 0x12)) + num13) + num15; + + nXStart = (num4 << 0x16) + (num6 << 0x12) + num12 + num14; + nYStart = (num5 << 0x16) + (num7 << 0x12) + num13 + num15; } } - string str6 = this.RenameBigAreaTmatrixPDF_OID4(StartPageID, this.gsSID, this.gsOID, this.gsBID, bGenerateVImage, bGenerateImage, dWidth / 10.0, dHeight / 10.0); - return ("0Generate code completely" + str6); + + var str6 = RenameBigAreaTmatrixPDF_OID4(StartPageID, gsSID, gsOID, gsBID, bGenerateVImage, bGenerateImage, + dWidth / 10.0, dHeight / 10.0); + return "0Generate code completely" + str6; } - - public string GenerateTmatrixCode(string KeyStr, string PDFFileName, int StartPageID, int PointType, bool bGenerateBGWithVImage, bool bGenerateVImage, bool bGenerateBGWithoutVImage) + + public string GenerateTmatrixCode(string KeyStr, string PDFFileName, int StartPageID, int PointType, + bool bGenerateBGWithVImage, bool bGenerateVImage, bool bGenerateBGWithoutVImage) { int num4; int num5; @@ -354,588 +342,267 @@ namespace TmatrixLibrary int num13; int num14; int num15; - string str = ""; - str = this.TmatrixKeyCheck_OID4(KeyStr); - if (str.Substring(0, 1) == "1") - { - return str; - } - if (PDFFileName == "") - { - return "1Please select PDF file first !"; - } - if ((StartPageID < int.Parse(this.gsPID1)) || (StartPageID > int.Parse(this.gsPID2))) - { - return ("1Start page ID must be located between " + this.gsPID1 + " ~ " + this.gsPID2); - } - this.gPageNum = this.GetPDFPageNumber(PDFFileName); - if (((this.gPageNum + StartPageID) - 1) > int.Parse(this.gsPID2)) - { + var str = ""; + str = TmatrixKeyCheck_OID4(KeyStr); + if (str.Substring(0, 1) == "1") return str; + + if (PDFFileName == "") return "1Please select PDF file first !"; + + if (StartPageID < int.Parse(gsPID1) || StartPageID > int.Parse(gsPID2)) + return "1Start page ID must be located between " + gsPID1 + " ~ " + gsPID2; + gPageNum = GetPDFPageNumber(PDFFileName); + if (gPageNum + StartPageID - 1 > int.Parse(gsPID2)) return "1Not enough code page for this PDF to generate !"; - } - this.gTotalPageID = StartPageID; - int nPageIndex = 0; - int nXStart = 0; - int nYStart = 0; - bool bPrintIdleCode = false; - bool bSplitBigImage = false; - bool bMergeSplittedImages = false; - bool bExportPDFImage = true; - int nPublishImageDPIType = 0; - this.gCurrentPageID = this.gTotalPageID; - this.gCurPageIndex = 0; - string str2 = PDFFileName; - string str3 = str2.Substring(0, str2.Length - 4) + "_.pdf"; - string str4 = str2.Substring(0, str2.Length - 4) + "_VI_.pdf"; - string str5 = str2.Substring(0, str2.Length - 4) + "_WOVI_.pdf"; - OIDBeginBuildState eBeginBuildState = OIDBeginBuildState.eBBState_OK; - eBeginBuildState = (OIDBeginBuildState) this.oidPIGenerator.BeginBuildPublishImage(str2.ToCharArray(), bExportPDFImage, this.Default_DPI); - this.CheckOidBuildState(eBeginBuildState); - if ((eBeginBuildState == OIDBeginBuildState.eBBState_OK) && (bGenerateBGWithVImage || bGenerateVImage)) + gTotalPageID = StartPageID; + var nPageIndex = 0; + var nXStart = 0; + var nYStart = 0; + var bPrintIdleCode = false; + var bSplitBigImage = false; + var bMergeSplittedImages = false; + var bExportPDFImage = true; + var nPublishImageDPIType = 0; + gCurrentPageID = gTotalPageID; + gCurPageIndex = 0; + var str2 = PDFFileName; + var str3 = str2.Substring(0, str2.Length - 4) + "_.pdf"; + var str4 = str2.Substring(0, str2.Length - 4) + "_VI_.pdf"; + var str5 = str2.Substring(0, str2.Length - 4) + "_WOVI_.pdf"; + var eBeginBuildState = OIDBeginBuildState.eBBState_OK; + eBeginBuildState = + (OIDBeginBuildState) oidPIGenerator.BeginBuildPublishImage(str2.ToCharArray(), bExportPDFImage, + Default_DPI); + CheckOidBuildState(eBeginBuildState); + + if (eBeginBuildState == OIDBeginBuildState.eBBState_OK && (bGenerateBGWithVImage || bGenerateVImage)) { - num4 = this.gSID % 2; - num5 = this.gSID / 2; - num6 = this.gOID % 0x10; - num7 = this.gOID / 0x10; - num10 = this.gCurrentPageID % 0x10; - num11 = this.gCurrentPageID / 0x10; + num4 = gSID % 2; + num5 = gSID / 2; + num6 = gOID % 0x10; + num7 = gOID / 0x10; + num10 = gCurrentPageID % 0x10; + num11 = gCurrentPageID / 0x10; num12 = 0; num13 = 0; num14 = 0; num15 = 0; - switch (this.gSID) + + switch (gSID) { case 0: case 1: case 2: - num12 = (this.gBID % 0x20) << 13; - num13 = (this.gBID / 0x20) << 13; + num12 = (gBID % 0x20) << 13; + num13 = (gBID / 0x20) << 13; num14 = num10 << 9; num15 = num11 << 9; break; - + case 3: - num12 = (this.gBID % 4) << 0x10; - num13 = (this.gBID / 4) << 0x10; + num12 = (gBID % 4) << 0x10; + num13 = (gBID / 4) << 0x10; num14 = num10 << 12; num15 = num11 << 12; break; - - default: - break; } - nXStart = (((num4 << 0x16) + (num6 << 0x12)) + num12) + num14; - nYStart = (((num5 << 0x16) + (num7 << 0x12)) + num13) + num15; + + nXStart = (num4 << 0x16) + (num6 << 0x12) + num12 + num14; + nYStart = (num5 << 0x16) + (num7 << 0x12) + num13 + num15; + while (true) { - if (!this.oidPIGenerator.SetStartPosition(nPageIndex, nXStart, nYStart)) + if (!oidPIGenerator.SetStartPosition(nPageIndex, nXStart, nYStart)) { - this.gPointType = (PointType != 1) ? "2" : "3"; + gPointType = PointType != 1 ? "2" : "3"; if (bGenerateBGWithVImage) - { - this.oidPIGenerator.BuildPublishImage(str3.ToCharArray(), bPrintIdleCode, bSplitBigImage, bMergeSplittedImages, 1, PointType, 2); - } + oidPIGenerator.BuildPublishImage(str3.ToCharArray(), bPrintIdleCode, bSplitBigImage, + bMergeSplittedImages, 1, PointType, 2); + if (bGenerateVImage) { nPublishImageDPIType = 1; - this.oidPIGenerator.BuildPublishImage(str4.ToCharArray(), bPrintIdleCode, bSplitBigImage, bMergeSplittedImages, nPublishImageDPIType, PointType, 1); + oidPIGenerator.BuildPublishImage(str4.ToCharArray(), bPrintIdleCode, bSplitBigImage, + bMergeSplittedImages, nPublishImageDPIType, PointType, 1); } - this.gCurPageIndex++; - this.oidPIGenerator.EndBuildPublishImage(); + + gCurPageIndex++; + oidPIGenerator.EndBuildPublishImage(); break; } - string filename = str2.Substring(0, str2.Length - 4) + "_Page" + nPageIndex.ToString() + ".png"; - Image image = Image.FromFile(filename); - uint num21 = (uint) (image.Width + 0x48); - uint num22 = (uint) (image.Height + 0x48); + + var filename = str2.Substring(0, str2.Length - 4) + "_Page" + nPageIndex + ".png"; + var image = Image.FromFile(filename); + var num21 = (uint) (image.Width + 0x48); + var num22 = (uint) (image.Height + 0x48); image.Dispose(); - uint[] numArray3 = new uint[5]; + var numArray3 = new uint[5]; numArray3[1] = 0x1372; numArray3[2] = 0x1372; - uint[] arPointX = numArray3; - uint[] numArray4 = new uint[5]; + var arPointX = numArray3; + var numArray4 = new uint[5]; numArray4[2] = 0x1a5d; numArray4[3] = 0x1a5d; - uint[] arPointY = numArray4; + var arPointY = numArray4; arPointX[1] = num21; arPointX[2] = num21; arPointY[2] = num22; arPointY[3] = num22; - this.oidPIGenerator.AddObjectInfo(nPageIndex, 0xffffffffUL, arPointX, arPointY, 4, 0, 1); + oidPIGenerator.AddObjectInfo(nPageIndex, 0xffffffffUL, arPointX, arPointY, 4, 0, 1); + if (nPageIndex == 0) { - this.gTPDFName[nPageIndex] = str3; - this.gTPDFVIName[nPageIndex] = str4; + gTPDFName[nPageIndex] = str3; + gTPDFVIName[nPageIndex] = str4; } else { - this.gTPDFName[nPageIndex] = str3.Substring(0, str3.Length - 4) + "_" + nPageIndex.ToString() + ".pdf"; - this.gTPDFVIName[nPageIndex] = str4.Substring(0, str4.Length - 4) + "_" + nPageIndex.ToString() + ".pdf"; + gTPDFName[nPageIndex] = str3.Substring(0, str3.Length - 4) + "_" + nPageIndex + ".pdf"; + gTPDFVIName[nPageIndex] = str4.Substring(0, str4.Length - 4) + "_" + nPageIndex + ".pdf"; } + nPageIndex++; - this.gCurrentPageID++; - num4 = this.gSID % 2; - num5 = this.gSID / 2; - num6 = this.gOID % 0x10; - num7 = this.gOID / 0x10; - num10 = this.gCurrentPageID % 0x10; - num11 = this.gCurrentPageID / 0x10; + gCurrentPageID++; + num4 = gSID % 2; + num5 = gSID / 2; + num6 = gOID % 0x10; + num7 = gOID / 0x10; + num10 = gCurrentPageID % 0x10; + num11 = gCurrentPageID / 0x10; num12 = 0; num13 = 0; num14 = 0; num15 = 0; - switch (this.gSID) - { - case 0: - case 1: - case 2: - num12 = (this.gBID % 0x20) << 13; - num13 = (this.gBID / 0x20) << 13; - num14 = num10 << 9; - num15 = num11 << 9; - break; - - case 3: - num12 = (this.gBID % 4) << 0x10; - num13 = (this.gBID / 4) << 0x10; - num14 = num10 << 12; - num15 = num11 << 12; - break; - - default: - break; - } - nXStart = (((num4 << 0x16) + (num6 << 0x12)) + num12) + num14; - nYStart = (((num5 << 0x16) + (num7 << 0x12)) + num13) + num15; - } - } - eBeginBuildState = OIDBeginBuildState.eBBState_OK; - eBeginBuildState = (OIDBeginBuildState) this.oidPIGenerator.BeginBuildPublishImage(str2.ToCharArray(), bExportPDFImage, this.Default_DPI); - this.CheckOidBuildState(eBeginBuildState); - if ((eBeginBuildState == OIDBeginBuildState.eBBState_OK) && bGenerateBGWithoutVImage) - { - this.gTotalPageID = StartPageID; - this.gCurrentPageID = this.gTotalPageID; - this.gCurPageIndex = 0; - nPageIndex = 0; - bPrintIdleCode = false; - num4 = this.gSID % 2; - num5 = this.gSID / 2; - num6 = this.gOID % 0x10; - num7 = this.gOID / 0x10; - num10 = this.gCurrentPageID % 0x10; - num11 = this.gCurrentPageID / 0x10; - num12 = 0; - num13 = 0; - num14 = 0; - num15 = 0; - switch (this.gSID) - { - case 0: - case 1: - case 2: - num12 = (this.gBID % 0x20) << 13; - num13 = (this.gBID / 0x20) << 13; - num14 = num10 << 9; - num15 = num11 << 9; - break; - - case 3: - num12 = (this.gBID % 4) << 0x10; - num13 = (this.gBID / 4) << 0x10; - num14 = num10 << 12; - num15 = num11 << 12; - break; - - default: - break; - } - nXStart = (((num4 << 0x16) + (num6 << 0x12)) + num12) + num14; - nYStart = (((num5 << 0x16) + (num7 << 0x12)) + num13) + num15; - while (true) - { - if (!this.oidPIGenerator.SetStartPosition(nPageIndex, nXStart, nYStart)) - { - this.gPointType = (PointType != 1) ? "2" : "3"; - if (bGenerateBGWithoutVImage) - { - this.oidPIGenerator.BuildPublishImage(str5.ToCharArray(), bPrintIdleCode, bSplitBigImage, bMergeSplittedImages, nPublishImageDPIType, PointType, 2); - } - this.gCurPageIndex++; - this.oidPIGenerator.EndBuildPublishImage(); - break; - } - this.gTPDFWOVIName[nPageIndex] = (nPageIndex != 0) ? (str5.Substring(0, str5.Length - 4) + "_" + nPageIndex.ToString() + ".pdf") : str5; - nPageIndex++; - this.gCurrentPageID++; - num4 = this.gSID % 2; - num5 = this.gSID / 2; - num6 = this.gOID % 0x10; - num7 = this.gOID / 0x10; - num10 = this.gCurrentPageID % 0x10; - num11 = this.gCurrentPageID / 0x10; - num12 = 0; - num13 = 0; - num14 = 0; - num15 = 0; - switch (this.gSID) - { - case 0: - case 1: - case 2: - num12 = (this.gBID % 0x20) << 13; - num13 = (this.gBID / 0x20) << 13; - num14 = num10 << 9; - num15 = num11 << 9; - break; - - case 3: - num12 = (this.gBID % 4) << 0x10; - num13 = (this.gBID / 4) << 0x10; - num14 = num10 << 12; - num15 = num11 << 12; - break; - - default: - break; - } - nXStart = (((num4 << 0x16) + (num6 << 0x12)) + num12) + num14; - nYStart = (((num5 << 0x16) + (num7 << 0x12)) + num13) + num15; - } - } - this.RenameTmatrixPDF(StartPageID, KeyStr.Substring(4, 2), bGenerateBGWithVImage, bGenerateVImage, bGenerateBGWithoutVImage); - return "0Generate code completely"; - } - - public string GenerateTmatrixCode(string KeyStr, string PDFFileName, int StartPageID, int PointType, bool bGenerateBGWithVImage, bool bGenerateVImage, bool bGenerateBGWithoutVImage, bool bGenerateBGWithImage) - { - int num4; - int num5; - int num6; - int num7; - int num10; - int num11; - int num12; - int num13; - int num14; - int num15; - string str = ""; - str = this.TmatrixKeyCheck_OID4(KeyStr); - if (str.Substring(0, 1) == "1") - { - return str; - } - if (PDFFileName == "") - { - return "1Please select PDF file first !"; - } - if ((StartPageID < int.Parse(this.gsPID1)) || (StartPageID > int.Parse(this.gsPID2))) - { - return ("1Start page ID must be located between " + this.gsPID1 + " ~ " + this.gsPID2); - } - this.gPageNum = this.GetPDFPageNumber(PDFFileName); - if (((this.gPageNum + StartPageID) - 1) > int.Parse(this.gsPID2)) - { - return "1Not enough code page for this PDF to generate !"; - } - this.gTotalPageID = StartPageID; - int nPageIndex = 0; - int nXStart = 0; - int nYStart = 0; - bool bPrintIdleCode = false; - bool bSplitBigImage = false; - bool bMergeSplittedImages = false; - bool bExportPDFImage = true; - this.gCurrentPageID = this.gTotalPageID; - this.gCurPageIndex = 0; - string str2 = PDFFileName; - string str3 = str2.Substring(0, str2.Length - 4) + "_.pdf"; - string str4 = str2.Substring(0, str2.Length - 4) + "_VI_.pdf"; - string str5 = str2.Substring(0, str2.Length - 4) + "_WOVI_.pdf"; - string str6 = str2.Substring(0, str2.Length - 4) + "_BGI_.pdf"; - OIDBeginBuildState eBeginBuildState = OIDBeginBuildState.eBBState_OK; - eBeginBuildState = (OIDBeginBuildState) this.oidPIGenerator.BeginBuildPublishImage(str2.ToCharArray(), bExportPDFImage, this.Default_DPI); - this.CheckOidBuildState(eBeginBuildState); - if ((eBeginBuildState == OIDBeginBuildState.eBBState_OK) && ((bGenerateBGWithVImage || bGenerateVImage) || bGenerateBGWithImage)) - { - num4 = this.gSID % 2; - num5 = this.gSID / 2; - num6 = this.gOID % 0x10; - num7 = this.gOID / 0x10; - num10 = this.gCurrentPageID % 0x10; - num11 = this.gCurrentPageID / 0x10; - num12 = 0; - num13 = 0; - num14 = 0; - num15 = 0; - switch (this.gSID) - { - case 0: - case 1: - case 2: - num12 = (this.gBID % 0x20) << 13; - num13 = (this.gBID / 0x20) << 13; - num14 = num10 << 9; - num15 = num11 << 9; - break; - - case 3: - num12 = (this.gBID % 4) << 0x10; - num13 = (this.gBID / 4) << 0x10; - num14 = num10 << 12; - num15 = num11 << 12; - break; - - default: - break; - } - nXStart = (((num4 << 0x16) + (num6 << 0x12)) + num12) + num14; - nYStart = (((num5 << 0x16) + (num7 << 0x12)) + num13) + num15; - while (true) - { - if (!this.oidPIGenerator.SetStartPosition(nPageIndex, nXStart, nYStart)) - { - switch (PointType) - { - case 0: - this.gPointType = "2"; - break; - - case 1: - this.gPointType = "3"; - break; - - case 2: - this.gPointType = "4"; - break; - - default: - break; - } - if (bGenerateBGWithVImage) - { - this.oidPIGenerator.BuildPublishImage(str3.ToCharArray(), bPrintIdleCode, bSplitBigImage, bMergeSplittedImages, 1, PointType, 2); - } - if (bGenerateVImage) - { - this.oidPIGenerator.BuildPublishImage(str4.ToCharArray(), bPrintIdleCode, bSplitBigImage, bMergeSplittedImages, 1, PointType, 1); - } - if (bGenerateBGWithImage) - { - this.oidPIGenerator.BuildPublishImage(str6.ToCharArray(), bPrintIdleCode, bSplitBigImage, bMergeSplittedImages, 1, 2, 3); - } - this.gCurPageIndex++; - this.oidPIGenerator.EndBuildPublishImage(); - break; - } - string filename = str2.Substring(0, str2.Length - 4) + "_Page" + nPageIndex.ToString() + ".png"; - Image image = Image.FromFile(filename); - uint width = (uint) image.Width; - uint height = (uint) image.Height; - image.Dispose(); - uint num16 = (uint) ((width * 25.4) / ((double) this.Default_DPI)); - uint num17 = (uint) ((height * 25.4) / ((double) this.Default_DPI)); - width += (uint) 0x48; - height += (uint) 0x48; - int gSID = this.gSID; + switch (gSID) { case 0: case 1: case 2: - if ((num16 <= 780) && (num17 <= 780)) - { - break; - } - return "1PDF page size's width or height > 780mm !"; - - case 3: - if ((num16 <= 0x1862) && (num17 <= 0x1862)) - { - break; - } - return "1PDF page size's width or height > 6242mm !"; - - default: - break; - } - uint[] numArray3 = new uint[5]; - numArray3[1] = 0x1372; - numArray3[2] = 0x1372; - uint[] arPointX = numArray3; - uint[] numArray4 = new uint[5]; - numArray4[2] = 0x1a5d; - numArray4[3] = 0x1a5d; - uint[] arPointY = numArray4; - arPointX[1] = width; - arPointX[2] = width; - arPointY[2] = height; - arPointY[3] = height; - this.oidPIGenerator.AddObjectInfo(nPageIndex, 0xffffffffUL, arPointX, arPointY, 4, 0, 1); - if (nPageIndex == 0) - { - this.gTPDFName[nPageIndex] = str3; - this.gTPDFVIName[nPageIndex] = str4; - this.gTPDFBGIName[nPageIndex] = str6; - } - else - { - this.gTPDFName[nPageIndex] = str3.Substring(0, str3.Length - 4) + "_" + nPageIndex.ToString() + ".pdf"; - this.gTPDFVIName[nPageIndex] = str4.Substring(0, str4.Length - 4) + "_" + nPageIndex.ToString() + ".pdf"; - this.gTPDFBGIName[nPageIndex] = str6.Substring(0, str6.Length - 4) + "_" + nPageIndex.ToString() + ".pdf"; - } - nPageIndex++; - this.gCurrentPageID++; - num4 = this.gSID % 2; - num5 = this.gSID / 2; - num6 = this.gOID % 0x10; - num7 = this.gOID / 0x10; - num10 = this.gCurrentPageID % 0x10; - num11 = this.gCurrentPageID / 0x10; - num12 = 0; - num13 = 0; - num14 = 0; - num15 = 0; - switch (this.gSID) - { - case 0: - case 1: - case 2: - num12 = (this.gBID % 0x20) << 13; - num13 = (this.gBID / 0x20) << 13; + num12 = (gBID % 0x20) << 13; + num13 = (gBID / 0x20) << 13; num14 = num10 << 9; num15 = num11 << 9; break; - + case 3: - num12 = (this.gBID % 4) << 0x10; - num13 = (this.gBID / 4) << 0x10; + num12 = (gBID % 4) << 0x10; + num13 = (gBID / 4) << 0x10; num14 = num10 << 12; num15 = num11 << 12; break; - - default: - break; } - nXStart = (((num4 << 0x16) + (num6 << 0x12)) + num12) + num14; - nYStart = (((num5 << 0x16) + (num7 << 0x12)) + num13) + num15; + + nXStart = (num4 << 0x16) + (num6 << 0x12) + num12 + num14; + nYStart = (num5 << 0x16) + (num7 << 0x12) + num13 + num15; } } + eBeginBuildState = OIDBeginBuildState.eBBState_OK; - eBeginBuildState = (OIDBeginBuildState) this.oidPIGenerator.BeginBuildPublishImage(str2.ToCharArray(), bExportPDFImage, this.Default_DPI); - this.CheckOidBuildState(eBeginBuildState); - if ((eBeginBuildState == OIDBeginBuildState.eBBState_OK) && bGenerateBGWithoutVImage) + eBeginBuildState = + (OIDBeginBuildState) oidPIGenerator.BeginBuildPublishImage(str2.ToCharArray(), bExportPDFImage, + Default_DPI); + CheckOidBuildState(eBeginBuildState); + + if (eBeginBuildState == OIDBeginBuildState.eBBState_OK && bGenerateBGWithoutVImage) { - this.gTotalPageID = StartPageID; - this.gCurrentPageID = this.gTotalPageID; - this.gCurPageIndex = 0; + gTotalPageID = StartPageID; + gCurrentPageID = gTotalPageID; + gCurPageIndex = 0; nPageIndex = 0; bPrintIdleCode = false; - num4 = this.gSID % 2; - num5 = this.gSID / 2; - num6 = this.gOID % 0x10; - num7 = this.gOID / 0x10; - num10 = this.gCurrentPageID % 0x10; - num11 = this.gCurrentPageID / 0x10; + num4 = gSID % 2; + num5 = gSID / 2; + num6 = gOID % 0x10; + num7 = gOID / 0x10; + num10 = gCurrentPageID % 0x10; + num11 = gCurrentPageID / 0x10; num12 = 0; num13 = 0; num14 = 0; num15 = 0; - switch (this.gSID) + + switch (gSID) { case 0: case 1: case 2: - num12 = (this.gBID % 0x20) << 13; - num13 = (this.gBID / 0x20) << 13; + num12 = (gBID % 0x20) << 13; + num13 = (gBID / 0x20) << 13; num14 = num10 << 9; num15 = num11 << 9; break; - + case 3: - num12 = (this.gBID % 4) << 0x10; - num13 = (this.gBID / 4) << 0x10; + num12 = (gBID % 4) << 0x10; + num13 = (gBID / 4) << 0x10; num14 = num10 << 12; num15 = num11 << 12; break; - - default: - break; } - nXStart = (((num4 << 0x16) + (num6 << 0x12)) + num12) + num14; - nYStart = (((num5 << 0x16) + (num7 << 0x12)) + num13) + num15; + + nXStart = (num4 << 0x16) + (num6 << 0x12) + num12 + num14; + nYStart = (num5 << 0x16) + (num7 << 0x12) + num13 + num15; + while (true) { - if (!this.oidPIGenerator.SetStartPosition(nPageIndex, nXStart, nYStart)) + if (!oidPIGenerator.SetStartPosition(nPageIndex, nXStart, nYStart)) { - switch (PointType) - { - case 0: - this.gPointType = "2"; - break; - - case 1: - this.gPointType = "3"; - break; - - case 2: - this.gPointType = "4"; - break; - - default: - break; - } + gPointType = PointType != 1 ? "2" : "3"; if (bGenerateBGWithoutVImage) - { - this.oidPIGenerator.BuildPublishImage(str5.ToCharArray(), bPrintIdleCode, bSplitBigImage, bMergeSplittedImages, 1, PointType, 2); - } - this.gCurPageIndex++; - this.oidPIGenerator.EndBuildPublishImage(); + oidPIGenerator.BuildPublishImage(str5.ToCharArray(), bPrintIdleCode, bSplitBigImage, + bMergeSplittedImages, nPublishImageDPIType, PointType, 2); + gCurPageIndex++; + oidPIGenerator.EndBuildPublishImage(); break; } - this.gTPDFWOVIName[nPageIndex] = (nPageIndex != 0) ? (str5.Substring(0, str5.Length - 4) + "_" + nPageIndex.ToString() + ".pdf") : str5; + + gTPDFWOVIName[nPageIndex] = nPageIndex != 0 + ? str5.Substring(0, str5.Length - 4) + "_" + nPageIndex + ".pdf" + : str5; nPageIndex++; - this.gCurrentPageID++; - num4 = this.gSID % 2; - num5 = this.gSID / 2; - num6 = this.gOID % 0x10; - num7 = this.gOID / 0x10; - num10 = this.gCurrentPageID % 0x10; - num11 = this.gCurrentPageID / 0x10; + gCurrentPageID++; + num4 = gSID % 2; + num5 = gSID / 2; + num6 = gOID % 0x10; + num7 = gOID / 0x10; + num10 = gCurrentPageID % 0x10; + num11 = gCurrentPageID / 0x10; num12 = 0; num13 = 0; num14 = 0; num15 = 0; - switch (this.gSID) + + switch (gSID) { case 0: case 1: case 2: - num12 = (this.gBID % 0x20) << 13; - num13 = (this.gBID / 0x20) << 13; + num12 = (gBID % 0x20) << 13; + num13 = (gBID / 0x20) << 13; num14 = num10 << 9; num15 = num11 << 9; break; - + case 3: - num12 = (this.gBID % 4) << 0x10; - num13 = (this.gBID / 4) << 0x10; + num12 = (gBID % 4) << 0x10; + num13 = (gBID / 4) << 0x10; num14 = num10 << 12; num15 = num11 << 12; break; - - default: - break; } - nXStart = (((num4 << 0x16) + (num6 << 0x12)) + num12) + num14; - nYStart = (((num5 << 0x16) + (num7 << 0x12)) + num13) + num15; + + nXStart = (num4 << 0x16) + (num6 << 0x12) + num12 + num14; + nYStart = (num5 << 0x16) + (num7 << 0x12) + num13 + num15; } } - this.RenameTmatrixPDF_OID4(StartPageID, this.gsSID, this.gsOID, this.gsBID, bGenerateBGWithVImage, bGenerateVImage, bGenerateBGWithoutVImage, bGenerateBGWithImage); + + RenameTmatrixPDF(StartPageID, KeyStr.Substring(4, 2), bGenerateBGWithVImage, bGenerateVImage, + bGenerateBGWithoutVImage); return "0Generate code completely"; } - - public string GenerateTmatrixCode_OID4(string KeyStr, string PDFFileName, int StartPageID, int[] PointType, bool[] bPublishImageType, int[] PointDPI) + + public string GenerateTmatrixCode(string KeyStr, string PDFFileName, int StartPageID, int PointType, + bool bGenerateBGWithVImage, bool bGenerateVImage, bool bGenerateBGWithoutVImage, bool bGenerateBGWithImage) { int num4; int num5; @@ -947,352 +614,667 @@ namespace TmatrixLibrary int num13; int num14; int num15; - string str = ""; - List imgFile = new List(); + var str = ""; + str = TmatrixKeyCheck_OID4(KeyStr); + if (str.Substring(0, 1) == "1") return str; + + if (PDFFileName == "") return "1Please select PDF file first !"; + + if (StartPageID < int.Parse(gsPID1) || StartPageID > int.Parse(gsPID2)) + return "1Start page ID must be located between " + gsPID1 + " ~ " + gsPID2; + gPageNum = GetPDFPageNumber(PDFFileName); + if (gPageNum + StartPageID - 1 > int.Parse(gsPID2)) + return "1Not enough code page for this PDF to generate !"; + gTotalPageID = StartPageID; + var nPageIndex = 0; + var nXStart = 0; + var nYStart = 0; + var bPrintIdleCode = false; + var bSplitBigImage = false; + var bMergeSplittedImages = false; + var bExportPDFImage = true; + gCurrentPageID = gTotalPageID; + gCurPageIndex = 0; + var str2 = PDFFileName; + var str3 = str2.Substring(0, str2.Length - 4) + "_.pdf"; + var str4 = str2.Substring(0, str2.Length - 4) + "_VI_.pdf"; + var str5 = str2.Substring(0, str2.Length - 4) + "_WOVI_.pdf"; + var str6 = str2.Substring(0, str2.Length - 4) + "_BGI_.pdf"; + var eBeginBuildState = OIDBeginBuildState.eBBState_OK; + eBeginBuildState = + (OIDBeginBuildState) oidPIGenerator.BeginBuildPublishImage(str2.ToCharArray(), bExportPDFImage, + Default_DPI); + CheckOidBuildState(eBeginBuildState); + + if (eBeginBuildState == OIDBeginBuildState.eBBState_OK && + (bGenerateBGWithVImage || bGenerateVImage || bGenerateBGWithImage)) + { + num4 = this.gSID % 2; + num5 = this.gSID / 2; + num6 = gOID % 0x10; + num7 = gOID / 0x10; + num10 = gCurrentPageID % 0x10; + num11 = gCurrentPageID / 0x10; + num12 = 0; + num13 = 0; + num14 = 0; + num15 = 0; + + switch (this.gSID) + { + case 0: + case 1: + case 2: + num12 = (gBID % 0x20) << 13; + num13 = (gBID / 0x20) << 13; + num14 = num10 << 9; + num15 = num11 << 9; + break; + + case 3: + num12 = (gBID % 4) << 0x10; + num13 = (gBID / 4) << 0x10; + num14 = num10 << 12; + num15 = num11 << 12; + break; + } + + nXStart = (num4 << 0x16) + (num6 << 0x12) + num12 + num14; + nYStart = (num5 << 0x16) + (num7 << 0x12) + num13 + num15; + + while (true) + { + if (!oidPIGenerator.SetStartPosition(nPageIndex, nXStart, nYStart)) + { + switch (PointType) + { + case 0: + gPointType = "2"; + break; + + case 1: + gPointType = "3"; + break; + + case 2: + gPointType = "4"; + break; + } + + if (bGenerateBGWithVImage) + oidPIGenerator.BuildPublishImage(str3.ToCharArray(), bPrintIdleCode, bSplitBigImage, + bMergeSplittedImages, 1, PointType, 2); + + if (bGenerateVImage) + oidPIGenerator.BuildPublishImage(str4.ToCharArray(), bPrintIdleCode, bSplitBigImage, + bMergeSplittedImages, 1, PointType, 1); + + if (bGenerateBGWithImage) + oidPIGenerator.BuildPublishImage(str6.ToCharArray(), bPrintIdleCode, bSplitBigImage, + bMergeSplittedImages, 1, 2, 3); + gCurPageIndex++; + oidPIGenerator.EndBuildPublishImage(); + break; + } + + var filename = str2.Substring(0, str2.Length - 4) + "_Page" + nPageIndex + ".png"; + var image = Image.FromFile(filename); + var width = (uint) image.Width; + var height = (uint) image.Height; + image.Dispose(); + var num16 = (uint) (width * 25.4 / Default_DPI); + var num17 = (uint) (height * 25.4 / Default_DPI); + width += 0x48; + height += 0x48; + var gSID = this.gSID; + + switch (gSID) + { + case 0: + case 1: + case 2: + if (num16 <= 780 && num17 <= 780) break; + return "1PDF page size's width or height > 780mm !"; + + case 3: + if (num16 <= 0x1862 && num17 <= 0x1862) break; + return "1PDF page size's width or height > 6242mm !"; + } + + var numArray3 = new uint[5]; + numArray3[1] = 0x1372; + numArray3[2] = 0x1372; + var arPointX = numArray3; + var numArray4 = new uint[5]; + numArray4[2] = 0x1a5d; + numArray4[3] = 0x1a5d; + var arPointY = numArray4; + arPointX[1] = width; + arPointX[2] = width; + arPointY[2] = height; + arPointY[3] = height; + oidPIGenerator.AddObjectInfo(nPageIndex, 0xffffffffUL, arPointX, arPointY, 4, 0, 1); + + if (nPageIndex == 0) + { + gTPDFName[nPageIndex] = str3; + gTPDFVIName[nPageIndex] = str4; + gTPDFBGIName[nPageIndex] = str6; + } + else + { + gTPDFName[nPageIndex] = str3.Substring(0, str3.Length - 4) + "_" + nPageIndex + ".pdf"; + gTPDFVIName[nPageIndex] = str4.Substring(0, str4.Length - 4) + "_" + nPageIndex + ".pdf"; + gTPDFBGIName[nPageIndex] = str6.Substring(0, str6.Length - 4) + "_" + nPageIndex + ".pdf"; + } + + nPageIndex++; + gCurrentPageID++; + num4 = this.gSID % 2; + num5 = this.gSID / 2; + num6 = gOID % 0x10; + num7 = gOID / 0x10; + num10 = gCurrentPageID % 0x10; + num11 = gCurrentPageID / 0x10; + num12 = 0; + num13 = 0; + num14 = 0; + num15 = 0; + + switch (this.gSID) + { + case 0: + case 1: + case 2: + num12 = (gBID % 0x20) << 13; + num13 = (gBID / 0x20) << 13; + num14 = num10 << 9; + num15 = num11 << 9; + break; + + case 3: + num12 = (gBID % 4) << 0x10; + num13 = (gBID / 4) << 0x10; + num14 = num10 << 12; + num15 = num11 << 12; + break; + } + + nXStart = (num4 << 0x16) + (num6 << 0x12) + num12 + num14; + nYStart = (num5 << 0x16) + (num7 << 0x12) + num13 + num15; + } + } + + eBeginBuildState = OIDBeginBuildState.eBBState_OK; + eBeginBuildState = + (OIDBeginBuildState) oidPIGenerator.BeginBuildPublishImage(str2.ToCharArray(), bExportPDFImage, + Default_DPI); + CheckOidBuildState(eBeginBuildState); + + if (eBeginBuildState == OIDBeginBuildState.eBBState_OK && bGenerateBGWithoutVImage) + { + gTotalPageID = StartPageID; + gCurrentPageID = gTotalPageID; + gCurPageIndex = 0; + nPageIndex = 0; + bPrintIdleCode = false; + num4 = gSID % 2; + num5 = gSID / 2; + num6 = gOID % 0x10; + num7 = gOID / 0x10; + num10 = gCurrentPageID % 0x10; + num11 = gCurrentPageID / 0x10; + num12 = 0; + num13 = 0; + num14 = 0; + num15 = 0; + + switch (gSID) + { + case 0: + case 1: + case 2: + num12 = (gBID % 0x20) << 13; + num13 = (gBID / 0x20) << 13; + num14 = num10 << 9; + num15 = num11 << 9; + break; + + case 3: + num12 = (gBID % 4) << 0x10; + num13 = (gBID / 4) << 0x10; + num14 = num10 << 12; + num15 = num11 << 12; + break; + } + + nXStart = (num4 << 0x16) + (num6 << 0x12) + num12 + num14; + nYStart = (num5 << 0x16) + (num7 << 0x12) + num13 + num15; + + while (true) + { + if (!oidPIGenerator.SetStartPosition(nPageIndex, nXStart, nYStart)) + { + switch (PointType) + { + case 0: + gPointType = "2"; + break; + + case 1: + gPointType = "3"; + break; + + case 2: + gPointType = "4"; + break; + } + + if (bGenerateBGWithoutVImage) + oidPIGenerator.BuildPublishImage(str5.ToCharArray(), bPrintIdleCode, bSplitBigImage, + bMergeSplittedImages, 1, PointType, 2); + gCurPageIndex++; + oidPIGenerator.EndBuildPublishImage(); + break; + } + + gTPDFWOVIName[nPageIndex] = nPageIndex != 0 + ? str5.Substring(0, str5.Length - 4) + "_" + nPageIndex + ".pdf" + : str5; + nPageIndex++; + gCurrentPageID++; + num4 = gSID % 2; + num5 = gSID / 2; + num6 = gOID % 0x10; + num7 = gOID / 0x10; + num10 = gCurrentPageID % 0x10; + num11 = gCurrentPageID / 0x10; + num12 = 0; + num13 = 0; + num14 = 0; + num15 = 0; + + switch (gSID) + { + case 0: + case 1: + case 2: + num12 = (gBID % 0x20) << 13; + num13 = (gBID / 0x20) << 13; + num14 = num10 << 9; + num15 = num11 << 9; + break; + + case 3: + num12 = (gBID % 4) << 0x10; + num13 = (gBID / 4) << 0x10; + num14 = num10 << 12; + num15 = num11 << 12; + break; + } + + nXStart = (num4 << 0x16) + (num6 << 0x12) + num12 + num14; + nYStart = (num5 << 0x16) + (num7 << 0x12) + num13 + num15; + } + } + + RenameTmatrixPDF_OID4(StartPageID, gsSID, gsOID, gsBID, bGenerateBGWithVImage, bGenerateVImage, + bGenerateBGWithoutVImage, bGenerateBGWithImage); + return "0Generate code completely"; + } + + public string GenerateTmatrixCode_OID4(string KeyStr, string PDFFileName, int StartPageID, int[] PointType, + bool[] bPublishImageType, int[] PointDPI) + { + int num4; + int num5; + int num6; + int num7; + int num10; + int num11; + int num12; + int num13; + int num14; + int num15; + var str = ""; + var imgFile = new List(); SetProgress(0); - str = this.TmatrixKeyCheck_OID4(KeyStr); - if (str.Substring(0, 1) != "0") - { - return str; - } - if (PDFFileName == "") - { - return "1Please select PDF file first !"; - } - if ((StartPageID < int.Parse(this.gsPID1)) || (StartPageID > int.Parse(this.gsPID2))) - { - return ("2Start page ID must be located between " + this.gsPID1 + " ~ " + this.gsPID2); - } - this.gPageNum = this.GetPDFPageNumber(PDFFileName); - if (((this.gPageNum + StartPageID) - 1) > int.Parse(this.gsPID2)) - { + str = TmatrixKeyCheck_OID4(KeyStr); + if (str.Substring(0, 1) != "0") return str; + + if (PDFFileName == "") return "1Please select PDF file first !"; + + if (StartPageID < int.Parse(gsPID1) || StartPageID > int.Parse(gsPID2)) + return "2Start page ID must be located between " + gsPID1 + " ~ " + gsPID2; + gPageNum = GetPDFPageNumber(PDFFileName); + if (gPageNum + StartPageID - 1 > int.Parse(gsPID2)) return "3Not enough code page for this PDF to generate !"; - } SetProgress(1); - bool bGenerateBGWithVImage = bPublishImageType[0]; - bool bGenerateVImage = bPublishImageType[1]; - bool bGenerateBGWithoutVImage = bPublishImageType[2]; - bool bGenerateBGWithImage = bPublishImageType[3]; - this.gTotalPageID = StartPageID; - int nPageIndex = 0; - int nXStart = 0; - int nYStart = 0; - bool bPrintIdleCode = false; - bool bSplitBigImage = false; - bool bMergeSplittedImages = false; - bool bExportPDFImage = true; - for (int i = 0; i < 4; i++) + var bGenerateBGWithVImage = bPublishImageType[0]; + var bGenerateVImage = bPublishImageType[1]; + var bGenerateBGWithoutVImage = bPublishImageType[2]; + var bGenerateBGWithImage = bPublishImageType[3]; + gTotalPageID = StartPageID; + var nPageIndex = 0; + var nXStart = 0; + var nYStart = 0; + var bPrintIdleCode = false; + var bSplitBigImage = false; + var bMergeSplittedImages = false; + var bExportPDFImage = true; + + for (var i = 0; i < 4; i++) { - int num26 = PointType[i]; + var num26 = PointType[i]; + switch (num26) { case 0: - this.gsPointType[i] = "2"; + gsPointType[i] = "2"; break; - + case 1: - this.gsPointType[i] = "3"; + gsPointType[i] = "3"; break; - + case 2: - this.gsPointType[i] = "4"; - break; - - default: + gsPointType[i] = "4"; break; } + switch (PointDPI[i]) { case 0: - this.gsPointDPI[i] = "D600"; + gsPointDPI[i] = "D600"; break; - + case 1: - this.gsPointDPI[i] = "D1200"; - break; - - default: + gsPointDPI[i] = "D1200"; break; } } - this.gCurrentPageID = this.gTotalPageID; - this.gCurPageIndex = 0; - string str2 = PDFFileName; - string str3 = str2.Substring(0, str2.Length - 4) + "_.pdf"; - string str4 = str2.Substring(0, str2.Length - 4) + "_VI_.pdf"; - string str5 = str2.Substring(0, str2.Length - 4) + "_WOVI_.pdf"; - string str6 = str2.Substring(0, str2.Length - 4) + "_BGI_.pdf"; - OIDBeginBuildState eBeginBuildState = OIDBeginBuildState.eBBState_OK; - eBeginBuildState = (OIDBeginBuildState) this.oidPIGenerator.BeginBuildPublishImage(str2.ToCharArray(), bExportPDFImage, this.Default_DPI); - this.CheckOidBuildState(eBeginBuildState); + + gCurrentPageID = gTotalPageID; + gCurPageIndex = 0; + var str2 = PDFFileName; + var str3 = str2.Substring(0, str2.Length - 4) + "_.pdf"; + var str4 = str2.Substring(0, str2.Length - 4) + "_VI_.pdf"; + var str5 = str2.Substring(0, str2.Length - 4) + "_WOVI_.pdf"; + var str6 = str2.Substring(0, str2.Length - 4) + "_BGI_.pdf"; + var eBeginBuildState = OIDBeginBuildState.eBBState_OK; + eBeginBuildState = + (OIDBeginBuildState) oidPIGenerator.BeginBuildPublishImage(str2.ToCharArray(), bExportPDFImage, + Default_DPI); + CheckOidBuildState(eBeginBuildState); SetProgress(10); - if ((eBeginBuildState == OIDBeginBuildState.eBBState_OK) && ((bGenerateBGWithVImage || bGenerateVImage) || bGenerateBGWithImage)) + + if (eBeginBuildState == OIDBeginBuildState.eBBState_OK && + (bGenerateBGWithVImage || bGenerateVImage || bGenerateBGWithImage)) { num4 = this.gSID % 2; num5 = this.gSID / 2; - num6 = this.gOID % 0x10; - num7 = this.gOID / 0x10; - num10 = this.gCurrentPageID % 0x10; - num11 = this.gCurrentPageID / 0x10; + num6 = gOID % 0x10; + num7 = gOID / 0x10; + num10 = gCurrentPageID % 0x10; + num11 = gCurrentPageID / 0x10; num12 = 0; num13 = 0; num14 = 0; num15 = 0; + switch (this.gSID) { case 0: case 1: case 2: - num12 = (this.gBID % 0x20) << 13; - num13 = (this.gBID / 0x20) << 13; + num12 = (gBID % 0x20) << 13; + num13 = (gBID / 0x20) << 13; num14 = num10 << 9; num15 = num11 << 9; break; - + case 3: - num12 = (this.gBID % 4) << 0x10; - num13 = (this.gBID / 4) << 0x10; + num12 = (gBID % 4) << 0x10; + num13 = (gBID / 4) << 0x10; num14 = num10 << 12; num15 = num11 << 12; break; - - default: - break; } - nXStart = (((num4 << 0x16) + (num6 << 0x12)) + num12) + num14; - nYStart = (((num5 << 0x16) + (num7 << 0x12)) + num13) + num15; + + nXStart = (num4 << 0x16) + (num6 << 0x12) + num12 + num14; + nYStart = (num5 << 0x16) + (num7 << 0x12) + num13 + num15; + while (true) { - int perCent = 10 + nPageIndex * 30 / this.gPageNum; + var perCent = 10 + nPageIndex * 30 / gPageNum; SetProgress(perCent); - if (!this.oidPIGenerator.SetStartPosition(nPageIndex, nXStart, nYStart)) + if (!oidPIGenerator.SetStartPosition(nPageIndex, nXStart, nYStart)) { SetProgress(40); if (bGenerateBGWithVImage) - { - this.oidPIGenerator.BuildPublishImage(str3.ToCharArray(), bPrintIdleCode, bSplitBigImage, bMergeSplittedImages, PointDPI[0], PointType[0], 2); - } + oidPIGenerator.BuildPublishImage(str3.ToCharArray(), bPrintIdleCode, bSplitBigImage, + bMergeSplittedImages, PointDPI[0], PointType[0], 2); + if (bGenerateVImage) - { - this.oidPIGenerator.BuildPublishImage(str4.ToCharArray(), bPrintIdleCode, bSplitBigImage, bMergeSplittedImages, PointDPI[1], PointType[1], 1); - } + oidPIGenerator.BuildPublishImage(str4.ToCharArray(), bPrintIdleCode, bSplitBigImage, + bMergeSplittedImages, PointDPI[1], PointType[1], 1); + if (bGenerateBGWithImage) - { - this.oidPIGenerator.BuildPublishImage(str6.ToCharArray(), bPrintIdleCode, bSplitBigImage, bMergeSplittedImages, PointDPI[3], PointType[3], 3); - } - this.gCurPageIndex++; - this.oidPIGenerator.EndBuildPublishImage(); + oidPIGenerator.BuildPublishImage(str6.ToCharArray(), bPrintIdleCode, bSplitBigImage, + bMergeSplittedImages, PointDPI[3], PointType[3], 3); + gCurPageIndex++; + oidPIGenerator.EndBuildPublishImage(); SetProgress(80); break; } - string filename = str2.Substring(0, str2.Length - 4) + "_Page" + nPageIndex.ToString() + ".png"; - Image image = Image.FromFile(filename); + + var filename = str2.Substring(0, str2.Length - 4) + "_Page" + nPageIndex + ".png"; + var image = Image.FromFile(filename); imgFile.Add(filename); - float horizontalResolution = image.HorizontalResolution; - float verticalResolution = image.VerticalResolution; - uint width = (uint) image.Width; - uint height = (uint) image.Height; + var horizontalResolution = image.HorizontalResolution; + var verticalResolution = image.VerticalResolution; + var width = (uint) image.Width; + var height = (uint) image.Height; image.Dispose(); - uint num16 = (uint) ((width * 25.4) / ((double) this.Default_DPI)); - uint num17 = (uint) ((height * 25.4) / ((double) this.Default_DPI)); - width += (uint) 0x48; - height += (uint) 0x48; - int gSID = this.gSID; + var num16 = (uint) (width * 25.4 / Default_DPI); + var num17 = (uint) (height * 25.4 / Default_DPI); + width += 0x48; + height += 0x48; + var gSID = this.gSID; + switch (gSID) { case 0: case 1: case 2: - if ((num16 <= 780) && (num17 <= 780)) - { - break; - } + if (num16 <= 780 && num17 <= 780) break; return "4PDF page size's width or height > 780mm !"; - + case 3: - if ((num16 <= 0x1862) && (num17 <= 0x1862)) - { - break; - } + if (num16 <= 0x1862 && num17 <= 0x1862) break; return "5PDF page size's width or height > 6242mm !"; - - default: - break; } - uint[] numArray3 = new uint[5]; + + var numArray3 = new uint[5]; numArray3[1] = 0x1372; numArray3[2] = 0x1372; - uint[] arPointX = numArray3; - uint[] numArray4 = new uint[5]; + var arPointX = numArray3; + var numArray4 = new uint[5]; numArray4[2] = 0x1a5d; numArray4[3] = 0x1a5d; - uint[] arPointY = numArray4; + var arPointY = numArray4; arPointX[1] = width; arPointX[2] = width; arPointY[2] = height; arPointY[3] = height; - this.oidPIGenerator.AddObjectInfo(nPageIndex, 0xffffffffUL, arPointX, arPointY, 4, 0, 1); + oidPIGenerator.AddObjectInfo(nPageIndex, 0xffffffffUL, arPointX, arPointY, 4, 0, 1); + if (nPageIndex == 0) { - this.gTPDFName[nPageIndex] = str3; - this.gTPDFVIName[nPageIndex] = str4; - this.gTPDFBGIName[nPageIndex] = str6; + gTPDFName[nPageIndex] = str3; + gTPDFVIName[nPageIndex] = str4; + gTPDFBGIName[nPageIndex] = str6; } else { - this.gTPDFName[nPageIndex] = str3.Substring(0, str3.Length - 4) + "_" + nPageIndex.ToString() + ".pdf"; - this.gTPDFVIName[nPageIndex] = str4.Substring(0, str4.Length - 4) + "_" + nPageIndex.ToString() + ".pdf"; - this.gTPDFBGIName[nPageIndex] = str6.Substring(0, str6.Length - 4) + "_" + nPageIndex.ToString() + ".pdf"; + gTPDFName[nPageIndex] = str3.Substring(0, str3.Length - 4) + "_" + nPageIndex + ".pdf"; + gTPDFVIName[nPageIndex] = str4.Substring(0, str4.Length - 4) + "_" + nPageIndex + ".pdf"; + gTPDFBGIName[nPageIndex] = str6.Substring(0, str6.Length - 4) + "_" + nPageIndex + ".pdf"; } + nPageIndex++; - this.gCurrentPageID++; + gCurrentPageID++; num4 = this.gSID % 2; num5 = this.gSID / 2; - num6 = this.gOID % 0x10; - num7 = this.gOID / 0x10; - num10 = this.gCurrentPageID % 0x10; - num11 = this.gCurrentPageID / 0x10; + num6 = gOID % 0x10; + num7 = gOID / 0x10; + num10 = gCurrentPageID % 0x10; + num11 = gCurrentPageID / 0x10; num12 = 0; num13 = 0; num14 = 0; num15 = 0; + switch (this.gSID) { case 0: case 1: case 2: - num12 = (this.gBID % 0x20) << 13; - num13 = (this.gBID / 0x20) << 13; + num12 = (gBID % 0x20) << 13; + num13 = (gBID / 0x20) << 13; num14 = num10 << 9; num15 = num11 << 9; break; - + case 3: - num12 = (this.gBID % 4) << 0x10; - num13 = (this.gBID / 4) << 0x10; + num12 = (gBID % 4) << 0x10; + num13 = (gBID / 4) << 0x10; num14 = num10 << 12; num15 = num11 << 12; break; - - default: - break; } - nXStart = (((num4 << 0x16) + (num6 << 0x12)) + num12) + num14; - nYStart = (((num5 << 0x16) + (num7 << 0x12)) + num13) + num15; + + nXStart = (num4 << 0x16) + (num6 << 0x12) + num12 + num14; + nYStart = (num5 << 0x16) + (num7 << 0x12) + num13 + num15; } } + eBeginBuildState = OIDBeginBuildState.eBBState_OK; - eBeginBuildState = (OIDBeginBuildState) this.oidPIGenerator.BeginBuildPublishImage(str2.ToCharArray(), bExportPDFImage, this.Default_DPI); - this.CheckOidBuildState(eBeginBuildState); - if ((eBeginBuildState == OIDBeginBuildState.eBBState_OK) && bGenerateBGWithoutVImage) + eBeginBuildState = + (OIDBeginBuildState) oidPIGenerator.BeginBuildPublishImage(str2.ToCharArray(), bExportPDFImage, + Default_DPI); + CheckOidBuildState(eBeginBuildState); + + if (eBeginBuildState == OIDBeginBuildState.eBBState_OK && bGenerateBGWithoutVImage) { - this.gTotalPageID = StartPageID; - this.gCurrentPageID = this.gTotalPageID; - this.gCurPageIndex = 0; + gTotalPageID = StartPageID; + gCurrentPageID = gTotalPageID; + gCurPageIndex = 0; nPageIndex = 0; bPrintIdleCode = false; - num4 = this.gSID % 2; - num5 = this.gSID / 2; - num6 = this.gOID % 0x10; - num7 = this.gOID / 0x10; - num10 = this.gCurrentPageID % 0x10; - num11 = this.gCurrentPageID / 0x10; + num4 = gSID % 2; + num5 = gSID / 2; + num6 = gOID % 0x10; + num7 = gOID / 0x10; + num10 = gCurrentPageID % 0x10; + num11 = gCurrentPageID / 0x10; num12 = 0; num13 = 0; num14 = 0; num15 = 0; - switch (this.gSID) + + switch (gSID) { case 0: case 1: case 2: - num12 = (this.gBID % 0x20) << 13; - num13 = (this.gBID / 0x20) << 13; + num12 = (gBID % 0x20) << 13; + num13 = (gBID / 0x20) << 13; num14 = num10 << 9; num15 = num11 << 9; break; - + case 3: - num12 = (this.gBID % 4) << 0x10; - num13 = (this.gBID / 4) << 0x10; + num12 = (gBID % 4) << 0x10; + num13 = (gBID / 4) << 0x10; num14 = num10 << 12; num15 = num11 << 12; break; - - default: - break; } - nXStart = (((num4 << 0x16) + (num6 << 0x12)) + num12) + num14; - nYStart = (((num5 << 0x16) + (num7 << 0x12)) + num13) + num15; + + nXStart = (num4 << 0x16) + (num6 << 0x12) + num12 + num14; + nYStart = (num5 << 0x16) + (num7 << 0x12) + num13 + num15; + while (true) { - if (!this.oidPIGenerator.SetStartPosition(nPageIndex, nXStart, nYStart)) + if (!oidPIGenerator.SetStartPosition(nPageIndex, nXStart, nYStart)) { if (bGenerateBGWithoutVImage) - { - this.oidPIGenerator.BuildPublishImage(str5.ToCharArray(), bPrintIdleCode, bSplitBigImage, bMergeSplittedImages, PointDPI[2], PointType[2], 2); - } - this.gCurPageIndex++; - this.oidPIGenerator.EndBuildPublishImage(); + oidPIGenerator.BuildPublishImage(str5.ToCharArray(), bPrintIdleCode, bSplitBigImage, + bMergeSplittedImages, PointDPI[2], PointType[2], 2); + gCurPageIndex++; + oidPIGenerator.EndBuildPublishImage(); break; } - this.gTPDFWOVIName[nPageIndex] = (nPageIndex != 0) ? (str5.Substring(0, str5.Length - 4) + "_" + nPageIndex.ToString() + ".pdf") : str5; + + gTPDFWOVIName[nPageIndex] = nPageIndex != 0 + ? str5.Substring(0, str5.Length - 4) + "_" + nPageIndex + ".pdf" + : str5; nPageIndex++; - this.gCurrentPageID++; - num4 = this.gSID % 2; - num5 = this.gSID / 2; - num6 = this.gOID % 0x10; - num7 = this.gOID / 0x10; - num10 = this.gCurrentPageID % 0x10; - num11 = this.gCurrentPageID / 0x10; + gCurrentPageID++; + num4 = gSID % 2; + num5 = gSID / 2; + num6 = gOID % 0x10; + num7 = gOID / 0x10; + num10 = gCurrentPageID % 0x10; + num11 = gCurrentPageID / 0x10; num12 = 0; num13 = 0; num14 = 0; num15 = 0; - switch (this.gSID) + + switch (gSID) { case 0: case 1: case 2: - num12 = (this.gBID % 0x20) << 13; - num13 = (this.gBID / 0x20) << 13; + num12 = (gBID % 0x20) << 13; + num13 = (gBID / 0x20) << 13; num14 = num10 << 9; num15 = num11 << 9; break; - + case 3: - num12 = (this.gBID % 4) << 0x10; - num13 = (this.gBID / 4) << 0x10; + num12 = (gBID % 4) << 0x10; + num13 = (gBID / 4) << 0x10; num14 = num10 << 12; num15 = num11 << 12; break; - - default: - break; } - nXStart = (((num4 << 0x16) + (num6 << 0x12)) + num12) + num14; - nYStart = (((num5 << 0x16) + (num7 << 0x12)) + num13) + num15; + + nXStart = (num4 << 0x16) + (num6 << 0x12) + num12 + num14; + nYStart = (num5 << 0x16) + (num7 << 0x12) + num13 + num15; } } + SetProgress(90); - this.RenameTmatrixPDF_OID4(StartPageID, this.gsSID, this.gsOID, this.gsBID, bGenerateBGWithVImage, bGenerateVImage, bGenerateBGWithoutVImage, bGenerateBGWithImage); - + RenameTmatrixPDF_OID4(StartPageID, gsSID, gsOID, gsBID, bGenerateBGWithVImage, bGenerateVImage, + bGenerateBGWithoutVImage, bGenerateBGWithImage); + foreach (var file in imgFile) - { if (File.Exists(file)) - { File.Delete(file); - } - } SetProgress(99); return "0Generate code completely"; } - - public string GenerateTmatrixCodeByArea(string KeyStr, string PDFFileName, int StartPageID, int PointType, bool bGenerateBGWithVImage, bool bGenerateVImage, bool bGenerateBGWithoutVImage, bool bGenerateBGWithImage, uint[][] Tx, uint[][] Ty, uint[][] Tw, uint[][] Th) + + public string GenerateTmatrixCodeByArea(string KeyStr, string PDFFileName, int StartPageID, int PointType, + bool bGenerateBGWithVImage, bool bGenerateVImage, bool bGenerateBGWithoutVImage, bool bGenerateBGWithImage, + uint[][] Tx, uint[][] Ty, uint[][] Tw, uint[][] Th) { int num4; int num5; @@ -1304,133 +1286,127 @@ namespace TmatrixLibrary int num13; int num14; int num15; - string str = ""; - - str = this.TmatrixKeyCheck_OID4(KeyStr); - if (str.Substring(0, 1) == "1") - { - return str; - } - if (PDFFileName == "") - { - return "1Please select PDF file first !"; - } - if ((StartPageID < int.Parse(this.gsPID1)) || (StartPageID > int.Parse(this.gsPID2))) - { - return ("1Start page ID must be located between " + this.gsPID1 + " ~ " + this.gsPID2); - } - this.gPageNum = this.GetPDFPageNumber(PDFFileName); - if (((this.gPageNum + StartPageID) - 1) > int.Parse(this.gsPID2)) - { + var str = ""; + + str = TmatrixKeyCheck_OID4(KeyStr); + if (str.Substring(0, 1) == "1") return str; + + if (PDFFileName == "") return "1Please select PDF file first !"; + + if (StartPageID < int.Parse(gsPID1) || StartPageID > int.Parse(gsPID2)) + return "1Start page ID must be located between " + gsPID1 + " ~ " + gsPID2; + gPageNum = GetPDFPageNumber(PDFFileName); + if (gPageNum + StartPageID - 1 > int.Parse(gsPID2)) return "1Not enough code page for this PDF to generate !"; - } - this.gTotalPageID = StartPageID; - int nPageIndex = 0; - int nXStart = 0; - int nYStart = 0; - bool bPrintIdleCode = false; - bool bSplitBigImage = false; - bool bMergeSplittedImages = false; - bool bExportPDFImage = true; - int index = 0; - this.gCurrentPageID = this.gTotalPageID; - this.gCurPageIndex = 0; - string str2 = PDFFileName; - string str3 = str2.Substring(0, str2.Length - 4) + "_.pdf"; - string str4 = str2.Substring(0, str2.Length - 4) + "_VI_.pdf"; - string str5 = str2.Substring(0, str2.Length - 4) + "_WOVI_.pdf"; - string str6 = str2.Substring(0, str2.Length - 4) + "_BGI_.pdf"; - OIDBeginBuildState eBeginBuildState = OIDBeginBuildState.eBBState_OK; - eBeginBuildState = (OIDBeginBuildState) this.oidPIGenerator.BeginBuildPublishImage(str2.ToCharArray(), bExportPDFImage, this.Default_DPI); - this.CheckOidBuildState(eBeginBuildState); - if ((eBeginBuildState == OIDBeginBuildState.eBBState_OK) && ((bGenerateBGWithVImage || bGenerateVImage) || bGenerateBGWithImage)) + gTotalPageID = StartPageID; + var nPageIndex = 0; + var nXStart = 0; + var nYStart = 0; + var bPrintIdleCode = false; + var bSplitBigImage = false; + var bMergeSplittedImages = false; + var bExportPDFImage = true; + var index = 0; + gCurrentPageID = gTotalPageID; + gCurPageIndex = 0; + var str2 = PDFFileName; + var str3 = str2.Substring(0, str2.Length - 4) + "_.pdf"; + var str4 = str2.Substring(0, str2.Length - 4) + "_VI_.pdf"; + var str5 = str2.Substring(0, str2.Length - 4) + "_WOVI_.pdf"; + var str6 = str2.Substring(0, str2.Length - 4) + "_BGI_.pdf"; + var eBeginBuildState = OIDBeginBuildState.eBBState_OK; + eBeginBuildState = + (OIDBeginBuildState) oidPIGenerator.BeginBuildPublishImage(str2.ToCharArray(), bExportPDFImage, + Default_DPI); + CheckOidBuildState(eBeginBuildState); + + if (eBeginBuildState == OIDBeginBuildState.eBBState_OK && + (bGenerateBGWithVImage || bGenerateVImage || bGenerateBGWithImage)) { - num4 = this.gSID % 2; - num5 = this.gSID / 2; - num6 = this.gOID % 0x10; - num7 = this.gOID / 0x10; - num10 = this.gCurrentPageID % 0x10; - num11 = this.gCurrentPageID / 0x10; + num4 = gSID % 2; + num5 = gSID / 2; + num6 = gOID % 0x10; + num7 = gOID / 0x10; + num10 = gCurrentPageID % 0x10; + num11 = gCurrentPageID / 0x10; num12 = 0; num13 = 0; num14 = 0; num15 = 0; - switch (this.gSID) + + switch (gSID) { case 0: case 1: case 2: - num12 = (this.gBID % 0x20) << 13; - num13 = (this.gBID / 0x20) << 13; + num12 = (gBID % 0x20) << 13; + num13 = (gBID / 0x20) << 13; num14 = num10 << 9; num15 = num11 << 9; break; - + case 3: - num12 = (this.gBID % 4) << 0x10; - num13 = (this.gBID / 4) << 0x10; + num12 = (gBID % 4) << 0x10; + num13 = (gBID / 4) << 0x10; num14 = num10 << 12; num15 = num11 << 12; break; - - default: - break; } - nXStart = (((num4 << 0x16) + (num6 << 0x12)) + num12) + num14; - nYStart = (((num5 << 0x16) + (num7 << 0x12)) + num13) + num15; + + nXStart = (num4 << 0x16) + (num6 << 0x12) + num12 + num14; + nYStart = (num5 << 0x16) + (num7 << 0x12) + num13 + num15; + while (true) { - if (!this.oidPIGenerator.SetStartPosition(nPageIndex, nXStart, nYStart)) + if (!oidPIGenerator.SetStartPosition(nPageIndex, nXStart, nYStart)) { switch (PointType) { case 0: - this.gPointType = "2"; + gPointType = "2"; break; - + case 1: - this.gPointType = "3"; + gPointType = "3"; break; - + case 2: - this.gPointType = "4"; - break; - - default: + gPointType = "4"; break; } + if (bGenerateBGWithVImage) - { - this.oidPIGenerator.BuildPublishImage(str3.ToCharArray(), bPrintIdleCode, bSplitBigImage, bMergeSplittedImages, 1, PointType, 2); - } + oidPIGenerator.BuildPublishImage(str3.ToCharArray(), bPrintIdleCode, bSplitBigImage, + bMergeSplittedImages, 1, PointType, 2); + if (bGenerateVImage) - { - this.oidPIGenerator.BuildPublishImage(str4.ToCharArray(), bPrintIdleCode, bSplitBigImage, bMergeSplittedImages, 1, PointType, 1); - } + oidPIGenerator.BuildPublishImage(str4.ToCharArray(), bPrintIdleCode, bSplitBigImage, + bMergeSplittedImages, 1, PointType, 1); + if (bGenerateBGWithImage) - { - this.oidPIGenerator.BuildPublishImage(str6.ToCharArray(), bPrintIdleCode, bSplitBigImage, bMergeSplittedImages, 1, PointType, 3); - } - this.gCurPageIndex++; - this.oidPIGenerator.EndBuildPublishImage(); + oidPIGenerator.BuildPublishImage(str6.ToCharArray(), bPrintIdleCode, bSplitBigImage, + bMergeSplittedImages, 1, PointType, 3); + gCurPageIndex++; + oidPIGenerator.EndBuildPublishImage(); break; } - int nZOrder = 0; - int nObjectType = 0; - string filename = str2.Substring(0, str2.Length - 4) + "_Page" + nPageIndex.ToString() + ".png"; - Image image = Image.FromFile(filename); - uint width = (uint) image.Width; + + var nZOrder = 0; + var nObjectType = 0; + var filename = str2.Substring(0, str2.Length - 4) + "_Page" + nPageIndex + ".png"; + var image = Image.FromFile(filename); + var width = (uint) image.Width; image.Dispose(); - width += (uint) 0x48; - uint num23 = (uint) (image.Height + 0x48); - uint[] numArray3 = new uint[5]; + width += 0x48; + var num23 = (uint) (image.Height + 0x48); + var numArray3 = new uint[5]; numArray3[1] = 0x1372; numArray3[2] = 0x1372; - uint[] arPointX = numArray3; - uint[] numArray4 = new uint[5]; + var arPointX = numArray3; + var numArray4 = new uint[5]; numArray4[2] = 0x1a5d; numArray4[3] = 0x1a5d; - uint[] arPointY = numArray4; + var arPointY = numArray4; arPointX[1] = width; arPointX[2] = width; arPointY[2] = num23; @@ -1438,59 +1414,63 @@ namespace TmatrixLibrary nZOrder = 0; nObjectType = 1; index = 0; + while (true) { - if ((Tw[nPageIndex][index] == 0) && (Th[nPageIndex][index] == 0)) + if (Tw[nPageIndex][index] == 0 && Th[nPageIndex][index] == 0) { if (nPageIndex == 0) { - this.gTPDFName[nPageIndex] = str3; - this.gTPDFVIName[nPageIndex] = str4; - this.gTPDFBGIName[nPageIndex] = str6; + gTPDFName[nPageIndex] = str3; + gTPDFVIName[nPageIndex] = str4; + gTPDFBGIName[nPageIndex] = str6; } else { - this.gTPDFName[nPageIndex] = str3.Substring(0, str3.Length - 4) + "_" + nPageIndex.ToString() + ".pdf"; - this.gTPDFVIName[nPageIndex] = str4.Substring(0, str4.Length - 4) + "_" + nPageIndex.ToString() + ".pdf"; - this.gTPDFBGIName[nPageIndex] = str6.Substring(0, str6.Length - 4) + "_" + nPageIndex.ToString() + ".pdf"; + gTPDFName[nPageIndex] = str3.Substring(0, str3.Length - 4) + "_" + nPageIndex + ".pdf"; + gTPDFVIName[nPageIndex] = + str4.Substring(0, str4.Length - 4) + "_" + nPageIndex + ".pdf"; + gTPDFBGIName[nPageIndex] = + str6.Substring(0, str6.Length - 4) + "_" + nPageIndex + ".pdf"; } + nPageIndex++; - this.gCurrentPageID++; - num4 = this.gSID % 2; - num5 = this.gSID / 2; - num6 = this.gOID % 0x10; - num7 = this.gOID / 0x10; - num10 = this.gCurrentPageID % 0x10; - num11 = this.gCurrentPageID / 0x10; + gCurrentPageID++; + num4 = gSID % 2; + num5 = gSID / 2; + num6 = gOID % 0x10; + num7 = gOID / 0x10; + num10 = gCurrentPageID % 0x10; + num11 = gCurrentPageID / 0x10; num12 = 0; num13 = 0; num14 = 0; num15 = 0; - switch (this.gSID) + + switch (gSID) { case 0: case 1: case 2: - num12 = (this.gBID % 0x20) << 13; - num13 = (this.gBID / 0x20) << 13; + num12 = (gBID % 0x20) << 13; + num13 = (gBID / 0x20) << 13; num14 = num10 << 9; num15 = num11 << 9; break; - + case 3: - num12 = (this.gBID % 4) << 0x10; - num13 = (this.gBID / 4) << 0x10; + num12 = (gBID % 4) << 0x10; + num13 = (gBID / 4) << 0x10; num14 = num10 << 12; num15 = num11 << 12; break; - - default: - break; } - nXStart = (((num4 << 0x16) + (num6 << 0x12)) + num12) + num14; - nYStart = (((num5 << 0x16) + (num7 << 0x12)) + num13) + num15; + + nXStart = (num4 << 0x16) + (num6 << 0x12) + num12 + num14; + nYStart = (num5 << 0x16) + (num7 << 0x12) + num13 + num15; break; } + arPointX[0] = Tx[nPageIndex][index]; arPointY[0] = Ty[nPageIndex][index]; arPointX[1] = Tx[nPageIndex][index] + Tw[nPageIndex][index]; @@ -1499,111 +1479,122 @@ namespace TmatrixLibrary arPointY[2] = Ty[nPageIndex][index] + Th[nPageIndex][index]; arPointX[3] = Tx[nPageIndex][index]; arPointY[3] = Ty[nPageIndex][index] + Th[nPageIndex][index]; - this.oidPIGenerator.AddObjectInfo(nPageIndex, 0xffffffffUL, arPointX, arPointY, 4, nZOrder, nObjectType); + oidPIGenerator.AddObjectInfo(nPageIndex, 0xffffffffUL, arPointX, arPointY, 4, nZOrder, + nObjectType); nZOrder++; index++; } } } + eBeginBuildState = OIDBeginBuildState.eBBState_OK; - eBeginBuildState = (OIDBeginBuildState) this.oidPIGenerator.BeginBuildPublishImage(str2.ToCharArray(), bExportPDFImage, this.Default_DPI); - this.CheckOidBuildState(eBeginBuildState); - if ((eBeginBuildState == OIDBeginBuildState.eBBState_OK) && bGenerateBGWithoutVImage) + eBeginBuildState = + (OIDBeginBuildState) oidPIGenerator.BeginBuildPublishImage(str2.ToCharArray(), bExportPDFImage, + Default_DPI); + CheckOidBuildState(eBeginBuildState); + + if (eBeginBuildState == OIDBeginBuildState.eBBState_OK && bGenerateBGWithoutVImage) { - this.gTotalPageID = StartPageID; - this.gCurrentPageID = this.gTotalPageID; - this.gCurPageIndex = 0; + gTotalPageID = StartPageID; + gCurrentPageID = gTotalPageID; + gCurPageIndex = 0; nPageIndex = 0; bPrintIdleCode = false; - num4 = this.gSID % 2; - num5 = this.gSID / 2; - num6 = this.gOID % 0x10; - num7 = this.gOID / 0x10; - num10 = this.gCurrentPageID % 0x10; - num11 = this.gCurrentPageID / 0x10; + num4 = gSID % 2; + num5 = gSID / 2; + num6 = gOID % 0x10; + num7 = gOID / 0x10; + num10 = gCurrentPageID % 0x10; + num11 = gCurrentPageID / 0x10; num12 = 0; num13 = 0; num14 = 0; num15 = 0; - switch (this.gSID) + + switch (gSID) { case 0: case 1: case 2: - num12 = (this.gBID % 0x20) << 13; - num13 = (this.gBID / 0x20) << 13; + num12 = (gBID % 0x20) << 13; + num13 = (gBID / 0x20) << 13; num14 = num10 << 9; num15 = num11 << 9; break; - + case 3: - num12 = (this.gBID % 4) << 0x10; - num13 = (this.gBID / 4) << 0x10; + num12 = (gBID % 4) << 0x10; + num13 = (gBID / 4) << 0x10; num14 = num10 << 12; num15 = num11 << 12; break; - - default: - break; } - nXStart = (((num4 << 0x16) + (num6 << 0x12)) + num12) + num14; - nYStart = (((num5 << 0x16) + (num7 << 0x12)) + num13) + num15; + + nXStart = (num4 << 0x16) + (num6 << 0x12) + num12 + num14; + nYStart = (num5 << 0x16) + (num7 << 0x12) + num13 + num15; + while (true) { - if (!this.oidPIGenerator.SetStartPosition(nPageIndex, nXStart, nYStart)) + if (!oidPIGenerator.SetStartPosition(nPageIndex, nXStart, nYStart)) { - this.gPointType = (PointType != 1) ? "2" : "3"; + gPointType = PointType != 1 ? "2" : "3"; if (bGenerateBGWithoutVImage) - { - this.oidPIGenerator.BuildPublishImage(str5.ToCharArray(), bPrintIdleCode, bSplitBigImage, bMergeSplittedImages, 1, PointType, 2); - } - this.gCurPageIndex++; - this.oidPIGenerator.EndBuildPublishImage(); + oidPIGenerator.BuildPublishImage(str5.ToCharArray(), bPrintIdleCode, bSplitBigImage, + bMergeSplittedImages, 1, PointType, 2); + gCurPageIndex++; + oidPIGenerator.EndBuildPublishImage(); break; } - this.gTPDFWOVIName[nPageIndex] = (nPageIndex != 0) ? (str5.Substring(0, str5.Length - 4) + "_" + nPageIndex.ToString() + ".pdf") : str5; + + gTPDFWOVIName[nPageIndex] = nPageIndex != 0 + ? str5.Substring(0, str5.Length - 4) + "_" + nPageIndex + ".pdf" + : str5; nPageIndex++; - this.gCurrentPageID++; - num4 = this.gSID % 2; - num5 = this.gSID / 2; - num6 = this.gOID % 0x10; - num7 = this.gOID / 0x10; - num10 = this.gCurrentPageID % 0x10; - num11 = this.gCurrentPageID / 0x10; + gCurrentPageID++; + num4 = gSID % 2; + num5 = gSID / 2; + num6 = gOID % 0x10; + num7 = gOID / 0x10; + num10 = gCurrentPageID % 0x10; + num11 = gCurrentPageID / 0x10; num12 = 0; num13 = 0; num14 = 0; num15 = 0; - switch (this.gSID) + + switch (gSID) { case 0: case 1: case 2: - num12 = (this.gBID % 0x20) << 13; - num13 = (this.gBID / 0x20) << 13; + num12 = (gBID % 0x20) << 13; + num13 = (gBID / 0x20) << 13; num14 = num10 << 9; num15 = num11 << 9; break; - + case 3: - num12 = (this.gBID % 4) << 0x10; - num13 = (this.gBID / 4) << 0x10; + num12 = (gBID % 4) << 0x10; + num13 = (gBID / 4) << 0x10; num14 = num10 << 12; num15 = num11 << 12; break; - - default: - break; } - nXStart = (((num4 << 0x16) + (num6 << 0x12)) + num12) + num14; - nYStart = (((num5 << 0x16) + (num7 << 0x12)) + num13) + num15; + + nXStart = (num4 << 0x16) + (num6 << 0x12) + num12 + num14; + nYStart = (num5 << 0x16) + (num7 << 0x12) + num13 + num15; } } - this.RenameTmatrixPDF_OID4(StartPageID, this.gsSID, this.gsOID, this.gsBID, bGenerateBGWithVImage, bGenerateVImage, bGenerateBGWithoutVImage, bGenerateBGWithImage); + + RenameTmatrixPDF_OID4(StartPageID, gsSID, gsOID, gsBID, bGenerateBGWithVImage, bGenerateVImage, + bGenerateBGWithoutVImage, bGenerateBGWithImage); return "0Generate code completely"; } - - public string GenerateTmatrixCodeByArea_OID4(string KeyStr, string PDFFileName, int StartPageID, int[] PointType, int[] PointDPI, bool bGenerateBGWithVImage, bool bGenerateVImage, bool bGenerateBGWithoutVImage, bool bGenerateBGWithImage, uint[][] Tx, uint[][] Ty, uint[][] Tw, uint[][] Th) + + public string GenerateTmatrixCodeByArea_OID4(string KeyStr, string PDFFileName, int StartPageID, + int[] PointType, int[] PointDPI, bool bGenerateBGWithVImage, bool bGenerateVImage, + bool bGenerateBGWithoutVImage, bool bGenerateBGWithImage, uint[][] Tx, uint[][] Ty, uint[][] Tw, + uint[][] Th) { int num4; int num5; @@ -1615,150 +1606,144 @@ namespace TmatrixLibrary int num13; int num14; int num15; - string str = ""; - str = this.TmatrixKeyCheck_OID4(KeyStr); - if (str.Substring(0, 1) == "1") - { - return str; - } - if (PDFFileName == "") - { - return "1Please select PDF file first !"; - } - if ((StartPageID < int.Parse(this.gsPID1)) || (StartPageID > int.Parse(this.gsPID2))) - { - return ("1Start page ID must be located between " + this.gsPID1 + " ~ " + this.gsPID2); - } - this.gPageNum = this.GetPDFPageNumber(PDFFileName); - if (((this.gPageNum + StartPageID) - 1) > int.Parse(this.gsPID2)) - { + var str = ""; + str = TmatrixKeyCheck_OID4(KeyStr); + if (str.Substring(0, 1) == "1") return str; + + if (PDFFileName == "") return "1Please select PDF file first !"; + + if (StartPageID < int.Parse(gsPID1) || StartPageID > int.Parse(gsPID2)) + return "1Start page ID must be located between " + gsPID1 + " ~ " + gsPID2; + gPageNum = GetPDFPageNumber(PDFFileName); + if (gPageNum + StartPageID - 1 > int.Parse(gsPID2)) return "1Not enough code page for this PDF to generate !"; - } - this.gTotalPageID = StartPageID; - int nPageIndex = 0; - int nXStart = 0; - int nYStart = 0; - bool bPrintIdleCode = false; - bool bSplitBigImage = false; - bool bMergeSplittedImages = false; - bool bExportPDFImage = true; - int index = 0; - int num20 = 0; + gTotalPageID = StartPageID; + var nPageIndex = 0; + var nXStart = 0; + var nYStart = 0; + var bPrintIdleCode = false; + var bSplitBigImage = false; + var bMergeSplittedImages = false; + var bExportPDFImage = true; + var index = 0; + var num20 = 0; + for (index = 0; index < 4; index++) { - int num25 = PointType[index]; + var num25 = PointType[index]; + switch (num25) { case 0: - this.gsPointType[index] = "2"; + gsPointType[index] = "2"; break; - + case 1: - this.gsPointType[index] = "3"; + gsPointType[index] = "3"; break; - + case 2: - this.gsPointType[index] = "4"; - break; - - default: + gsPointType[index] = "4"; break; } + switch (PointDPI[index]) { case 0: - this.gsPointDPI[index] = "D600"; + gsPointDPI[index] = "D600"; break; - + case 1: - this.gsPointDPI[index] = "D1200"; - break; - - default: + gsPointDPI[index] = "D1200"; break; } } - this.gCurrentPageID = this.gTotalPageID; - this.gCurPageIndex = 0; - string str2 = PDFFileName; - string str3 = str2.Substring(0, str2.Length - 4) + "_.pdf"; - string str4 = str2.Substring(0, str2.Length - 4) + "_VI_.pdf"; - string str5 = str2.Substring(0, str2.Length - 4) + "_WOVI_.pdf"; - string str6 = str2.Substring(0, str2.Length - 4) + "_BGI_.pdf"; - OIDBeginBuildState eBeginBuildState = OIDBeginBuildState.eBBState_OK; - eBeginBuildState = (OIDBeginBuildState) this.oidPIGenerator.BeginBuildPublishImage(str2.ToCharArray(), bExportPDFImage, this.Default_DPI); - this.CheckOidBuildState(eBeginBuildState); - if ((eBeginBuildState == OIDBeginBuildState.eBBState_OK) && ((bGenerateBGWithVImage || bGenerateVImage) || bGenerateBGWithImage)) + + gCurrentPageID = gTotalPageID; + gCurPageIndex = 0; + var str2 = PDFFileName; + var str3 = str2.Substring(0, str2.Length - 4) + "_.pdf"; + var str4 = str2.Substring(0, str2.Length - 4) + "_VI_.pdf"; + var str5 = str2.Substring(0, str2.Length - 4) + "_WOVI_.pdf"; + var str6 = str2.Substring(0, str2.Length - 4) + "_BGI_.pdf"; + var eBeginBuildState = OIDBeginBuildState.eBBState_OK; + eBeginBuildState = + (OIDBeginBuildState) oidPIGenerator.BeginBuildPublishImage(str2.ToCharArray(), bExportPDFImage, + Default_DPI); + CheckOidBuildState(eBeginBuildState); + + if (eBeginBuildState == OIDBeginBuildState.eBBState_OK && + (bGenerateBGWithVImage || bGenerateVImage || bGenerateBGWithImage)) { - num4 = this.gSID % 2; - num5 = this.gSID / 2; - num6 = this.gOID % 0x10; - num7 = this.gOID / 0x10; - num10 = this.gCurrentPageID % 0x10; - num11 = this.gCurrentPageID / 0x10; + num4 = gSID % 2; + num5 = gSID / 2; + num6 = gOID % 0x10; + num7 = gOID / 0x10; + num10 = gCurrentPageID % 0x10; + num11 = gCurrentPageID / 0x10; num12 = 0; num13 = 0; num14 = 0; num15 = 0; - switch (this.gSID) + + switch (gSID) { case 0: case 1: case 2: - num12 = (this.gBID % 0x20) << 13; - num13 = (this.gBID / 0x20) << 13; + num12 = (gBID % 0x20) << 13; + num13 = (gBID / 0x20) << 13; num14 = num10 << 9; num15 = num11 << 9; break; - + case 3: - num12 = (this.gBID % 4) << 0x10; - num13 = (this.gBID / 4) << 0x10; + num12 = (gBID % 4) << 0x10; + num13 = (gBID / 4) << 0x10; num14 = num10 << 12; num15 = num11 << 12; break; - - default: - break; } - nXStart = (((num4 << 0x16) + (num6 << 0x12)) + num12) + num14; - nYStart = (((num5 << 0x16) + (num7 << 0x12)) + num13) + num15; + + nXStart = (num4 << 0x16) + (num6 << 0x12) + num12 + num14; + nYStart = (num5 << 0x16) + (num7 << 0x12) + num13 + num15; + while (true) { - if (!this.oidPIGenerator.SetStartPosition(nPageIndex, nXStart, nYStart)) + if (!oidPIGenerator.SetStartPosition(nPageIndex, nXStart, nYStart)) { if (bGenerateBGWithVImage) - { - this.oidPIGenerator.BuildPublishImage(str3.ToCharArray(), bPrintIdleCode, bSplitBigImage, bMergeSplittedImages, PointDPI[0], PointType[0], 2); - } + oidPIGenerator.BuildPublishImage(str3.ToCharArray(), bPrintIdleCode, bSplitBigImage, + bMergeSplittedImages, PointDPI[0], PointType[0], 2); + if (bGenerateVImage) - { - this.oidPIGenerator.BuildPublishImage(str4.ToCharArray(), bPrintIdleCode, bSplitBigImage, bMergeSplittedImages, PointDPI[1], PointType[1], 1); - } + oidPIGenerator.BuildPublishImage(str4.ToCharArray(), bPrintIdleCode, bSplitBigImage, + bMergeSplittedImages, PointDPI[1], PointType[1], 1); + if (bGenerateBGWithImage) - { - this.oidPIGenerator.BuildPublishImage(str6.ToCharArray(), bPrintIdleCode, bSplitBigImage, bMergeSplittedImages, PointDPI[3], PointType[3], 3); - } - this.gCurPageIndex++; - this.oidPIGenerator.EndBuildPublishImage(); + oidPIGenerator.BuildPublishImage(str6.ToCharArray(), bPrintIdleCode, bSplitBigImage, + bMergeSplittedImages, PointDPI[3], PointType[3], 3); + gCurPageIndex++; + oidPIGenerator.EndBuildPublishImage(); break; } - int nZOrder = 0; - int nObjectType = 0; - string filename = str2.Substring(0, str2.Length - 4) + "_Page" + nPageIndex.ToString() + ".png"; - Image image = Image.FromFile(filename); - uint width = (uint) image.Width; + + var nZOrder = 0; + var nObjectType = 0; + var filename = str2.Substring(0, str2.Length - 4) + "_Page" + nPageIndex + ".png"; + var image = Image.FromFile(filename); + var width = (uint) image.Width; image.Dispose(); - width += (uint) 0x48; - uint num24 = (uint) (image.Height + 0x48); - uint[] numArray3 = new uint[5]; + width += 0x48; + var num24 = (uint) (image.Height + 0x48); + var numArray3 = new uint[5]; numArray3[1] = 0x1372; numArray3[2] = 0x1372; - uint[] arPointX = numArray3; - uint[] numArray4 = new uint[5]; + var arPointX = numArray3; + var numArray4 = new uint[5]; numArray4[2] = 0x1a5d; numArray4[3] = 0x1a5d; - uint[] arPointY = numArray4; + var arPointY = numArray4; arPointX[1] = width; arPointX[2] = width; arPointY[2] = num24; @@ -1766,59 +1751,63 @@ namespace TmatrixLibrary nZOrder = 0; nObjectType = 1; num20 = 0; + while (true) { - if ((Tw[nPageIndex][num20] == 0) && (Th[nPageIndex][num20] == 0)) + if (Tw[nPageIndex][num20] == 0 && Th[nPageIndex][num20] == 0) { if (nPageIndex == 0) { - this.gTPDFName[nPageIndex] = str3; - this.gTPDFVIName[nPageIndex] = str4; - this.gTPDFBGIName[nPageIndex] = str6; + gTPDFName[nPageIndex] = str3; + gTPDFVIName[nPageIndex] = str4; + gTPDFBGIName[nPageIndex] = str6; } else { - this.gTPDFName[nPageIndex] = str3.Substring(0, str3.Length - 4) + "_" + nPageIndex.ToString() + ".pdf"; - this.gTPDFVIName[nPageIndex] = str4.Substring(0, str4.Length - 4) + "_" + nPageIndex.ToString() + ".pdf"; - this.gTPDFBGIName[nPageIndex] = str6.Substring(0, str6.Length - 4) + "_" + nPageIndex.ToString() + ".pdf"; + gTPDFName[nPageIndex] = str3.Substring(0, str3.Length - 4) + "_" + nPageIndex + ".pdf"; + gTPDFVIName[nPageIndex] = + str4.Substring(0, str4.Length - 4) + "_" + nPageIndex + ".pdf"; + gTPDFBGIName[nPageIndex] = + str6.Substring(0, str6.Length - 4) + "_" + nPageIndex + ".pdf"; } + nPageIndex++; - this.gCurrentPageID++; - num4 = this.gSID % 2; - num5 = this.gSID / 2; - num6 = this.gOID % 0x10; - num7 = this.gOID / 0x10; - num10 = this.gCurrentPageID % 0x10; - num11 = this.gCurrentPageID / 0x10; + gCurrentPageID++; + num4 = gSID % 2; + num5 = gSID / 2; + num6 = gOID % 0x10; + num7 = gOID / 0x10; + num10 = gCurrentPageID % 0x10; + num11 = gCurrentPageID / 0x10; num12 = 0; num13 = 0; num14 = 0; num15 = 0; - switch (this.gSID) + + switch (gSID) { case 0: case 1: case 2: - num12 = (this.gBID % 0x20) << 13; - num13 = (this.gBID / 0x20) << 13; + num12 = (gBID % 0x20) << 13; + num13 = (gBID / 0x20) << 13; num14 = num10 << 9; num15 = num11 << 9; break; - + case 3: - num12 = (this.gBID % 4) << 0x10; - num13 = (this.gBID / 4) << 0x10; + num12 = (gBID % 4) << 0x10; + num13 = (gBID / 4) << 0x10; num14 = num10 << 12; num15 = num11 << 12; break; - - default: - break; } - nXStart = (((num4 << 0x16) + (num6 << 0x12)) + num12) + num14; - nYStart = (((num5 << 0x16) + (num7 << 0x12)) + num13) + num15; + + nXStart = (num4 << 0x16) + (num6 << 0x12) + num12 + num14; + nYStart = (num5 << 0x16) + (num7 << 0x12) + num13 + num15; break; } + arPointX[0] = Tx[nPageIndex][num20]; arPointY[0] = Ty[nPageIndex][num20]; arPointX[1] = Tx[nPageIndex][num20] + Tw[nPageIndex][num20]; @@ -1827,519 +1816,541 @@ namespace TmatrixLibrary arPointY[2] = Ty[nPageIndex][num20] + Th[nPageIndex][num20]; arPointX[3] = Tx[nPageIndex][num20]; arPointY[3] = Ty[nPageIndex][num20] + Th[nPageIndex][num20]; - this.oidPIGenerator.AddObjectInfo(nPageIndex, 0xffffffffUL, arPointX, arPointY, 4, nZOrder, nObjectType); + oidPIGenerator.AddObjectInfo(nPageIndex, 0xffffffffUL, arPointX, arPointY, 4, nZOrder, + nObjectType); nZOrder++; num20++; } } } + eBeginBuildState = OIDBeginBuildState.eBBState_OK; - eBeginBuildState = (OIDBeginBuildState) this.oidPIGenerator.BeginBuildPublishImage(str2.ToCharArray(), bExportPDFImage, this.Default_DPI); - this.CheckOidBuildState(eBeginBuildState); - if ((eBeginBuildState == OIDBeginBuildState.eBBState_OK) && bGenerateBGWithoutVImage) + eBeginBuildState = + (OIDBeginBuildState) oidPIGenerator.BeginBuildPublishImage(str2.ToCharArray(), bExportPDFImage, + Default_DPI); + CheckOidBuildState(eBeginBuildState); + + if (eBeginBuildState == OIDBeginBuildState.eBBState_OK && bGenerateBGWithoutVImage) { - this.gTotalPageID = StartPageID; - this.gCurrentPageID = this.gTotalPageID; - this.gCurPageIndex = 0; + gTotalPageID = StartPageID; + gCurrentPageID = gTotalPageID; + gCurPageIndex = 0; nPageIndex = 0; bPrintIdleCode = false; - num4 = this.gSID % 2; - num5 = this.gSID / 2; - num6 = this.gOID % 0x10; - num7 = this.gOID / 0x10; - num10 = this.gCurrentPageID % 0x10; - num11 = this.gCurrentPageID / 0x10; + num4 = gSID % 2; + num5 = gSID / 2; + num6 = gOID % 0x10; + num7 = gOID / 0x10; + num10 = gCurrentPageID % 0x10; + num11 = gCurrentPageID / 0x10; num12 = 0; num13 = 0; num14 = 0; num15 = 0; - switch (this.gSID) + + switch (gSID) { case 0: case 1: case 2: - num12 = (this.gBID % 0x20) << 13; - num13 = (this.gBID / 0x20) << 13; + num12 = (gBID % 0x20) << 13; + num13 = (gBID / 0x20) << 13; num14 = num10 << 9; num15 = num11 << 9; break; - + case 3: - num12 = (this.gBID % 4) << 0x10; - num13 = (this.gBID / 4) << 0x10; + num12 = (gBID % 4) << 0x10; + num13 = (gBID / 4) << 0x10; num14 = num10 << 12; num15 = num11 << 12; break; - - default: - break; } - nXStart = (((num4 << 0x16) + (num6 << 0x12)) + num12) + num14; - nYStart = (((num5 << 0x16) + (num7 << 0x12)) + num13) + num15; + + nXStart = (num4 << 0x16) + (num6 << 0x12) + num12 + num14; + nYStart = (num5 << 0x16) + (num7 << 0x12) + num13 + num15; + while (true) { - if (!this.oidPIGenerator.SetStartPosition(nPageIndex, nXStart, nYStart)) + if (!oidPIGenerator.SetStartPosition(nPageIndex, nXStart, nYStart)) { if (bGenerateBGWithoutVImage) - { - this.oidPIGenerator.BuildPublishImage(str5.ToCharArray(), bPrintIdleCode, bSplitBigImage, bMergeSplittedImages, PointDPI[2], PointType[2], 2); - } - this.gCurPageIndex++; - this.oidPIGenerator.EndBuildPublishImage(); + oidPIGenerator.BuildPublishImage(str5.ToCharArray(), bPrintIdleCode, bSplitBigImage, + bMergeSplittedImages, PointDPI[2], PointType[2], 2); + gCurPageIndex++; + oidPIGenerator.EndBuildPublishImage(); break; } - this.gTPDFWOVIName[nPageIndex] = (nPageIndex != 0) ? (str5.Substring(0, str5.Length - 4) + "_" + nPageIndex.ToString() + ".pdf") : str5; + + gTPDFWOVIName[nPageIndex] = nPageIndex != 0 + ? str5.Substring(0, str5.Length - 4) + "_" + nPageIndex + ".pdf" + : str5; nPageIndex++; - this.gCurrentPageID++; - num4 = this.gSID % 2; - num5 = this.gSID / 2; - num6 = this.gOID % 0x10; - num7 = this.gOID / 0x10; - num10 = this.gCurrentPageID % 0x10; - num11 = this.gCurrentPageID / 0x10; + gCurrentPageID++; + num4 = gSID % 2; + num5 = gSID / 2; + num6 = gOID % 0x10; + num7 = gOID / 0x10; + num10 = gCurrentPageID % 0x10; + num11 = gCurrentPageID / 0x10; num12 = 0; num13 = 0; num14 = 0; num15 = 0; - switch (this.gSID) + + switch (gSID) { case 0: case 1: case 2: - num12 = (this.gBID % 0x20) << 13; - num13 = (this.gBID / 0x20) << 13; + num12 = (gBID % 0x20) << 13; + num13 = (gBID / 0x20) << 13; num14 = num10 << 9; num15 = num11 << 9; break; - + case 3: - num12 = (this.gBID % 4) << 0x10; - num13 = (this.gBID / 4) << 0x10; + num12 = (gBID % 4) << 0x10; + num13 = (gBID / 4) << 0x10; num14 = num10 << 12; num15 = num11 << 12; break; - - default: - break; } - nXStart = (((num4 << 0x16) + (num6 << 0x12)) + num12) + num14; - nYStart = (((num5 << 0x16) + (num7 << 0x12)) + num13) + num15; + + nXStart = (num4 << 0x16) + (num6 << 0x12) + num12 + num14; + nYStart = (num5 << 0x16) + (num7 << 0x12) + num13 + num15; } } - this.RenameTmatrixPDF_OID4(StartPageID, this.gsSID, this.gsOID, this.gsBID, bGenerateBGWithVImage, bGenerateVImage, bGenerateBGWithoutVImage, bGenerateBGWithImage); + + RenameTmatrixPDF_OID4(StartPageID, gsSID, gsOID, gsBID, bGenerateBGWithVImage, bGenerateVImage, + bGenerateBGWithoutVImage, bGenerateBGWithImage); return "0Generate code completely"; } - - public string GenerateTmatrixCodeForTForm(string KeyStr, string PDFFileName, int StartPageID, int PointType, bool bGenerateBGWithImage) + + public string GenerateTmatrixCodeForTForm(string KeyStr, string PDFFileName, int StartPageID, int PointType, + bool bGenerateBGWithImage) { - string str = ""; - str = this.TmatrixKeyCheck_OID4(KeyStr); - if (str.Substring(0, 1) == "1") - { - return str; - } - if (PDFFileName == "") - { - return "1Please select PDF file first !"; - } - if ((StartPageID < int.Parse(this.gsPID1)) || (StartPageID > int.Parse(this.gsPID2))) - { - return ("1Start page ID must be located between " + this.gsPID1 + " ~ " + this.gsPID2); - } - this.gPageNum = this.GetPDFPageNumber(PDFFileName); - if (((this.gPageNum + StartPageID) - 1) > int.Parse(this.gsPID2)) - { + var str = ""; + str = TmatrixKeyCheck_OID4(KeyStr); + if (str.Substring(0, 1) == "1") return str; + + if (PDFFileName == "") return "1Please select PDF file first !"; + + if (StartPageID < int.Parse(gsPID1) || StartPageID > int.Parse(gsPID2)) + return "1Start page ID must be located between " + gsPID1 + " ~ " + gsPID2; + gPageNum = GetPDFPageNumber(PDFFileName); + if (gPageNum + StartPageID - 1 > int.Parse(gsPID2)) return "1Not enough code page for this PDF to generate !"; - } - this.gTotalPageID = (int.Parse(KeyStr.Substring(4, 2)) * 0x100) + StartPageID; - int nPageIndex = 0; - int nXStart = 0; - int nYStart = 0; - bool bPrintIdleCode = false; - bool bSplitBigImage = false; - bool bMergeSplittedImages = false; - bool bExportPDFImage = true; - this.gCurrentPageID = this.gTotalPageID; - this.gCurPageIndex = 0; - string str2 = PDFFileName; + gTotalPageID = int.Parse(KeyStr.Substring(4, 2)) * 0x100 + StartPageID; + var nPageIndex = 0; + var nXStart = 0; + var nYStart = 0; + var bPrintIdleCode = false; + var bSplitBigImage = false; + var bMergeSplittedImages = false; + var bExportPDFImage = true; + gCurrentPageID = gTotalPageID; + gCurPageIndex = 0; + var str2 = PDFFileName; str2 = str2.Substring(0, str2.Length - 4) + "_.pdf"; str2 = str2.Substring(0, str2.Length - 4) + "_VI_.pdf"; str2 = str2.Substring(0, str2.Length - 4) + "_WOVI_.pdf"; - string str3 = str2.Substring(0, str2.Length - 4) + "_BGI_.pdf"; - OIDBeginBuildState eBeginBuildState = OIDBeginBuildState.eBBState_OK; - eBeginBuildState = (OIDBeginBuildState) this.oidPIGenerator.BeginBuildPublishImage(str2.ToCharArray(), bExportPDFImage, this.Default_DPI); - this.CheckOidBuildState(eBeginBuildState); - if ((eBeginBuildState == OIDBeginBuildState.eBBState_OK) && bGenerateBGWithImage) + var str3 = str2.Substring(0, str2.Length - 4) + "_BGI_.pdf"; + var eBeginBuildState = OIDBeginBuildState.eBBState_OK; + eBeginBuildState = + (OIDBeginBuildState) oidPIGenerator.BeginBuildPublishImage(str2.ToCharArray(), bExportPDFImage, + Default_DPI); + CheckOidBuildState(eBeginBuildState); + + if (eBeginBuildState == OIDBeginBuildState.eBBState_OK && bGenerateBGWithImage) { - int num4 = this.gSID % 2; - int num5 = this.gSID / 2; - int num6 = this.gOID % 0x10; - int num7 = this.gOID / 0x10; - int num10 = this.gCurrentPageID % 0x10; - int num11 = this.gCurrentPageID / 0x10; - int num12 = 0; - int num13 = 0; - int num14 = 0; - int num15 = 0; - switch (this.gSID) + var num4 = gSID % 2; + var num5 = gSID / 2; + var num6 = gOID % 0x10; + var num7 = gOID / 0x10; + var num10 = gCurrentPageID % 0x10; + var num11 = gCurrentPageID / 0x10; + var num12 = 0; + var num13 = 0; + var num14 = 0; + var num15 = 0; + + switch (gSID) { case 0: case 1: case 2: - num12 = (this.gBID % 0x20) << 13; - num13 = (this.gBID / 0x20) << 13; + num12 = (gBID % 0x20) << 13; + num13 = (gBID / 0x20) << 13; num14 = num10 << 9; num15 = num11 << 9; break; - + case 3: - num12 = (this.gBID % 4) << 0x10; - num13 = (this.gBID / 4) << 0x10; + num12 = (gBID % 4) << 0x10; + num13 = (gBID / 4) << 0x10; num14 = num10 << 12; num15 = num11 << 12; break; - - default: - break; } - nXStart = (((num4 << 0x16) + (num6 << 0x12)) + num12) + num14; - nYStart = (((num5 << 0x16) + (num7 << 0x12)) + num13) + num15; + + nXStart = (num4 << 0x16) + (num6 << 0x12) + num12 + num14; + nYStart = (num5 << 0x16) + (num7 << 0x12) + num13 + num15; + while (true) { - if (!this.oidPIGenerator.SetStartPosition(nPageIndex, nXStart, nYStart)) + if (!oidPIGenerator.SetStartPosition(nPageIndex, nXStart, nYStart)) { switch (PointType) { case 0: - this.gPointType = "2"; + gPointType = "2"; break; - + case 1: - this.gPointType = "3"; + gPointType = "3"; break; - + case 2: - this.gPointType = "4"; - break; - - default: + gPointType = "4"; break; } + if (bGenerateBGWithImage) - { - this.oidPIGenerator.BuildPublishImage(str3.ToCharArray(), bPrintIdleCode, bSplitBigImage, bMergeSplittedImages, 1, 2, 3); - } - this.gCurPageIndex++; - this.oidPIGenerator.EndBuildPublishImage(); + oidPIGenerator.BuildPublishImage(str3.ToCharArray(), bPrintIdleCode, bSplitBigImage, + bMergeSplittedImages, 1, 2, 3); + gCurPageIndex++; + oidPIGenerator.EndBuildPublishImage(); break; } - string filename = str2.Substring(0, str2.Length - 4) + "_Page" + nPageIndex.ToString() + ".png"; - Image image = Image.FromFile(filename); - uint width = (uint) image.Width; + + var filename = str2.Substring(0, str2.Length - 4) + "_Page" + nPageIndex + ".png"; + var image = Image.FromFile(filename); + var width = (uint) image.Width; image.Dispose(); - width += (uint) 0x48; - uint num22 = (uint) (image.Height + 0x48); - uint[] numArray3 = new uint[5]; + width += 0x48; + var num22 = (uint) (image.Height + 0x48); + var numArray3 = new uint[5]; numArray3[1] = 0x1372; numArray3[2] = 0x1372; - uint[] arPointX = numArray3; - uint[] numArray4 = new uint[5]; + var arPointX = numArray3; + var numArray4 = new uint[5]; numArray4[2] = 0x1a5d; numArray4[3] = 0x1a5d; - uint[] arPointY = numArray4; + var arPointY = numArray4; arPointX[1] = width; arPointX[2] = width; arPointY[2] = num22; arPointY[3] = num22; - this.oidPIGenerator.AddObjectInfo(nPageIndex, 0xffffffffUL, arPointX, arPointY, 4, 0, 1); - this.gTPDFBGIName[nPageIndex] = (nPageIndex != 0) ? (str3.Substring(0, str3.Length - 4) + "_" + nPageIndex.ToString() + ".pdf") : str3; + oidPIGenerator.AddObjectInfo(nPageIndex, 0xffffffffUL, arPointX, arPointY, 4, 0, 1); + gTPDFBGIName[nPageIndex] = nPageIndex != 0 + ? str3.Substring(0, str3.Length - 4) + "_" + nPageIndex + ".pdf" + : str3; nPageIndex++; - this.gCurrentPageID++; - num4 = this.gSID % 2; - num5 = this.gSID / 2; - num6 = this.gOID % 0x10; - num7 = this.gOID / 0x10; - num10 = this.gCurrentPageID % 0x10; - num11 = this.gCurrentPageID / 0x10; + gCurrentPageID++; + num4 = gSID % 2; + num5 = gSID / 2; + num6 = gOID % 0x10; + num7 = gOID / 0x10; + num10 = gCurrentPageID % 0x10; + num11 = gCurrentPageID / 0x10; num12 = 0; num13 = 0; num14 = 0; num15 = 0; - switch (this.gSID) + + switch (gSID) { case 0: case 1: case 2: - num12 = (this.gBID % 0x20) << 13; - num13 = (this.gBID / 0x20) << 13; + num12 = (gBID % 0x20) << 13; + num13 = (gBID / 0x20) << 13; num14 = num10 << 9; num15 = num11 << 9; break; - + case 3: - num12 = (this.gBID % 4) << 0x10; - num13 = (this.gBID / 4) << 0x10; + num12 = (gBID % 4) << 0x10; + num13 = (gBID / 4) << 0x10; num14 = num10 << 12; num15 = num11 << 12; break; - - default: - break; } - nXStart = (((num4 << 0x16) + (num6 << 0x12)) + num12) + num14; - nYStart = (((num5 << 0x16) + (num7 << 0x12)) + num13) + num15; + + nXStart = (num4 << 0x16) + (num6 << 0x12) + num12 + num14; + nYStart = (num5 << 0x16) + (num7 << 0x12) + num13 + num15; } } - this.RenameTmatrixPDF_OID4(StartPageID, this.gsSID, this.gsOID, this.gsBID, false, false, false, bGenerateBGWithImage); + + RenameTmatrixPDF_OID4(StartPageID, gsSID, gsOID, gsBID, false, false, false, bGenerateBGWithImage); return "0Generate code completely"; } - + public int GetPDFPageNumber(string PDFName) { - PdfReader obj = new PdfReader(PDFName); + var obj = new PdfReader(PDFName); return obj.NumberOfPages; } - - private string RenameBigAreaTmatrixPDF_OID4(int SP, string SID, string OID, string BID, bool bGenerateVImage, bool bGenerateImage, double w, double h) + + private string RenameBigAreaTmatrixPDF_OID4(int SP, string SID, string OID, string BID, bool bGenerateVImage, + bool bGenerateImage, double w, double h) { string str; string str2; string fileName; string str4; - int index = 0; + var index = 0; + if (bGenerateVImage) { - str2 = Path.GetDirectoryName(this.gTPDFVIName[index]) + @"\BA Vector Images"; - fileName = Path.GetFileName(this.gTPDFVIName[index]); - if (!Directory.Exists(str2)) - { - Directory.CreateDirectory(str2); - } + str2 = Path.GetDirectoryName(gTPDFVIName[index]) + @"\BA Vector Images"; + fileName = Path.GetFileName(gTPDFVIName[index]); + if (!Directory.Exists(str2)) Directory.CreateDirectory(str2); str4 = str2 + @"\" + fileName; - string[] strArray = new string[] { str4.Substring(0, str4.Length - 4), "0(Tmx", this.gsPointType[1], "S", SID, "O", OID, "B", BID }; + string[] strArray = + { str4.Substring(0, str4.Length - 4), "0(Tmx", gsPointType[1], "S", SID, "O", OID, "B", BID }; strArray[9] = "P"; strArray[10] = (SP + index).ToString("000"); - strArray[11] = this.gsPointDPI[1]; + strArray[11] = gsPointDPI[1]; strArray[12] = "W"; strArray[13] = w.ToString(); strArray[14] = "H"; strArray[15] = h.ToString(); strArray[0x10] = ").pdf"; str = string.Concat(strArray); - if (File.Exists(this.gTPDFVIName[index])) + + if (File.Exists(gTPDFVIName[index])) { - if (File.Exists(str)) - { - File.Delete(str); - } - File.Move(this.gTPDFVIName[index], str); + if (File.Exists(str)) File.Delete(str); + File.Move(gTPDFVIName[index], str); } } + if (bGenerateImage) { - str2 = Path.GetDirectoryName(this.gTPDFBGIName[0]) + @"\BA Images"; - fileName = Path.GetFileName(this.gTPDFBGIName[0]); - if (!Directory.Exists(str2)) - { - Directory.CreateDirectory(str2); - } + str2 = Path.GetDirectoryName(gTPDFBGIName[0]) + @"\BA Images"; + fileName = Path.GetFileName(gTPDFBGIName[0]); + if (!Directory.Exists(str2)) Directory.CreateDirectory(str2); str4 = str2 + @"\" + fileName; - string[] strArray2 = new string[] { str4.Substring(0, str4.Length - 4), "0(Tmx", this.gsPointType[3], "S", SID, "O", OID, "B", BID }; + string[] strArray2 = + { str4.Substring(0, str4.Length - 4), "0(Tmx", gsPointType[3], "S", SID, "O", OID, "B", BID }; strArray2[9] = "P"; strArray2[10] = (SP + index).ToString("000"); - strArray2[11] = this.gsPointDPI[3]; + strArray2[11] = gsPointDPI[3]; strArray2[12] = "W"; strArray2[13] = w.ToString(); strArray2[14] = "H"; strArray2[15] = h.ToString(); strArray2[0x10] = ").tif"; str = string.Concat(strArray2); - if (File.Exists(this.gTPDFBGIName[0])) + + if (File.Exists(gTPDFBGIName[0])) { - if (File.Exists(str)) - { - File.Delete(str); - } - File.Move(this.gTPDFBGIName[0], str); + if (File.Exists(str)) File.Delete(str); + File.Move(gTPDFBGIName[0], str); } } + return ""; } - + private void RenameTmatrixPDF(int SP, string BID) { - for (int i = 0; i < this.gPageNum; i++) + for (var i = 0; i < gPageNum; i++) { string str; + if (i == 0) { - string[] strArray = new string[] { this.gTPDFName[i].Substring(0, this.gTPDFName[i].Length - 4), "0(Tmx", this.gPointType, this.gsSize, "B", BID, "P", (SP + i).ToString("000"), ").pdf" }; + string[] strArray = + { + gTPDFName[i].Substring(0, gTPDFName[i].Length - 4), "0(Tmx", gPointType, gsSize, "B", BID, "P", + (SP + i).ToString("000"), ").pdf" + }; str = string.Concat(strArray); - if (File.Exists(this.gTPDFName[i])) + + if (File.Exists(gTPDFName[i])) { - if (File.Exists(str)) - { - File.Delete(str); - } - File.Move(this.gTPDFName[i], str); + if (File.Exists(str)) File.Delete(str); + File.Move(gTPDFName[i], str); } - string[] strArray2 = new string[] { this.gTPDFVIName[i].Substring(0, this.gTPDFVIName[i].Length - 4), "0(Tmx", this.gPointType, this.gsSize, "B", BID, "P", (SP + i).ToString("000"), ").pdf" }; - str = string.Concat(strArray2); - if (File.Exists(this.gTPDFVIName[i])) + + string[] strArray2 = { - if (File.Exists(str)) - { - File.Delete(str); - } - File.Move(this.gTPDFVIName[i], str); + gTPDFVIName[i].Substring(0, gTPDFVIName[i].Length - 4), "0(Tmx", gPointType, gsSize, "B", BID, + "P", (SP + i).ToString("000"), ").pdf" + }; + str = string.Concat(strArray2); + + if (File.Exists(gTPDFVIName[i])) + { + if (File.Exists(str)) File.Delete(str); + File.Move(gTPDFVIName[i], str); } } else if (i < 10) { - string[] strArray3 = new string[] { this.gTPDFName[i].Substring(0, this.gTPDFName[i].Length - 6), i.ToString(), "(Tmx", this.gPointType, this.gsSize, "B", BID, "P", (SP + i).ToString("000") }; + string[] strArray3 = + { + gTPDFName[i].Substring(0, gTPDFName[i].Length - 6), i.ToString(), "(Tmx", gPointType, gsSize, + "B", BID, "P", (SP + i).ToString("000") + }; strArray3[9] = ").pdf"; str = string.Concat(strArray3); - if (File.Exists(this.gTPDFName[i])) + + if (File.Exists(gTPDFName[i])) { - if (File.Exists(str)) - { - File.Delete(str); - } - File.Move(this.gTPDFName[i], str); + if (File.Exists(str)) File.Delete(str); + File.Move(gTPDFName[i], str); } - string[] strArray4 = new string[] { this.gTPDFVIName[i].Substring(0, this.gTPDFVIName[i].Length - 6), i.ToString(), "(Tmx", this.gPointType, this.gsSize, "B", BID, "P", (SP + i).ToString("000") }; + + string[] strArray4 = + { + gTPDFVIName[i].Substring(0, gTPDFVIName[i].Length - 6), i.ToString(), "(Tmx", gPointType, + gsSize, "B", BID, "P", (SP + i).ToString("000") + }; strArray4[9] = ").pdf"; str = string.Concat(strArray4); - if (File.Exists(this.gTPDFVIName[i])) + + if (File.Exists(gTPDFVIName[i])) { - if (File.Exists(str)) - { - File.Delete(str); - } - File.Move(this.gTPDFVIName[i], str); + if (File.Exists(str)) File.Delete(str); + File.Move(gTPDFVIName[i], str); } } else if (i < 100) { - string[] strArray5 = new string[] { this.gTPDFName[i].Substring(0, this.gTPDFName[i].Length - 7), i.ToString(), "(Tmx", this.gPointType, this.gsSize, "B", BID, "P", (SP + i).ToString("000") }; + string[] strArray5 = + { + gTPDFName[i].Substring(0, gTPDFName[i].Length - 7), i.ToString(), "(Tmx", gPointType, gsSize, + "B", BID, "P", (SP + i).ToString("000") + }; strArray5[9] = ").pdf"; str = string.Concat(strArray5); - if (File.Exists(this.gTPDFName[i])) + + if (File.Exists(gTPDFName[i])) { - if (File.Exists(str)) - { - File.Delete(str); - } - File.Move(this.gTPDFName[i], str); + if (File.Exists(str)) File.Delete(str); + File.Move(gTPDFName[i], str); } - string[] strArray6 = new string[] { this.gTPDFVIName[i].Substring(0, this.gTPDFVIName[i].Length - 7), i.ToString(), "(Tmx", this.gPointType, this.gsSize, "B", BID, "P", (SP + i).ToString("000") }; + + string[] strArray6 = + { + gTPDFVIName[i].Substring(0, gTPDFVIName[i].Length - 7), i.ToString(), "(Tmx", gPointType, + gsSize, "B", BID, "P", (SP + i).ToString("000") + }; strArray6[9] = ").pdf"; str = string.Concat(strArray6); - if (File.Exists(this.gTPDFVIName[i])) + + if (File.Exists(gTPDFVIName[i])) { - if (File.Exists(str)) - { - File.Delete(str); - } - File.Move(this.gTPDFVIName[i], str); + if (File.Exists(str)) File.Delete(str); + File.Move(gTPDFVIName[i], str); } } else { - string[] strArray7 = new string[] { this.gTPDFName[i].Substring(0, this.gTPDFName[i].Length - 8), i.ToString(), "(Tmx", this.gPointType, this.gsSize, "B", BID, "P", (SP + i).ToString("000") }; + string[] strArray7 = + { + gTPDFName[i].Substring(0, gTPDFName[i].Length - 8), i.ToString(), "(Tmx", gPointType, gsSize, + "B", BID, "P", (SP + i).ToString("000") + }; strArray7[9] = ").pdf"; str = string.Concat(strArray7); - if (File.Exists(this.gTPDFName[i])) + + if (File.Exists(gTPDFName[i])) { - if (File.Exists(str)) - { - File.Delete(str); - } - File.Move(this.gTPDFName[i], str); + if (File.Exists(str)) File.Delete(str); + File.Move(gTPDFName[i], str); } - string[] strArray8 = new string[] { this.gTPDFVIName[i].Substring(0, this.gTPDFVIName[i].Length - 8), i.ToString(), "(Tmx", this.gPointType, this.gsSize, "B", BID, "P", (SP + i).ToString("000") }; + + string[] strArray8 = + { + gTPDFVIName[i].Substring(0, gTPDFVIName[i].Length - 8), i.ToString(), "(Tmx", gPointType, + gsSize, "B", BID, "P", (SP + i).ToString("000") + }; strArray8[9] = ").pdf"; str = string.Concat(strArray8); - if (File.Exists(this.gTPDFVIName[i])) + + if (File.Exists(gTPDFVIName[i])) { - if (File.Exists(str)) - { - File.Delete(str); - } - File.Move(this.gTPDFVIName[i], str); + if (File.Exists(str)) File.Delete(str); + File.Move(gTPDFVIName[i], str); } } } } - - private void RenameTmatrixPDF(int SP, string BID, bool bGenerateBGWithVImage, bool bGenerateVImage, bool bGenerateBGWithoutVImage) + + private void RenameTmatrixPDF(int SP, string BID, bool bGenerateBGWithVImage, bool bGenerateVImage, + bool bGenerateBGWithoutVImage) { - for (int i = 0; i < this.gPageNum; i++) + for (var i = 0; i < gPageNum; i++) { string str; string str2; string fileName; string str4; + if (i == 0) { if (bGenerateBGWithVImage) { - str2 = Path.GetDirectoryName(this.gTPDFName[i]) + @"\Bg with Vector Images"; - fileName = Path.GetFileName(this.gTPDFName[i]); - if (!Directory.Exists(str2)) - { - Directory.CreateDirectory(str2); - } + str2 = Path.GetDirectoryName(gTPDFName[i]) + @"\Bg with Vector Images"; + fileName = Path.GetFileName(gTPDFName[i]); + if (!Directory.Exists(str2)) Directory.CreateDirectory(str2); str4 = str2 + @"\" + fileName; - string[] strArray = new string[] { str4.Substring(0, str4.Length - 4), "0(Tmx", this.gPointType, this.gsSize, "B", BID, "P", (SP + i).ToString("000"), ").pdf" }; - str = string.Concat(strArray); - if (File.Exists(this.gTPDFName[i])) + string[] strArray = { - if (File.Exists(str)) - { - File.Delete(str); - } - File.Move(this.gTPDFName[i], str); + str4.Substring(0, str4.Length - 4), "0(Tmx", gPointType, gsSize, "B", BID, "P", + (SP + i).ToString("000"), ").pdf" + }; + str = string.Concat(strArray); + + if (File.Exists(gTPDFName[i])) + { + if (File.Exists(str)) File.Delete(str); + File.Move(gTPDFName[i], str); } } + if (bGenerateVImage) { - str2 = Path.GetDirectoryName(this.gTPDFVIName[i]) + @"\Vector Images"; - fileName = Path.GetFileName(this.gTPDFVIName[i]); - if (!Directory.Exists(str2)) - { - Directory.CreateDirectory(str2); - } + str2 = Path.GetDirectoryName(gTPDFVIName[i]) + @"\Vector Images"; + fileName = Path.GetFileName(gTPDFVIName[i]); + if (!Directory.Exists(str2)) Directory.CreateDirectory(str2); str4 = str2 + @"\" + fileName; - string[] strArray2 = new string[] { str4.Substring(0, str4.Length - 4), "0(Tmx", this.gPointType, this.gsSize, "B", BID, "P", (SP + i).ToString("000"), ").pdf" }; - str = string.Concat(strArray2); - if (File.Exists(this.gTPDFVIName[i])) + string[] strArray2 = { - if (File.Exists(str)) - { - File.Delete(str); - } - File.Move(this.gTPDFVIName[i], str); + str4.Substring(0, str4.Length - 4), "0(Tmx", gPointType, gsSize, "B", BID, "P", + (SP + i).ToString("000"), ").pdf" + }; + str = string.Concat(strArray2); + + if (File.Exists(gTPDFVIName[i])) + { + if (File.Exists(str)) File.Delete(str); + File.Move(gTPDFVIName[i], str); } } + if (bGenerateBGWithoutVImage) { - str2 = Path.GetDirectoryName(this.gTPDFWOVIName[i]) + @"\Bg without Vector Images"; - fileName = Path.GetFileName(this.gTPDFWOVIName[i]); - if (!Directory.Exists(str2)) - { - Directory.CreateDirectory(str2); - } + str2 = Path.GetDirectoryName(gTPDFWOVIName[i]) + @"\Bg without Vector Images"; + fileName = Path.GetFileName(gTPDFWOVIName[i]); + if (!Directory.Exists(str2)) Directory.CreateDirectory(str2); str4 = str2 + @"\" + fileName; - string[] strArray3 = new string[] { str4.Substring(0, str4.Length - 4), "0(Tmx", this.gPointType, this.gsSize, "B", BID, "P", (SP + i).ToString("000"), ").pdf" }; - str = string.Concat(strArray3); - if (File.Exists(this.gTPDFWOVIName[i])) + string[] strArray3 = { - if (File.Exists(str)) - { - File.Delete(str); - } - File.Move(this.gTPDFWOVIName[i], str); + str4.Substring(0, str4.Length - 4), "0(Tmx", gPointType, gsSize, "B", BID, "P", + (SP + i).ToString("000"), ").pdf" + }; + str = string.Concat(strArray3); + + if (File.Exists(gTPDFWOVIName[i])) + { + if (File.Exists(str)) File.Delete(str); + File.Move(gTPDFWOVIName[i], str); } } } @@ -2347,65 +2358,64 @@ namespace TmatrixLibrary { if (bGenerateBGWithVImage) { - str2 = Path.GetDirectoryName(this.gTPDFName[i]) + @"\Bg with Vector Images"; - fileName = Path.GetFileName(this.gTPDFName[i]); - if (!Directory.Exists(str2)) - { - Directory.CreateDirectory(str2); - } + str2 = Path.GetDirectoryName(gTPDFName[i]) + @"\Bg with Vector Images"; + fileName = Path.GetFileName(gTPDFName[i]); + if (!Directory.Exists(str2)) Directory.CreateDirectory(str2); str4 = str2 + @"\" + fileName; - string[] strArray4 = new string[] { str4.Substring(0, str4.Length - 6), i.ToString(), "(Tmx", this.gPointType, this.gsSize, "B", BID, "P", (SP + i).ToString("000") }; + string[] strArray4 = + { + str4.Substring(0, str4.Length - 6), i.ToString(), "(Tmx", gPointType, gsSize, "B", BID, "P", + (SP + i).ToString("000") + }; strArray4[9] = ").pdf"; str = string.Concat(strArray4); - if (File.Exists(this.gTPDFName[i])) + + if (File.Exists(gTPDFName[i])) { - if (File.Exists(str)) - { - File.Delete(str); - } - File.Move(this.gTPDFName[i], str); + if (File.Exists(str)) File.Delete(str); + File.Move(gTPDFName[i], str); } } + if (bGenerateVImage) { - str2 = Path.GetDirectoryName(this.gTPDFVIName[i]) + @"\Vector Images"; - fileName = Path.GetFileName(this.gTPDFVIName[i]); - if (!Directory.Exists(str2)) - { - Directory.CreateDirectory(str2); - } + str2 = Path.GetDirectoryName(gTPDFVIName[i]) + @"\Vector Images"; + fileName = Path.GetFileName(gTPDFVIName[i]); + if (!Directory.Exists(str2)) Directory.CreateDirectory(str2); str4 = str2 + @"\" + fileName; - string[] strArray5 = new string[] { str4.Substring(0, str4.Length - 6), i.ToString(), "(Tmx", this.gPointType, this.gsSize, "B", BID, "P", (SP + i).ToString("000") }; + string[] strArray5 = + { + str4.Substring(0, str4.Length - 6), i.ToString(), "(Tmx", gPointType, gsSize, "B", BID, "P", + (SP + i).ToString("000") + }; strArray5[9] = ").pdf"; str = string.Concat(strArray5); - if (File.Exists(this.gTPDFVIName[i])) + + if (File.Exists(gTPDFVIName[i])) { - if (File.Exists(str)) - { - File.Delete(str); - } - File.Move(this.gTPDFVIName[i], str); + if (File.Exists(str)) File.Delete(str); + File.Move(gTPDFVIName[i], str); } } + if (bGenerateBGWithoutVImage) { - str2 = Path.GetDirectoryName(this.gTPDFWOVIName[i]) + @"\Bg without Vector Images"; - fileName = Path.GetFileName(this.gTPDFWOVIName[i]); - if (!Directory.Exists(str2)) - { - Directory.CreateDirectory(str2); - } + str2 = Path.GetDirectoryName(gTPDFWOVIName[i]) + @"\Bg without Vector Images"; + fileName = Path.GetFileName(gTPDFWOVIName[i]); + if (!Directory.Exists(str2)) Directory.CreateDirectory(str2); str4 = str2 + @"\" + fileName; - string[] strArray6 = new string[] { str4.Substring(0, str4.Length - 6), i.ToString(), "(Tmx", this.gPointType, this.gsSize, "B", BID, "P", (SP + i).ToString("000") }; + string[] strArray6 = + { + str4.Substring(0, str4.Length - 6), i.ToString(), "(Tmx", gPointType, gsSize, "B", BID, "P", + (SP + i).ToString("000") + }; strArray6[9] = ").pdf"; str = string.Concat(strArray6); - if (File.Exists(this.gTPDFWOVIName[i])) + + if (File.Exists(gTPDFWOVIName[i])) { - if (File.Exists(str)) - { - File.Delete(str); - } - File.Move(this.gTPDFWOVIName[i], str); + if (File.Exists(str)) File.Delete(str); + File.Move(gTPDFWOVIName[i], str); } } } @@ -2413,65 +2423,64 @@ namespace TmatrixLibrary { if (bGenerateBGWithVImage) { - str2 = Path.GetDirectoryName(this.gTPDFName[i]) + @"\Bg with Vector Images"; - fileName = Path.GetFileName(this.gTPDFName[i]); - if (!Directory.Exists(str2)) - { - Directory.CreateDirectory(str2); - } + str2 = Path.GetDirectoryName(gTPDFName[i]) + @"\Bg with Vector Images"; + fileName = Path.GetFileName(gTPDFName[i]); + if (!Directory.Exists(str2)) Directory.CreateDirectory(str2); str4 = str2 + @"\" + fileName; - string[] strArray7 = new string[] { str4.Substring(0, str4.Length - 7), i.ToString(), "(Tmx", this.gPointType, this.gsSize, "B", BID, "P", (SP + i).ToString("000") }; + string[] strArray7 = + { + str4.Substring(0, str4.Length - 7), i.ToString(), "(Tmx", gPointType, gsSize, "B", BID, "P", + (SP + i).ToString("000") + }; strArray7[9] = ").pdf"; str = string.Concat(strArray7); - if (File.Exists(this.gTPDFName[i])) + + if (File.Exists(gTPDFName[i])) { - if (File.Exists(str)) - { - File.Delete(str); - } - File.Move(this.gTPDFName[i], str); + if (File.Exists(str)) File.Delete(str); + File.Move(gTPDFName[i], str); } } + if (bGenerateVImage) { - str2 = Path.GetDirectoryName(this.gTPDFVIName[i]) + @"\Vector Images"; - fileName = Path.GetFileName(this.gTPDFVIName[i]); - if (!Directory.Exists(str2)) - { - Directory.CreateDirectory(str2); - } + str2 = Path.GetDirectoryName(gTPDFVIName[i]) + @"\Vector Images"; + fileName = Path.GetFileName(gTPDFVIName[i]); + if (!Directory.Exists(str2)) Directory.CreateDirectory(str2); str4 = str2 + @"\" + fileName; - string[] strArray8 = new string[] { str4.Substring(0, str4.Length - 7), i.ToString(), "(Tmx", this.gPointType, this.gsSize, "B", BID, "P", (SP + i).ToString("000") }; + string[] strArray8 = + { + str4.Substring(0, str4.Length - 7), i.ToString(), "(Tmx", gPointType, gsSize, "B", BID, "P", + (SP + i).ToString("000") + }; strArray8[9] = ").pdf"; str = string.Concat(strArray8); - if (File.Exists(this.gTPDFVIName[i])) + + if (File.Exists(gTPDFVIName[i])) { - if (File.Exists(str)) - { - File.Delete(str); - } - File.Move(this.gTPDFVIName[i], str); + if (File.Exists(str)) File.Delete(str); + File.Move(gTPDFVIName[i], str); } } + if (bGenerateBGWithoutVImage) { - str2 = Path.GetDirectoryName(this.gTPDFWOVIName[i]) + @"\Bg without Vector Images"; - fileName = Path.GetFileName(this.gTPDFWOVIName[i]); - if (!Directory.Exists(str2)) - { - Directory.CreateDirectory(str2); - } + str2 = Path.GetDirectoryName(gTPDFWOVIName[i]) + @"\Bg without Vector Images"; + fileName = Path.GetFileName(gTPDFWOVIName[i]); + if (!Directory.Exists(str2)) Directory.CreateDirectory(str2); str4 = str2 + @"\" + fileName; - string[] strArray9 = new string[] { str4.Substring(0, str4.Length - 7), i.ToString(), "(Tmx", this.gPointType, this.gsSize, "B", BID, "P", (SP + i).ToString("000") }; + string[] strArray9 = + { + str4.Substring(0, str4.Length - 7), i.ToString(), "(Tmx", gPointType, gsSize, "B", BID, "P", + (SP + i).ToString("000") + }; strArray9[9] = ").pdf"; str = string.Concat(strArray9); - if (File.Exists(this.gTPDFWOVIName[i])) + + if (File.Exists(gTPDFWOVIName[i])) { - if (File.Exists(str)) - { - File.Delete(str); - } - File.Move(this.gTPDFWOVIName[i], str); + if (File.Exists(str)) File.Delete(str); + File.Move(gTPDFWOVIName[i], str); } } } @@ -2479,159 +2488,159 @@ namespace TmatrixLibrary { if (bGenerateBGWithVImage) { - str2 = Path.GetDirectoryName(this.gTPDFName[i]) + @"\Bg with Vector Images"; - fileName = Path.GetFileName(this.gTPDFName[i]); - if (!Directory.Exists(str2)) - { - Directory.CreateDirectory(str2); - } + str2 = Path.GetDirectoryName(gTPDFName[i]) + @"\Bg with Vector Images"; + fileName = Path.GetFileName(gTPDFName[i]); + if (!Directory.Exists(str2)) Directory.CreateDirectory(str2); str4 = str2 + @"\" + fileName; - string[] strArray10 = new string[] { str4.Substring(0, str4.Length - 8), i.ToString(), "(Tmx", this.gPointType, this.gsSize, "B", BID, "P", (SP + i).ToString("000") }; + string[] strArray10 = + { + str4.Substring(0, str4.Length - 8), i.ToString(), "(Tmx", gPointType, gsSize, "B", BID, "P", + (SP + i).ToString("000") + }; strArray10[9] = ").pdf"; str = string.Concat(strArray10); - if (File.Exists(this.gTPDFName[i])) + + if (File.Exists(gTPDFName[i])) { - if (File.Exists(str)) - { - File.Delete(str); - } - File.Move(this.gTPDFName[i], str); + if (File.Exists(str)) File.Delete(str); + File.Move(gTPDFName[i], str); } } + if (bGenerateVImage) { - str2 = Path.GetDirectoryName(this.gTPDFVIName[i]) + @"\Vector Images"; - fileName = Path.GetFileName(this.gTPDFVIName[i]); - if (!Directory.Exists(str2)) - { - Directory.CreateDirectory(str2); - } + str2 = Path.GetDirectoryName(gTPDFVIName[i]) + @"\Vector Images"; + fileName = Path.GetFileName(gTPDFVIName[i]); + if (!Directory.Exists(str2)) Directory.CreateDirectory(str2); str4 = str2 + @"\" + fileName; - string[] strArray11 = new string[] { str4.Substring(0, str4.Length - 8), i.ToString(), "(Tmx", this.gPointType, this.gsSize, "B", BID, "P", (SP + i).ToString("000") }; + string[] strArray11 = + { + str4.Substring(0, str4.Length - 8), i.ToString(), "(Tmx", gPointType, gsSize, "B", BID, "P", + (SP + i).ToString("000") + }; strArray11[9] = ").pdf"; str = string.Concat(strArray11); - if (File.Exists(this.gTPDFVIName[i])) + + if (File.Exists(gTPDFVIName[i])) { - if (File.Exists(str)) - { - File.Delete(str); - } - File.Move(this.gTPDFVIName[i], str); + if (File.Exists(str)) File.Delete(str); + File.Move(gTPDFVIName[i], str); } } + if (bGenerateBGWithoutVImage) { - str2 = Path.GetDirectoryName(this.gTPDFWOVIName[i]) + @"\Bg without Vector Images"; - fileName = Path.GetFileName(this.gTPDFWOVIName[i]); - if (!Directory.Exists(str2)) - { - Directory.CreateDirectory(str2); - } + str2 = Path.GetDirectoryName(gTPDFWOVIName[i]) + @"\Bg without Vector Images"; + fileName = Path.GetFileName(gTPDFWOVIName[i]); + if (!Directory.Exists(str2)) Directory.CreateDirectory(str2); str4 = str2 + @"\" + fileName; - string[] strArray12 = new string[] { str4.Substring(0, str4.Length - 8), i.ToString(), "(Tmx", this.gPointType, this.gsSize, "B", BID, "P", (SP + i).ToString("000") }; + string[] strArray12 = + { + str4.Substring(0, str4.Length - 8), i.ToString(), "(Tmx", gPointType, gsSize, "B", BID, "P", + (SP + i).ToString("000") + }; strArray12[9] = ").pdf"; str = string.Concat(strArray12); - if (File.Exists(this.gTPDFWOVIName[i])) + + if (File.Exists(gTPDFWOVIName[i])) { - if (File.Exists(str)) - { - File.Delete(str); - } - File.Move(this.gTPDFWOVIName[i], str); + if (File.Exists(str)) File.Delete(str); + File.Move(gTPDFWOVIName[i], str); } } } } } - - private void RenameTmatrixPDF(int SP, string BID, bool bGenerateBGWithVImage, bool bGenerateVImage, bool bGenerateBGWithoutVImage, bool bGenerateBGWithImage) + + private void RenameTmatrixPDF(int SP, string BID, bool bGenerateBGWithVImage, bool bGenerateVImage, + bool bGenerateBGWithoutVImage, bool bGenerateBGWithImage) { - for (int i = 0; i < this.gPageNum; i++) + for (var i = 0; i < gPageNum; i++) { string str; string str2; string fileName; string str4; + if (i == 0) { if (bGenerateBGWithVImage) { - str2 = Path.GetDirectoryName(this.gTPDFName[i]) + @"\Bg with Vector Images"; - fileName = Path.GetFileName(this.gTPDFName[i]); - if (!Directory.Exists(str2)) - { - Directory.CreateDirectory(str2); - } + str2 = Path.GetDirectoryName(gTPDFName[i]) + @"\Bg with Vector Images"; + fileName = Path.GetFileName(gTPDFName[i]); + if (!Directory.Exists(str2)) Directory.CreateDirectory(str2); str4 = str2 + @"\" + fileName; - string[] strArray = new string[] { str4.Substring(0, str4.Length - 4), "0(Tmx", this.gPointType, this.gsSize, "B", BID, "P", (SP + i).ToString("000"), ").pdf" }; - str = string.Concat(strArray); - if (File.Exists(this.gTPDFName[i])) + string[] strArray = { - if (File.Exists(str)) - { - File.Delete(str); - } - File.Move(this.gTPDFName[i], str); + str4.Substring(0, str4.Length - 4), "0(Tmx", gPointType, gsSize, "B", BID, "P", + (SP + i).ToString("000"), ").pdf" + }; + str = string.Concat(strArray); + + if (File.Exists(gTPDFName[i])) + { + if (File.Exists(str)) File.Delete(str); + File.Move(gTPDFName[i], str); } } + if (bGenerateVImage) { - str2 = Path.GetDirectoryName(this.gTPDFVIName[i]) + @"\Vector Images"; - fileName = Path.GetFileName(this.gTPDFVIName[i]); - if (!Directory.Exists(str2)) - { - Directory.CreateDirectory(str2); - } + str2 = Path.GetDirectoryName(gTPDFVIName[i]) + @"\Vector Images"; + fileName = Path.GetFileName(gTPDFVIName[i]); + if (!Directory.Exists(str2)) Directory.CreateDirectory(str2); str4 = str2 + @"\" + fileName; - string[] strArray2 = new string[] { str4.Substring(0, str4.Length - 4), "0(Tmx", this.gPointType, this.gsSize, "B", BID, "P", (SP + i).ToString("000"), ").pdf" }; - str = string.Concat(strArray2); - if (File.Exists(this.gTPDFVIName[i])) + string[] strArray2 = { - if (File.Exists(str)) - { - File.Delete(str); - } - File.Move(this.gTPDFVIName[i], str); + str4.Substring(0, str4.Length - 4), "0(Tmx", gPointType, gsSize, "B", BID, "P", + (SP + i).ToString("000"), ").pdf" + }; + str = string.Concat(strArray2); + + if (File.Exists(gTPDFVIName[i])) + { + if (File.Exists(str)) File.Delete(str); + File.Move(gTPDFVIName[i], str); } } + if (bGenerateBGWithoutVImage) { - str2 = Path.GetDirectoryName(this.gTPDFWOVIName[i]) + @"\Bg without Vector Images"; - fileName = Path.GetFileName(this.gTPDFWOVIName[i]); - if (!Directory.Exists(str2)) - { - Directory.CreateDirectory(str2); - } + str2 = Path.GetDirectoryName(gTPDFWOVIName[i]) + @"\Bg without Vector Images"; + fileName = Path.GetFileName(gTPDFWOVIName[i]); + if (!Directory.Exists(str2)) Directory.CreateDirectory(str2); str4 = str2 + @"\" + fileName; - string[] strArray3 = new string[] { str4.Substring(0, str4.Length - 4), "0(Tmx", this.gPointType, this.gsSize, "B", BID, "P", (SP + i).ToString("000"), ").pdf" }; - str = string.Concat(strArray3); - if (File.Exists(this.gTPDFWOVIName[i])) + string[] strArray3 = { - if (File.Exists(str)) - { - File.Delete(str); - } - File.Move(this.gTPDFWOVIName[i], str); + str4.Substring(0, str4.Length - 4), "0(Tmx", gPointType, gsSize, "B", BID, "P", + (SP + i).ToString("000"), ").pdf" + }; + str = string.Concat(strArray3); + + if (File.Exists(gTPDFWOVIName[i])) + { + if (File.Exists(str)) File.Delete(str); + File.Move(gTPDFWOVIName[i], str); } } + if (bGenerateBGWithImage) { - str2 = Path.GetDirectoryName(this.gTPDFBGIName[i]) + @"\Bg with Images"; - fileName = Path.GetFileName(this.gTPDFBGIName[i]); - if (!Directory.Exists(str2)) - { - Directory.CreateDirectory(str2); - } + str2 = Path.GetDirectoryName(gTPDFBGIName[i]) + @"\Bg with Images"; + fileName = Path.GetFileName(gTPDFBGIName[i]); + if (!Directory.Exists(str2)) Directory.CreateDirectory(str2); str4 = str2 + @"\" + fileName; - string[] strArray4 = new string[] { str4.Substring(0, str4.Length - 4), "0(Tmx", this.gPointType, this.gsSize, "B", BID, "P", (SP + i).ToString("000"), ").pdf" }; - str = string.Concat(strArray4); - if (File.Exists(this.gTPDFBGIName[i])) + string[] strArray4 = { - if (File.Exists(str)) - { - File.Delete(str); - } - File.Move(this.gTPDFBGIName[i], str); + str4.Substring(0, str4.Length - 4), "0(Tmx", gPointType, gsSize, "B", BID, "P", + (SP + i).ToString("000"), ").pdf" + }; + str = string.Concat(strArray4); + + if (File.Exists(gTPDFBGIName[i])) + { + if (File.Exists(str)) File.Delete(str); + File.Move(gTPDFBGIName[i], str); } } } @@ -2639,86 +2648,85 @@ namespace TmatrixLibrary { if (bGenerateBGWithVImage) { - str2 = Path.GetDirectoryName(this.gTPDFName[i]) + @"\Bg with Vector Images"; - fileName = Path.GetFileName(this.gTPDFName[i]); - if (!Directory.Exists(str2)) - { - Directory.CreateDirectory(str2); - } + str2 = Path.GetDirectoryName(gTPDFName[i]) + @"\Bg with Vector Images"; + fileName = Path.GetFileName(gTPDFName[i]); + if (!Directory.Exists(str2)) Directory.CreateDirectory(str2); str4 = str2 + @"\" + fileName; - string[] strArray5 = new string[] { str4.Substring(0, str4.Length - 6), i.ToString(), "(Tmx", this.gPointType, this.gsSize, "B", BID, "P", (SP + i).ToString("000") }; + string[] strArray5 = + { + str4.Substring(0, str4.Length - 6), i.ToString(), "(Tmx", gPointType, gsSize, "B", BID, "P", + (SP + i).ToString("000") + }; strArray5[9] = ").pdf"; str = string.Concat(strArray5); - if (File.Exists(this.gTPDFName[i])) + + if (File.Exists(gTPDFName[i])) { - if (File.Exists(str)) - { - File.Delete(str); - } - File.Move(this.gTPDFName[i], str); + if (File.Exists(str)) File.Delete(str); + File.Move(gTPDFName[i], str); } } + if (bGenerateVImage) { - str2 = Path.GetDirectoryName(this.gTPDFVIName[i]) + @"\Vector Images"; - fileName = Path.GetFileName(this.gTPDFVIName[i]); - if (!Directory.Exists(str2)) - { - Directory.CreateDirectory(str2); - } + str2 = Path.GetDirectoryName(gTPDFVIName[i]) + @"\Vector Images"; + fileName = Path.GetFileName(gTPDFVIName[i]); + if (!Directory.Exists(str2)) Directory.CreateDirectory(str2); str4 = str2 + @"\" + fileName; - string[] strArray6 = new string[] { str4.Substring(0, str4.Length - 6), i.ToString(), "(Tmx", this.gPointType, this.gsSize, "B", BID, "P", (SP + i).ToString("000") }; + string[] strArray6 = + { + str4.Substring(0, str4.Length - 6), i.ToString(), "(Tmx", gPointType, gsSize, "B", BID, "P", + (SP + i).ToString("000") + }; strArray6[9] = ").pdf"; str = string.Concat(strArray6); - if (File.Exists(this.gTPDFVIName[i])) + + if (File.Exists(gTPDFVIName[i])) { - if (File.Exists(str)) - { - File.Delete(str); - } - File.Move(this.gTPDFVIName[i], str); + if (File.Exists(str)) File.Delete(str); + File.Move(gTPDFVIName[i], str); } } + if (bGenerateBGWithoutVImage) { - str2 = Path.GetDirectoryName(this.gTPDFWOVIName[i]) + @"\Bg without Vector Images"; - fileName = Path.GetFileName(this.gTPDFWOVIName[i]); - if (!Directory.Exists(str2)) - { - Directory.CreateDirectory(str2); - } + str2 = Path.GetDirectoryName(gTPDFWOVIName[i]) + @"\Bg without Vector Images"; + fileName = Path.GetFileName(gTPDFWOVIName[i]); + if (!Directory.Exists(str2)) Directory.CreateDirectory(str2); str4 = str2 + @"\" + fileName; - string[] strArray7 = new string[] { str4.Substring(0, str4.Length - 6), i.ToString(), "(Tmx", this.gPointType, this.gsSize, "B", BID, "P", (SP + i).ToString("000") }; + string[] strArray7 = + { + str4.Substring(0, str4.Length - 6), i.ToString(), "(Tmx", gPointType, gsSize, "B", BID, "P", + (SP + i).ToString("000") + }; strArray7[9] = ").pdf"; str = string.Concat(strArray7); - if (File.Exists(this.gTPDFWOVIName[i])) + + if (File.Exists(gTPDFWOVIName[i])) { - if (File.Exists(str)) - { - File.Delete(str); - } - File.Move(this.gTPDFWOVIName[i], str); + if (File.Exists(str)) File.Delete(str); + File.Move(gTPDFWOVIName[i], str); } } + if (bGenerateBGWithImage) { - str2 = Path.GetDirectoryName(this.gTPDFBGIName[i]) + @"\Bg with Images"; - fileName = Path.GetFileName(this.gTPDFBGIName[i]); - if (!Directory.Exists(str2)) - { - Directory.CreateDirectory(str2); - } + str2 = Path.GetDirectoryName(gTPDFBGIName[i]) + @"\Bg with Images"; + fileName = Path.GetFileName(gTPDFBGIName[i]); + if (!Directory.Exists(str2)) Directory.CreateDirectory(str2); str4 = str2 + @"\" + fileName; - string[] strArray8 = new string[] { str4.Substring(0, str4.Length - 6), i.ToString(), "(Tmx", this.gPointType, this.gsSize, "B", BID, "P", (SP + i).ToString("000") }; + string[] strArray8 = + { + str4.Substring(0, str4.Length - 6), i.ToString(), "(Tmx", gPointType, gsSize, "B", BID, "P", + (SP + i).ToString("000") + }; strArray8[9] = ").pdf"; str = string.Concat(strArray8); - if (File.Exists(this.gTPDFBGIName[i])) + + if (File.Exists(gTPDFBGIName[i])) { - if (File.Exists(str)) - { - File.Delete(str); - } - File.Move(this.gTPDFBGIName[i], str); + if (File.Exists(str)) File.Delete(str); + File.Move(gTPDFBGIName[i], str); } } } @@ -2726,86 +2734,85 @@ namespace TmatrixLibrary { if (bGenerateBGWithVImage) { - str2 = Path.GetDirectoryName(this.gTPDFName[i]) + @"\Bg with Vector Images"; - fileName = Path.GetFileName(this.gTPDFName[i]); - if (!Directory.Exists(str2)) - { - Directory.CreateDirectory(str2); - } + str2 = Path.GetDirectoryName(gTPDFName[i]) + @"\Bg with Vector Images"; + fileName = Path.GetFileName(gTPDFName[i]); + if (!Directory.Exists(str2)) Directory.CreateDirectory(str2); str4 = str2 + @"\" + fileName; - string[] strArray9 = new string[] { str4.Substring(0, str4.Length - 7), i.ToString(), "(Tmx", this.gPointType, this.gsSize, "B", BID, "P", (SP + i).ToString("000") }; + string[] strArray9 = + { + str4.Substring(0, str4.Length - 7), i.ToString(), "(Tmx", gPointType, gsSize, "B", BID, "P", + (SP + i).ToString("000") + }; strArray9[9] = ").pdf"; str = string.Concat(strArray9); - if (File.Exists(this.gTPDFName[i])) + + if (File.Exists(gTPDFName[i])) { - if (File.Exists(str)) - { - File.Delete(str); - } - File.Move(this.gTPDFName[i], str); + if (File.Exists(str)) File.Delete(str); + File.Move(gTPDFName[i], str); } } + if (bGenerateVImage) { - str2 = Path.GetDirectoryName(this.gTPDFVIName[i]) + @"\Vector Images"; - fileName = Path.GetFileName(this.gTPDFVIName[i]); - if (!Directory.Exists(str2)) - { - Directory.CreateDirectory(str2); - } + str2 = Path.GetDirectoryName(gTPDFVIName[i]) + @"\Vector Images"; + fileName = Path.GetFileName(gTPDFVIName[i]); + if (!Directory.Exists(str2)) Directory.CreateDirectory(str2); str4 = str2 + @"\" + fileName; - string[] strArray10 = new string[] { str4.Substring(0, str4.Length - 7), i.ToString(), "(Tmx", this.gPointType, this.gsSize, "B", BID, "P", (SP + i).ToString("000") }; + string[] strArray10 = + { + str4.Substring(0, str4.Length - 7), i.ToString(), "(Tmx", gPointType, gsSize, "B", BID, "P", + (SP + i).ToString("000") + }; strArray10[9] = ").pdf"; str = string.Concat(strArray10); - if (File.Exists(this.gTPDFVIName[i])) + + if (File.Exists(gTPDFVIName[i])) { - if (File.Exists(str)) - { - File.Delete(str); - } - File.Move(this.gTPDFVIName[i], str); + if (File.Exists(str)) File.Delete(str); + File.Move(gTPDFVIName[i], str); } } + if (bGenerateBGWithoutVImage) { - str2 = Path.GetDirectoryName(this.gTPDFWOVIName[i]) + @"\Bg without Vector Images"; - fileName = Path.GetFileName(this.gTPDFWOVIName[i]); - if (!Directory.Exists(str2)) - { - Directory.CreateDirectory(str2); - } + str2 = Path.GetDirectoryName(gTPDFWOVIName[i]) + @"\Bg without Vector Images"; + fileName = Path.GetFileName(gTPDFWOVIName[i]); + if (!Directory.Exists(str2)) Directory.CreateDirectory(str2); str4 = str2 + @"\" + fileName; - string[] strArray11 = new string[] { str4.Substring(0, str4.Length - 7), i.ToString(), "(Tmx", this.gPointType, this.gsSize, "B", BID, "P", (SP + i).ToString("000") }; + string[] strArray11 = + { + str4.Substring(0, str4.Length - 7), i.ToString(), "(Tmx", gPointType, gsSize, "B", BID, "P", + (SP + i).ToString("000") + }; strArray11[9] = ").pdf"; str = string.Concat(strArray11); - if (File.Exists(this.gTPDFWOVIName[i])) + + if (File.Exists(gTPDFWOVIName[i])) { - if (File.Exists(str)) - { - File.Delete(str); - } - File.Move(this.gTPDFWOVIName[i], str); + if (File.Exists(str)) File.Delete(str); + File.Move(gTPDFWOVIName[i], str); } } + if (bGenerateBGWithImage) { - str2 = Path.GetDirectoryName(this.gTPDFBGIName[i]) + @"\Bg with Images"; - fileName = Path.GetFileName(this.gTPDFBGIName[i]); - if (!Directory.Exists(str2)) - { - Directory.CreateDirectory(str2); - } + str2 = Path.GetDirectoryName(gTPDFBGIName[i]) + @"\Bg with Images"; + fileName = Path.GetFileName(gTPDFBGIName[i]); + if (!Directory.Exists(str2)) Directory.CreateDirectory(str2); str4 = str2 + @"\" + fileName; - string[] strArray12 = new string[] { str4.Substring(0, str4.Length - 7), i.ToString(), "(Tmx", this.gPointType, this.gsSize, "B", BID, "P", (SP + i).ToString("000") }; + string[] strArray12 = + { + str4.Substring(0, str4.Length - 7), i.ToString(), "(Tmx", gPointType, gsSize, "B", BID, "P", + (SP + i).ToString("000") + }; strArray12[9] = ").pdf"; str = string.Concat(strArray12); - if (File.Exists(this.gTPDFBGIName[i])) + + if (File.Exists(gTPDFBGIName[i])) { - if (File.Exists(str)) - { - File.Delete(str); - } - File.Move(this.gTPDFBGIName[i], str); + if (File.Exists(str)) File.Delete(str); + File.Move(gTPDFBGIName[i], str); } } } @@ -2813,116 +2820,114 @@ namespace TmatrixLibrary { if (bGenerateBGWithVImage) { - str2 = Path.GetDirectoryName(this.gTPDFName[i]) + @"\Bg with Vector Images"; - fileName = Path.GetFileName(this.gTPDFName[i]); - if (!Directory.Exists(str2)) - { - Directory.CreateDirectory(str2); - } + str2 = Path.GetDirectoryName(gTPDFName[i]) + @"\Bg with Vector Images"; + fileName = Path.GetFileName(gTPDFName[i]); + if (!Directory.Exists(str2)) Directory.CreateDirectory(str2); str4 = str2 + @"\" + fileName; - string[] strArray13 = new string[] { str4.Substring(0, str4.Length - 8), i.ToString(), "(Tmx", this.gPointType, this.gsSize, "B", BID, "P", (SP + i).ToString("000") }; + string[] strArray13 = + { + str4.Substring(0, str4.Length - 8), i.ToString(), "(Tmx", gPointType, gsSize, "B", BID, "P", + (SP + i).ToString("000") + }; strArray13[9] = ").pdf"; str = string.Concat(strArray13); - if (File.Exists(this.gTPDFName[i])) + + if (File.Exists(gTPDFName[i])) { - if (File.Exists(str)) - { - File.Delete(str); - } - File.Move(this.gTPDFName[i], str); + if (File.Exists(str)) File.Delete(str); + File.Move(gTPDFName[i], str); } } + if (bGenerateVImage) { - str2 = Path.GetDirectoryName(this.gTPDFVIName[i]) + @"\Vector Images"; - fileName = Path.GetFileName(this.gTPDFVIName[i]); - if (!Directory.Exists(str2)) - { - Directory.CreateDirectory(str2); - } + str2 = Path.GetDirectoryName(gTPDFVIName[i]) + @"\Vector Images"; + fileName = Path.GetFileName(gTPDFVIName[i]); + if (!Directory.Exists(str2)) Directory.CreateDirectory(str2); str4 = str2 + @"\" + fileName; - string[] strArray14 = new string[] { str4.Substring(0, str4.Length - 8), i.ToString(), "(Tmx", this.gPointType, this.gsSize, "B", BID, "P", (SP + i).ToString("000") }; + string[] strArray14 = + { + str4.Substring(0, str4.Length - 8), i.ToString(), "(Tmx", gPointType, gsSize, "B", BID, "P", + (SP + i).ToString("000") + }; strArray14[9] = ").pdf"; str = string.Concat(strArray14); - if (File.Exists(this.gTPDFVIName[i])) + + if (File.Exists(gTPDFVIName[i])) { - if (File.Exists(str)) - { - File.Delete(str); - } - File.Move(this.gTPDFVIName[i], str); + if (File.Exists(str)) File.Delete(str); + File.Move(gTPDFVIName[i], str); } } + if (bGenerateBGWithoutVImage) { - str2 = Path.GetDirectoryName(this.gTPDFWOVIName[i]) + @"\Bg without Vector Images"; - fileName = Path.GetFileName(this.gTPDFWOVIName[i]); - if (!Directory.Exists(str2)) - { - Directory.CreateDirectory(str2); - } + str2 = Path.GetDirectoryName(gTPDFWOVIName[i]) + @"\Bg without Vector Images"; + fileName = Path.GetFileName(gTPDFWOVIName[i]); + if (!Directory.Exists(str2)) Directory.CreateDirectory(str2); str4 = str2 + @"\" + fileName; - string[] strArray15 = new string[] { str4.Substring(0, str4.Length - 8), i.ToString(), "(Tmx", this.gPointType, this.gsSize, "B", BID, "P", (SP + i).ToString("000") }; + string[] strArray15 = + { + str4.Substring(0, str4.Length - 8), i.ToString(), "(Tmx", gPointType, gsSize, "B", BID, "P", + (SP + i).ToString("000") + }; strArray15[9] = ").pdf"; str = string.Concat(strArray15); - if (File.Exists(this.gTPDFWOVIName[i])) + + if (File.Exists(gTPDFWOVIName[i])) { - if (File.Exists(str)) - { - File.Delete(str); - } - File.Move(this.gTPDFWOVIName[i], str); + if (File.Exists(str)) File.Delete(str); + File.Move(gTPDFWOVIName[i], str); } } + if (bGenerateBGWithImage) { - str2 = Path.GetDirectoryName(this.gTPDFBGIName[i]) + @"\Bg with Images"; - fileName = Path.GetFileName(this.gTPDFBGIName[i]); - if (!Directory.Exists(str2)) - { - Directory.CreateDirectory(str2); - } + str2 = Path.GetDirectoryName(gTPDFBGIName[i]) + @"\Bg with Images"; + fileName = Path.GetFileName(gTPDFBGIName[i]); + if (!Directory.Exists(str2)) Directory.CreateDirectory(str2); str4 = str2 + @"\" + fileName; - string[] strArray16 = new string[] { str4.Substring(0, str4.Length - 8), i.ToString(), "(Tmx", this.gPointType, this.gsSize, "B", BID, "P", (SP + i).ToString("000") }; + string[] strArray16 = + { + str4.Substring(0, str4.Length - 8), i.ToString(), "(Tmx", gPointType, gsSize, "B", BID, "P", + (SP + i).ToString("000") + }; strArray16[9] = ").pdf"; str = string.Concat(strArray16); - if (File.Exists(this.gTPDFBGIName[i])) + + if (File.Exists(gTPDFBGIName[i])) { - if (File.Exists(str)) - { - File.Delete(str); - } - File.Move(this.gTPDFBGIName[i], str); + if (File.Exists(str)) File.Delete(str); + File.Move(gTPDFBGIName[i], str); } } } } } - - private void RenameTmatrixPDF_OID4(int SP, string SID, string OID, string BID, bool bGenerateBGWithVImage, bool bGenerateVImage, bool bGenerateBGWithoutVImage, bool bGenerateBGWithImage) + + private void RenameTmatrixPDF_OID4(int SP, string SID, string OID, string BID, bool bGenerateBGWithVImage, + bool bGenerateVImage, bool bGenerateBGWithoutVImage, bool bGenerateBGWithImage) { - for (int i = 0; i < this.gPageNum; i++) + for (var i = 0; i < gPageNum; i++) { string str; string str2; string fileName; string str4; + if (i == 0) { if (bGenerateBGWithVImage) { - str2 = Path.GetDirectoryName(this.gTPDFName[i]) + @"\Bg with Vector Images"; - fileName = Path.GetFileName(this.gTPDFName[i]); - if (!Directory.Exists(str2)) - { - Directory.CreateDirectory(str2); - } + str2 = Path.GetDirectoryName(gTPDFName[i]) + @"\Bg with Vector Images"; + fileName = Path.GetFileName(gTPDFName[i]); + if (!Directory.Exists(str2)) Directory.CreateDirectory(str2); str4 = str2 + @"\" + fileName; - string[] strArray = new string[13]; + var strArray = new string[13]; //string[] strArray = new string[] { str4.Substring(0, str4.Length - 4), "0(Tmx", this.gsPointType[0], "S", SID, "O", OID, "B", BID }; strArray[0] = str4.Substring(0, str4.Length - 4); strArray[1] = "0(Tmx"; - strArray[2] = this.gsPointType[0]; + strArray[2] = gsPointType[0]; strArray[3] = "S"; strArray[4] = SID; strArray[5] = "0"; @@ -2931,33 +2936,29 @@ namespace TmatrixLibrary strArray[8] = "BID"; strArray[9] = "P"; strArray[10] = (SP + i).ToString("000"); - strArray[11] = this.gsPointDPI[0]; + strArray[11] = gsPointDPI[0]; strArray[12] = ").pdf"; str = string.Concat(strArray); - if (File.Exists(this.gTPDFName[i])) + + if (File.Exists(gTPDFName[i])) { - if (File.Exists(str)) - { - File.Delete(str); - } - File.Move(this.gTPDFName[i], str); + if (File.Exists(str)) File.Delete(str); + File.Move(gTPDFName[i], str); } } + if (bGenerateVImage) { - str2 = Path.GetDirectoryName(this.gTPDFVIName[i]) + @"\Vector Images"; - fileName = Path.GetFileName(this.gTPDFVIName[i]); - if (!Directory.Exists(str2)) - { - Directory.CreateDirectory(str2); - } + str2 = Path.GetDirectoryName(gTPDFVIName[i]) + @"\Vector Images"; + fileName = Path.GetFileName(gTPDFVIName[i]); + if (!Directory.Exists(str2)) Directory.CreateDirectory(str2); str4 = str2 + @"\" + fileName; //string[] strArray2 = new string[] { str4.Substring(0, str4.Length - 4), "0(Tmx", this.gsPointType[1], "S", SID, "O", OID, "B", BID }; - string[] strArray2 = new string[13]; + var strArray2 = new string[13]; strArray2[0] = str4.Substring(0, str4.Length - 4); strArray2[1] = "0(Tmx"; - strArray2[2] = this.gsPointType[1]; + strArray2[2] = gsPointType[1]; strArray2[3] = "S"; strArray2[4] = SID; strArray2[5] = "0"; @@ -2966,33 +2967,29 @@ namespace TmatrixLibrary strArray2[8] = "BID"; strArray2[9] = "P"; strArray2[10] = (SP + i).ToString("000"); - strArray2[11] = this.gsPointDPI[1]; + strArray2[11] = gsPointDPI[1]; strArray2[12] = ").pdf"; str = string.Concat(strArray2); - if (File.Exists(this.gTPDFVIName[i])) + + if (File.Exists(gTPDFVIName[i])) { - if (File.Exists(str)) - { - File.Delete(str); - } - File.Move(this.gTPDFVIName[i], str); + if (File.Exists(str)) File.Delete(str); + File.Move(gTPDFVIName[i], str); } } + if (bGenerateBGWithoutVImage) { - str2 = Path.GetDirectoryName(this.gTPDFWOVIName[i]) + @"\Bg without Vector Images"; - fileName = Path.GetFileName(this.gTPDFWOVIName[i]); - if (!Directory.Exists(str2)) - { - Directory.CreateDirectory(str2); - } + str2 = Path.GetDirectoryName(gTPDFWOVIName[i]) + @"\Bg without Vector Images"; + fileName = Path.GetFileName(gTPDFWOVIName[i]); + if (!Directory.Exists(str2)) Directory.CreateDirectory(str2); str4 = str2 + @"\" + fileName; //string[] strArray3 = new string[] { str4.Substring(0, str4.Length - 4), "0(Tmx", this.gsPointType[2], "S", SID, "O", OID, "B", BID }; - string[] strArray3 = new string[13]; + var strArray3 = new string[13]; strArray3[0] = str4.Substring(0, str4.Length - 4); strArray3[1] = "0(Tmx"; - strArray3[2] = this.gsPointType[2]; + strArray3[2] = gsPointType[2]; strArray3[3] = "S"; strArray3[4] = SID; strArray3[5] = "0"; @@ -3001,33 +2998,29 @@ namespace TmatrixLibrary strArray3[8] = "BID"; strArray3[9] = "P"; strArray3[10] = (SP + i).ToString("000"); - strArray3[11] = this.gsPointDPI[2]; + strArray3[11] = gsPointDPI[2]; strArray3[12] = ").pdf"; str = string.Concat(strArray3); - if (File.Exists(this.gTPDFWOVIName[i])) + + if (File.Exists(gTPDFWOVIName[i])) { - if (File.Exists(str)) - { - File.Delete(str); - } - File.Move(this.gTPDFWOVIName[i], str); + if (File.Exists(str)) File.Delete(str); + File.Move(gTPDFWOVIName[i], str); } } + if (bGenerateBGWithImage) { - str2 = Path.GetDirectoryName(this.gTPDFBGIName[i]) + @"\Bg with Images"; - fileName = Path.GetFileName(this.gTPDFBGIName[i]); - if (!Directory.Exists(str2)) - { - Directory.CreateDirectory(str2); - } + str2 = Path.GetDirectoryName(gTPDFBGIName[i]) + @"\Bg with Images"; + fileName = Path.GetFileName(gTPDFBGIName[i]); + if (!Directory.Exists(str2)) Directory.CreateDirectory(str2); str4 = str2 + @"\" + fileName; //string[] strArray4 = new string[] { str4.Substring(0, str4.Length - 4), "0(Tmx", this.gsPointType[3], "S", SID, "O", OID, "B", BID }; - string[] strArray4 = new string[13]; + var strArray4 = new string[13]; strArray4[0] = str4.Substring(0, str4.Length - 4); strArray4[1] = "0(Tmx"; - strArray4[2] = this.gsPointType[3]; + strArray4[2] = gsPointType[3]; strArray4[3] = "S"; strArray4[4] = SID; strArray4[5] = "0"; @@ -3037,16 +3030,14 @@ namespace TmatrixLibrary strArray4[9] = "P"; strArray4[10] = (SP + i).ToString("000"); - strArray4[11] = this.gsPointDPI[3]; + strArray4[11] = gsPointDPI[3]; strArray4[12] = ").pdf"; str = string.Concat(strArray4); - if (File.Exists(this.gTPDFBGIName[i])) + + if (File.Exists(gTPDFBGIName[i])) { - if (File.Exists(str)) - { - File.Delete(str); - } - File.Move(this.gTPDFBGIName[i], str); + if (File.Exists(str)) File.Delete(str); + File.Move(gTPDFBGIName[i], str); } } } @@ -3054,20 +3045,17 @@ namespace TmatrixLibrary { if (bGenerateBGWithVImage) { - str2 = Path.GetDirectoryName(this.gTPDFName[i]) + @"\Bg with Vector Images"; - fileName = Path.GetFileName(this.gTPDFName[i]); - if (!Directory.Exists(str2)) - { - Directory.CreateDirectory(str2); - } + str2 = Path.GetDirectoryName(gTPDFName[i]) + @"\Bg with Vector Images"; + fileName = Path.GetFileName(gTPDFName[i]); + if (!Directory.Exists(str2)) Directory.CreateDirectory(str2); str4 = str2 + @"\" + fileName; //string[] strArray5 = new string[] { str4.Substring(0, str4.Length - 6), i.ToString(), "(Tmx", this.gsPointType[0], "S", SID, "O", OID, "B" }; - string[] strArray5 = new string[14]; + var strArray5 = new string[14]; strArray5[0] = str4.Substring(0, str4.Length - 6); strArray5[1] = i.ToString(); strArray5[2] = "0(Tmx"; - strArray5[3] = this.gsPointType[0]; + strArray5[3] = gsPointType[0]; strArray5[4] = "S"; strArray5[5] = SID; strArray5[6] = "0"; @@ -3076,34 +3064,30 @@ namespace TmatrixLibrary strArray5[9] = BID; strArray5[10] = "P"; strArray5[11] = (SP + i).ToString("000"); - strArray5[12] = this.gsPointDPI[0]; + strArray5[12] = gsPointDPI[0]; strArray5[13] = ").pdf"; str = string.Concat(strArray5); - if (File.Exists(this.gTPDFName[i])) + + if (File.Exists(gTPDFName[i])) { - if (File.Exists(str)) - { - File.Delete(str); - } - File.Move(this.gTPDFName[i], str); + if (File.Exists(str)) File.Delete(str); + File.Move(gTPDFName[i], str); } } + if (bGenerateVImage) { - str2 = Path.GetDirectoryName(this.gTPDFVIName[i]) + @"\Vector Images"; - fileName = Path.GetFileName(this.gTPDFVIName[i]); - if (!Directory.Exists(str2)) - { - Directory.CreateDirectory(str2); - } + str2 = Path.GetDirectoryName(gTPDFVIName[i]) + @"\Vector Images"; + fileName = Path.GetFileName(gTPDFVIName[i]); + if (!Directory.Exists(str2)) Directory.CreateDirectory(str2); str4 = str2 + @"\" + fileName; //string[] strArray6 = new string[] { str4.Substring(0, str4.Length - 6), i.ToString(), "(Tmx", this.gsPointType[1], "S", SID, "O", OID, "B" }; - string[] strArray6 = new string[14]; + var strArray6 = new string[14]; strArray6[0] = str4.Substring(0, str4.Length - 6); strArray6[1] = i.ToString(); strArray6[2] = "0(Tmx"; - strArray6[3] = this.gsPointType[1]; + strArray6[3] = gsPointType[1]; strArray6[4] = "S"; strArray6[5] = SID; strArray6[6] = "0"; @@ -3113,34 +3097,30 @@ namespace TmatrixLibrary strArray6[9] = BID; strArray6[10] = "P"; strArray6[11] = (SP + i).ToString("000"); - strArray6[12] = this.gsPointDPI[1]; + strArray6[12] = gsPointDPI[1]; strArray6[13] = ").pdf"; str = string.Concat(strArray6); - if (File.Exists(this.gTPDFVIName[i])) + + if (File.Exists(gTPDFVIName[i])) { - if (File.Exists(str)) - { - File.Delete(str); - } - File.Move(this.gTPDFVIName[i], str); + if (File.Exists(str)) File.Delete(str); + File.Move(gTPDFVIName[i], str); } } + if (bGenerateBGWithoutVImage) { - str2 = Path.GetDirectoryName(this.gTPDFWOVIName[i]) + @"\Bg without Vector Images"; - fileName = Path.GetFileName(this.gTPDFWOVIName[i]); - if (!Directory.Exists(str2)) - { - Directory.CreateDirectory(str2); - } + str2 = Path.GetDirectoryName(gTPDFWOVIName[i]) + @"\Bg without Vector Images"; + fileName = Path.GetFileName(gTPDFWOVIName[i]); + if (!Directory.Exists(str2)) Directory.CreateDirectory(str2); str4 = str2 + @"\" + fileName; //string[] strArray7 = new string[] { str4.Substring(0, str4.Length - 6), i.ToString(), "(Tmx", this.gsPointType[2], "S", SID, "O", OID, "B" }; - string[] strArray7 = new string[14]; + var strArray7 = new string[14]; strArray7[0] = str4.Substring(0, str4.Length - 6); strArray7[1] = i.ToString(); strArray7[2] = "0(Tmx"; - strArray7[3] = this.gsPointType[2]; + strArray7[3] = gsPointType[2]; strArray7[4] = "S"; strArray7[5] = SID; strArray7[6] = "0"; @@ -3149,33 +3129,29 @@ namespace TmatrixLibrary strArray7[9] = BID; strArray7[10] = "P"; strArray7[11] = (SP + i).ToString("000"); - strArray7[12] = this.gsPointDPI[2]; + strArray7[12] = gsPointDPI[2]; strArray7[13] = ").pdf"; str = string.Concat(strArray7); - if (File.Exists(this.gTPDFWOVIName[i])) + + if (File.Exists(gTPDFWOVIName[i])) { - if (File.Exists(str)) - { - File.Delete(str); - } - File.Move(this.gTPDFWOVIName[i], str); + if (File.Exists(str)) File.Delete(str); + File.Move(gTPDFWOVIName[i], str); } } + if (bGenerateBGWithImage) { - str2 = Path.GetDirectoryName(this.gTPDFBGIName[i]) + @"\Bg with Images"; - fileName = Path.GetFileName(this.gTPDFBGIName[i]); - if (!Directory.Exists(str2)) - { - Directory.CreateDirectory(str2); - } + str2 = Path.GetDirectoryName(gTPDFBGIName[i]) + @"\Bg with Images"; + fileName = Path.GetFileName(gTPDFBGIName[i]); + if (!Directory.Exists(str2)) Directory.CreateDirectory(str2); str4 = str2 + @"\" + fileName; //string[] strArray8 = new string[] { str4.Substring(0, str4.Length - 6), i.ToString(), "(Tmx", this.gsPointType[3], "S", SID, "O", OID, "B" }; - string[] strArray8 = new string[14]; + var strArray8 = new string[14]; strArray8[0] = str4.Substring(0, str4.Length - 6); strArray8[1] = i.ToString(); strArray8[2] = "0(Tmx"; - strArray8[3] = this.gsPointType[3]; + strArray8[3] = gsPointType[3]; strArray8[4] = "S"; strArray8[5] = SID; strArray8[6] = "0"; @@ -3185,16 +3161,14 @@ namespace TmatrixLibrary strArray8[9] = BID; strArray8[10] = "P"; strArray8[11] = (SP + i).ToString("000"); - strArray8[12] = this.gsPointDPI[3]; + strArray8[12] = gsPointDPI[3]; strArray8[13] = ").pdf"; str = string.Concat(strArray8); - if (File.Exists(this.gTPDFBGIName[i])) + + if (File.Exists(gTPDFBGIName[i])) { - if (File.Exists(str)) - { - File.Delete(str); - } - File.Move(this.gTPDFBGIName[i], str); + if (File.Exists(str)) File.Delete(str); + File.Move(gTPDFBGIName[i], str); } } } @@ -3202,20 +3176,17 @@ namespace TmatrixLibrary { if (bGenerateBGWithVImage) { - str2 = Path.GetDirectoryName(this.gTPDFName[i]) + @"\Bg with Vector Images"; - fileName = Path.GetFileName(this.gTPDFName[i]); - if (!Directory.Exists(str2)) - { - Directory.CreateDirectory(str2); - } + str2 = Path.GetDirectoryName(gTPDFName[i]) + @"\Bg with Vector Images"; + fileName = Path.GetFileName(gTPDFName[i]); + if (!Directory.Exists(str2)) Directory.CreateDirectory(str2); str4 = str2 + @"\" + fileName; //string[] strArray9 = new string[] { str4.Substring(0, str4.Length - 7), i.ToString(), "(Tmx", this.gsPointType[0], "S", SID, "O", OID, "B" }; - string[] strArray9 = new string[14]; + var strArray9 = new string[14]; strArray9[0] = str4.Substring(0, str4.Length - 7); strArray9[1] = i.ToString(); strArray9[2] = "0(Tmx"; - strArray9[3] = this.gsPointType[0]; + strArray9[3] = gsPointType[0]; strArray9[4] = "S"; strArray9[5] = SID; strArray9[6] = "0"; @@ -3225,34 +3196,30 @@ namespace TmatrixLibrary strArray9[9] = BID; strArray9[10] = "P"; strArray9[11] = (SP + i).ToString("000"); - strArray9[12] = this.gsPointDPI[0]; + strArray9[12] = gsPointDPI[0]; strArray9[13] = ").pdf"; str = string.Concat(strArray9); - if (File.Exists(this.gTPDFName[i])) + + if (File.Exists(gTPDFName[i])) { - if (File.Exists(str)) - { - File.Delete(str); - } - File.Move(this.gTPDFName[i], str); + if (File.Exists(str)) File.Delete(str); + File.Move(gTPDFName[i], str); } } + if (bGenerateVImage) { - str2 = Path.GetDirectoryName(this.gTPDFVIName[i]) + @"\Vector Images"; - fileName = Path.GetFileName(this.gTPDFVIName[i]); - if (!Directory.Exists(str2)) - { - Directory.CreateDirectory(str2); - } + str2 = Path.GetDirectoryName(gTPDFVIName[i]) + @"\Vector Images"; + fileName = Path.GetFileName(gTPDFVIName[i]); + if (!Directory.Exists(str2)) Directory.CreateDirectory(str2); str4 = str2 + @"\" + fileName; //string[] strArray10 = new string[] { str4.Substring(0, str4.Length - 7), i.ToString(), "(Tmx", this.gsPointType[1], "S", SID, "O", OID, "B" }; - string[] strArray10 = new string[14]; + var strArray10 = new string[14]; strArray10[0] = str4.Substring(0, str4.Length - 7); strArray10[1] = i.ToString(); strArray10[2] = "0(Tmx"; - strArray10[3] = this.gsPointType[1]; + strArray10[3] = gsPointType[1]; strArray10[4] = "S"; strArray10[5] = SID; strArray10[6] = "0"; @@ -3262,34 +3229,30 @@ namespace TmatrixLibrary strArray10[9] = BID; strArray10[10] = "P"; strArray10[11] = (SP + i).ToString("000"); - strArray10[12] = this.gsPointDPI[1]; + strArray10[12] = gsPointDPI[1]; strArray10[13] = ").pdf"; str = string.Concat(strArray10); - if (File.Exists(this.gTPDFVIName[i])) + + if (File.Exists(gTPDFVIName[i])) { - if (File.Exists(str)) - { - File.Delete(str); - } - File.Move(this.gTPDFVIName[i], str); + if (File.Exists(str)) File.Delete(str); + File.Move(gTPDFVIName[i], str); } } + if (bGenerateBGWithoutVImage) { - str2 = Path.GetDirectoryName(this.gTPDFWOVIName[i]) + @"\Bg without Vector Images"; - fileName = Path.GetFileName(this.gTPDFWOVIName[i]); - if (!Directory.Exists(str2)) - { - Directory.CreateDirectory(str2); - } + str2 = Path.GetDirectoryName(gTPDFWOVIName[i]) + @"\Bg without Vector Images"; + fileName = Path.GetFileName(gTPDFWOVIName[i]); + if (!Directory.Exists(str2)) Directory.CreateDirectory(str2); str4 = str2 + @"\" + fileName; //string[] strArray11 = new string[] { str4.Substring(0, str4.Length - 7), i.ToString(), "(Tmx", this.gsPointType[2], "S", SID, "O", OID, "B" }; - string[] strArray11 = new string[14]; + var strArray11 = new string[14]; strArray11[0] = str4.Substring(0, str4.Length - 7); strArray11[1] = i.ToString(); strArray11[2] = "0(Tmx"; - strArray11[3] = this.gsPointType[2]; + strArray11[3] = gsPointType[2]; strArray11[4] = "S"; strArray11[5] = SID; strArray11[6] = "0"; @@ -3299,34 +3262,30 @@ namespace TmatrixLibrary strArray11[9] = BID; strArray11[10] = "P"; strArray11[11] = (SP + i).ToString("000"); - strArray11[12] = this.gsPointDPI[2]; + strArray11[12] = gsPointDPI[2]; strArray11[13] = ").pdf"; str = string.Concat(strArray11); - if (File.Exists(this.gTPDFWOVIName[i])) + + if (File.Exists(gTPDFWOVIName[i])) { - if (File.Exists(str)) - { - File.Delete(str); - } - File.Move(this.gTPDFWOVIName[i], str); + if (File.Exists(str)) File.Delete(str); + File.Move(gTPDFWOVIName[i], str); } } + if (bGenerateBGWithImage) { - str2 = Path.GetDirectoryName(this.gTPDFBGIName[i]) + @"\Bg with Images"; - fileName = Path.GetFileName(this.gTPDFBGIName[i]); - if (!Directory.Exists(str2)) - { - Directory.CreateDirectory(str2); - } + str2 = Path.GetDirectoryName(gTPDFBGIName[i]) + @"\Bg with Images"; + fileName = Path.GetFileName(gTPDFBGIName[i]); + if (!Directory.Exists(str2)) Directory.CreateDirectory(str2); str4 = str2 + @"\" + fileName; //string[] strArray12 = new string[] { str4.Substring(0, str4.Length - 7), i.ToString(), "(Tmx", this.gsPointType[3], "S", SID, "O", OID, "B" }; - string[] strArray12 = new string[14]; + var strArray12 = new string[14]; strArray12[0] = str4.Substring(0, str4.Length - 7); strArray12[1] = i.ToString(); strArray12[2] = "0(Tmx"; - strArray12[3] = this.gsPointType[3]; + strArray12[3] = gsPointType[3]; strArray12[4] = "S"; strArray12[5] = SID; strArray12[6] = "0"; @@ -3336,16 +3295,14 @@ namespace TmatrixLibrary strArray12[9] = BID; strArray12[10] = "P"; strArray12[11] = (SP + i).ToString("000"); - strArray12[12] = this.gsPointDPI[3]; + strArray12[12] = gsPointDPI[3]; strArray12[13] = ").pdf"; str = string.Concat(strArray12); - if (File.Exists(this.gTPDFBGIName[i])) + + if (File.Exists(gTPDFBGIName[i])) { - if (File.Exists(str)) - { - File.Delete(str); - } - File.Move(this.gTPDFBGIName[i], str); + if (File.Exists(str)) File.Delete(str); + File.Move(gTPDFBGIName[i], str); } } } @@ -3353,20 +3310,17 @@ namespace TmatrixLibrary { if (bGenerateBGWithVImage) { - str2 = Path.GetDirectoryName(this.gTPDFName[i]) + @"\Bg with Vector Images"; - fileName = Path.GetFileName(this.gTPDFName[i]); - if (!Directory.Exists(str2)) - { - Directory.CreateDirectory(str2); - } + str2 = Path.GetDirectoryName(gTPDFName[i]) + @"\Bg with Vector Images"; + fileName = Path.GetFileName(gTPDFName[i]); + if (!Directory.Exists(str2)) Directory.CreateDirectory(str2); str4 = str2 + @"\" + fileName; //string[] strArray13 = new string[] { str4.Substring(0, str4.Length - 8), i.ToString(), "(Tmx", this.gsPointType[0], "S", SID, "O", OID, "B" }; - string[] strArray13 = new string[14]; + var strArray13 = new string[14]; strArray13[0] = str4.Substring(0, str4.Length - 8); strArray13[1] = i.ToString(); strArray13[2] = "0(Tmx"; - strArray13[3] = this.gsPointType[0]; + strArray13[3] = gsPointType[0]; strArray13[4] = "S"; strArray13[5] = SID; strArray13[6] = "0"; @@ -3376,34 +3330,30 @@ namespace TmatrixLibrary strArray13[9] = BID; strArray13[10] = "P"; strArray13[11] = (SP + i).ToString("000"); - strArray13[12] = this.gsPointDPI[0]; + strArray13[12] = gsPointDPI[0]; strArray13[13] = ").pdf"; str = string.Concat(strArray13); - if (File.Exists(this.gTPDFName[i])) + + if (File.Exists(gTPDFName[i])) { - if (File.Exists(str)) - { - File.Delete(str); - } - File.Move(this.gTPDFName[i], str); + if (File.Exists(str)) File.Delete(str); + File.Move(gTPDFName[i], str); } } + if (bGenerateVImage) { - str2 = Path.GetDirectoryName(this.gTPDFVIName[i]) + @"\Vector Images"; - fileName = Path.GetFileName(this.gTPDFVIName[i]); - if (!Directory.Exists(str2)) - { - Directory.CreateDirectory(str2); - } + str2 = Path.GetDirectoryName(gTPDFVIName[i]) + @"\Vector Images"; + fileName = Path.GetFileName(gTPDFVIName[i]); + if (!Directory.Exists(str2)) Directory.CreateDirectory(str2); str4 = str2 + @"\" + fileName; //string[] strArray14 = new string[] { str4.Substring(0, str4.Length - 8), i.ToString(), "(Tmx", this.gsPointType[1], "S", SID, "O", OID, "B" }; - string[] strArray14 = new string[14]; + var strArray14 = new string[14]; strArray14[0] = str4.Substring(0, str4.Length - 8); strArray14[1] = i.ToString(); strArray14[2] = "0(Tmx"; - strArray14[3] = this.gsPointType[1]; + strArray14[3] = gsPointType[1]; strArray14[4] = "S"; strArray14[5] = SID; strArray14[6] = "0"; @@ -3413,34 +3363,30 @@ namespace TmatrixLibrary strArray14[9] = BID; strArray14[10] = "P"; strArray14[11] = (SP + i).ToString("000"); - strArray14[12] = this.gsPointDPI[1]; + strArray14[12] = gsPointDPI[1]; strArray14[13] = ").pdf"; str = string.Concat(strArray14); - if (File.Exists(this.gTPDFVIName[i])) + + if (File.Exists(gTPDFVIName[i])) { - if (File.Exists(str)) - { - File.Delete(str); - } - File.Move(this.gTPDFVIName[i], str); + if (File.Exists(str)) File.Delete(str); + File.Move(gTPDFVIName[i], str); } } + if (bGenerateBGWithoutVImage) { - str2 = Path.GetDirectoryName(this.gTPDFWOVIName[i]) + @"\Bg without Vector Images"; - fileName = Path.GetFileName(this.gTPDFWOVIName[i]); - if (!Directory.Exists(str2)) - { - Directory.CreateDirectory(str2); - } + str2 = Path.GetDirectoryName(gTPDFWOVIName[i]) + @"\Bg without Vector Images"; + fileName = Path.GetFileName(gTPDFWOVIName[i]); + if (!Directory.Exists(str2)) Directory.CreateDirectory(str2); str4 = str2 + @"\" + fileName; //string[] strArray15 = new string[] { str4.Substring(0, str4.Length - 8), i.ToString(), "(Tmx", this.gsPointType[2], "S", SID, "O", OID, "B" }; - string[] strArray15 = new string[14]; + var strArray15 = new string[14]; strArray15[0] = str4.Substring(0, str4.Length - 8); strArray15[1] = i.ToString(); strArray15[2] = "0(Tmx"; - strArray15[3] = this.gsPointType[2]; + strArray15[3] = gsPointType[2]; strArray15[4] = "S"; strArray15[5] = SID; strArray15[6] = "0"; @@ -3450,34 +3396,30 @@ namespace TmatrixLibrary strArray15[9] = BID; strArray15[10] = "P"; strArray15[11] = (SP + i).ToString("000"); - strArray15[12] = this.gsPointDPI[2]; + strArray15[12] = gsPointDPI[2]; strArray15[13] = ").pdf"; str = string.Concat(strArray15); - if (File.Exists(this.gTPDFWOVIName[i])) + + if (File.Exists(gTPDFWOVIName[i])) { - if (File.Exists(str)) - { - File.Delete(str); - } - File.Move(this.gTPDFWOVIName[i], str); + if (File.Exists(str)) File.Delete(str); + File.Move(gTPDFWOVIName[i], str); } } + if (bGenerateBGWithImage) { - str2 = Path.GetDirectoryName(this.gTPDFBGIName[i]) + @"\Bg with Images"; - fileName = Path.GetFileName(this.gTPDFBGIName[i]); - if (!Directory.Exists(str2)) - { - Directory.CreateDirectory(str2); - } + str2 = Path.GetDirectoryName(gTPDFBGIName[i]) + @"\Bg with Images"; + fileName = Path.GetFileName(gTPDFBGIName[i]); + if (!Directory.Exists(str2)) Directory.CreateDirectory(str2); str4 = str2 + @"\" + fileName; //string[] strArray16 = new string[] { str4.Substring(0, str4.Length - 8), i.ToString(), "(Tmx", this.gsPointType[3], "S", SID, "O", OID, "B" }; - string[] strArray16 = new string[14]; + var strArray16 = new string[14]; strArray16[0] = str4.Substring(0, str4.Length - 8); strArray16[1] = i.ToString(); strArray16[2] = "0(Tmx"; - strArray16[3] = this.gsPointType[3]; + strArray16[3] = gsPointType[3]; strArray16[4] = "S"; strArray16[5] = SID; strArray16[6] = "0"; @@ -3487,166 +3429,137 @@ namespace TmatrixLibrary strArray16[9] = BID; strArray16[10] = "P"; strArray16[11] = (SP + i).ToString("000"); - strArray16[12] = this.gsPointDPI[3]; + strArray16[12] = gsPointDPI[3]; strArray16[13] = ").pdf"; str = string.Concat(strArray16); - if (File.Exists(this.gTPDFBGIName[i])) + + if (File.Exists(gTPDFBGIName[i])) { - if (File.Exists(str)) - { - File.Delete(str); - } - File.Move(this.gTPDFBGIName[i], str); + if (File.Exists(str)) File.Delete(str); + File.Move(gTPDFBGIName[i], str); } } } } } - + public bool TmatrixInitialize() { - return this.oidPIGenerator.Initialize(); + return oidPIGenerator.Initialize(); } - + public string TmatrixKeyCheck(string sKey) { - this.gbKeyValidate = false; - string[] strArray = sKey.Split(new char[] { ';' }); - if (this.DecodeLicense_TmatrixKey(strArray[0]) != strArray[1]) - { + gbKeyValidate = false; + var strArray = sKey.Split(';'); + if (DecodeLicense_TmatrixKey(strArray[0]) != strArray[1]) return "1Key is not correct, it should be modified !"; - } - string[] strArray2 = strArray[0].Split(new char[] { ',' }); - if (strArray2.Length < 4) - { - return "1 It might be Old key file format, please use new key file !"; - } - if ((strArray2[3].Substring(1, 4) != "0000") && !this.CheckExpirationValidate(strArray2[3])) - { + var strArray2 = strArray[0].Split(','); + if (strArray2.Length < 4) return "1 It might be Old key file format, please use new key file !"; + + if (strArray2[3].Substring(1, 4) != "0000" && !CheckExpirationValidate(strArray2[3])) return "1Key is expired !"; - } - if (strArray2[1].Substring(0, 1) == "O") - { - return "1Element Key has not supported yet !"; - } - this.gsSize = strArray2[0]; - this.gsBID = strArray2[1].Substring(1, 2); - this.gsPID1 = strArray2[2].Substring(1, 3); - this.gsPID2 = strArray2[2].Substring(5, 3); - this.gsExpiration = strArray2[3].Substring(1, strArray2[3].Length - 1); - this.gTotalPageID = int.Parse(this.gsBID) * 0x100; - this.gbKeyValidate = true; + + if (strArray2[1].Substring(0, 1) == "O") return "1Element Key has not supported yet !"; + gsSize = strArray2[0]; + gsBID = strArray2[1].Substring(1, 2); + gsPID1 = strArray2[2].Substring(1, 3); + gsPID2 = strArray2[2].Substring(5, 3); + gsExpiration = strArray2[3].Substring(1, strArray2[3].Length - 1); + gTotalPageID = int.Parse(gsBID) * 0x100; + gbKeyValidate = true; return "0"; } - + public string TmatrixKeyCheck(string sKey, int type) { - this.gbKeyValidate = false; - string[] strArray = sKey.Split(new char[] { ';' }); - if (this.DecodeLicense_TmatrixKey(strArray[0]) != strArray[1]) - { + gbKeyValidate = false; + var strArray = sKey.Split(';'); + if (DecodeLicense_TmatrixKey(strArray[0]) != strArray[1]) return "1Key is not correct, it should be modified !"; - } - string[] strArray2 = strArray[0].Split(new char[] { ',' }); - if (strArray2.Length < 4) - { - return "1Old key file format, please use new key file !"; - } - if ((strArray2[3].Substring(1, 4) != "0000") && !this.CheckExpirationValidate(strArray2[3])) - { + var strArray2 = strArray[0].Split(','); + if (strArray2.Length < 4) return "1Old key file format, please use new key file !"; + + if (strArray2[3].Substring(1, 4) != "0000" && !CheckExpirationValidate(strArray2[3])) return "1Key is expired !"; - } - if ((strArray2[1].Substring(0, 1) == "O") && (type == 0)) - { - return "1Element Key has not supported yet !"; - } - this.gsSize = strArray2[0]; - this.gsBID = strArray2[1].Substring(1, 2); - this.gsPID1 = strArray2[2].Substring(1, 3); - this.gsPID2 = strArray2[2].Substring(5, 3); - this.gsExpiration = strArray2[3].Substring(1, strArray2[3].Length - 1); - this.gTotalPageID = int.Parse(this.gsBID) * 0x100; - this.gbKeyValidate = true; + + if (strArray2[1].Substring(0, 1) == "O" && type == 0) return "1Element Key has not supported yet !"; + gsSize = strArray2[0]; + gsBID = strArray2[1].Substring(1, 2); + gsPID1 = strArray2[2].Substring(1, 3); + gsPID2 = strArray2[2].Substring(5, 3); + gsExpiration = strArray2[3].Substring(1, strArray2[3].Length - 1); + gTotalPageID = int.Parse(gsBID) * 0x100; + gbKeyValidate = true; return "0"; } - + public string TmatrixKeyCheck_OID4(string sKey) { - this.gbKeyValidate = false; - string[] strArray = sKey.Split(new char[] { ';' }); - if (this.DecodeLicense_TmatrixKey(strArray[0]) != strArray[1]) - { + gbKeyValidate = false; + var strArray = sKey.Split(';'); + if (DecodeLicense_TmatrixKey(strArray[0]) != strArray[1]) return "1Key is not correct, it should be modified !"; - } - string[] strArray2 = strArray[0].Split(new char[] { ',' }); - if (strArray2.Length < 5) - { - return "2It might be old key file format, please use OID4 key file !"; - } + var strArray2 = strArray[0].Split(','); + if (strArray2.Length < 5) return "2It might be old key file format, please use OID4 key file !"; - if ((strArray2[4].Substring(1, 4) != "0000") && !this.CheckExpirationValidate(strArray2[4])) + if (strArray2[4].Substring(1, 4) != "0000" && !CheckExpirationValidate(strArray2[4])) { //return "3Key is expired!"; } - this.gsSID = strArray2[0].Substring(1, 1); - this.gsOID = strArray2[1].Substring(1, 3); - this.gsBID = strArray2[2].Substring(1, 4); - this.gsPID1 = strArray2[3].Substring(1, 3); - this.gsPID2 = strArray2[3].Substring(5, 3); - this.gSID = int.Parse(this.gsSID); - this.gOID = int.Parse(this.gsOID); - this.gBID = int.Parse(this.gsBID); - this.gPID1 = int.Parse(this.gsPID1); - this.gPID2 = int.Parse(this.gsPID2); - this.gsExpiration = strArray2[4].Substring(1, strArray2[4].Length - 1); - this.gTotalPageID = int.Parse(this.gsBID) * 0x100; - this.gbKeyValidate = true; + gsSID = strArray2[0].Substring(1, 1); + gsOID = strArray2[1].Substring(1, 3); + gsBID = strArray2[2].Substring(1, 4); + gsPID1 = strArray2[3].Substring(1, 3); + gsPID2 = strArray2[3].Substring(5, 3); + gSID = int.Parse(gsSID); + gOID = int.Parse(gsOID); + gBID = int.Parse(gsBID); + gPID1 = int.Parse(gsPID1); + gPID2 = int.Parse(gsPID2); + gsExpiration = strArray2[4].Substring(1, strArray2[4].Length - 1); + gTotalPageID = int.Parse(gsBID) * 0x100; + gbKeyValidate = true; return "0"; } - + public string TmatrixKeyCheck_OID4(string sKey, int type) { - this.gbKeyValidate = false; - string[] strArray = sKey.Split(new char[] { ';' }); - if (this.DecodeLicense_TmatrixKey(strArray[0]) != strArray[1]) - { + gbKeyValidate = false; + var strArray = sKey.Split(';'); + if (DecodeLicense_TmatrixKey(strArray[0]) != strArray[1]) return "1Key is not correct, it should be modified !"; - } - string[] strArray2 = strArray[0].Split(new char[] { ',' }); - if (strArray2.Length < 5) - { - return "1Old key file format, please use new key file !"; - } - if ((strArray2[4].Substring(1, 4) != "0000") && !this.CheckExpirationValidate(strArray2[4])) - { + var strArray2 = strArray[0].Split(','); + if (strArray2.Length < 5) return "1Old key file format, please use new key file !"; + + if (strArray2[4].Substring(1, 4) != "0000" && !CheckExpirationValidate(strArray2[4])) return "1Key is expired !"; - } - if ((strArray2[1].Substring(0, 1) == "O") && (type == 0)) - { - return "1Element Key has not supported yet !"; - } + + if (strArray2[1].Substring(0, 1) == "O" && type == 0) return "1Element Key has not supported yet !"; + if (type != 0x63) { - this.gsSID = strArray2[0].Substring(1, 1); - this.gsOID = strArray2[1].Substring(1, 3); - this.gsBID = strArray2[2].Substring(1, 4); - this.gsPID1 = strArray2[3].Substring(1, 3); - this.gsPID2 = strArray2[3].Substring(5, 3); - this.gSID = int.Parse(this.gsSID); - this.gOID = int.Parse(this.gsOID); - this.gBID = int.Parse(this.gsBID); - this.gPID1 = int.Parse(this.gsPID1); - this.gPID2 = int.Parse(this.gsPID2); - this.gsExpiration = strArray2[4].Substring(1, strArray2[4].Length - 1); - this.gbKeyValidate = true; + gsSID = strArray2[0].Substring(1, 1); + gsOID = strArray2[1].Substring(1, 3); + gsBID = strArray2[2].Substring(1, 4); + gsPID1 = strArray2[3].Substring(1, 3); + gsPID2 = strArray2[3].Substring(5, 3); + gSID = int.Parse(gsSID); + gOID = int.Parse(gsOID); + gBID = int.Parse(gsBID); + gPID1 = int.Parse(gsPID1); + gPID2 = int.Parse(gsPID2); + gsExpiration = strArray2[4].Substring(1, strArray2[4].Length - 1); + gbKeyValidate = true; } + return "0"; } - + public void TmatrixUninitialize() { - this.oidPIGenerator.Uninitialize(); + oidPIGenerator.Uninitialize(); } } } diff --git a/GeneratorCode/config.ini b/GeneratorCode/config.ini index 6b279c6..bed0699 100644 --- a/GeneratorCode/config.ini +++ b/GeneratorCode/config.ini @@ -1,5 +1,16 @@ ; 应用程序配置文件 +;--------------------------------------- +; 主要配置项 +; +[Main] +; 是否对协议中的 msg 字段进行 Base64 编码 +ProBase64Msg = false +; 服务器端口号 +ProServerPort = 10088 +; 服务器 IP 地址 +ProServerAddr = 127.0.0.1 + ;--------------------------------------- ; Log 相关配置 ; diff --git a/GeneratorCode/packages.config b/GeneratorCode/packages.config index 4f35d8e..f393aad 100644 --- a/GeneratorCode/packages.config +++ b/GeneratorCode/packages.config @@ -1,4 +1,5 @@  +