Ejemplo n.º 1
0
        /// <summary>
        /// 设置信息
        /// </summary>
        /// <param name="model"></param>
        public void SetMessage(ParaModel model)
        {
            RangeValueInput_NDD input = null;
            RangeValue          value = null;

            S_RotateSpeed_TB.Text = model.S_RotateSpeed.ToString();

            if (model.S_InjectionTime > 0)
            {
                //模拟点击,选取了喷油次数规则
                ARuleContainer_MouseLeftButtonUp(Add_S_InjectionTime_Button, null);
                ((TextBox)S_InjectionTimeContainer.Children[2]).Text = model.S_InjectionTime.ToString();
            }

            if (model.R_InjectionQuantity != null)
            {
                //模拟点击
                ARuleContainer_MouseLeftButtonUp(Add_R_InjectionQuantity_Button, null);


                input = ((RangeValueInput_NDD)R_InjectionQuantityContainer.Children[2]);
                value = model.R_InjectionQuantity;

                //设置参数
                if (value.IsInfinity())
                {
                    input.SetRangeValue_Infinity(value.GetMin().ToString());
                }
                else
                {
                    input.SetRangeValue(value.GetMax().ToString(), value.GetMin().ToString());
                }
            }

            if (model.R_RackTravel != null)
            {
                //模拟点击
                ARuleContainer_MouseLeftButtonUp(Add_R_RackTravel_Button, null);

                input = ((RangeValueInput_NDD)R_RackTravelContainer.Children[2]);
                value = model.R_RackTravel;

                //设置参数
                if (value.IsInfinity())
                {
                    input.SetRangeValue_Infinity(value.GetMin().ToString());
                }
                else
                {
                    input.SetRangeValue(value.GetMax().ToString(), value.GetMin().ToString());
                }
            }

            if (model.R_Asymmetry > 0)
            {
                //模拟点击
                ARuleContainer_MouseLeftButtonUp(Add_R_Asymmetry_Button, null);
                ((TextBox)R_AsymmetryContainer.Children[2]).Text = model.R_Asymmetry.ToString();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 检查值是否合理
        /// </summary>
        /// <returns></returns>
        public bool IsValueRight()
        {
            bool   result      = true;
            String speedString = S_RotateSpeed_TB.Text;
            int    speed;

            //速度无法解析为整数 , 或者输入数据为负数
            if (!int.TryParse(speedString.Trim(), out speed) || speed < 0)
            {
                result = false;
            }

            for (int counter = 2; counter < TotalParasContainer.Children.Count; counter++)
            {
                String tag = ((Grid)TotalParasContainer.Children[counter]).Tag.ToString();

                //为范围数
                if (tag == "R_InjectionQuantity" || tag == "R_RackTravel")
                {
                    RangeValueInput_NDD value = (RangeValueInput_NDD)(((Grid)TotalParasContainer.Children[counter]).Children[2]);
                    //范围数据出现了错误
                    if (!value.IsValueRight())
                    {
                        result = false;
                        break;
                    }
                }
                //喷油次数,单数,整数
                else if (tag == "S_InjectionTime")
                {
                    int value;
                    if (!int.TryParse(((TextBox)(((Grid)TotalParasContainer.Children[counter]).Children[2])).Text.Trim(), out value) || value < 0)
                    {
                        result = false;
                        break;
                    }
                }
                //不均匀度,单数,浮点
                else
                {
                    float value;
                    if (!float.TryParse(((TextBox)(((Grid)TotalParasContainer.Children[counter]).Children[2])).Text.Trim(), out value) || value < 0)
                    {
                        result = false;
                        break;
                    }
                }
            }

            return(result);
        }