/[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/19 14:18:50	728
+++ trunk/RomCheater.RVAScratchPad/Form1.cs	2014/09/16 01:06:04	839
@@ -1,4 +1,5 @@
-´╗┐using System;
+´╗┐#define FORCE_DISABLE_PROFILER_LOGLEVEL // when define will forcibly disable the profiler loglevel
+using System;
 using System.Collections.Generic;
 using System.ComponentModel;
 using System.Data;
@@ -12,20 +13,23 @@
 using RomCheater.PluginFramework.Core;
 using RomCheater.Core;
 using RomCheater.UserSettingsSupport;
+using Enterprise.Logging;
 
 namespace RomCheater.RVAScratchPad
 {
     public partial class Form1 : Form
     {
+        const string DockPanelConfig = "RVAScratchPad-DockPanel.conf";
         private SettingSubscriber SettingsSubscriber = null;
-        //private bool m_bSaveLayout = true;
+        private bool m_bSaveLayout = true;
         PluginLoader loader = null;
         IConfigPlugin ConfigPlugin = null;
 
         IUserControlPlugin RVACalcPlugin = null;
-        //IUserControlPlugin ScratchPadPlugin = null;
+        IUserControlPlugin ScratchPadPlugin = null;
 
-        //private DeserializeDockContent m_deserializeDockContent;
+        private LogLevel logging_level = LogLevel.kLogLevel_All;
+        private DeserializeDockContent m_deserializeDockContent;
         //private FloatingLogWindow m_LogWindow = new FloatingLogWindow();
         //private FloatingWebBrowser m_wb = new FloatingWebBrowser();
 
@@ -46,24 +50,40 @@
         public Form1(bool no_console_redirect)
         {
             InitializeComponent();
+            this.Icon = Core.Properties.Resources.romcheater_icon;
             SettingsSubscriber = new SettingSubscriber();
             SettingsSubscriber.AddSubscriber(this, RomCheater.Properties.Settings.Default);              
-            load_loggerflags();
+            //load_loggerflags();
             SetupDocks();
             //LoggerInstance = m_LogWindow.Logwriter;
-            LoggerInstance = new LogWriter(!no_console_redirect);
-            LoggerInstance.CreateNewLog(false);
-            logger.ForceLog.Info.WriteLine("LoggingFlags = 0x{0:x4} ({1})", logger.GetLoggingFlags().Value, logger.GetLoggingFlags().Name);
+            LoggerInstance = new LogWriter();
+            load_loggerflags();
             load_plugins();
-            if (no_console_redirect)
-                LoggerInstance.RedirectConsoleOutput = false;           
+            //if (no_console_redirect)
+            //    LoggerInstance.RedirectConsoleOutput = false;           
         }
         private void load_loggerflags()
         {
-            logger.SetLoggingFlags(Logging.Properties.Settings.Default.LoggingFlags);
+            bool upgraded_flags = Logging.Properties.Settings.Default.UpgradedLogLevel;
+            if (!upgraded_flags)
+            {
+                logging_level = new LoggingFlagsConverter(Logging.Properties.Settings.Default.LoggingFlags).ConvertFlags();
+                Logging.Properties.Settings.Default.UpgradedLogLevel = true;
+                Logging.Properties.Settings.Default.gLogLoggingFlags = (uint)logging_level;
+                Logging.Properties.Settings.Default.Save();
+            }
+            logging_level = (LogLevel)Logging.Properties.Settings.Default.gLogLoggingFlags;
 #if FORCE_ALL_LOGGING_FLAGS
-            logger.SetLoggingFlags(loggerflags.ALL);
+      logging_level = LogLevel.kLogLevel_All;
+#endif
+#if FORCE_DISABLE_PROFILER_LOGLEVEL
+             logging_level = logging_level & ~LogLevel.kLogLevel_Profiler;
+             logging_level = logging_level & ~LogLevel.kLogLevel_VerboseProfiler;
 #endif
+             gLog.CreateLog(LoggingConstants.AppFullLogPath, true, logging_level, new EventHandler<LoggerOnFlushEventArgs>(Log_OnFlush), LoggerInstance.Log);
+        }
+        private void Log_OnFlush(object sender, LoggerOnFlushEventArgs e)
+        {
         }
         private void load_plugins() { load_plugins(false); }
         private void load_plugins_silent() { load_plugins(true); }
@@ -83,32 +103,32 @@
                 ConfigPlugin = loader.GetPluginByGuid<IConfigPlugin>(config.ID.ToString());
             }
 
-            //// update the Config plugin's reference to the webbrowswer
-            ////ConfigPlugin.WebBrowserProvider = this.WebBrowserProvider;
+            // 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 scratchpad = PluginCollection.GetPluginByName(PluginNames.ScratchPadPlugin);
             var rvacalc = PluginCollection.GetPluginByName(PluginNames.RVACalculatorPlugin);
-            //ScratchPadPlugin = loader.GetPluginByGuid<IUserControlPlugin>(scratchpad.ID.ToString());
+            ScratchPadPlugin = loader.GetPluginByGuid<IUserControlPlugin>(scratchpad.ID.ToString());
             RVACalcPlugin = loader.GetPluginByGuid<IUserControlPlugin>(rvacalc.ID.ToString());
 
             // update config of each plugin
-            //ScratchPadPlugin.SetAcceptedConfig(ConfigPlugin);
+            ScratchPadPlugin.SetAcceptedConfig(ConfigPlugin);
             RVACalcPlugin.SetAcceptedConfig(ConfigPlugin);
         }
 
 
 
         #region Dock Support
-        //private IDockContent GetContentFromPersistString(string persistString)
-        //{
-        //    if (persistString == typeof(FloatingLogWindow).ToString()) { return m_LogWindow; }
-        //    if (persistString == typeof(FloatingWebBrowser).ToString()) { return m_wb; }
-        //    if (RVACalcPlugin != null) { if (persistString == RVACalcPlugin.IDockContentTypeName) { return RVACalcPlugin.DockContent; } }
-        //    if (ScratchPadPlugin != null) { if (persistString == ScratchPadPlugin.IDockContentTypeName) { return ScratchPadPlugin.DockContent; } }
-        //    return null;
-        //}
+        private IDockContent GetContentFromPersistString(string persistString)
+        {
+            //if (persistString == typeof(FloatingLogWindow).ToString()) { return m_LogWindow; }
+            //if (persistString == typeof(FloatingWebBrowser).ToString()) { return m_wb; }
+            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();
@@ -119,7 +139,20 @@
             //m_wb.CloseButton = false;
             //m_wb.CloseButtonVisible = false;
 
-            //m_deserializeDockContent = new DeserializeDockContent(GetContentFromPersistString);
+            if (RVACalcPlugin != null)
+            {
+                RVACalcPlugin.DockHandler.CloseButton = false;
+                RVACalcPlugin.DockHandler.CloseButtonVisible = false;
+                RVACalcPlugin.DockHandler.AllowEndUserDocking = false;
+            }
+            if (ScratchPadPlugin != null)
+            {
+                ScratchPadPlugin.DockHandler.CloseButton = false;
+                ScratchPadPlugin.DockHandler.CloseButtonVisible = false;
+                ScratchPadPlugin.DockHandler.AllowEndUserDocking = false;
+            }
+
+            m_deserializeDockContent = new DeserializeDockContent(GetContentFromPersistString);
         }
         #region SetupDockWindowHandler support
         public void SetupDockWindowHandler()
@@ -132,12 +165,18 @@
         {
             if (RVACalcPlugin != null)
             {
+                RVACalcPlugin.DockHandler.CloseButton = false;
+                RVACalcPlugin.DockHandler.CloseButtonVisible = false;
+                RVACalcPlugin.DockHandler.AllowEndUserDocking = false;
                 RVACalcPlugin.Activate();
             }
-            //if (ScratchPadPlugin != null)
-            //{
-            //    ScratchPadPlugin.Activate();
-            //}
+            if (ScratchPadPlugin != null)
+            {
+                ScratchPadPlugin.DockHandler.CloseButton = false;
+                ScratchPadPlugin.DockHandler.CloseButtonVisible = false;
+                ScratchPadPlugin.DockHandler.AllowEndUserDocking = false;
+                ScratchPadPlugin.Activate();
+            }
         }
         //private void SetupLogWindowHandler()
         //{
@@ -163,8 +202,8 @@
             ShowPluginWindows();
             SetupPluginWindowHandlers();
 
-            //if (RVACalcPlugin != null)
-            //    RVACalcPlugin.Activate();
+            if (RVACalcPlugin != null)
+                RVACalcPlugin.Activate();
         }
         public void ShowLogWindow()
         {
@@ -198,27 +237,27 @@
                 RVACalcPlugin.DockHandler.CloseButton = false;
                 RVACalcPlugin.DockHandler.CloseButtonVisible = false;
                 RVACalcPlugin.DockHandler.AllowEndUserDocking = false;
-                RVACalcPlugin.Show(dockPanel);
+                RVACalcPlugin.Show(dockPanel, DockState.DockLeft);
+            }
+            if (ScratchPadPlugin != null)
+            {
+                // ScratchPad                
+                ScratchPadPlugin.DockHandler.CloseButton = false;
+                ScratchPadPlugin.DockHandler.CloseButtonVisible = false;
+                ScratchPadPlugin.DockHandler.AllowEndUserDocking = false;
+                ScratchPadPlugin.Show(dockPanel, DockState.Document);
             }
