tx
2025-04-09 fa7510e1ed63df0366787fa4ed1b3db6426d2b46
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
using Eventech.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using WW.Cad.Base;
using WW.Cad.Drawing;
using WW.Cad.Drawing.GDI;
using WW.Cad.IO;
using WW.Cad.Model;
using WW.Cad.Model.Entities;
using WW.Cad.Model.Tables;
using WW.Math;
 
namespace TProduct.PumpGraph.Dxf
{
    public class FeatChart
    {
        protected short _defaultFeatCurveWidth = 40;//默认曲线宽度
        protected short _defatulCurveLabelHeight = 8;//曲线上文字的高度
        protected short _equalCurveParaLabelHeight = 8;//等效线文字高度
        protected short _equalCurveParaLabelHeight_Offset_X = 0;//等效线文字高度 偏置X
        protected short _equalCurveParaLabelHeight_Offset_Y = 2;//等效线文字高度 偏置Y
 
        // 第二刻度
        public Eventech.Model.CoordAxis2 SecondAxisQ { get; set; }
 
        public Eventech.Model.CoordAxis2 SecondAxisH { get; set; }
 
        //各种字体
        protected DxfTextStyle _axisTextFont = null;//坐标默认字体 可空 
        protected DxfTextStyle _frameTextFont = null;//图框默认字体 可空
        protected DxfTextStyle _curveTextFont = null;//曲线默认字体 可空
 
        protected DxfModel _dxfFileModel = null;
 
        protected string _axisTtileContentQ = "流量";
        protected string _axisTtileContentH = "扬程";
        protected string _axisTtileContentE = "效率";
        protected string _axisTtileContentP = "功率";
        protected string _axisTtileContentNPSH = "NPSH";
 
        //文件格式
        protected Eventech.Model.eFileSuffixType _fileSuffixType = Eventech.Model.eFileSuffixType.DWG;
        public Eventech.Model.eFileSuffixType FileSuffixType
        {
            get { return _fileSuffixType; }
            set { _fileSuffixType = value; }
        }
 
        //如果其他格式时,是否保留DWG文件
        protected bool _isRetainDwgFile = false;
        public bool IsRetainDwgFile
        {
            get { return _isRetainDwgFile; }
            set { _isRetainDwgFile = value; }
        }
 
        //设计员签名
        protected string _designUserDrawSignal = "";
 
        public string DesignUserDrawSignal
        {
            get { return _designUserDrawSignal; }
            set { _designUserDrawSignal = value; }
        }
 
        //产品型号
        protected string _productName = null;
 
        public string ProductName
        {
            get { return _productName; }
            set { _productName = value; }
        }
 
        //产品 系列
        protected string _seriesName = null;
 
        public string SeriesName
        {
            get { return _seriesName; }
            set { _seriesName = value; }
        }
 
        //产品 类型
        protected string _catalogName = null;
 
        public string CatalogName
        {
            get { return _catalogName; }
            set { _catalogName = value; }
        }
 
        //产品 别名
        protected string _kindName = null;
 
        public string KindName
        {
            get { return _kindName; }
            set { _kindName = value; }
        }
 
        //曲线号
        protected string _curveCode = null;
 
        public string CurveCode
        {
            get { return _curveCode; }
            set { _curveCode = value; }
        }
 
        //公司名
        protected string _corpFullName = null;
 
        public string CorpFullName
        {
            get { return _corpFullName; }
            set { _corpFullName = value; }
        }
 
        protected bool _isDrawWaterMark = false;
 
        public bool IsDrawWaterMark
        {
            get { return _isDrawWaterMark; }
            set { _isDrawWaterMark = value; }
        }
 
        protected string _waterMarkText = null;
 
        public string WaterMarkText
        {
            get { return _waterMarkText; }
            set { _waterMarkText = value; }
        }
 
        //是否黑白显示
        protected bool _isMonoColor = false;
        public bool IsMonoColor
        {
            get { return _isMonoColor; }
            set { _isMonoColor = value; }
        }
 
