ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/RomCheater/trunk/RomCheater/Main.cs
Revision: 146
Committed: Sun May 27 22:24:30 2012 UTC (10 years, 6 months ago) by william
File size: 5080 byte(s)
Log Message:

File Contents

# User Rev Content
1 william 99 #define FORCE_ALL_LOGGING_FLAGS // when defined will force logging flags to ALL
2     using System;
3 william 5 using System.Collections.Generic;
4     using System.ComponentModel;
5     using System.Data;
6     using System.Drawing;
7     using System.Linq;
8     using System.Text;
9     using System.Windows.Forms;
10 william 17 using RomCheater.Logging;
11 william 34 using RomCheater.Properties;
12     using RomCheater.UserSettingsSupport;
13 william 83 using RomCheater.PluginFramework.Core;
14 william 86 using System.Diagnostics;
15 william 87 using RomCheater.PluginFramework.Interfaces;
16 william 144 using WeifenLuo.WinFormsUI.Docking;
17 william 146 using RomCheater.Docking;
18 william 5
19     namespace RomCheater
20     {
21 william 13 public partial class Main : Form
22 william 5 {
23 william 144 private DeserializeDockContent m_deserializeDockContent;
24     private FloatingLogWindow m_LogWindow = new FloatingLogWindow();
25     //private bool log_window_expanded = false;
26     //private double log_window_splitter_default_position = 1.4045;
27 william 86 PluginLoader loader = null;
28 william 87 IConfigPlugin ConfigPlugin = null;
29     IInputPlugin InputPlugin = null;
30     IWindowPlugin WindowPlugin = null;
31 william 146 static Main() { SettingSubscriber.AddSubscriber(new Main(), Settings.Default); }
32 william 20 private const string t = "RomCheater";
33 william 17 #region LogWriterSupport
34     static LogWriter _LoggerInstance;
35     static LogWriter LoggerInstance
36     {
37     get { return _LoggerInstance; }
38     set { _LoggerInstance = value; }
39     }
40     #endregion
41    
42    
43 william 144 #region Dock Support
44     private IDockContent GetContentFromPersistString(string persistString)
45     {
46     if (persistString == typeof(FloatingLogWindow).ToString())
47     {
48     return m_LogWindow;
49     }
50     else
51     {
52     // not sure if this is appropriate
53     return null;
54     }
55     }
56     public void SetupDocks()
57     {
58     m_LogWindow = new FloatingLogWindow();
59     m_deserializeDockContent = new DeserializeDockContent(GetContentFromPersistString);
60     }
61     public void ShowDocks()
62     {
63     ShowLogWindow();
64     }
65     public void ShowLogWindow()
66     {
67     m_LogWindow.Show(dockPanel);
68     }
69     #endregion
70    
71    
72 william 117 public Main() : this(false) { }
73     public Main(bool no_console_redirect)
74 william 5 {
75     InitializeComponent();
76 william 83 load_loggerflags();
77 william 144 SetupDocks();
78     LoggerInstance = m_LogWindow.Logwriter;
79 william 23 LoggerInstance.CreateNewLog(false);
80 william 112 logger.ForceLog.Info.WriteLine("LoggingFlags = 0x{0:x4} ({1})", logger.GetLoggingFlags().Value, logger.GetLoggingFlags().Name);
81 william 87 load_plugins();
82 william 117 if (no_console_redirect)
83     LoggerInstance.RedirectConsoleOutput = false;
84 william 144
85 william 5 }
86 william 83 private void load_loggerflags()
87     {
88 william 111 logger.SetLoggingFlags(Logging.Properties.Settings.Default.LoggingFlags);
89 william 99 #if FORCE_ALL_LOGGING_FLAGS
90     logger.SetLoggingFlags(loggerflags.ALL);
91     #endif
92 william 83 }
93 william 87 private void load_plugins()
94     {
95     loader = new PluginLoader();
96     loader.LoadPlugins();
97 william 83
98 william 87 ConfigPlugin = loader.GetConfigPlugin(RomCheater.Properties.Settings.Default.LastConfigPlugin);
99     if (ConfigPlugin != null)
100     logger.Info.WriteLine("Loaded Config Plugin: {0}", ConfigPlugin.ToString());
101     InputPlugin = loader.GetInputPlugin(RomCheater.Properties.Settings.Default.LastInputPlugin);
102     if (InputPlugin != null)
103     logger.Info.WriteLine("Loaded Input Plugin: {0}", InputPlugin.ToString());
104     WindowPlugin = loader.GetWindowPlugin(RomCheater.Properties.Settings.Default.LastWindowPlugin);
105     if (WindowPlugin != null)
106     logger.Info.WriteLine("Loaded Window Plugin: {0}", WindowPlugin.ToString());
107    
108     }
109    
110 william 14 private void mnuItemExit_Click(object sender, EventArgs e)
111     {
112     this.Close();
113     }
114 william 16
115     private void btnCopyLogToClipboard_Click(object sender, EventArgs e)
116     {
117    
118     }
119 william 17
120     private void Main_Load(object sender, EventArgs e)
121 william 144 {
122    
123 william 17 }
124 william 63
125     private void mnuItemConfig_Click(object sender, EventArgs e)
126     {
127 william 86 RomCheaterConfigDialog dlg = new RomCheaterConfigDialog(loader);
128 william 63 dlg.ShowDialog();
129 william 92 // reload plugins
130     load_plugins();
131 william 63 }
132 william 69
133     private void mnuItemOpenProcess_Click(object sender, EventArgs e)
134     {
135 william 88 //List<Process> procs = ConfigPlugin.ValidProcessesForPlugin;
136     PIDSelector selector = new PIDSelector(ConfigPlugin);
137     selector.ShowDialog();
138 william 69 }
139 william 104
140 william 144 private void Main_Shown(object sender, EventArgs e)
141 william 104 {
142 william 144 ShowDocks();
143 william 104 }
144 william 144
145     private void mnuItemShowLogWindow_Click(object sender, EventArgs e)
146     {
147     ShowLogWindow();
148     }
149 william 5 }
150     }