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 (11 years ago) by william
File size: 5080 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 bool log_window_expanded = false;
26 //private double log_window_splitter_default_position = 1.4045;
27 PluginLoader loader = null;
28 IConfigPlugin ConfigPlugin = null;
29 IInputPlugin InputPlugin = null;
30 IWindowPlugin WindowPlugin = null;
31 static Main() { SettingSubscriber.AddSubscriber(new Main(), Settings.Default); }
32 private const string t = "RomCheater";
33 #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 #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 public Main() : this(false) { }
73 public Main(bool no_console_redirect)
74 {
75 InitializeComponent();
76 load_loggerflags();
77 SetupDocks();
78 LoggerInstance = m_LogWindow.Logwriter;
79 LoggerInstance.CreateNewLog(false);
80 logger.ForceLog.Info.WriteLine("LoggingFlags = 0x{0:x4} ({1})", logger.GetLoggingFlags().Value, logger.GetLoggingFlags().Name);
81 load_plugins();
82 if (no_console_redirect)
83 LoggerInstance.RedirectConsoleOutput = false;
84
85 }
86 private void load_loggerflags()
87 {
88 logger.SetLoggingFlags(Logging.Properties.Settings.Default.LoggingFlags);
89 #if FORCE_ALL_LOGGING_FLAGS
90 logger.SetLoggingFlags(loggerflags.ALL);
91 #endif
92 }
93 private void load_plugins()
94 {
95 loader = new PluginLoader();
96 loader.LoadPlugins();
97
98 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 private void mnuItemExit_Click(object sender, EventArgs e)
111 {
112 this.Close();
113 }
114
115 private void btnCopyLogToClipboard_Click(object sender, EventArgs e)
116 {
117
118 }
119
120 private void Main_Load(object sender, EventArgs e)
121 {
122
123 }
124
125 private void mnuItemConfig_Click(object sender, EventArgs e)
126 {
127 RomCheaterConfigDialog dlg = new RomCheaterConfigDialog(loader);
128 dlg.ShowDialog();
129 // reload plugins
130 load_plugins();
131 }
132
133 private void mnuItemOpenProcess_Click(object sender, EventArgs e)
134 {
135 //List<Process> procs = ConfigPlugin.ValidProcessesForPlugin;
136 PIDSelector selector = new PIDSelector(ConfigPlugin);
137 selector.ShowDialog();
138 }
139
140 private void Main_Shown(object sender, EventArgs e)
141 {
142 ShowDocks();
143 }
144
145 private void mnuItemShowLogWindow_Click(object sender, EventArgs e)
146 {
147 ShowLogWindow();
148 }
149 }
150 }