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 bool log_window_expanded = false; |
23 |
< |
private double log_window_splitter_default_position = 1.4045; |
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; |
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 |
< |
LoggerInstance = logwriter; |
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 |
|
{ |
120 |
|
} |
121 |
|
|
122 |
|
private void Main_Load(object sender, EventArgs e) |
123 |
< |
{ |
123 |
> |
{ |
124 |
> |
|
125 |
|
} |
126 |
|
|
127 |
|
private void mnuItemConfig_Click(object sender, EventArgs e) |
139 |
|
selector.ShowDialog(); |
140 |
|
} |
141 |
|
|
142 |
< |
private void btnExapandCollapseLogWindow_Click(object sender, EventArgs e) |
142 |
> |
private void Main_Shown(object sender, EventArgs e) |
143 |
|
{ |
144 |
< |
if (log_window_expanded) |
145 |
< |
{ |
146 |
< |
// collapse |
147 |
< |
main_split.SplitterDistance = (int)((double)this.Height/ log_window_splitter_default_position); |
148 |
< |
log_window_expanded = false; |
149 |
< |
btnExapandCollapseLogWindow.Text = "expand"; |
115 |
< |
} |
116 |
< |
else |
117 |
< |
{ |
118 |
< |
// expand |
119 |
< |
main_split.SplitterDistance = 0; |
120 |
< |
btnExapandCollapseLogWindow.Text = "collapse"; |
121 |
< |
log_window_expanded = true; |
122 |
< |
} |
144 |
> |
ShowDocks(); |
145 |
> |
} |
146 |
> |
|
147 |
> |
private void mnuItemShowLogWindow_Click(object sender, EventArgs e) |
148 |
> |
{ |
149 |
> |
ShowLogWindow(); |
150 |
|
} |
151 |
|
} |
152 |
|
} |