コード例 #1
0
        private void undaterange(object sender, RoutedEventArgs e)
        {
            TextBox textBox = sender as TextBox;

            if (textBox != input)
            {
                string        str = input.Text;
                StringToValue exp = new StringToValue(str);
                int           i   = 0;
                foreach (TextBox t1 in listBox2.Items)
                {
                    i++;
                    if (t1 == textBox)
                    {
                        break;
                    }
                }
                try
                {
                    double temp = Convert.ToDouble(textBox.Text);
                    double td   = ((slidersList[i - 1].Value - 5) * temp) / 5;
                    valuesList[i - 1].Content             = td;
                    variableCollection.vlist[i - 1].value = td;
                    exp.setVariables(variableCollection);
                    result.Content = exp.getValue();
                }
                catch (FormatException ee)
                {
                    MessageBox.Show("只能输入数字或者数字过大");
                }
            }
        }
コード例 #2
0
 private void threads(object c, EventArgs e)
 {
     try
     {
         int count = CountToAnimation;
         slidersList[count - 1].Value = ProcessToanimation;
         double td = (slidersList[count - 1].Value - 5) * Convert.ToDouble(rangesList[count - 1].Text);
         td = td / 5;
         valuesList[count - 1].Content             = td;
         variableCollection.vlist[count - 1].value = td;
         exp.setVariables(variableCollection);
         try
         {
             result.Content = exp.getValue();
         }
         catch (UserException ue)
         {
             result.Content = ue.Message;
         }
         ProcessToanimation += 0.025;
         if (ProcessToanimation >= 10)
         {
             slidersList[count - 1].Value = 6;
             double ts = (slidersList[count - 1].Value - 5) * Convert.ToDouble(rangesList[count - 1].Text) / 5;
             valuesList[count - 1].Content             = ts;
             variableCollection.vlist[count - 1].value = ts;
             exp.setVariables(variableCollection);
             try
             {
                 result.Content = exp.getValue();
             }
             catch (UserException ue)
             {
                 result.Content = ue.Message;
             }
             (c as System.Windows.Threading.DispatcherTimer).Stop();
         }
     }
     catch (Exception e1)
     {
     }
 }
コード例 #3
0
        private void undateslide(object sender, RoutedEventArgs e)
        {
            string        str = input.Text;
            StringToValue exp = new StringToValue(str);

            Slider s = sender as Slider;
            int    i = 0;

            foreach (Slider s1 in listBox3.Items)
            {
                i++;
                if (s1 == s)
                {
                    break;
                }
            }
            try
            {
                if (i <= listBox4.Items.Count)
                {
                    double td = (slidersList[i - 1].Value - 5) * Convert.ToDouble(rangesList[i - 1].Text);
                    td = td / 5;
                    valuesList[i - 1].Content             = td;
                    variableCollection.vlist[i - 1].value = td;
                    exp.setVariables(variableCollection);
                    try
                    {
                        result.Content = exp.getValue();
                    }
                    catch (UserException ue)
                    {
                        result.Content = ue.Message;
                    }
                    //MessageBox.Show(exp.getValue().ToString());
                }
            }
            catch (Exception e1)
            {
                //MessageBox.Show(e1.ToString());
            }
        }
コード例 #4
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            string s = input.Text;

            exp = new StringToValue(s);
            variableCollection = exp.GetVariables();
            try
            {
                result.Content = exp.getValue();
            }
            catch (UserException ue)
            {
                result.Content = ue.Message;
            }
            listBox1.Items.Clear();
            listBox2.Items.Clear();
            listBox3.Items.Clear();
            listBox4.Items.Clear();
            namesList.Clear();
            rangesList.Clear();
            slidersList.Clear();
            valuesList.Clear();
            if (variableCollection.vlist != null)
            {
                for (int i = 0; i < variableCollection.vlist.Length; i++)
                {
                    Label name = new Label();
                    name.Content           = variableCollection.vlist[i].name;
                    name.Height            = 30;
                    name.MouseDoubleClick += new MouseButtonEventHandler(animation);

                    TextBox textBox = new TextBox();
                    textBox.Text              = "5";
                    textBox.Height            = 30;
                    textBox.Width             = listBox1.Width;
                    textBox.VerticalAlignment = VerticalAlignment.Center;
                    textBox.KeyDown          += new KeyEventHandler(undaterange);

                    Slider slider1 = new Slider();
                    slider1.Height = 30;
                    slider1.Value  = 6;
                    slider1.HorizontalAlignment = HorizontalAlignment.Center;
                    slider1.Width      = 200;
                    slider1.MouseMove += new MouseEventHandler(undateslide);

                    Label var_value = new Label();
                    var_value.Content = "1";
                    var_value.Height  = 30;

                    namesList.Add(name);
                    rangesList.Add(textBox);
                    slidersList.Add(slider1);
                    valuesList.Add(var_value);

                    listBox1.Items.Add(name);
                    listBox2.Items.Add(textBox);
                    listBox3.Items.Add(slider1);
                    listBox4.Items.Add(var_value);
                }
            }
        }