Ejemplo n.º 1
0
            /// <summary>
            /// 更新cbInput
            /// </summary>
            private void updatecbInput()
            {
                String strLine;

                listWarning.Clear();
                cbInput.Items.Clear();
                try
                {
                    FileStream   dataFile = new FileStream(Path.Combine(GlobalSettings.Path_data, "WarningValue.dat"), FileMode.Open);
                    StreamReader sr       = new StreamReader(dataFile);
                    strLine = sr.ReadLine();
                    while (strLine != null)
                    {
                        WarningValue warning   = BinarySerializer.Decode64(strLine) as WarningValue;
                        String       warningId = warning.getId();
                        this.cbInput.Items.Add(warningId);
                        listWarning.Add(warningId, warning);
                        strLine = sr.ReadLine();
                    }
                    sr.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
Ejemplo n.º 2
0
            private void button1_Click(object sender, EventArgs e)
            {
                //得到界面的值
                WarningValue warning   = getFormValve();
                String       warningId = warning.getId();

                //重复命名即为修改,没有重复即添加
                if (listWarning.ContainsKey(warningId) == true)
                {
                    listWarning[warningId] = warning;
                }
                else
                {
                    listWarning.Add(warningId, warning);
                }

                try
                {
                    //保存
                    FileStream   dataFile = new FileStream(Path.Combine(GlobalSettings.Path_data, "WarningValue.dat"), FileMode.Create);
                    StreamWriter sw       = new StreamWriter(dataFile);
                    foreach (var ele in listWarning)
                    {
                        String warningEleEncode = BinarySerializer.Encode64(ele.Value);
                        sw.WriteLine(warningEleEncode);
                    }
                    sw.Close();
                    //当前的选择
                    FileStream   dataFileUsing      = new FileStream(Path.Combine(GlobalSettings.Path_data, "WarningValueUsing.dat"), FileMode.Create);
                    StreamWriter swUsing            = new StreamWriter(dataFileUsing);
                    String       warningUsingEncode = BinarySerializer.Encode64(warning);
                    swUsing.WriteLine(warningUsingEncode);
                    swUsing.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    this.Close();
                }
                updatecbInput();
                this.Close();
            }
Ejemplo n.º 3
0
            private void btnDele_Click(object sender, EventArgs e)
            {
                //得到界面的值
                WarningValue warning   = getFormValve();
                String       warningId = warning.getId();

                listWarning.Remove(warningId);

                //保存
                FileStream   dataFile = new FileStream(Path.Combine(GlobalSettings.Path_data, "WarningValue.dat"), FileMode.Create);
                StreamWriter sw       = new StreamWriter(dataFile);

                foreach (var ele in listWarning)
                {
                    String warningEleEncode = BinarySerializer.Encode64(ele.Value);
                    sw.WriteLine(warningEleEncode);
                }
                sw.Close();

                //更新
                updatecbInput();
                return;
            }