        protected virtual string BuildCadText(string content)
        {
            return content;
        }
        protected string BuildCadText(Eventech.Model.UnitQ unit)
        {
            if (unit == Eventech.Model.UnitQ.M3S)
                return @"m{{\fArial|b0|i0|c0|p34;³}}/s";
            else if (unit == Eventech.Model.UnitQ.M3H)
                return @"m{{\fArial|b0|i0|c0|p34;³}}/h";
            else
                return Eventech.Common.UnitQHelper.GetEnUnitName(unit);
        }
        protected virtual string BuildCadText_Trim0(string content)
        {
            if (content == null)
                return "";
            if (content.EndsWith(".0"))
            {
                return BuildCadText(content.Replace(".0", ""));
            }
            return BuildCadText(content);
        }
        protected virtual string Trim0(double vvv)
        {
            string content = vvv.ToString();
            if (content == null)
                return "";
            if (content.EndsWith(".0"))
            {
                return content.Replace(".0", "");
            }
            return content;
        }
        //其他参数
        protected Dictionary<string, string> _dwgObjectDict = null;
        public Dictionary<string, string> DwgObjectDict
        {
            get { return _dwgObjectDict; }
            set { _dwgObjectDict = value; }
        }
 
        //文字
        protected List<Eventech.Model.AnnoAnchorPoint> _labelTextList = null;
 
        public List<Eventech.Model.AnnoAnchorPoint> LabelTextList
        {
            get { return _labelTextList; }
            set { _labelTextList = value; }
        }
 
        public enum eAxisTitlePosiStyle
        {
            Center = 0,
            Top = 1
        }
 
        //纵坐标标题的位置 0表示 中间, 1表示刻度的上面
        protected eAxisTitlePosiStyle _axisTitlePosiStyleY = eAxisTitlePosiStyle.Center;
 
        public eAxisTitlePosiStyle AxisTitlePosiStyleY
        {
            get { return _axisTitlePosiStyleY; }
            set { _axisTitlePosiStyleY = value; }
        }
 
 
 
        protected ChartCurveLabelHelper theCurveLabelHelper = null;
 
        protected TProduct.Model.RatedParas4Pump _ratedParas = null;
 
        protected Eventech.Model.PointToleranceParas _toleranceParas = null;
 
        public void SetRatedParas(
           TProduct.Model.RatedParas4Pump ratedParas,
           List<Model.TestGradeJudgeItem> testJudgeItems)
        {
            this._ratedParas = ratedParas;
            if (ratedParas == null)
                return;
 
            _toleranceParas = new PointToleranceParas();
            var flow_min = testJudgeItems.Find(x => x.TargeType == TProduct.Model.eTestJudgeTargetType.流量 && x.ThresholdType == TProduct.Model.TestGradeJudgeItem.eThresholdType.Min);
            if (flow_min != null)
            {
                _toleranceParas.TolRatioMinQ = flow_min.ThresholdValue;
            }
            var flow_max = testJudgeItems.Find(x => x.TargeType == TProduct.Model.eTestJudgeTargetType.流量 && x.ThresholdType == TProduct.Model.TestGradeJudgeItem.eThresholdType.Max);
            if (flow_max != null)
            {
                _toleranceParas.TolRatioMaxQ = flow_max.ThresholdValue;
            }
 
            var head_min = testJudgeItems.Find(x => x.TargeType == TProduct.Model.eTestJudgeTargetType.扬程 && x.ThresholdType == TProduct.Model.TestGradeJudgeItem.eThresholdType.Min);
            if (head_min != null)
            {
                _toleranceParas.TolRatioMinH = head_min.ThresholdValue;
            }
            var head_max = testJudgeItems.Find(x => x.TargeType == TProduct.Model.eTestJudgeTargetType.扬程 && x.ThresholdType == TProduct.Model.TestGradeJudgeItem.eThresholdType.Max);
            if (head_max != null)
            {
                _toleranceParas.TolRatioMaxH = head_max.ThresholdValue;
            }
 
        }
 
 
        //绘制额定点线
        protected bool _isDrawRatedParasCurve = true;
        public bool IsDrawRatedParasCurve
        {
            get { return _isDrawRatedParasCurve; }
            set { _isDrawRatedParasCurve = value; }
        }
 
