示例#1
0
 private void openToolStripMenuItem_Click(object sender, EventArgs e)
 {
     toolStripStatusLabel1.Text = "Opening file...";
     try
     {
         openFileDialog1.Filter   = "JSON File|*.json";
         openFileDialog1.Title    = "Open File";
         openFileDialog1.FileName = "";
         DialogResult result = openFileDialog1.ShowDialog();
         if (result == DialogResult.OK)
         {
             fileStream   = new FileStream(openFileDialog1.FileName, FileMode.Open);
             streamReader = new StreamReader(fileStream);
             try
             {
                 string line,
                        json = "";
                 while ((line = streamReader.ReadLine()) != null)
                 {
                     json += line;
                 }
                 Interval[] arr = JsonConvert.DeserializeObject <Interval[]>(json);
                 S = new Series();
                 for (int i = 0; i < arr.Length; i++)
                 {
                     if (arr[i].A.IndexOf(',') == -1 && arr[i].B.IndexOf(',') == -1)
                     {
                         int          a = Convert.ToInt32(arr[i].A);
                         int          b = Convert.ToInt32(arr[i].B);
                         IntegerRange T = new IntegerRange(a, b);
                         S.Add(T.Retu());
                     }
                     else
                     {
                         double    a = Convert.ToDouble(arr[i].A);
                         double    b = Convert.ToDouble(arr[i].B);
                         RealRange T = new RealRange(a, b);
                         S.Add(T.Retu());
                     }
                     UpdLast();
                 }
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
             streamReader.Close();
             fileStream.Close();
             toolStripStatusLabel1.Text = "Open file: " + openFileDialog1.FileName;
         }
         else
         {
             toolStripStatusLabel1.Text = "Opening canceled";
         }
     }
     catch (Exception) { }
 }
示例#2
0
        private void realFunc(double a1, double a2, double b1, double b2)
        {
            string    sign = comboBox1.Text;
            RealRange A    = new RealRange(a1, a2);
            RealRange B    = new RealRange(b1, b2);

            switch (sign)
            {
            case "+":
                C = (RealRange)A.Add(B);
                break;

            case "-":
                C = (RealRange)A.Sub(B);
                break;

            case "*":
                C = (RealRange)A.Mul(B);
                break;

            case "/":
                C = (RealRange)A.Div(B);
                break;

            default:
                C = (RealRange)A.Add(B);
                break;
            }
            string str1 = C.ToString().Split(':')[0].ToString(),
                   str2 = C.ToString().Split(':')[1].ToString();

            textBox6.Text = str1;
            textBox5.Text = str2;
            toolStripStatusLabel1.Text   = "Result:  " + str1 + " ... " + str2;
            addToolStripMenuItem.Enabled = true;
        }