Example #1
0
 private void Formmain_Load(object sender, EventArgs e)
 {
     try
     {
         if (File.Exists("mainStatus.cfg"))
         {
             using (FileStream fs = new FileStream("mainStatus.cfg", FileMode.Open))
             {
                 IFormatter ft = new BinaryFormatter();
                 saveInfo   = ft.Deserialize(fs) as mainWinInfo;
                 this.users = saveInfo.savedNodes;
                 foreach (userNode temp in users)
                 {
                     userPanel newP = new userPanel(this, temp.userName);
                     userL.Add(newP);
                     userId++;
                     userList.AppendText(temp.userName + "\n");
                     newP.Show();
                     foreach (var P in userL)
                     {
                         P.RefreshComboBox();
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Example #2
0
        private void Formmain_FormClosing(object sender, FormClosingEventArgs e)
        {
            saveInfo            = new mainWinInfo();
            saveInfo.savedNodes = this.users;


            using (FileStream fs = new FileStream("mainStatus.cfg", FileMode.Create))
            {
                IFormatter ft = new BinaryFormatter();
                ft.Serialize(fs, saveInfo);
            }

            foreach (var panel in userL)
            {
                panel.Close();
            }
        }