        //绘制额定点文字
        protected bool _isDrawRatedParasText = true;
        public bool IsDrawRatedParasText
        {
            get { return _isDrawRatedParasText; }
            set { _isDrawRatedParasText = value; }
        }
 
        protected double _ratedN = -1;
        public double RatedN
        {
            get { return _ratedN; }
            set { _ratedN = value; }
        }
 
        protected double _originD2 = -1;
        public double OriginD2
        {
            get { return _originD2; }
            set { _originD2 = value; }
        }
 
        protected double _workSpeed = -1;
        public double WorkSpeed
        {
            get { return _workSpeed; }
            set { _workSpeed = value; }
        }
 
        protected string _inletDia = null;
        public string InletDia
        {
            get { return _inletDia; }
            set { _inletDia = value; }
        }
 
        protected string _outletDia = null;
        public string OutletDia
        {
            get { return _outletDia; }
            set { _outletDia = value; }
        }
 
        protected Eventech.Model.CrossPoint _crossPoint = null;
        public Eventech.Model.CrossPoint CrossPoint
        {
            get { return _crossPoint; }
            set { _crossPoint = value; }
        }
 
        protected bool _isDrawDesignPoint = true;
        public bool IsDrawDesignPoint
        {
            get { return _isDrawDesignPoint; }
            set { _isDrawDesignPoint = value; }
        }
 
 
 
        //单位 (设计点)   
        protected Eventech.Model.UnitH _dpUnitH = Eventech.Model.UnitH.M;
        public Eventech.Model.UnitH DpUnitH
        {
            get { return _dpUnitH; }
            set { _dpUnitH = value; }
        }
        protected Eventech.Model.UnitQ _dpUnitQ = Eventech.Model.UnitQ.M3H;
        public Eventech.Model.UnitQ DpUnitQ
        {
            get { return _dpUnitQ; }
            set { _dpUnitQ = value; }
        }
        //单位(图表)
        protected Eventech.Model.UnitQ _unitQ = Eventech.Model.UnitQ.M3H;
        protected Eventech.Model.UnitH _unitH = Eventech.Model.UnitH.M;
        public Eventech.Model.UnitH UnitH
        {
            get { return _unitH; }
            set { _unitH = value; }
        }
 
        public Eventech.Model.UnitQ UnitQ
        {
            get { return _unitQ; }
            set { _unitQ = value; }
        }
 
 
 
        //设计点显示方式:注意有的模板此设置无效,有的模板已经固华了显示方式
        protected Eventech.Model.eDesignPointDispType _designPointDispType = Eventech.Model.eDesignPointDispType.Cross;
        public Eventech.Model.eDesignPointDispType DesignPointDispType
        {
            get { return _designPointDispType; }
            set { _designPointDispType = value; }
        }
 
        //电机功率
        protected string _motorPower = null;
        public string MotorPower
        {
            get { return _motorPower; }
            set { _motorPower = value; }
        }
 
        //
        protected Eventech.Model.AnnoAnchorPointList _annoAnchorPointList = null;
        public Eventech.Model.AnnoAnchorPointList AnnoAnchorPointList
        {
            get { return _annoAnchorPointList; }
            set { _annoAnchorPointList = value; }
        }
 
        #region 等效线
 
        protected Eventech.Model.CombineCurveList _equalParaCurveE = null;
        public Eventech.Model.CombineCurveList EqualParaCurveE
        {
            get { return _equalParaCurveE; }
            set { _equalParaCurveE = value; }
        }
 
        //是否显示等效线
        protected bool isDispEqualParaCurveE = true;
 
        public bool IsDispEqualParaCurveE
        {
            get { return isDispEqualParaCurveE; }
            set
            {
                isDispEqualParaCurveE = value;
                isDispEqualParaTextE = value;
            }
        }
 
        //是否显示等效线效率值
        protected bool isDispEqualParaTextE = true;
 
        public bool IsDispEqualParaTextE
        {
            get { return isDispEqualParaTextE; }
            set { isDispEqualParaTextE = value; }
        }
 
        #endregion 等效线
 
        //
        protected WW.Cad.Model.Entities.EntityColor _whiteColor;//白色
 
