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

Comparing trunk/RomCheater/Main.cs (file contents):
Revision 151 by william, Mon May 28 00:17:16 2012 UTC vs.
Revision 152 by william, Mon May 28 02:01:34 2012 UTC

--- trunk/RomCheater/Main.cs	2012/05/28 00:17:16	151
+++ trunk/RomCheater/Main.cs	2012/05/28 02:01:34	152
@@ -15,11 +15,13 @@ using System.Diagnostics;
 using RomCheater.PluginFramework.Interfaces;
 using WeifenLuo.WinFormsUI.Docking;
 using RomCheater.Docking;
+using System.IO;
 
 namespace RomCheater
 {
     public partial class Main : Form
     {
+        private bool m_bSaveLayout = true;
         private Process Proc = new Process();
         private DeserializeDockContent m_deserializeDockContent;
         private FloatingLogWindow m_LogWindow = new FloatingLogWindow();
@@ -56,14 +58,18 @@ namespace RomCheater
             {
                 return m_LogWindow;
             }
-            if (persistString == typeof(FloatingAboutBox).ToString())
-            {
-                return m_AboutBox;
-            }
+            //if (persistString == typeof(FloatingAboutBox).ToString())
+            //{
+            //    return m_AboutBox;
+            //}
             if (persistString == typeof(FloatingRamDumperDialog).ToString())
             {
                 return m_RamDump;
             }
+            if (persistString == typeof(PIDSelector).ToString())
+            {
+                return m_PIDSelector;
+            }
             else
             {
                 // not sure if this is appropriate
@@ -82,12 +88,13 @@ namespace RomCheater
         public void ShowDocks()
         {
             ShowLogWindow();
+            //ShowAboutBox();
             ShowRamDump();
             ShowPidSelector();
         }
         public void ShowLogWindow()
         {           
-            m_LogWindow.Show(dockPanel);
+            m_LogWindow.Show(dockPanel, DockState.DockBottom);
         }
         public void ShowAboutBox()
         {
@@ -143,6 +150,8 @@ namespace RomCheater
             if (WindowPlugin != null)
                 logger.Info.WriteLine("Loaded Window Plugin: {0}", WindowPlugin.ToString());
 
+            m_PIDSelector.ConfigPlugin = ConfigPlugin;
+
         }
 
         private void mnuItemExit_Click(object sender, EventArgs e)
@@ -157,7 +166,7 @@ namespace RomCheater
 
         private void Main_Load(object sender, EventArgs e)
         {
-           
+            
         }
 
         private void mnuItemConfig_Click(object sender, EventArgs e)
@@ -177,7 +186,31 @@ namespace RomCheater
 
         private void Main_Shown(object sender, EventArgs e)
         {
-            ShowDocks();
+            //dockPanel.SuspendLayout(true);
+            //ShowDocks();
+            string configFile = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "DockPanel.config");
+            if (File.Exists(configFile))
+            {
+                try
+                {
+                    dockPanel.LoadFromXml(configFile, m_deserializeDockContent);
+                }
+                catch (Exception ex)
+                {
+                    this.Controls.Remove(dockPanel);
+                    dockPanel = new DockPanel();
+                    dockPanel.Dock = DockStyle.Fill;
+                    dockPanel.DocumentStyle = DocumentStyle.DockingWindow;
+                    this.Controls.Add(dockPanel);
+                    ShowDocks();
+                }
+            }
+            else
+            {
+                ShowDocks();
+            }
+
+            //dockPanel.ResumeLayout(true, true);
         }
 
         private void mnuItemShowLogWindow_Click(object sender, EventArgs e)
@@ -199,5 +232,14 @@ namespace RomCheater
         {
             ShowPidSelector();
         }
+
+        private void Main_FormClosing(object sender, FormClosingEventArgs e)
+        {
+            string configFile = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "DockPanel.config");
+            if (m_bSaveLayout)
+                dockPanel.SaveAsXml(configFile);
+            else if (File.Exists(configFile))
+                File.Delete(configFile);
+        }
     }
 }