diff --git a/TheGameExtreme/IO/IOGamePreparation.cs b/TheGameExtreme/IO/IOGamePreparation.cs new file mode 100644 index 0000000..c4fc6d5 --- /dev/null +++ b/TheGameExtreme/IO/IOGamePreparation.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; +using System.Xml.Serialization; + +namespace TheGameExtreme.IO +{ + class IOGamePreparation + { + static string pathPlayers = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "NbPlayers.xml"); + + public static void SaveParamaterGamePreparation(int nbPlayers) + { + XmlSerializer ser = new XmlSerializer(typeof(int)); + TextWriter tw = new StreamWriter(pathPlayers); + ser.Serialize(tw, nbPlayers); + tw.Close(); + } + public static int LoadParameterGamePreparation() + { + XmlSerializer xs = new XmlSerializer(typeof(int)); + FileStream fs = new FileStream(pathPlayers, FileMode.Open); + try + { + int players = (int)xs.Deserialize(fs); + fs.Close(); + return players; + } + catch + { + fs.Close(); + return 0; + } + } + } +} diff --git a/TheGameExtreme/IO/IOOptions.cs b/TheGameExtreme/IO/IOOptions.cs index 7bcf752..34f1615 100644 --- a/TheGameExtreme/IO/IOOptions.cs +++ b/TheGameExtreme/IO/IOOptions.cs @@ -2,24 +2,42 @@ using System.Collections.Generic; using System.IO; using System.Text; +using System.Xml.Serialization; namespace TheGameExtreme.IO { class IOOptions { - string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "file.xml"); + static string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Options.xml"); - public void SaveOptionParameter() + public static void SaveOptionParameter(bool b) { - /*if (!File.Exists(path)) + + XmlSerializer ser = new XmlSerializer(typeof(bool)); + TextWriter ws = new StreamWriter(path); + ser.Serialize(ws, b); + ws.Close(); + } + + public static bool LoadOptionsParameter() + { + XmlSerializer xs = new XmlSerializer(typeof(bool)); + + try { - XmlSerializer ser = new XmlSerializer(typeof(bool)); - using (StreamWriter sw = File.CreateText(path)) + using(FileStream fs = new FileStream(path, FileMode.Open)) { - sw.WriteLine(swTheme.IsToggled); + bool b = (bool)xs.Deserialize(fs); + return b; } + } + catch + { + //fs.Close(); + return false; + } - }*/ + } } diff --git a/TheGameExtreme/view/App.xaml b/TheGameExtreme/view/App.xaml index 7cadacc..71f87a2 100644 --- a/TheGameExtreme/view/App.xaml +++ b/TheGameExtreme/view/App.xaml @@ -3,9 +3,9 @@ - black - white - SkyBlue + black + white + SkyBlue diff --git a/TheGameExtreme/view/GamePreparationPage.xaml b/TheGameExtreme/view/GamePreparationPage.xaml index 2bbc500..44c2acd 100644 --- a/TheGameExtreme/view/GamePreparationPage.xaml +++ b/TheGameExtreme/view/GamePreparationPage.xaml @@ -90,7 +90,7 @@