        protected short _equalParaCurveWidth = 20;
        protected WW.Cad.Model.Entities.EntityColor _equalParaCurveColor;
        protected WW.Cad.Model.Entities.EntityColor _gridLineColor;
 
        protected WW.Cad.Model.Entities.EntityColor _gridSubLineColor;//子刻度
        protected WW.Cad.Model.Entities.EntityColor _axisTitleColorQ;
        protected WW.Cad.Model.Entities.EntityColor _axisTitleColorH;
        protected WW.Cad.Model.Entities.EntityColor _axisTitleColorE;
        protected WW.Cad.Model.Entities.EntityColor _axisTitleColorP;
        protected WW.Cad.Model.Entities.EntityColor _axisTitleColorNPSH;
        protected WW.Cad.Model.Entities.EntityColor _axisLabelColorQ;
        protected WW.Cad.Model.Entities.EntityColor _axisLabelColorH;
        protected WW.Cad.Model.Entities.EntityColor _axisLabelColorE;
        protected WW.Cad.Model.Entities.EntityColor _axisLabelColorP;
        protected WW.Cad.Model.Entities.EntityColor _axisLabelColorNPSH;
        protected WW.Cad.Model.Entities.EntityColor _designPointColor;
        protected WW.Cad.Model.Entities.EntityColor _frameTextColor;
 
        //语言
        protected Eventech.Model.eLocalizationType _currentLangugage = Eventech.Model.eLocalizationType.zhCN;
 
        public Eventech.Model.eLocalizationType CurrentLangugage
        {
            get { return _currentLangugage; }
            set
            {
                SetLangugageType(value);
            }
        }
 
        protected virtual void SetLangugageType(Eventech.Model.eLocalizationType currentLangugage)
        {
            this._currentLangugage = currentLangugage;
            if (this._currentLangugage != Eventech.Model.eLocalizationType.zhCN)
            {
                _axisTtileContentQ = "Flow";
                _axisTtileContentH = "Head";
                _axisTtileContentP = "Power";
                _axisTtileContentE = "Eta";
                _axisTtileContentNPSH = "NPSH";
            }
        }
 
        //初始化模版文件
        protected string _strTemplateFile = null;
 
        public virtual bool InitialTemplate(string CorpDataFolder, Eventech.Model.eLocalizationType location, string attachInfo)
        {
            _currentLangugage = location;
            return false;
        }
 
        //介质
        protected TProduct.PumpGraph.Dxf.JieZhiFullPara _jieZhiInfo = null;// TProduct.Model.JieZhiFullPara的 toJsonString
 
        public void SetJieZhiInfo(string jieZhiJsonInfo)
        {
            if (string.IsNullOrEmpty(jieZhiJsonInfo))
                return;
 
            try
            {
                this._jieZhiInfo = new JieZhiFullPara(jieZhiJsonInfo);
            }
            catch
            {
                _jieZhiInfo = null;
            }
        }
 
        #region 网格线
 
        //是否显示Y的网格线
        protected bool _isDispGridLineY = true;
 
        public bool IsDispGridLineY
        {
            get { return _isDispGridLineY; }
            set { _isDispGridLineY = value; }
        }
 
        //是否显示Y的子网格线
        protected bool _isDispGridSubLineY = false;
 
        public bool IsDispGridSubLineY
        {
            get { return _isDispGridSubLineY; }
            set { _isDispGridSubLineY = value; }
        }
 
        //是否显示扬程曲线X的网格线
        protected bool _isDispGridLineX = true;
 
        public bool IsDispGridLineX
        {
            get { return _isDispGridLineX; }
            set { _isDispGridLineX = value; }
        }
 
        //是否显示Y的子网格线
        protected bool _isDispGridSubLineX = false;
 
        public bool IsDispGridSubLineX
        {
            get { return _isDispGridSubLineX; }
            set { _isDispGridSubLineX = value; }
        }
 
        protected short _gridLineWidth = 5;
 
        public short GridLineWidth
        {
            get { return _gridLineWidth; }
            set { _gridLineWidth = value; }
        }
 
        //子网格线数量
        protected int _subGridLineNumber = 5;
 
        public int SubGridLineNumber
        {
            get { return _subGridLineNumber; }
            set { _subGridLineNumber = value; }
        }
 
