Esempio n. 1
0
 public MainWindow(string login)
 {
     InitializeComponent();
     pf = new PreferenceUtilisateur(login);
     if (pf.Load(login))
     {
         this.Top = pf.PosX;
         this.Left = pf.PosY;
         this.Height = pf.HeightMainWindow;
         this.Width = pf.WidthMainWindow;
     }
 }
 /// <summary>
 /// Charge le fichier XML
 /// </summary>
 /// <param name="login"></param>
 public bool Load(string login)
 {
     XMLAgenda xml = new XMLAgenda(login);
     PreferenceUtilisateur tmp = new PreferenceUtilisateur();
     bool ret=xml.Load(ref tmp);
     if (ret)
     {
         login = tmp.Login;
         HeightMainWindow = tmp.HeightMainWindow;
         WidthMainWindow = tmp.WidthMainWindow;
         PosX = tmp.PosX;
         PosY = tmp.PosY;
     }
     return ret;
 }
Esempio n. 3
0
        /// <summary>
        /// Sérialize l'objet dans un fichier XML
        /// </summary>
        public void Save(PreferenceUtilisateur inPf)
        {
            StreamWriter sw = null;

            try
            {
                sw = new StreamWriter(url + login + ".xml");
                XmlSerializer serializer = new XmlSerializer(typeof(PreferenceUtilisateur));
                serializer.Serialize(sw, inPf);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (sw != null)
                    sw.Close();
            }
        }
Esempio n. 4
0
 /// <summary>
 /// Charge le fichier XML
 /// </summary>
 public bool Load(ref PreferenceUtilisateur inPf)
 {
     StreamReader sr = null;
     bool ret = true;
     try
     {
         sr = new StreamReader(url + login + ".xml");
         XmlSerializer serializer = new XmlSerializer(typeof(PreferenceUtilisateur));
         inPf=serializer.Deserialize(sr) as PreferenceUtilisateur;
     }
     catch (Exception)
     {
         ret = false;
     }
     finally
     {
         if(sr != null)
             sr.Close();
     }
     return ret;
 }