ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/RomCheater/trunk/RomCheater/Main.cs
Revision: 147
Committed: Sun May 27 23:05:18 2012 UTC (11 years, 4 months ago) by william
File size: 5439 byte(s)
Log Message:

File Contents

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