Пример #1
0
 private void Form1_FormClosed(object sender, FormClosedEventArgs e)
 {
     mConfig.Clear();
     foreach (var item in Mapping.Get())
     {
         //添加到配置文件中
         mConfig.Add(new WorkItemXml(item.lExternalPort, item.ip_out, item.ip_out_port));
         //序列号保存配置文件
         XmlSerializeUtil.Serializer(mConfig.GetList().GetType(), mConfig.GetList(), "Config.xml");
     }
     System.Environment.Exit(0);
 }
Пример #2
0
 private void loadConfig()
 {
     try
     {
         //从配置文件中加载
         List <WorkItemXml> list = XmlSerializeUtil.Deserialize(mConfig.GetList().GetType(), "Config.xml") as List <WorkItemXml>;
         foreach (WorkItemXml item in list)
         {
             dataGridView1.Rows.Add(new object[] { item.ExternalPort, item.Ip_out, item.Ip_out_port });
             Mapping.Add(new WorkItem
             {
                 lExternalPort = item.ExternalPort,
                 ip_out        = item.Ip_out,
                 ip_out_port   = item.Ip_out_port,
                 workState     = new WorkState(" ", " ", " ", false, 0, 0, 0)
             });
         }
         //刷新表格数据
         RefreshDatagridViewData();
     }
     catch (Exception)
     {
     }
 }