tangxu
2024-01-27 29a6de30e328c46cbbcae15066f449b0660c2db1
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace Yw.Coordinate
{
    public class QhCoordinateParas: ICloneable
    {
        public QhCoordinateParas( )
        { 
        }
        public QhCoordinateParas(ZlpCoordinateParas rhs)
        {
            this.IsLogQ = rhs.IsLogQ;
            this.GridValueQ = rhs.GridValueQ;
            this.UnitQ = rhs.UnitQ;
 
            this.IsLogH = rhs.IsLogH;
            this.GridValueH = rhs.GridValueH;
            this.UnitH = rhs.UnitH;
        }
        public QhCoordinateParas(QhCoordinateParas rhs)
        {
            this.IsLogQ = rhs.IsLogQ;
            this.GridValueQ = rhs.GridValueQ;
            this.UnitQ = rhs.UnitQ;
 
            this.IsLogH = rhs.IsLogH;
            this.GridValueH = rhs.GridValueH;
            this.UnitH = rhs.UnitH;
        }
        public QhCoordinateParas(string strChartCoord)
        {
            if (string.IsNullOrEmpty(strChartCoord))
            {
                isNull = true;
                return;
            }
 
            string[] coords = strChartCoord.Split('|');
            if (coords.Count() != 2)
            {
                isNull = true;
                return;
            }
 
 
            this.GridValueQ = new List<double>();
            string sbQ = coords[0];
            string[] coordParasQ = sbQ.Split(',');
            //this.UnitQ = (UnitQ)Convert.ToInt32(coordParasQ[0]);
            this.IsLogQ = Convert.ToBoolean(coordParasQ[1]);
            
            for (int i = 2; i < coordParasQ.Count(); i++)
                this.GridValueQ.Add(Convert.ToDouble(coordParasQ[i]));
 
            this.GridValueH = new List<double>();
            string sbH = coords[1];
            string[] coordParasH = sbH.Split(',');
            //this.UnitH = (UnitH)Convert.ToInt32(coordParasH[0]);
            this.IsLogH = Convert.ToBoolean(coordParasH[1]);
            for (int i = 2; i < coordParasH.Count(); i++)
                this.GridValueH.Add(Convert.ToDouble(coordParasH[i]));
        }
 
        private bool _isLogQ = false;//默认不是对数坐标
        public bool IsLogQ
        {
            get { return _isLogQ; }
            set
            {
                _isLogQ = value;
            }
        }
 
        public List<double> GridValueQ = null;
        private int? _unitQ = null;
        public int? UnitQ
        {
            get { return _unitQ; }
            set
            {
                _unitQ = value; 
            }
        }
 
 
        public int? UnitH
        {
            get { return _unitH; }
            set
            {
                _unitH = value; 
            }
        }
        private int? _unitH = null;
        public List<double> GridValueH = null;
        private bool _isLogH = false;//默认不是对数坐标
        public bool IsLogH
        {
            get { return _isLogH; }
            set
            {
                _isLogH = value;
            }
        }
 
 
        protected bool isNull = false;
        public bool IsNull
        {
            get { return isNull; }
        }
 
      
        public double MinH
        {
            get
            {
                if (GridValueH == null || GridValueH.Count == 0)
                    return 0;
                return GridValueH.First();
            }
        }
        public double MaxH
        {
            get
            {
                if (GridValueH == null || GridValueH.Count == 0)
                    return 0;
                return GridValueH.Last();
            }
        }
 
  
        public double MinQ
        {
            get
            {
                if (GridValueQ == null || GridValueQ.Count == 0)
                    return 0;
                return GridValueQ.First();
            }
        }
        public double MaxQ
        {
            get
            {
                if (GridValueQ == null || GridValueQ.Count == 0)
                    return 0;
                return GridValueQ.Last();
            }
        }
 
 
  
 
 
 
 
 
 
 
 
 
        #region Clone
        public QhCoordinateParas Clone()  //对外提供一个创建自身的浅表副本的能力
        {
            return new QhCoordinateParas(this);
        }
        object ICloneable.Clone()
        {
            return this.Clone();
        }
 
        #endregion
 
        public string ToDsString()
        {
            return ToDsString(this);
        }
        public static string ToDsString(QhCoordinateParas paras)
        {
            if (paras == null)
                return "";//为了ACCESS只能用""
            if (paras.GridValueQ == null || paras.GridValueQ.Count < 3)
                return "";
            if (paras.GridValueH == null || paras.GridValueH.Count < 3)
                return "";
 
            StringBuilder sbQ = new StringBuilder();
            sbQ.Append(paras.UnitQ == null ? "" : paras.UnitQ.ToString());sbQ.Append(",");
            sbQ.Append(paras.IsLogQ); sbQ.Append(",");
            sbQ.Append(string.Join(",", paras.GridValueQ));
 
            //
            StringBuilder sbH = new StringBuilder();
            sbH.Append(paras.UnitH == null ? "" : paras.UnitH.ToString()); sbH.Append(",");
            sbQ.Append(paras.IsLogH); sbQ.Append(",");
            sbH.Append(string.Join(",", paras.GridValueH));
 
            string strChartCoord = string.Format("{0}|{1}", sbQ.ToString(), sbH.ToString());
 
            return strChartCoord;
        }
        public static QhCoordinateParas ToParameter(string strChartCoord)
        {
            try
            {
                var paras = new QhCoordinateParas(strChartCoord);
                if (paras.isNull)
                    return null;
                else
                    return paras;
            }
            catch (Exception)
            {
                return null;
            }
        }
 
    }
}