| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- using System;
- using System.Collections.Concurrent;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using static PDFMonitor_SVG.Entities;
- namespace PDFMonitor_SVG {
- internal class Entities {
- public const int DEFAULT_DPI = 96;
- public const double DEFAULT_RATIO = 25.4;
- public static int px2mm(double px) {
- return (int)Math.Round(px / DEFAULT_DPI * DEFAULT_RATIO);
- }
- //仿FixedThreadPool
- public class FixedThreadPool {
- private readonly BlockingCollection<Action> _taskQueue;
- private readonly Thread[] _threads;
- public FixedThreadPool(int size) {
- _taskQueue = new BlockingCollection<Action>();
- _threads = new Thread[size];
- for (int i = 0; i < size; i++) {
- _threads[i] = new Thread(Worker);
- _threads[i].Start();
- }
- }
- public void Execute(Action action) {
- _taskQueue.Add(action);
- }
- private void Worker() {
- foreach (var task in _taskQueue.GetConsumingEnumerable()) {
- task();
- }
- }
- public void Shutdown() {
- _taskQueue.CompleteAdding();
- foreach (var thread in _threads) {
- thread.Join();
- }
- }
- }
- public class SVGTaskInfo {
- private string width;
- private string height;
- private string svgPath;
- private string svgFileName;
- private long idDesignOrder;
- public SVGTaskInfo() {
- }
- public string SvgPath { get => svgPath; set => svgPath = value; }
- public string Height { get => height; set => height = value; }
- public string Width { get => width; set => width = value; }
- public string SvgFileName { get => svgFileName; set => svgFileName = value; }
- public long IdDesignOrder { get => idDesignOrder; set => idDesignOrder = value; }
- }
- public class PDFCallbackInfo {
- private long idDesignOrder;
- private string pdfFileName;
- public long IdDesignOrder { get => idDesignOrder; set => idDesignOrder = value; }
- public string PdfFileName { get => pdfFileName; set => pdfFileName = value; }
- }
- }
- }
|