private void cmbDimension_SelectedIndexChanged(object sender, EventArgs e)
 {
     Detail det;
       switch (cmbDimension.SelectedIndex) {
     case 0:
       det = new Detail1D(pgrdTest, new double[] { 1.0 });
       break;
     case 1:
       det = new Detail2D(pgrdTest, new double[] { 1.0, 1.0 });
       break;
     default:
       throw new NotImplementedException("Не реализованный код!");
       }
       pgrdTest.SelectedObject = det;
       lbxOrderDetails.Items.Clear();
       pgrdOrderDetail.SelectedObject = null;
       order = new List<OrderPair>();
 }
        private void mnuFilELoadTask_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

              ofd.InitialDirectory = path;
              ofd.Filter = "task files (*.tsk)|*.tsk";
              ofd.FilterIndex = 1; ofd.RestoreDirectory = true;

              if (ofd.ShowDialog() == DialogResult.OK) {
            try {
              if (ofd.FileName != null) {
            lbxOrderDetails.Items.Clear();
            order.Clear();
            pgrdOrderDetail.SelectedObject = null;

            StreamReader sr = new StreamReader(ofd.FileName);
            sr.ReadLine();
            String st = sr.ReadLine();
            String[] sts = st.Split(new char[]{' '});
            int dimTask = Convert.ToInt32(sts[2]);
            cmbDimension.SelectedIndex = dimTask - 1;
            st = sr.ReadLine();
            sts = st.Split(new char[] { ' ' });
            cutThick = Convert.ToDouble(sts[2]);
            tbxCutTHick.Text = cutThick.ToString().Replace(',','.');
            sr.ReadLine();
            st = sr.ReadLine();
            sts = st.Split(new char[] { ' ' });

            Detail det;
            switch (dimTask) {
              case 1:
                det = new Detail1D(pgrdTest, new double[] { Convert.ToDouble(sts[0]) });
                break;
              case 2:
                det = new Detail2D(pgrdTest, new double[] { Convert.ToDouble(sts[0]), Convert.ToDouble(sts[1]) });
                break;
              default:
                throw new NotImplementedException("Размерность ошибка!");
            }
            pgrdTest.SelectedObject = det;

            st = sr.ReadLine();
            sts = st.Split(new char[] { ' ' });

            int countOrder = Convert.ToInt32(sts[1]);
            for (int i = 0; i < countOrder; i++) {
              st = sr.ReadLine();
              sts = st.Split(new char[] { ' ' });

              Detail detOrder;
              switch (dimTask) {
                case 1:
                  detOrder = new Detail1D(pgrdOrderDetail, new double[] { Convert.ToDouble(sts[1]) });
                  break;
                case 2:
                  detOrder = new Detail2D(pgrdOrderDetail, new double[] { Convert.ToDouble(sts[1]), Convert.ToDouble(sts[2]) });
                  break;
                default:
                  throw new NotImplementedException("Размерность ошибка!");
              }
              order.Add(new OrderPair(detOrder, Convert.ToInt32(sts[0])));
              lbxOrderDetails.Items.Add("Detail_" + lbxOrderDetails.Items.Count.ToString() + "   num:" + sts[0]);
            }

            sr.Close();
              }
            }
            catch (Exception ex) {
              MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
            }
              }
        }