示例#1
0
        /// <summary>Deserializes to an instance of GameCatalog.</summary>
        /// <param name="reader">TextReader instance.</param>
        /// <returns>GameCatalog result.</returns>
        public GameCatalog Deserialize(TextReader reader)
        {
            GameCatalog o = (GameCatalog)s.Deserialize(reader);

            reader.Close();
            return(o);
        }
示例#2
0
        private string StringSerialize(GameCatalog gamecatalog)
        {
            TextWriter w   = WriterSerialize(gamecatalog);
            string     xml = w.ToString();

            w.Close();
            return(xml);
        }
示例#3
0
        private TextWriter WriterSerialize(GameCatalog gamecatalog)
        {
            TextWriter w = new StringWriter();

            this.s = new XmlSerializer(this.type);
            s.Serialize(w, gamecatalog);
            w.Flush();
            return(w);
        }
示例#4
0
        /// <summary>Serializes to an XmlDocument.</summary>
        /// <param name="GameCatalog">GameCatalog to serialize.</param>
        /// <returns>XmlDocument instance.</returns>
        public XmlDocument Serialize(GameCatalog gamecatalog)
        {
            string      xml = StringSerialize(gamecatalog);
            XmlDocument doc = new XmlDocument();

            doc.PreserveWhitespace = true;
            doc.LoadXml(xml);
            doc = Clean(doc);
            return(doc);
        }
示例#5
0
        /// <summary>Writes config data to config file.</summary>
        /// <param name="file">Config file name.</param>
        /// <param name="config">Config object.</param>
        /// <returns></returns>
        public static bool WriteFile(string file, GameCatalog config)
        {
            bool ok = false;
            GameCatalogSerializer serializer = new GameCatalogSerializer();

            try {
                string xml = serializer.Serialize(config).OuterXml;
                using (StreamWriter writer = new StreamWriter(file, false)) {
                    writer.Write(xml);
                    writer.Flush();
                    writer.Close();
                }
                ok = true;
            } catch {}
            return(ok);
        }
示例#6
0
文件: Form1.cs 项目: xrfmail/GitHub
 // File New
 private void menuItem12_Click(object sender, System.EventArgs e)
 {
     if (dirty)
     {
         DialogResult dr = MessageBox.Show(this, "Data changed, would you like to save?", "Save", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
         if (dr == DialogResult.Yes)
         {
             menuItem10_Click(sender, e);
         }
         else if (dr == DialogResult.Cancel)
         {
             return;
         }
     }
     games    = new GameCatalog();
     filename = null;
     gamelist.Items.Clear();
 }
示例#7
0
文件: Form1.cs 项目: xrfmail/GitHub
 public Form1()
 {
     InitializeComponent();
     PaintMenu();
     games = new GameCatalog();
 }
示例#8
0
文件: Form1.cs 项目: xrfmail/GitHub
 private void OpenFile(string filename)
 {
     this.filename = filename;
     games         = GameCatalogSerializer.ReadFile(filename);
     dirty         = false;
 }
示例#9
0
 public PrintForm2(Games games) : this()
 {
     this.games       = new GameCatalog();
     this.games.Games = games;
     Init();
 }
示例#10
0
 public PrintForm2(GameCatalog gcat) : this()
 {
     this.games = gcat;
     Init();
 }
示例#11
0
 public StatsForm(GameCatalog game)
 {
     InitializeComponent();
     this.game = game;
     UpdateUI();
 }