Ejemplo n.º 1
0
        private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            //SocketInfo si = new SocketInfo();
            //si.Name = "服务器端";
            //socketList.Add(si);
            socketInfoList = new List <SocketInfo>();
            foreach (TreeNode tn in this.deviceTree.Nodes)
            {
                foreach (TreeNode ctn in tn.Nodes)
                {
                    TabPage tp = (TabPage)ctn.Tag;
                    if (tp != null)
                    {
                        tp.Text = ctn.Text;
                    }
                    foreach (Form f in tp.Controls)
                    {
                        ISocketInfo isi = (ISocketInfo)f;
                        isi.SocketInfo.Name = tp.Text;
                        f.Close();
                        socketInfoList.Add(isi.SocketInfo);
                    }
                }
            }


            MySerializer.Serialize(socketInfoList, XMLFileName);
        }
Ejemplo n.º 2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            rootNode1 = new TreeNode("客户终端", 5, 5);
            this.deviceTree.Nodes.Add(rootNode1);
            rootNode2 = new TreeNode("服务器终端", 6, 6);
            this.deviceTree.Nodes.Add(rootNode2);

            try
            {
                //SocketInfo[] sis = MySerializer.DeSerialize(XMLFileName);
                socketInfoList = MySerializer.Deserialize <List <SocketInfo> >(XMLFileName);
                //SocketInfo[] sis = MySerializer.Deserialize<SocketInfo[]>(XMLFileName);

                foreach (SocketInfo si in socketInfoList)
                {
                    if (si.Type == "Server")
                    {
                        AddServerFormNode(si.Name, si);
                    }
                    else
                    {
                        AddClientFormNode(si.Name, si);
                    }
                }
            }
            catch (System.Exception ex)
            {
                Debug.WriteLine(ex.Message);
                Debug.WriteLine(ex.StackTrace);
            }
        }
Ejemplo n.º 3
0
 private void Form1_Load(object sender, EventArgs e)
 {
     this.rootNode1 = new TreeNode("客户终端", 5, 5);
     this.deviceTree.Nodes.Add(this.rootNode1);
     this.rootNode2 = new TreeNode("服务器终端", 6, 6);
     this.deviceTree.Nodes.Add(this.rootNode2);
     try
     {
         this.socketInfoList = MySerializer.Deserialize <List <SocketInfo> >(this.XMLFileName);
         foreach (SocketInfo current in this.socketInfoList)
         {
             if (current.Types == "Server")
             {
                 this.AddServerFormNode(current.Names, current);
             }
             else
             {
                 this.AddClientFormNode(current.Names, current);
             }
         }
     }
     catch (Exception)
     {
     }
 }