-            //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);
-            //else if (File.Exists(configFile))
-            //    File.Delete(configFile);
+            string configFile = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), DockPanelConfig);
+            if (m_bSaveLayout)
+                dockPanel.SaveAsXml(configFile);
+            else if (File.Exists(configFile))
+                File.Delete(configFile);
             // notify any docked windows of formclosing
             foreach (var t in this.dockPanel.Contents)
             {
@@ -230,31 +269,31 @@
         {
             ////dockPanel.SuspendLayout(true);
             ////ShowDocks();
-            //string configFile = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "RVAScratchPad-DockPanel.config");
-            //if (File.Exists(configFile))
-            //{
-            //    try
-            //    {
-            //        dockPanel.LoadFromXml(configFile, m_deserializeDockContent);
-            //        SetupDockWindowHandler();
-            //    }
-            //    catch (Exception)
-            //    {
-            //        this.Controls.Remove(dockPanel);
-            //        dockPanel = new DockPanel();
-            //        dockPanel.Dock = DockStyle.Fill;
-            //        dockPanel.DocumentStyle = DocumentStyle.DockingWindow;
-            //        this.Controls.Add(dockPanel);
-            //        ShowDocks();
-            //    }
-            //}
-            //else
-            //{
-            ShowDocks();
-            //}
+            string configFile = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), DockPanelConfig);
+            if (File.Exists(configFile))
+            {
+                try
+                {
+                    dockPanel.LoadFromXml(configFile, m_deserializeDockContent);
+                    SetupDockWindowHandler();
+                }
+                catch (Exception)
+                {
+                    this.Controls.Remove(dockPanel);
+                    dockPanel = new DockPanel();
+                    dockPanel.Dock = DockStyle.Fill;
+                    dockPanel.DocumentStyle = DocumentStyle.DockingWindow;
+                    this.Controls.Add(dockPanel);
+                    ShowDocks();
+                }
+            }
+            else
+            {
+                ShowDocks();
+            }
 
-            //if (RVACalcPlugin != null)
-            //    RVACalcPlugin.Activate();
+            if (RVACalcPlugin != null)
+                RVACalcPlugin.Activate();
             ////dockPanel.ResumeLayout(true, true);
         }
 

 

  ViewVC Help
Powered by ViewVC 1.1.22