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