ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/RomCheater/trunk/RomCheater.ScratchPad/ScratchPad.cs
Revision: 838
Committed: Tue Sep 16 00:57:18 2014 UTC (9 years ago) by william
File size: 5653 byte(s)
Log Message:
+ add an icon resource

File Contents

# Content
1 #region Logging Defines
2 // include this any class or method that required logging, and comment-out what is not needed
3 #define LOGGING_ENABLED // this is only valid within the logger class
4 #region Enabled logging levels
5 #define LOGGING_ENABLE_INFO
6 #define LOGGING_ENABLE_WARN
7 #define LOGGING_ENABLE_DEBUG
8 #define LOGGING_ENABLE_VERBOSEDEBUG
9 #define LOGGING_ENABLE_ERROR
10 #define LOGGING_ENABLE_VERBOSEERROR
11 #define LOGGING_ENABLE_PROFILER
12 #endregion
13 #endregion
14 using System;
15 using System.Collections.Generic;
16 using System.ComponentModel;
17 using System.Data;
18 using System.Drawing;
19 using System.Linq;
20 using System.Text;
21 using System.Windows.Forms;
22 using WeifenLuo.WinFormsUI.Docking;
23 using System.IO;
24 using RomCheater.Logging;
25 using RomCheater.Core;
26 using RomCheater.PluginFramework.Core;
27 using Enterprise.Logging;
28
29 namespace RomCheater.ScratchPad
30 {
31 public partial class ScratchPad : DockContent
32 {
33 List<ScratchPadDocument> docuemntList = new List<ScratchPadDocument>();
34 private UserControlPlugin plugin;
35 public ScratchPad(UserControlPlugin plugin)
36 {
37 this.plugin = plugin;
38 InitPluginFramework();
39 InitializeComponent();
40 this.Icon = Core.Properties.Resources.romcheater_icon;
41 }
42
43
44 private void InitPluginFramework()
45 {
46 if (this.plugin == null) { return; }
47 this.plugin.OnSelectedProcessChanged += new BaseEventHandler<ProcessChangedEventArgs>(plugin_OnSelectedProcessChanged);
48 this.plugin.OnSelectedConfigChanged += new BaseEventHandler<ConfigChangedEventArgs>(plugin_OnSelectedConfigChanged);
49 this.plugin.OnPEDataUpdated += new BaseEventHandler<PEViewerDataUpdatedEventArgs>(plugin_OnPEDataUpdated);
50 RaisePluginFrameworkEvents();
51 }
52
53 bool EventsRaised = false;
54 private void RaisePluginFrameworkEvents()
55 {
56
57 if (this.plugin == null) { EventsRaised = true; return; }
58 if (!EventsRaised)
59 {
60 this.plugin.RaisePluginFrameworkEvents();
61 EventsRaised = true;
62 }
63 }
64
65 void plugin_OnPEDataUpdated(PEViewerDataUpdatedEventArgs e)
66 {
67 //logger.Warn.WriteLine("plugin_OnPEDataUpdated::has not been implemented!");
68 }
69 void plugin_OnSelectedConfigChanged(ConfigChangedEventArgs e)
70 {
71 //logger.Warn.WriteLine("plugin_OnSelectedConfigChanged::has not been implemented!");
72 }
73 void plugin_OnSelectedProcessChanged(ProcessChangedEventArgs e)
74 {
75 //logger.Warn.WriteLine("plugin_OnSelectedProcessChanged::has not been implemented!");
76 }
77
78 private void ScratchPad_FormClosing(object sender, FormClosingEventArgs e)
79 {
80 for (int i = 0; i < docuemntList.Count; i++)
81 {
82 var Document = docuemntList[i];
83 Document.OnDocumentQuit();
84 }
85 }
86
87 private void ScratchPad_Deactivate<T>(object sender, T e) where T: EventArgs
88 {
89 try
90 {
91 FormClosingEventArgs args = (e as FormClosingEventArgs);
92 ScratchPad_FormClosing(sender, args);
93 }
94 catch { }
95 }
96
97
98 private void AddDocument(ScratchPadDocument t)
99 {
100 t.DocumentClosing += new BaseEventHandler<ControlClosingEventArgs<int>>(t_DocumentClosing);
101 docuemntList.Add(t);
102 t.Dock = DockStyle.Fill;
103 t.Font = new System.Drawing.Font(this.Font.FontFamily, this.Font.SizeInPoints);
104 t.LinkClicked += new EventHandler<LinkClickedEventArgs>(t_LinkClicked);
105 this.tb.TabPages.Add(t.DocumentTab);
106 }
107
108 void t_LinkClicked(object sender, LinkClickedEventArgs e)
109 {
110 //System.Diagnostics.Process.Start(e.LinkText);
111 if (this.plugin != null)
112 {
113 var p = this.plugin.WebBrowserInterface;
114 if (p != null)
115 {
116 p.Navigate(e.LinkText);
117 }
118 else
119 {
120 gLog.Debug.WriteLine("Could not navigate to url: '{0}'", e.LinkText);
121 gLog.Debug.WriteLine("Could not obtain a handle to the WebBrowser Provider's Interface.");
122 }
123 }
124 else
125 {
126 gLog.Debug.WriteLine("Could not navigate to url: '{0}'", e.LinkText);
127 gLog.Debug.WriteLine("Loaded plugin is null");
128 }
129 }
130
131 private void mnuItemNew_Click(object sender, EventArgs e)
132 {
133 // create new document
134 int tp_index = this.tb.TabPages.Count;
135 ScratchPadDocument t = new ScratchPadDocument(tp_index);
136 AddDocument(t);
137 }
138
139 private void ScratchPad_Load(object sender, EventArgs e)
140 {
141 int tp_index = this.tb.TabPages.Count;
142 ScratchPadDocument t = new ScratchPadDocument(tp_index);
143 AddDocument(t);
144 }
145
146 void t_DocumentClosing(ControlClosingEventArgs<int> e)
147 {
148 int index = e.Args;
149 this.docuemntList.RemoveAt(index);
150 }
151
152 private void ScratchPad_Shown(object sender, EventArgs e)
153 {
154 //tb.Font = new System.Drawing.Font(this.Font.FontFamily, this.Font.SizeInPoints);
155 }
156 }
157 }