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

Annotation of /trunk/RomCheater/Main.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 151 - (hide annotations) (download)
Mon May 28 00:17:16 2012 UTC (9 years, 4 months ago) by william
File size: 7078 byte(s)

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

  ViewVC Help
Powered by ViewVC 1.1.22