Example #1
0
        public static void listcpLoad()
        {
            Settings.listcp.Clear();

            if (!File.Exists(ContainerPath))
            {
                File.Create(ContainerPath).Close();
            }
            else
            {
                StreamReader sr = new StreamReader(ContainerPath);
                String       line;
                while ((line = sr.ReadLine()) != null)
                {
                    ContainerPara cp = new ContainerPara();
                    cp.Description = line;
                    for (int i = 0; i < 6; i++)
                    {
                        line = sr.ReadLine();
                        double.TryParse(line, out cp.nums[i]); //exception dealing
                    }
                    Settings.listcp.Add(cp);
                }
                sr.Close();
            }
        }
Example #2
0
 public void Copy(ContainerPara cp)
 {
     Description = cp.Description;
     for (int i = 0; i < 10; i++)
     {
         nums[i] = cp.nums[i];
     }
 }
Example #3
0
        private void ButtonOK_Click(object sender, RoutedEventArgs e)
        {
            bool          isOK = true;
            ContainerPara tmp  = new ContainerPara();

            if (Opt)
            {
                foreach (ContainerPara exist in Settings.listcp)
                {
                    if (exist.Description == Description.Text)
                    {
                        System.Windows.MessageBox.Show(
                            "容器名称已存在",
                            "错误",
                            MessageBoxButton.OK,
                            MessageBoxImage.Information);
                        return;
                    }
                }
            }
            if ("" == (tmp.Description = Description.Text))
            {
                isOK = false;
            }
            isOK &= double.TryParse(n1.Text, out tmp.nums[0]);
            isOK &= double.TryParse(n2.Text, out tmp.nums[1]);
            isOK &= double.TryParse(n3.Text, out tmp.nums[2]);
            isOK &= double.TryParse(n4.Text, out tmp.nums[3]);
            isOK &= double.TryParse(n5.Text, out tmp.nums[4]);
            isOK &= double.TryParse(n6.Text, out tmp.nums[5]);

            if (isOK)
            {
                if (Opt)
                {
                    Settings.listcp.Add(tmp);
                }
                else
                {
                    cp.Copy(tmp);
                }

                C.Refresh();
                this.Close();
            }
            else
            {
                System.Windows.MessageBox.Show(
                    "参数有误,请修改",
                    "错误",
                    MessageBoxButton.OK,
                    MessageBoxImage.Information);
            }
        }
Example #4
0
        //Opt=true,New
        //Opt=false,Edit
        public NeworEditContainer(Container cont, bool opt)
        {
            InitializeComponent();

            C   = cont;
            Opt = opt;
            if (Opt)
            {
                //Nothing
            }
            else
            {
                index = C.list1.SelectedIndex;
                cp    = Settings.listcp[index];

                Description.Text = cp.Description;
                n1.Text          = cp.nums[0].ToString();
                n2.Text          = cp.nums[1].ToString();
                n3.Text          = cp.nums[2].ToString();
                n4.Text          = cp.nums[3].ToString();
                n5.Text          = cp.nums[4].ToString();
                n6.Text          = cp.nums[5].ToString();
            }
        }