/[RomCheater]/trunk/RomCheater/Main.cs
ViewVC logotype

Contents of /trunk/RomCheater/Main.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 148 - (show annotations) (download)
Sun May 27 23:33:54 2012 UTC (8 years, 4 months ago) by william
File size: 6637 byte(s)

1 #define FORCE_ALL_LOGGING_FLAGS // when defined will force logging flags to ALL
2 using System;
3 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 using RomCheater.Logging;
11 using RomCheater.Properties;
12 using RomCheater.UserSettingsSupport;
13 using RomCheater.PluginFramework.Core;
14 using System.Diagnostics;
15 using RomCheater.PluginFramework.Interfaces;
16 using WeifenLuo.WinFormsUI.Docking;
17 using RomCheater.Docking;
18
19 namespace RomCheater
20 {
21 public partial class Main : Form
22 {
23 private DeserializeDockContent m_deserializeDockContent;
24 private FloatingLogWindow m_LogWindow = new FloatingLogWindow();
25 private FloatingAboutBox m_AboutBox = new FloatingAboutBox();
26 private FloatingRamDumperDialog m_RamDump = new FloatingRamDumperDialog();
27 private PIDSelector m_PIDSelector = new PIDSelector();
28 //private bool log_window_expanded = false;
29 //private double log_window_splitter_default_position = 1.4045;
30 PluginLoader loader = null;
31 IConfigPlugin ConfigPlugin = null;
32 IInputPlugin InputPlugin = null;
33 IWindowPlugin WindowPlugin = null;
34 static Main() { SettingSubscriber.AddSubscriber(new Main(), Settings.Default); }
35 private const string t = "RomCheater";
36 #region LogWriterSupport
37 static LogWriter _LoggerInstance;
38 static LogWriter LoggerInstance
39 {
40 get { return _LoggerInstance; }
41 set { _LoggerInstance = value; }
42 }
43 #endregion
44
45
46 #region Dock Support
47 private IDockContent GetContentFromPersistString(string persistString)
48 {
49 if (persistString == typeof(FloatingLogWindow).ToString())
50 {
51 return m_LogWindow;
52 }
53 if (persistString == typeof(FloatingAboutBox).ToString())
54 {
55 return m_AboutBox;
56 }
57 if (persistString == typeof(FloatingRamDumperDialog).ToString())
58 {
59 return m_RamDump;
60 }
61 else
62 {
63 // not sure if this is appropriate
64 return null;
65 }
66 }
67 public void SetupDocks()
68 {
69 m_LogWindow = new FloatingLogWindow();
70 m_AboutBox = new FloatingAboutBox();
71 m_RamDump = new FloatingRamDumperDialog();
72 m_PIDSelector = new PIDSelector();
73 m_deserializeDockContent = new DeserializeDockContent(GetContentFromPersistString);
74 }
75 public void ShowDocks()
76 {
77 ShowLogWindow();
78 ShowRamDump();
79 ShowPidSelector();
80 }
81 public void ShowLogWindow()
82 {
83 m_LogWindow.Show(dockPanel);
84 }
85 public void ShowAboutBox()
86 {
87 m_AboutBox.ShowDialog();
88 }
89 public void ShowRamDump()
90 {
91 m_RamDump.Show(dockPanel);
92 }
93 public void ShowPidSelector()
94 {
95 //List<Process> procs = ConfigPlugin.ValidProcessesForPlugin;
96 m_PIDSelector = new PIDSelector(ConfigPlugin);
97 m_PIDSelector.Show(dockPanel);
98 }
99 #endregion
100
101
102 public Main() : this(false) { }
103 public Main(bool no_console_redirect)
104 {
105 InitializeComponent();
106 load_loggerflags();
107 SetupDocks();
108 LoggerInstance = m_LogWindow.Logwriter;
109 LoggerInstance.CreateNewLog(false);
110 logger.ForceLog.Info.WriteLine("LoggingFlags = 0x{0:x4} ({1})", logger.GetLoggingFlags().Value, logger.GetLoggingFlags().Name);
111 load_plugins();
112 if (no_console_redirect)
113 LoggerInstance.RedirectConsoleOutput = false;
114
115 }
116 private void load_loggerflags()
117 {
118 logger.SetLoggingFlags(Logging.Properties.Settings.Default.LoggingFlags);
119 #if FORCE_ALL_LOGGING_FLAGS
120 logger.SetLoggingFlags(loggerflags.ALL);
121 #endif
122 }
123 private void load_plugins()
124 {
125 loader = new PluginLoader();
126 loader.LoadPlugins();
127
128 ConfigPlugin = loader.GetConfigPlugin(RomCheater.Properties.Settings.Default.LastConfigPlugin);
129 if (ConfigPlugin != null)
130 logger.Info.WriteLine("Loaded Config Plugin: {0}", ConfigPlugin.ToString());
131 InputPlugin = loader.GetInputPlugin(RomCheater.Properties.Settings.Default.LastInputPlugin);
132 if (InputPlugin != null)
133 logger.Info.WriteLine("Loaded Input Plugin: {0}", InputPlugin.ToString());
134 WindowPlugin = loader.GetWindowPlugin(RomCheater.Properties.Settings.Default.LastWindowPlugin);
135 if (WindowPlugin != null)
136 logger.Info.WriteLine("Loaded Window Plugin: {0}", WindowPlugin.ToString());
137
138 }
139
140 private void mnuItemExit_Click(object sender, EventArgs e)
141 {
142 this.Close();
143 }
144
145 private void btnCopyLogToClipboard_Click(object sender, EventArgs e)
146 {
147
148 }
149
150 private void Main_Load(object sender, EventArgs e)
151 {
152
153 }
154
155 private void mnuItemConfig_Click(object sender, EventArgs e)
156 {
157 RomCheaterConfigDialog dlg = new RomCheaterConfigDialog(loader);
158 dlg.ShowDialog();
159 // reload plugins
160 load_plugins();
161 }
162
163 private void mnuItemOpenProcess_Click(object sender, EventArgs e)
164 {
165 ////List<Process> procs = ConfigPlugin.ValidProcessesForPlugin;
166 //PIDSelector selector = new PIDSelector(ConfigPlugin);
167 //selector.ShowDialog();
168 }
169
170 private void Main_Shown(object sender, EventArgs e)
171 {
172 ShowDocks();
173 }
174
175 private void mnuItemShowLogWindow_Click(object sender, EventArgs e)
176 {
177 ShowLogWindow();
178 }
179
180 private void mnuItemHelpAbout_Click(object sender, EventArgs e)
181 {
182 ShowAboutBox();
183 }
184
185 private void mnuItemShowRamDumpDialog_Click(object sender, EventArgs e)
186 {
187 ShowRamDump();
188 }
189
190 private void mnuItemShowPIDSelector_Click(object sender, EventArgs e)
191 {
192 ShowPidSelector();
193 }
194 }
195 }

  ViewVC Help
Powered by ViewVC 1.1.22