        #endregion 网格线
 
        public virtual bool CreateDxf(string strFile)
        {
            return false;
        }
 
        public virtual bool CreateDxf(string strFilePath, string strTemplateFile)
        {
            this._strTemplateFile = strTemplateFile;
 
            return true;
        }
 
        protected System.Drawing.Color _colorAxisQ = System.Drawing.Color.Yellow;
        protected System.Drawing.Color _colorAxisH = System.Drawing.Color.Yellow;
        protected System.Drawing.Color _colorAxisE = System.Drawing.Color.Yellow;
        protected System.Drawing.Color _colorAxisP = System.Drawing.Color.Yellow;
        protected System.Drawing.Color _colorAxisNPSH = System.Drawing.Color.Yellow;
        protected System.Drawing.Color _colorParaCurveE = System.Drawing.Color.White;
        protected System.Drawing.Color _colorFrameText = System.Drawing.Color.White;
        protected System.Drawing.Color _colorGridLine = System.Drawing.Color.Gray;
        protected System.Drawing.Color _colorDeignPoint = System.Drawing.Color.Red;
 
        //设置默认字体
        protected virtual void InitialChartColorAndFont()
        {
            try
            {
                if (this._isMonoColor)
                {
                    _whiteColor = TProduct.PumpGraph.Dxf.AutoCadHelper.WhiteColor;
 
                    _axisLabelColorQ = _whiteColor;
                    _axisTitleColorQ = _whiteColor;
                    _axisLabelColorH = _whiteColor;
                    _axisTitleColorH = _whiteColor;
                    _axisLabelColorE = _whiteColor;
                    _axisTitleColorE = _whiteColor;
                    _axisLabelColorP = _whiteColor;
                    _axisTitleColorP = _whiteColor;
                    _axisLabelColorNPSH = _whiteColor;
                    _axisTitleColorNPSH = _whiteColor;
                    _equalParaCurveColor = _whiteColor;
                    _frameTextColor = _whiteColor;
                    _gridLineColor = _whiteColor;
                    _designPointColor = _whiteColor;
                }
                else
                {
                    _whiteColor = TProduct.PumpGraph.Dxf.AutoCadHelper.WhiteColor;
 
                    _axisLabelColorQ = TProduct.PumpGraph.Dxf.AutoCadHelper.GetColor(_colorAxisQ);
                    _axisTitleColorQ = TProduct.PumpGraph.Dxf.AutoCadHelper.GetColor(_colorAxisQ);
 
                    _axisLabelColorH = TProduct.PumpGraph.Dxf.AutoCadHelper.GetColor(_colorAxisH);
                    _axisTitleColorH = TProduct.PumpGraph.Dxf.AutoCadHelper.GetColor(_colorAxisH);
 
                    _axisLabelColorE = TProduct.PumpGraph.Dxf.AutoCadHelper.GetColor(_colorAxisE);
                    _axisTitleColorE = TProduct.PumpGraph.Dxf.AutoCadHelper.GetColor(_colorAxisE);
 
                    _axisLabelColorP = TProduct.PumpGraph.Dxf.AutoCadHelper.GetColor(_colorAxisP);
                    _axisTitleColorP = TProduct.PumpGraph.Dxf.AutoCadHelper.GetColor(_colorAxisP);
 
                    _axisLabelColorNPSH = TProduct.PumpGraph.Dxf.AutoCadHelper.GetColor(_colorAxisNPSH);
                    _axisTitleColorNPSH = TProduct.PumpGraph.Dxf.AutoCadHelper.GetColor(_colorAxisNPSH);
 
                    _equalParaCurveColor = TProduct.PumpGraph.Dxf.AutoCadHelper.GetColor(_colorParaCurveE);
                    _frameTextColor = TProduct.PumpGraph.Dxf.AutoCadHelper.GetColor(_colorFrameText);
                    _gridLineColor = TProduct.PumpGraph.Dxf.AutoCadHelper.GetColor(_colorGridLine);
                    _designPointColor = TProduct.PumpGraph.Dxf.AutoCadHelper.GetColor(_colorDeignPoint);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
 
            //_defaultTextFont = new DxfTextStyle("MYSTYLE", "simfang.ttf");//仿宋体 在WINDOWS/FONT下的文件名称
            //_dxfFileModel.TextStyles.Add(_defaultTextFont);
            //DxfTextStyle titleType = null;
            //titleType = new DxfTextStyle("MY", "txt.shx");
            //// titleType.Name = "MY";
            //// titleType.FontFilename = "txt.shx";
            //titleType.BigFontFilename = "bigfont.shx";
            //_dxfFileModel.TextStyles.Add(titleType);
 
            //var fs_path = @"D:\WorkData\TProduct\Client\OutAlone\DataCYJX\template\acadiso.dwt";
            ////
            //if (System.IO.File.Exists(fs_path))
            //{
            //    _defaultTextFont = new DxfTextStyle("FS", fs_path);//仿宋体 在WINDOWS/FONT下的文件名称
            //    _dxfFileModel.TextStyles.Add(_defaultTextFont);
            //}
 
            //if (!string.IsNullOrEmpty(_defaultFontFilePath) && System.IO.File.Exists(_defaultFontFilePath))
            //{
            //    _defaultTextFont = new DxfTextStyle(_defaultFontName, _defaultFontFilePath);//仿宋体 在WINDOWS/FONT下的文件名称
            //    _dxfFileModel.TextStyles.Add(_defaultTextFont);
            //}
 
            //string font_file = System.IO.Path.Combine(TProduct.GlobeParas.DataFolder, "PumpDwgFeatCurveTemplate", "simfang.ttf");
            //if (System.IO.File.Exists(font_file))
            //{
            //    lxpChart.DefaultFontFilePath = font_file;//默认字体
            //    lxpChart.DefaultFontName = "simfang";
            //}
            //else
            //{
            //    font_file = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "PumpDwgFeatCurveTemplate", "simfang.ttf");
            //    if (System.IO.File.Exists(font_file))
            //    {
            //        lxpChart.DefaultFontFilePath = font_file;//默认字体
            //        lxpChart.DefaultFontName = "simfang";
            //    }
            //}
            //protected string _defaultFontName = "simfang";//默认字体
            //public string DefaultFontName
            //{
            //    get { return _defaultFontName; }
            //    set { _defaultFontName = value; }
            //}
 
            //protected string _defaultFontFilePath = null;//默认字体
            //public string DefaultFontFilePath
            //{
            //    get { return _defaultFontFilePath; }
            //    set { _defaultFontFilePath = value; }
            //}
 
            //if (!zlpChart.InitialTemplate(TProduct.GlobeParas.DataFolder, TProduct.UserSetting.Localization.Current))
            //{
            //    zlpChart = new TProduct.PumpGraph.Dxf.ZlpChartCurve1_NewFile();
            //    string font_file = System.IO.Path.Combine(TProduct.GlobeParas.DataFolder, "PumpDwgFeatCurveTemplate", "simfang.ttf");
            //    if (System.IO.File.Exists(font_file))
            //    {
            //        zlpChart.DefaultFontFilePath = font_file;//默认字体
            //        zlpChart.DefaultFontName = "simfang";
            //    }
            //    else
            //    {
            //        font_file = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "PumpDwgFeatCurveTemplate", "simfang.ttf");
            //        if (System.IO.File.Exists(font_file))
            //        {
            //            zlpChart.DefaultFontFilePath = font_file;//默认字体
            //            zlpChart.DefaultFontName = "simfang";
            //        }
            //    }
            //}
        }
 
        //产生图框文字
        protected DxfMText CreateFrameDxfText(string text, double x, double y, double text_height, AttachmentPoint AttachmentPoint = AttachmentPoint.BottomLeft)
        {
            if (string.IsNullOrEmpty(text))
                return null;
 
            DxfMText txtLabel = new DxfMText(text, new Point3D(x, y, 0d), text_height);
 
            if (this._frameTextFont != null)
                txtLabel.Style = this._frameTextFont;
            txtLabel.Color = this._frameTextColor;
            txtLabel.AttachmentPoint = AttachmentPoint;
            txtLabel.Height = text_height;
            _dxfFileModel.Entities.Add(txtLabel);
            return txtLabel;
        }
 
        protected DxfMText CreateFrameDxfText(string text, double x, double y, double text_height, AttachmentPoint AttachmentPoint, DxfTextStyle style)
        {
            if (string.IsNullOrEmpty(text))
                return null;
 
            DxfMText txtLabel = new DxfMText(text, new Point3D(x, y, 0d), text_height);
            if (style != null)
                txtLabel.Style = style;
            else if (this._frameTextFont != null)
                txtLabel.Style = this._frameTextFont;
            txtLabel.Color = this._frameTextColor;
            txtLabel.AttachmentPoint = AttachmentPoint;
            txtLabel.Height = text_height;
            _dxfFileModel.Entities.Add(txtLabel);
            return txtLabel;
        }
 
        //
        protected System.Drawing.Printing.PaperKind _printKindSize = System.Drawing.Printing.PaperKind.A4;
 
        //
        protected bool SaveFile(string strFilePath)
        {
            if (_fileSuffixType == Eventech.Model.eFileSuffixType.DWG || this._isRetainDwgFile)
            {
                string file_dwg = string.Format(@"{0}\{1}.{2}",
                    System.IO.Path.GetDirectoryName(strFilePath), System.IO.Path.GetFileNameWithoutExtension(strFilePath), "dwg");
 
                if (System.IO.File.Exists(file_dwg))
                {
                    System.IO.File.Delete(file_dwg);
                }
                DwgWriter.Write(file_dwg, _dxfFileModel);
 
                //DwgWriter.Write("DwgWriteExample-ascii.dwg", model);
                //DxfWriter.Write(strFilePath, _dxfFileModel, false);
                //DxfWriter.Write("DxfWriteExample-bin.dxf", model, true);
            }
 
            //产生 PDF
            CreatePdfFile(strFilePath);
            //产生 PNG图片
            CreatePngFile(strFilePath);
 
            return true;
        }
 
        //产生 PDF
        protected bool CreatePdfFile(string strFilePath)
        {
            try
            {
                System.Drawing.Printing.PaperKind pdfPageKind = _printKindSize;
                if (_fileSuffixType != Eventech.Model.eFileSuffixType.PDF)
                {
                    return true;
                }
                if (_dxfFileModel == null)
                    return false;
                var model_new_file = new DxfModel(_dxfFileModel);
                if (this._isMonoColor)
                {
                    foreach (var m in model_new_file.Entities)
                    {
                        m.Color = _whiteColor;
                    }
                }
                string strPdfFile = string.Format(@"{0}\{1}.{2}",
   System.IO.Path.GetDirectoryName(strFilePath), System.IO.Path.GetFileNameWithoutExtension(strFilePath), "pdf");
 
                if (System.IO.File.Exists(strPdfFile))
                {
                    System.IO.File.Delete(strPdfFile);
                }
 
                BoundsCalculator boundsCalculator = new BoundsCalculator();
                boundsCalculator.GetBounds(model_new_file);
                Bounds3D bounds = boundsCalculator.Bounds;
                System.Drawing.Printing.PaperSize paperSize = PaperSizes.GetPaperSize(pdfPageKind);
                // Lengths in inches.
                float pageWidth = (float)paperSize.Width / 100f;
                float pageHeight = (float)paperSize.Height / 100f;
                float margin = 0.5f;
                // Scale and transform such that its fits max width/height and the top left middle of
                // the cad drawing will match the top middle of the pdf page. The transform
                // transforms to pdf pixels.
                Matrix4D to2DTransform = DxfUtil.GetScaleTransform(
                    bounds.Corner1,
                    bounds.Corner2,
                    new Point3D(bounds.Center.X, bounds.Corner2.Y, 0d),
                    new Point3D(new Vector3D(margin, margin, 0d) * PdfExporter.InchToPixel),
                    new Point3D(new Vector3D(pageWidth - margin, pageHeight - margin, 0d) * PdfExporter.InchToPixel),
                    new Point3D(new Vector3D(pageWidth / 2d, pageHeight - margin, 0d) * PdfExporter.InchToPixel)
                );
                // to2DTransform.TransformAngle(90);
                System.IO.Stream stream_pdf = null;
                using (stream_pdf = System.IO.File.Create(strPdfFile))
                {
                    PdfExporter pdfGraphics = new PdfExporter(stream_pdf);
                    pdfGraphics.DrawPage(
                        model_new_file,
                        GraphicsConfig.WhiteBackgroundCorrectForBackColor, //AcadLikeWithWhiteBackground   WhiteBackgroundCorrectForBackColor  BlackBackgroundCorrectForBackColor
                        to2DTransform,
                        paperSize
                    );
                    pdfGraphics.EndDocument();
                }
            }
            catch // (Exception ex)
            {
                return false;
            }
 
            return true;
        }
 
        //产生 图片
        protected bool CreatePngFile(string strFilePath)
        {
            try
            {
                if (_dxfFileModel == null)
                    return false;
 
                if (_fileSuffixType != Eventech.Model.eFileSuffixType.PNG)
                    return true;
                int ImageWidth = 2100;
                int ImageHeight = 2970;
                if (this._printKindSize == System.Drawing.Printing.PaperKind.A4Rotated)
                {
                    ImageWidth = 2970;
                    ImageHeight = 2100;
                }
 
                var model_new_file = new DxfModel(_dxfFileModel);
                if (this._isMonoColor)
                {
                    var blackColor = TProduct.PumpGraph.Dxf.AutoCadHelper.WhiteColor;
                    foreach (var m in model_new_file.Entities)
                    {
                        m.Color = blackColor;
                    }
                }
 
                //var bCopy = strFilePath.Replace(".dwg", "_copyB.dwg");
                //System.IO.File.Copy(strFilePath, bCopy);
                //DxfModel model_new_file_image = WW.Cad.IO.DwgReader.Read(bCopy);
 
                string strImgageFile = string.Format(@"{0}\{1}.{2}",
System.IO.Path.GetDirectoryName(strFilePath), System.IO.Path.GetFileNameWithoutExtension(strFilePath), "png");
 
                if (System.IO.File.Exists(strImgageFile))
                {
                    System.IO.File.Delete(strImgageFile);
                }
 
                GDIGraphics3D graphics = new GDIGraphics3D(GraphicsConfig.AcadLikeWithWhiteBackground);//.BlackBackgroundCorrectForBackColor);
                System.Drawing.Size maxSize = new System.Drawing.Size(ImageWidth, ImageHeight);
                System.Drawing.Bitmap bitmap =
                    ImageExporter.CreateAutoSizedBitmap(
                        model_new_file,
                        graphics,
                        Matrix4D.Identity,
                        System.Drawing.Color.White,
                        maxSize
                    );
 
                System.IO.Stream stream_image = null;
                using (stream_image = System.IO.File.Create(strImgageFile))
                {
                    ImageExporter.EncodeImageToPng(bitmap, stream_image);
                }
            }
            catch // (Exception ex)
            {
                return false;
            }
 
            return true;
        }
 
        protected WW.Cad.Model.Tables.DxfLayer GetLayerByName(string name)
        {
            foreach (var ly in _dxfFileModel.Layers)
            {
                if (ly.Name == name)
                {
                    return ly;
                }
            }
 
            return null;
        }
 
        protected void ReplaceDictText(Dictionary<string, string> dictFrameText)
        {
            if (dictFrameText == null)
                return;
 
            var dxfMTexts = this._dxfFileModel.Entities.Where(t => t is DxfMText).Select(t => t as DxfMText).ToList();
 
            foreach (var mtext in dxfMTexts)
            {
                if (dictFrameText.ContainsKey(mtext.SimplifiedText))
                {
                    mtext.Text = mtext.Text.Replace(mtext.SimplifiedText, dictFrameText[mtext.SimplifiedText]);
                }
            }
        }
 
 
 
        protected string GetNumberString(double v)
        {
            if ((int)v == v)
            {
                return ((int)v).ToString();
            }
            else if (v < 3)
            {
                return Math.Round(v, 3).ToString();
            }
            else if (v < 10)
            {
                return Math.Round(v, 2).ToString();
            }
            else
            {
                return Math.Round(v, 1).ToString();
            }
        }
    }
}