Esempio n. 1
0
        public ME_If Copy()
        {
            ME_If ret = new ME_If();

            ret.name        = this.name;
            ret.form        = this.form;
            ret.method      = this.method;
            ret.left_var    = this.left_var;
            ret.right_var   = this.right_var;
            ret.right_const = this.right_const;
            return(ret);
        }
Esempio n. 2
0
 public SetVariable(Dictionary <string, double> variables, Dictionary <string, string> lang_dic, ArrayList ME_List, List <string> used_var)
 {
     InitializeComponent();
     this.var_lang_dic  = lang_dic;
     this.global_var    = variables;
     this.var_num       = 0;
     this.ME_Motionlist = ME_List;
     this.used_var      = used_var;
     foreach (KeyValuePair <string, double> entry in variables)
     {
         var_num = var_num + 1;
         string[] row     = { var_num.ToString(), entry.Key };
         var      varItem = new ListViewItem(row);
         VarListView.Items.Add(varItem);
     }
     for (int i = 0; i < ME_Motionlist.Count; i++)
     {
         ME_Motion m = (ME_Motion)ME_Motionlist[i];
         for (int j = 0; j < m.Events.Count; j++)
         {
             if (m.Events[j] is ME_If)
             {
                 ME_If mif = (ME_If)m.Events[j];
                 if (mif.left_var < variables.Count && !used_element.Contains(mif))
                 {
                     used_element.Add(mif);
                     tmp_element.Add(mif.Copy());
                 }
                 if (mif.right_var < variables.Count && !used_element.Contains(mif))
                 {
                     used_element.Add(mif);
                     tmp_element.Add(mif.Copy());
                 }
             }
             else if (m.Events[j] is ME_Compute)
             {
                 ME_Compute op = (ME_Compute)m.Events[j];
                 if (op.left_var < variables.Count && !used_element.Contains(op))
                 {
                     used_element.Add(op);
                     tmp_element.Add(op.Copy());
                 }
                 if (op.f1_var1 < variables.Count && !used_element.Contains(op))
                 {
                     used_element.Add(op);
                     tmp_element.Add(op.Copy());
                 }
                 if (op.f1_var2 < variables.Count && !used_element.Contains(op))
                 {
                     used_element.Add(op);
                     tmp_element.Add(op.Copy());
                 }
                 if (op.f2_var < variables.Count && !used_element.Contains(op))
                 {
                     used_element.Add(op);
                     tmp_element.Add(op.Copy());
                 }
                 if (op.f3_var < variables.Count && !used_element.Contains(op))
                 {
                     used_element.Add(op);
                     tmp_element.Add(op.Copy());
                 }
             }
         }
     }
 }
Esempio n. 3
0
        private void removeSelectedItem()
        {
            if (VarListView.SelectedItems.Count == 0)
            {
                return;
            }
            ListViewItem cur = VarListView.SelectedItems[0];

            for (int i = 0; i < used_var.Count; i++)
            {
                if (string.Compare(used_var[i], VarListView.SelectedItems[0].SubItems[1].Text) == 0)
                {
                    warningLabel.Text = var_lang_dic["errorMsg27"];
                    return;
                }
            }
            int index = VarListView.Items.IndexOf(cur);

            if (index != VarListView.Items.Count - 1)
            {
                for (int i = index + 1; i < var_num; i++)
                {
                    int origin_num = int.Parse(VarListView.Items[i].SubItems[0].Text);
                    VarListView.Items[i].SubItems[0].Text = (origin_num - 1).ToString();
                    for (int j = 0; j < tmp_element.Count; j++)
                    {
                        int prev_num = global_var.Count;
                        if (tmp_element[j] is ME_If)
                        {
                            ME_If mif = (ME_If)tmp_element[j];
                            if (mif.left_var == i && mif.left_var < prev_num)
                            {
                                mif.left_var = mif.left_var - 1;
                            }
                            if (mif.right_var == i && mif.right_var < prev_num)
                            {
                                mif.right_var = mif.right_var - 1;
                            }
                        }
                        else if (tmp_element[j] is ME_Compute)
                        {
                            ME_Compute op = (ME_Compute)tmp_element[j];
                            if (op.left_var == i && op.left_var < prev_num)
                            {
                                op.left_var = op.left_var - 1;
                            }
                            if (op.f1_var1 == i && op.f1_var1 < prev_num)
                            {
                                op.f1_var1 = op.f1_var1 - 1;
                            }
                            if (op.f1_var2 == i && op.f1_var2 < prev_num)
                            {
                                op.f1_var2 = op.f1_var2 - 1;
                            }
                            if (op.f2_var == i && op.f2_var < prev_num)
                            {
                                op.f2_var = op.f2_var - 1;
                            }
                            if (op.f3_var == i && op.f3_var < prev_num)
                            {
                                op.f3_var = op.f3_var - 1;
                            }
                        }
                    }
                }
            }
            VarListView.Items.Remove(cur);
            var_num = var_num - 1;
            nameMaskedTextBox.Text = "";
            warningLabel.Text      = "";
        }