Пример #1
0
        /// <summary>
        /// 撤销操作
        /// </summary>
        /// <param name="PeakList">峰列表</param>
        /// <param name="operate">操作字符串</param>
        public static void Undo(List <Peak> PeakList, string operate)
        {
            if (operate.Trim() == "")
            {
                return;
            }
            string[]     oprs     = operate.Split(';');
            int          idx      = -1;
            string       opr      = "";
            string       propname = "";
            string       value    = "";
            PropertyInfo pinf     = null;
            bool         extend   = false;
            Peak         peak     = null;

            for (int i = oprs.GetLength(0) - 1; i >= 0; i--)
            {
                opr = oprs[i];
                //operate="1:BaseLineEnd=True"
                //get peak object
                idx = opr.IndexOf(":");
                if (idx == -1)
                {
                    continue;
                }
                string peaknum = opr.Substring(0, idx);
                opr    = opr.Substring(idx + 1);
                extend = (int.Parse(peaknum) <= (int)PeakExtendOperates.peo_PeakListChange);
                if (extend)
                {
                    List <Peak> pks = (List <Peak>)StaticMethods.DSerialObject(opr);
                    if (pks != null)
                    {
                        PeakList.Clear();
                        PeakList.AddRange(pks);
                    }
                    continue;
                }

                peak = PeakList[int.Parse(peaknum)];
                if (peak == null)
                {
                    continue;
                }
                //get property name and value
                idx = opr.IndexOf("=");
                if (idx == -1)
                {
                    continue;
                }
                value    = opr.Substring(idx + 1);
                propname = opr.Substring(0, idx);

                pinf = peak.GetType().GetProperty(propname);
                pinf.SetValue(peak, StaticMethods.DSerialObject(value), null);
            }
        }
Пример #2
0
        /// <summary>
        /// 设置峰参数,并且返回设置前的参数值,格式为:“属性名称=属性值;”
        /// </summary>
        /// <param name="peak">当前峰</param>
        /// <param name="propname">属性名</param>
        /// <param name="value">属性值</param>
        /// <returns></returns>
        private static string SetPeakProperty(Peak peak, string propname, object value)
        {
            string rs = null;

            if (peak == null)
            {
                return("");
            }
            PropertyInfo pinf = peak.GetType().GetProperty(propname);

            if (pinf == null)
            {
                return("");
            }
            rs += propname + "=" + StaticMethods.SerialObject(pinf.GetValue(peak, null)) + ";";
            pinf.SetValue(peak, value, null);
            return(rs);
        }
Пример #3
0
        /// <summary>
        /// 格式化峰信息
        /// </summary>
        /// <param name="peak"></param>
        private static void FormatPeak(Peak peak, int Multiple)
        {
            System.Reflection.PropertyInfo[] pinfs = peak.GetType().GetProperties();
            object value = null;

            foreach (System.Reflection.PropertyInfo pinf in pinfs)
            {
                if (pinf.PropertyType.Name.ToLower() != "double")
                {
                    continue;
                }
                value = pinf.GetValue(peak, null);
                if (value == null)
                {
                    continue;
                }
                //if (value.ToString() == "-1") value = Double.NaN;
                if (value.ToString() != "-1" && Multiple != 0 &&
                    (pinf.Name == "PeakArea" ||
                     pinf.Name == "PeakHeight" ||
                     pinf.Name == "PeakWidth1" ||
                     pinf.Name == "PeakWidth2" ||
                     pinf.Name == "PeakWidth4" ||
                     pinf.Name == "AdjustFactor"))
                {
                    if (Multiple > 0)
                    {
                        value = ((double)value) * Multiple;
                    }
                    else
                    {
                        value = ((double)value) / Math.Abs(Multiple);
                    }
                }

                pinf.SetValue(peak, Convert.ChangeType(((double)value).ToString("f6"), typeof(Double), null), null);
            }
        }