Exemple #1
0
        /// <summary>
        /// 获取坐标轴
        /// </summary>
        /// <returns></returns>
        public List <OutputAxisEntity> getAxisFromDgv()
        {
            List <OutputAxisEntity> itemList = new List <OutputAxisEntity>();

            for (int row = 0; row < this._axisDgv.Rows.Count; row++)
            {
                OutputAxisEntity item = new OutputAxisEntity {
                    EAxis     = (EnumAxis)this._axisDgv.Rows[row].Tag,
                    Axis      = this._axisDgv.Rows[row].Cells["axis"].Value != null ? this._axisDgv.Rows[row].Cells["axis"].Value.ToString() : string.Empty,
                    AxisName  = this._axisDgv.Rows[row].Cells["name"].Value != null ? this._axisDgv.Rows[row].Cells["name"].Value.ToString() : string.Empty,
                    Unit      = this._axisDgv.Rows[row].Cells["unit"].Value != null ? this._axisDgv.Rows[row].Cells["unit"].Value.ToString() : string.Empty,
                    DownLimit = this._axisDgv.Rows[row].Cells["DownLimit"].Value != null ? this._axisDgv.Rows[row].Cells["DownLimit"].Value.ToString() : string.Empty,
                    UpLimit   = this._axisDgv.Rows[row].Cells["UpLimit"].Value != null ? this._axisDgv.Rows[row].Cells["UpLimit"].Value.ToString() : string.Empty,
                    DecNumber = this._axisDgv.Rows[row].Cells["DecNumber"].Value != null ? this._axisDgv.Rows[row].Cells["DecNumber"].Value.ToString() : string.Empty
                };

                itemList.Add(item);
            }

            var tempList = itemList.Where(o => string.IsNullOrWhiteSpace(o.AxisName) != true).ToList();

            return(tempList);
        }
Exemple #2
0
        private double isBetweenDownUp(double num, OutputAxisEntity col)
        {
            double res = double.NaN;

            if (col == null)
            {
                res = num;
            }

            if (col.dDownLimit == null && col.dUpLimit != null)
            {
                if (num < col.dUpLimit)
                {
                    res = num;
                }
            }
            else if (col.dDownLimit != null && col.dUpLimit == null)
            {
                if (num > col.dDownLimit)
                {
                    res = num;
                }
            }
            else if (col.dDownLimit != null && col.dUpLimit != null)
            {
                if (col.dDownLimit < num && num < col.dUpLimit)
                {
                    res = num;
                }
            }
            else
            {
                res = num;
            }
            return(res);
        }
Exemple #3
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        private List <OutputCurveEntity> getCurvesFromCurveDataDgv()
        {
            List <OutputCurveEntity> curveList = new List <OutputCurveEntity>();
            int curAxisCol = -1;
            Dictionary <OutputAxisEntity, PointPairList> Dic = new Dictionary <OutputAxisEntity, PointPairList>();

            for (int col = 1; col < this._curveDataDgv.Columns.Count; col++)
            {
                string axis = this._curveDataDgv["col" + col.ToString(), 0].Value != null ? this._curveDataDgv["col" + col.ToString(), 0].Value.ToString() : string.Empty;

                if (axis == EnumAxis.X.GetDescription())//遇到X轴
                {
                    #region
                    curAxisCol = col;

                    if (Dic.Count > 0)
                    {
                        OutputCurveEntity curve = new OutputCurveEntity()
                        {
                            X = this._axisItemList.Where(o => o.Axis == axis).FirstOrDefault()
                        };

                        Dictionary <OutputAxisEntity, PointPairList> tempDic = new Dictionary <OutputAxisEntity, PointPairList>();
                        foreach (var key in Dic.Keys)
                        {
                            tempDic.Add((OutputAxisEntity)key.Clone(), Dic[key]);
                        }
                        curve.Curves = tempDic;
                        curveList.Add(curve);
                        Dic.Clear();
                    }

                    continue;
                    #endregion
                }
                else
                {
                    if (string.IsNullOrWhiteSpace(axis))
                    {
                        continue;
                    }

                    string tempName  = this._curveDataDgv["col" + col.ToString(), 1].Value != null ? this._curveDataDgv["col" + col.ToString(), 1].Value.ToString() : string.Empty;
                    string curveName = this._curveDataDgv["col" + col.ToString(), 2].Value != null ? this._curveDataDgv["col" + col.ToString(), 2].Value.ToString() : string.Empty;

                    if (string.IsNullOrWhiteSpace(tempName) || string.IsNullOrWhiteSpace(curveName))//如果有空则跳出
                    {
                        continue;
                    }

                    PointPairList list = getPointListFromDgv(curAxisCol, col);

                    OutputAxisEntity outputYAxis = (OutputAxisEntity)this._axisItemList.Where(o => o.Axis == axis).FirstOrDefault().Clone();
                    outputYAxis.CurveName = curveName;
                    if (list.Count > 0 && !string.IsNullOrWhiteSpace(curveName))
                    {
                        Dic.Add(outputYAxis, list);
                    }
                }
            }
            if (curAxisCol != -1)
            {
                string tempAxis = this._curveDataDgv["col" + curAxisCol.ToString(), 0].Value != null ? this._curveDataDgv["col" + curAxisCol.ToString(), 0].Value.ToString() : string.Empty;

                if (Dic.Count > 0)
                {
                    OutputCurveEntity curve = new OutputCurveEntity()
                    {
                        X = this._axisItemList.Where(o => o.Axis == tempAxis).FirstOrDefault()
                    };
                    Dictionary <OutputAxisEntity, PointPairList> tempDic = new Dictionary <OutputAxisEntity, PointPairList>();
                    foreach (var key in Dic.Keys)
                    {
                        tempDic.Add((OutputAxisEntity)key.Clone(), Dic[key]);
                    }
                    curve.Curves = tempDic;
                    curveList.Add(curve);
                    Dic.Clear();
                }
            }

            return(curveList);
        }