/[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 10:25:55	713
+++ trunk/RomCheater.RVAScratchPad/Form1.cs	2013/06/18 11:37:38	719
@@ -11,6 +11,7 @@
 using System.IO;
 using RomCheater.PluginFramework.Core;
 using RomCheater.Core;
+using RomCheater.UserSettingsSupport;
 
 namespace RomCheater.RVAScratchPad
 {
@@ -41,7 +42,7 @@
         {
             InitializeComponent();
             load_loggerflags();
-            //SetupDocks();
+            SetupDocks();
             LoggerInstance = m_LogWindow.Logwriter;
             LoggerInstance.CreateNewLog(false);
             logger.ForceLog.Info.WriteLine("LoggingFlags = 0x{0:x4} ({1})", logger.GetLoggingFlags().Value, logger.GetLoggingFlags().Name);
@@ -62,79 +63,54 @@
         {
             loader = new PluginLoader();
             loader.LoadPlugins(silent);
-
-
-            ConfigPlugin = loader.GetGenericConfigPlugin();
-            if (ConfigPlugin != null && !silent)
-                logger.Info.WriteLine("Loaded Config Plugin: {0}", ConfigPlugin.ToString());
-
-            //var UserControlPlugins = new List<IUserControlPlugin>(loader.LoadedUserControlPlugins);
-            //foreach (var userplugin in UserControlPlugins) { }
-
-
-            //var config_guids = loader.GetKnownPluginGuids<IConfigPlugin>();
-            //var input_guids = loader.GetKnownPluginGuids<IInputPlugin>();
-            //var window_guids = loader.GetKnownPluginGuids<IWindowPlugin>();
-            //var userplugin_guids = loader.GetKnownPluginGuids<IUserControlPlugin>();
-            //var plugin1 = loader.GetPluginByName<IUserControlPlugin>("ScratchPad Plugin");
-            //var plugin2 = loader.GetPluginByName<IUserControlPlugin>("RVA Calculator Plugin");
-
-
-            //var plugin1 = PluginCollection.UserControlPlugins.CheatCodePlugin.Plugin;
-            //var plugin2 = PluginCollection.UserControlPlugins.EmuMMAPPlugin.Plugin;
-            //var plugin3 = PluginCollection.UserControlPlugins.RVACalculatorPlugin.Plugin;
-            //var plugin4 = PluginCollection.UserControlPlugins.ScratchPadPlugin.Plugin;
-
-            //var plugin1 = PluginCollection.GetPluginByName(PluginNames.ScratchPadPlugin);
-            //var plugin2 = PluginCollection.GetPluginByName(PluginNames.RVACalculatorPlugin);            
-
-            var plugins = PluginCollection.GetPluginsByType(PluginType.Window);
-
+            var config = PluginCollection.GetPluginByName(PluginNames.GenericConfig);
+            var scratchpad = PluginCollection.GetPluginByName(PluginNames.ScratchPadPlugin);
+            var rvacalc = PluginCollection.GetPluginByName(PluginNames.RVACalculatorPlugin);
+            ConfigPlugin = loader.GetPluginByGuid<IConfigPlugin>(config.ID.ToString());
+            ScratchPadPlugin = loader.GetPluginByGuid<IUserControlPlugin>(scratchpad.ID.ToString());
+            RVACalcPlugin = loader.GetPluginByGuid<IUserControlPlugin>(rvacalc.ID.ToString());
         }
 
 
 
         #region Dock Support
-        //void AddDockToWindowList(object sender, EventArgs e)
-        //{
-        //    DockContent dc;
-        //    TypeBinder.Bind(sender, out dc);
-        //    ToolStripMenuItem tsmi = new ToolStripMenuItem(dc.Text);
-        //    tsmi.Name = dc.Name;
-        //    tsmi.Tag = dc;
-        //    tsmi.Click += new EventHandler(tsmi_Click);
-        //    mnuWindows.DropDownItems.Add(tsmi);
-        //}
-        //void tsmi_Click(object sender, EventArgs e)
-        //{
-        //    ToolStripMenuItem tsmi;
-        //    TypeBinder.Bind(sender, out tsmi);
-        //    DockContent dc;
-        //    TypeBinder.Bind(tsmi.Tag, out dc);
-        //    dc.Activate();
-        //}
-        //void RemoveDockFromWindowList(object sender, FormClosedEventArgs e)
-        //{
-        //    DockContent dc;
-        //    TypeBinder.Bind(sender, out dc);
-        //    mnuWindows.DropDownItems.RemoveByKey(dc.Name);
-        //}
         private IDockContent GetContentFromPersistString(string persistString)
         {
             if (persistString == typeof(FloatingLogWindow).ToString()) { return m_LogWindow; }
             if (persistString == typeof(FloatingWebBrowser).ToString()) { return m_wb; }
-            else { return null; }
+            if (RVACalcPlugin != null) { if (persistString == RVACalcPlugin.IDockContentTypeName) { return RVACalcPlugin.DockContent; } }
+            if (ScratchPadPlugin != null) { if (persistString == ScratchPadPlugin.IDockContentTypeName) { return ScratchPadPlugin.DockContent; } }            
+            return null;
         }
         public void SetupDocks()
         {
             m_LogWindow = new FloatingLogWindow();
+            m_LogWindow.CloseButton = false;
+            m_LogWindow.CloseButtonVisible = false;
+
             m_wb = new FloatingWebBrowser();
+            m_wb.CloseButton = false;
+            m_wb.CloseButtonVisible = false;
+
+            m_deserializeDockContent = new DeserializeDockContent(GetContentFromPersistString);
         }
         #region SetupDockWindowHandler support
         public void SetupDockWindowHandler()
         {
             SetupLogWindowHandler();
             SetupWebBrowserWindowHandler();
+            SetupPluginWindowHandlers();
+        }
+        private void SetupPluginWindowHandlers()
+        {
+            if (RVACalcPlugin != null)
+            {
+                RVACalcPlugin.Activate();
+            }
+            if (ScratchPadPlugin != null)
+            {
+                ScratchPadPlugin.Activate();
+            }
         }
         private void SetupLogWindowHandler()
         {
@@ -148,7 +124,7 @@
             if (m_wb == null) return;
             //m_wb.Shown += new EventHandler(AddDockToWindowList);
             //m_wb.FormClosed += new FormClosedEventHandler(RemoveDockFromWindowList);
-            //m_wb.Activate();
+            m_wb.Activate();
         }
         #endregion
         public void ShowDocks()
@@ -157,6 +133,8 @@
             SetupLogWindowHandler();
             ShowWebBrowser();
             SetupWebBrowserWindowHandler();
+            ShowPluginWindows();
+            SetupPluginWindowHandlers();
         }
         public void ShowLogWindow()
         {
@@ -177,6 +155,13 @@
             m_wb.CloseButtonVisible = false;
             m_wb.Show(dockPanel);
         }
+        public void ShowPluginWindows()
+        {
+            // RVA Calc
+            RVACalcPlugin.Show(dockPanel);
+            // ScratchPad
+            ScratchPadPlugin.Show(dockPanel);
+        }
         #endregion
 
         private void Form1_FormClosing(object sender, FormClosingEventArgs e)
@@ -227,5 +212,10 @@
         {
             this.Close();
         }
+
+        private void Form1_Load(object sender, EventArgs e)
+        {
+            SettingSubscriber.AddSubscriber(this, RomCheater.Properties.Settings.Default); 
+        }
     }
 }

 

  ViewVC Help
Powered by ViewVC 1.1.22