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

Annotation of /trunk/RomCheater/Main.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 147 - (hide annotations) (download)
Sun May 27 23:05:18 2012 UTC (8 years, 11 months ago) by william
File size: 5439 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 144 private DeserializeDockContent m_deserializeDockContent;
24     private FloatingLogWindow m_LogWindow = new FloatingLogWindow();
25 william 147 private FloatingAboutBox m_AboutBox = new FloatingAboutBox();
26 william 144 //private bool log_window_expanded = false;
27     //private double log_window_splitter_default_position = 1.4045;
28 william 86 PluginLoader loader = null;
29 william 87 IConfigPlugin ConfigPlugin = null;
30     IInputPlugin InputPlugin = null;
31     IWindowPlugin WindowPlugin = null;
32 william 146 static Main() { SettingSubscriber.AddSubscriber(new Main(), Settings.Default); }
33 william 20 private const string t = "RomCheater";
34 william 17 #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 william 144 #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 william 147
61     m_AboutBox = new FloatingAboutBox();
62 william 144 m_deserializeDockContent = new DeserializeDockContent(GetContentFromPersistString);
63     }
64     public void ShowDocks()
65     {
66     ShowLogWindow();
67     }
68     public void ShowLogWindow()
69 william 147 {
70 william 144 m_LogWindow.Show(dockPanel);
71     }
72 william 147 public void ShowAboutBox()
73     {
74     m_AboutBox.Show(dockPanel);
75     }
76 william 144 #endregion
77    
78    
79 william 117 public Main() : this(false) { }
80     public Main(bool no_console_redirect)
81 william 5 {
82     InitializeComponent();
83 william 83 load_loggerflags();
84 william 144 SetupDocks();
85     LoggerInstance = m_LogWindow.Logwriter;
86 william 23 LoggerInstance.CreateNewLog(false);
87 william 112 logger.ForceLog.Info.WriteLine("LoggingFlags = 0x{0:x4} ({1})", logger.GetLoggingFlags().Value, logger.GetLoggingFlags().Name);
88 william 87 load_plugins();
89 william 117 if (no_console_redirect)
90     LoggerInstance.RedirectConsoleOutput = false;
91 william 144
92 william 5 }
93 william 83 private void load_loggerflags()
94     {
95 william 111 logger.SetLoggingFlags(Logging.Properties.Settings.Default.LoggingFlags);
96 william 99 #if FORCE_ALL_LOGGING_FLAGS
97     logger.SetLoggingFlags(loggerflags.ALL);
98     #endif
99 william 83 }
100 william 87 private void load_plugins()
101     {
102     loader = new PluginLoader();
103     loader.LoadPlugins();
104 william 83
105 william 87 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 william 14 private void mnuItemExit_Click(object sender, EventArgs e)
118     {
119     this.Close();
120     }
121 william 16
122     private void btnCopyLogToClipboard_Click(object sender, EventArgs e)
123     {
124    
125     }
126 william 17
127     private void Main_Load(object sender, EventArgs e)
128 william 144 {
129    
130 william 17 }
131 william 63
132     private void mnuItemConfig_Click(object sender, EventArgs e)
133     {
134 william 86 RomCheaterConfigDialog dlg = new RomCheaterConfigDialog(loader);
135 william 63 dlg.ShowDialog();
136 william 92 // reload plugins
137     load_plugins();
138 william 63 }
139 william 69
140     private void mnuItemOpenProcess_Click(object sender, EventArgs e)
141     {
142 william 88 //List<Process> procs = ConfigPlugin.ValidProcessesForPlugin;
143     PIDSelector selector = new PIDSelector(ConfigPlugin);
144     selector.ShowDialog();
145 william 69 }
146 william 104
147 william 144 private void Main_Shown(object sender, EventArgs e)
148 william 104 {
149 william 144 ShowDocks();
150 william 104 }
151 william 144
152     private void mnuItemShowLogWindow_Click(object sender, EventArgs e)
153     {
154     ShowLogWindow();
155     }
156 william 147
157     private void mnuItemHelpAbout_Click(object sender, EventArgs e)
158     {
159     ShowAboutBox();
160     }
161 william 5 }
162     }

  ViewVC Help
Powered by ViewVC 1.1.22