ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/EmuXPortal/trunk/EmuXPortal/Api/ConfigLoader.cs
(Generate patch)

Comparing trunk/EmuXPortal/Api/ConfigLoader.cs (file contents):
Revision 12 by william, Tue Apr 3 20:35:32 2012 UTC vs.
Revision 13 by william, Tue Apr 3 21:00:28 2012 UTC

--- trunk/EmuXPortal/Api/ConfigLoader.cs	2012/04/03 20:35:32	12
+++ trunk/EmuXPortal/Api/ConfigLoader.cs	2012/04/03 21:00:28	13
@@ -4,6 +4,8 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Windows.Forms;
+using System.Xml;
+using System.IO;
 
 namespace EmuXPortal.Api
 {
@@ -35,6 +37,25 @@ namespace EmuXPortal.Api
             public bool LoadConfig(string path)
             {
                 bool loaded = false;
+                try
+                {
+                    using (FileStream fs = new FileStream(CONFIG_FILE_PATH, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
+                    {
+                        using (XmlReader reader = XmlReader.Create(fs))
+                        {
+                            reader.ReadToFollowing("ROMPATH");
+                            RomPath = reader.ReadElementContentAsString();
+                            reader.ReadToFollowing("DISPLAYDEVICE");
+                            DisplayDevice = reader.ReadElementContentAsString();
+                        }
+                    }
+                    loaded = true;
+                }
+                catch (Exception ex)
+                {
+                    Console.WriteLine(ex.ToString());
+                    loaded = false;
+                }
                 return loaded;
             }
             #endregion
@@ -54,6 +75,13 @@ namespace EmuXPortal.Api
         public static string RomPath { get { return loader.RomPath; } }
         public static string DisplayDevice { get { return loader.DisplayDevice; } }
         #endregion
+        public static void InitializePresentationForm(Form frm)
+        {
+            DisplayHelper helper = new DisplayHelper(DisplayDevice);
+            Screen s = helper.PhysicalDisplayDevice;
+            frm.Location = new System.Drawing.Point(s.Bounds.X,s.Bounds.Y);
+            frm.Size = s.Bounds.Size;
+        }
     }