示例#1
0
 public override void OnRefresh()
 {
     mw.Test();
 }
示例#2
0
        private void IvChange_Click(object sender, RoutedEventArgs e)
        {
            ConditionJudgmentOperationModel conditionJudgmentOperationModel = new ConditionJudgmentOperationModel();

            if (cbOperator.SelectedIndex == 0)
            {
                conditionJudgmentOperationModel.MyOperator = ConditionJudgmentOperationModel.Operation.REPLACE;
            }
            else
            {
                conditionJudgmentOperationModel.MyOperator = ConditionJudgmentOperationModel.Operation.REMOVE;
            }

            char splitNotation = StaticConstant.mw.projectUserControl.suc.StrInputFormatDelimiter;
            char rangeNotation = StaticConstant.mw.projectUserControl.suc.StrInputFormatRange;

            if (!tbIfTime.Text.Equals(String.Empty))
            {
                try
                {
                    object result              = null;
                    string expression          = tbIfTime.Text;
                    System.Data.DataTable eval = new System.Data.DataTable();
                    result = eval.Compute(expression, "");
                    conditionJudgmentOperationModel.IfTime = (int)result;
                }
                catch
                {
                    tbIfTime.Select(0, tbIfTime.Text.Length);
                    tbIfTime.Focus();
                    return;
                }
            }

            if (!tbIfPosition.Text.Equals(String.Empty))
            {
                StringBuilder fastGenerationrPositionBuilder = new StringBuilder();
                if (suc.rangeDictionary.ContainsKey(tbIfPosition.Text))
                {
                    for (int i = 0; i < suc.rangeDictionary[tbIfPosition.Text].Count; i++)
                    {
                        if (i != suc.rangeDictionary[tbIfPosition.Text].Count - 1)
                        {
                            fastGenerationrPositionBuilder.Append(suc.rangeDictionary[tbIfPosition.Text][i] + splitNotation.ToString());
                        }
                        else
                        {
                            fastGenerationrPositionBuilder.Append(suc.rangeDictionary[tbIfPosition.Text][i]);
                        }
                    }
                }
                else
                {
                    List <int> positions = GetTrueContent(tbIfPosition.Text, splitNotation, rangeNotation);
                    if (positions != null)
                    {
                        fastGenerationrPositionBuilder.Append(tbIfPosition.Text);
                        conditionJudgmentOperationModel.IfPosition = positions;
                    }
                    else
                    {
                        tbIfPosition.Select(0, tbIfPosition.Text.Length);
                        tbIfPosition.Focus();
                        return;
                    }
                }
            }

            if (!tbIfColor.Text.Equals(String.Empty))
            {
                StringBuilder fastGenerationrColorBuilder = new StringBuilder();
                if (suc.rangeDictionary.ContainsKey(tbIfColor.Text))
                {
                    for (int i = 0; i < suc.rangeDictionary[tbIfColor.Text].Count; i++)
                    {
                        if (i != suc.rangeDictionary[tbIfColor.Text].Count - 1)
                        {
                            fastGenerationrColorBuilder.Append(suc.rangeDictionary[tbIfColor.Text][i] + splitNotation.ToString());
                        }
                        else
                        {
                            fastGenerationrColorBuilder.Append(suc.rangeDictionary[tbIfColor.Text][i]);
                        }
                    }
                }
                else
                {
                    List <int> colors = GetTrueContent(tbIfColor.Text, splitNotation, rangeNotation);
                    if (colors != null)
                    {
                        fastGenerationrColorBuilder.Append(tbIfColor.Text);
                        conditionJudgmentOperationModel.IfColor = colors;
                    }
                    else
                    {
                        tbIfColor.Select(0, tbIfColor.Text.Length);
                        tbIfColor.Focus();
                        return;
                    }
                }
            }

            String result2;

            if (!tbThenTime.Text.Equals(String.Empty))
            {
                if (tbThenTime.Text.Trim()[0] == '+' || tbThenTime.Text.Trim()[0] == '-')
                {
                    //计算数学表达式
                    string expression          = tbThenTime.Text.Substring(1);
                    System.Data.DataTable eval = new System.Data.DataTable();
                    result2 = eval.Compute(expression, "").ToString();
                    result2 = tbThenTime.Text.Trim()[0] + result2;
                    conditionJudgmentOperationModel.ThenTime = result2;
                }
                else
                {
                    //计算数学表达式
                    string expression          = tbThenTime.Text;
                    System.Data.DataTable eval = new System.Data.DataTable();
                    result2 = eval.Compute(expression, "").ToString();
                    conditionJudgmentOperationModel.ThenTime = result2;
                }
            }

            if (!tbThenPosition.Text.Equals(String.Empty))
            {
                String strNumber = tbThenPosition.Text.Trim();
                if (strNumber[0] == '+' || strNumber[0] == '-')
                {
                    if (!System.Text.RegularExpressions.Regex.IsMatch(strNumber.Substring(1), "^\\d+$"))
                    {
                        tbThenPosition.Select(0, tbThenPosition.Text.Length);
                        tbThenPosition.Focus();
                        return;
                    }
                }
                else
                {
                    if (!System.Text.RegularExpressions.Regex.IsMatch(strNumber, "^\\d+$"))
                    {
                        tbThenPosition.Select(0, tbThenPosition.Text.Length);
                        tbThenPosition.Focus();
                        return;
                    }
                }
            }
            conditionJudgmentOperationModel.ThenPosition = tbThenPosition.Text;

            if (!tbThenColor.Text.Equals(String.Empty))
            {
                String strNumber = tbThenColor.Text.Trim();
                if (strNumber[0] == '+' || strNumber[0] == '-')
                {
                    if (!System.Text.RegularExpressions.Regex.IsMatch(strNumber.Substring(1), "^\\d+$"))
                    {
                        tbThenColor.Select(0, tbThenColor.Text.Length);
                        tbThenColor.Focus();
                        return;
                    }
                }
                else
                {
                    if (!System.Text.RegularExpressions.Regex.IsMatch(strNumber, "^\\d+$"))
                    {
                        tbThenColor.Select(0, tbThenColor.Text.Length);
                        tbThenColor.Focus();
                        return;
                    }
                }
            }
            conditionJudgmentOperationModel.ThenColor = tbThenColor.Text;
            //this.conditionJudgmentOperationModel = conditionJudgmentOperationModel;
            this.conditionJudgmentOperationModel.MyOperator   = conditionJudgmentOperationModel.MyOperator;
            this.conditionJudgmentOperationModel.IfTime       = conditionJudgmentOperationModel.IfTime;
            this.conditionJudgmentOperationModel.IfAction     = conditionJudgmentOperationModel.IfAction;
            this.conditionJudgmentOperationModel.IfPosition   = conditionJudgmentOperationModel.IfPosition;
            this.conditionJudgmentOperationModel.IfColor      = conditionJudgmentOperationModel.IfColor;
            this.conditionJudgmentOperationModel.ThenTime     = conditionJudgmentOperationModel.ThenTime;
            this.conditionJudgmentOperationModel.ThenPosition = conditionJudgmentOperationModel.ThenPosition;
            this.conditionJudgmentOperationModel.ThenColor    = conditionJudgmentOperationModel.ThenColor;

            suc.Test();
        }
示例#3
0
 public override void ToRefresh()
 {
     RefreshView();
     suc.Test();
 }