/[RomCheater]/trunk/RomCheater.RVAScratchPad/Form1.cs
ViewVC logotype

Diff of /trunk/RomCheater.RVAScratchPad/Form1.cs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

--- trunk/RomCheater.RVAScratchPad/Form1.cs	2013/06/18 11:27:53	717
+++ trunk/RomCheater.RVAScratchPad/Form1.cs	2013/06/19 01:37:36	727
@@ -11,11 +11,13 @@
 using System.IO;
 using RomCheater.PluginFramework.Core;
 using RomCheater.Core;
+using RomCheater.UserSettingsSupport;
 
 namespace RomCheater.RVAScratchPad
 {
     public partial class Form1 : Form
     {
+        private SettingSubscriber SettingsSubscriber = null;
         private bool m_bSaveLayout = true;
         PluginLoader loader = null;
         IConfigPlugin ConfigPlugin = null;
@@ -27,6 +29,10 @@
         private FloatingLogWindow m_LogWindow = new FloatingLogWindow();
         private FloatingWebBrowser m_wb = new FloatingWebBrowser();
 
+        public IWebBrowserProvider WebBrowserProvider
+        {
+            get { return new WebBrowserProvider(m_wb); }
+        }
         #region LogWriterSupport
         static LogWriter _LoggerInstance;
         static LogWriter LoggerInstance
@@ -40,6 +46,8 @@
         public Form1(bool no_console_redirect)
         {
             InitializeComponent();
+            SettingsSubscriber = new SettingSubscriber();
+            SettingsSubscriber.AddSubscriber(this, RomCheater.Properties.Settings.Default);              
             load_loggerflags();
             SetupDocks();
             LoggerInstance = m_LogWindow.Logwriter;
@@ -62,12 +70,31 @@
         {
             loader = new PluginLoader();
             loader.LoadPlugins(silent);
-            var config = PluginCollection.GetPluginByName(PluginNames.GenericConfig);
+
+            var LastConfigPlugin = SettingsSubscriber.GetValue("LastConfigPlugin").ToString();
+            if (LastConfigPlugin != null)
+            {
+                ConfigPlugin = loader.GetConfigPlugin(LastConfigPlugin.ToString());
+            }
+            else
+            {
+                var config = PluginCollection.GetPluginByName(PluginNames.GenericConfig);
+                ConfigPlugin = loader.GetPluginByGuid<IConfigPlugin>(config.ID.ToString());
+            }
+
+            // update the Config plugin's reference to the webbrowswer
+            ConfigPlugin.WebBrowserProvider = this.WebBrowserProvider;
+
+            SettingsSubscriber.SetValue("LastConfigPlugin", ConfigPlugin.ToString());
+
             var scratchpad = PluginCollection.GetPluginByName(PluginNames.ScratchPadPlugin);
-            var rvacalc = PluginCollection.GetPluginByName(PluginNames.RVACalculatorPlugin);
-            ConfigPlugin = loader.GetPluginByGuid<IConfigPlugin>(config.ID.ToString());
+            var rvacalc = PluginCollection.GetPluginByName(PluginNames.RVACalculatorPlugin);            
             ScratchPadPlugin = loader.GetPluginByGuid<IUserControlPlugin>(scratchpad.ID.ToString());
             RVACalcPlugin = loader.GetPluginByGuid<IUserControlPlugin>(rvacalc.ID.ToString());
+
+            // update config of each plugin
+            ScratchPadPlugin.SetAcceptedConfig(ConfigPlugin);
+            RVACalcPlugin.SetAcceptedConfig(ConfigPlugin);
         }
 
 
@@ -84,12 +111,12 @@
         public void SetupDocks()
         {
             m_LogWindow = new FloatingLogWindow();
-            m_LogWindow.CloseButton = false;
-            m_LogWindow.CloseButtonVisible = false;
+            //m_LogWindow.CloseButton = false;
+            //m_LogWindow.CloseButtonVisible = false;
 
             m_wb = new FloatingWebBrowser();
-            m_wb.CloseButton = false;
-            m_wb.CloseButtonVisible = false;
+            //m_wb.CloseButton = false;
+            //m_wb.CloseButtonVisible = false;
 
             m_deserializeDockContent = new DeserializeDockContent(GetContentFromPersistString);
         }
@@ -134,14 +161,21 @@
             SetupWebBrowserWindowHandler();
             ShowPluginWindows();
             SetupPluginWindowHandlers();
+
+            if (RVACalcPlugin != null)
+                RVACalcPlugin.Activate();
         }
         public void ShowLogWindow()
         {
             if (m_LogWindow == null || m_LogWindow.IsDisposed) { m_LogWindow = new FloatingLogWindow(); }
-            LoggerInstance = m_LogWindow.Logwriter;
-            LoggerInstance.CreateNewLog(false);
-            m_LogWindow.CloseButton = false;
-            m_LogWindow.CloseButtonVisible = false;
+            if (LoggerInstance == null)
+            {
+                LoggerInstance = m_LogWindow.Logwriter;
+                LoggerInstance.CreateNewLog(false);
+            }
+            //m_LogWindow.AllowEndUserDocking = true;
+            //m_LogWindow.CloseButton = false;
+            //m_LogWindow.CloseButtonVisible = false;
             m_LogWindow.Show(dockPanel, DockState.DockBottom);
         }
 
@@ -150,21 +184,35 @@
         {
             //load_plugins_silent();
             m_wb = new FloatingWebBrowser();
-            m_wb.CloseButton = false;
-            m_wb.CloseButtonVisible = false;
-            m_wb.Show(dockPanel);
+            //m_wb.AllowEndUserDocking = true;
+            //m_wb.CloseButton = false;
+            //m_wb.CloseButtonVisible = false;
+            m_wb.Show(dockPanel, DockState.Document);
         }
         public void ShowPluginWindows()
         {
-            // RVA Calc
-            RVACalcPlugin.Show(dockPanel);
-            // ScratchPad
-            ScratchPadPlugin.Show(dockPanel);
+            if (RVACalcPlugin != null)
+            {
+                // RVA Calc                
+                //RVACalcPlugin.DockHandler.CloseButton = false;                
+                //RVACalcPlugin.DockHandler.CloseButtonVisible = false;
+                //RVACalcPlugin.DockHandler.AllowEndUserDocking = true;
+                RVACalcPlugin.Show(dockPanel);
+            }
+            if (ScratchPadPlugin != null)
+            {
+                // ScratchPad                
+                //ScratchPadPlugin.DockHandler.CloseButton = false;
+                //ScratchPadPlugin.DockHandler.CloseButtonVisible = false;
+                //ScratchPadPlugin.DockHandler.AllowEndUserDocking = true;
+                ScratchPadPlugin.Show(dockPanel, DockState.Document);
+            }
         }
         #endregion
 
         private void Form1_FormClosing(object sender, FormClosingEventArgs e)
         {
+            SettingsSubscriber.SaveSettings();
             string configFile = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "RVAScratchPad-DockPanel.config");
             if (m_bSaveLayout)
                 dockPanel.SaveAsXml(configFile);
@@ -204,6 +252,8 @@
                 ShowDocks();
             }
 
+            if (RVACalcPlugin != null)
+                RVACalcPlugin.Activate();
             //dockPanel.ResumeLayout(true, true);
         }
 
@@ -211,5 +261,7 @@
         {
             this.Close();
         }
+
+        private void Form1_Load(object sender, EventArgs e) { }
     }
 }

 

  ViewVC Help
Powered by ViewVC 1.1.22