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;
|
}
|
}
|
|
}
|
}
|