示例#1
0
 public void Copy(DetectorPara cp)
 {
     Description = cp.Description;
     Information = cp.Information;
     DetectorIP  = cp.DetectorIP;
     MotorIP     = cp.MotorIP;
 }
示例#2
0
        private void ButtonOK_Click(object sender, RoutedEventArgs e)
        {
            bool         isOK = true;
            DetectorPara tmp  = new DetectorPara();

            if (Opt)
            {
                foreach (DetectorPara exist in Settings.listdp)
                {
                    if (exist.Description == Description.Text)
                    {
                        System.Windows.MessageBox.Show(
                            "探测器名称已存在",
                            "错误",
                            MessageBoxButton.OK,
                            MessageBoxImage.Information);
                        return;
                    }
                }
            }
            if ("" == (tmp.Description = Description.Text))
            {
                isOK = false;
            }
            if ("" == (tmp.Information = Information.Text))
            {
                isOK = false;
            }
            if ("" == (tmp.DetectorIP = DetectorIP.Text))
            {
                isOK = false;
            }
            if ("" == (tmp.MotorIP = MotorIP.Text))
            {
                isOK = false;
            }

            if (isOK)
            {
                if (Opt)
                {
                    Settings.listdp.Add(tmp);
                }
                else
                {
                    dp.Copy(tmp);
                }

                D.Refresh();
                this.Close();
            }
            else
            {
                System.Windows.MessageBox.Show(
                    "参数有误,请修改",
                    "错误",
                    MessageBoxButton.OK,
                    MessageBoxImage.Information);
            }
        }
示例#3
0
        public static void listdpLoad()
        {
            Settings.listdp.Clear();

            if (!File.Exists(DetectorPath))
            {
                File.Create(DetectorPath).Close();
            }
            else
            {
                StreamReader sr = new StreamReader(DetectorPath);
                String       line;
                while ((line = sr.ReadLine()) != null)
                {
                    DetectorPara dp = new DetectorPara();
                    dp.Description = line;

                    line           = sr.ReadLine();
                    dp.Information = line;

                    line          = sr.ReadLine();
                    dp.DetectorIP = line;

                    line       = sr.ReadLine();
                    dp.MotorIP = line;

                    Settings.listdp.Add(dp);
                }
                sr.Close();
            }
        }
示例#4
0
        //Opt=true,New
        //Opt=false,Edit
        public NeworEditDetector(Detector cont, bool opt)
        {
            InitializeComponent();

            D   = cont;
            Opt = opt;
            if (Opt)
            {
                //Nothing
            }
            else
            {
                index = D.list1.SelectedIndex;
                dp    = Settings.listdp[index];

                Description.Text = dp.Description;
                Information.Text = dp.Information;
                DetectorIP.Text  = dp.DetectorIP;
                MotorIP.Text     = dp.MotorIP;
            }
        }