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

Contents of /trunk/RomCheater.ScratchPad/ScratchPad.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 785 - (show annotations) (download)
Fri Jun 21 04:50:33 2013 UTC (6 years, 7 months ago) by william
File size: 5572 byte(s)

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
28 namespace RomCheater.ScratchPad
29 {
30 public partial class ScratchPad : DockContent
31 {
32 List<ScratchPadDocument> docuemntList = new List<ScratchPadDocument>();
33 private UserControlPlugin plugin;
34 public ScratchPad(UserControlPlugin plugin)
35 {
36 this.plugin = plugin;
37 InitPluginFramework();
38 InitializeComponent();
39 }
40
41
42 private void InitPluginFramework()
43 {
44 if (this.plugin == null) { return; }
45 this.plugin.OnSelectedProcessChanged += new BaseEventHandler<ProcessChangedEventArgs>(plugin_OnSelectedProcessChanged);
46 this.plugin.OnSelectedConfigChanged += new BaseEventHandler<ConfigChangedEventArgs>(plugin_OnSelectedConfigChanged);
47 this.plugin.OnPEDataUpdated += new BaseEventHandler<PEViewerDataUpdatedEventArgs>(plugin_OnPEDataUpdated);
48 RaisePluginFrameworkEvents();
49 }
50
51 bool EventsRaised = false;
52 private void RaisePluginFrameworkEvents()
53 {
54
55 if (this.plugin == null) { EventsRaised = true; return; }
56 if (!EventsRaised)
57 {
58 this.plugin.RaisePluginFrameworkEvents();
59 EventsRaised = true;
60 }
61 }
62
63 void plugin_OnPEDataUpdated(PEViewerDataUpdatedEventArgs e)
64 {
65 //logger.Warn.WriteLine("plugin_OnPEDataUpdated::has not been implemented!");
66 }
67 void plugin_OnSelectedConfigChanged(ConfigChangedEventArgs e)
68 {
69 //logger.Warn.WriteLine("plugin_OnSelectedConfigChanged::has not been implemented!");
70 }
71 void plugin_OnSelectedProcessChanged(ProcessChangedEventArgs e)
72 {
73 //logger.Warn.WriteLine("plugin_OnSelectedProcessChanged::has not been implemented!");
74 }
75
76 private void ScratchPad_FormClosing(object sender, FormClosingEventArgs e)
77 {
78 for (int i = 0; i < docuemntList.Count; i++)
79 {
80 var Document = docuemntList[i];
81 Document.OnDocumentQuit();
82 }
83 }
84
85 private void ScratchPad_Deactivate<T>(object sender, T e) where T: EventArgs
86 {
87 try
88 {
89 FormClosingEventArgs args = (e as FormClosingEventArgs);
90 ScratchPad_FormClosing(sender, args);
91 }
92 catch { }
93 }
94
95
96 private void AddDocument(ScratchPadDocument t)
97 {
98 t.DocumentClosing += new BaseEventHandler<ControlClosingEventArgs<int>>(t_DocumentClosing);
99 docuemntList.Add(t);
100 t.Dock = DockStyle.Fill;
101 t.Font = new System.Drawing.Font(this.Font.FontFamily, this.Font.SizeInPoints);
102 t.LinkClicked += new EventHandler<LinkClickedEventArgs>(t_LinkClicked);
103 this.tb.TabPages.Add(t.DocumentTab);
104 }
105
106 void t_LinkClicked(object sender, LinkClickedEventArgs e)
107 {
108 //System.Diagnostics.Process.Start(e.LinkText);
109 if (this.plugin != null)
110 {
111 var p = this.plugin.WebBrowserInterface;
112 if (p != null)
113 {
114 p.Navigate(e.LinkText);
115 }
116 else
117 {
118 logger.Debug.WriteLine("Could not navigate to url: '{0}'", e.LinkText);
119 logger.Debug.WriteLine("Could not obtain a handle to the WebBrowser Provider's Interface.");
120 }
121 }
122 else
123 {
124 logger.Debug.WriteLine("Could not navigate to url: '{0}'", e.LinkText);
125 logger.Debug.WriteLine("Loaded plugin is null");
126 }
127 }
128
129 private void mnuItemNew_Click(object sender, EventArgs e)
130 {
131 // create new document
132 int tp_index = this.tb.TabPages.Count;
133 ScratchPadDocument t = new ScratchPadDocument(tp_index);
134 AddDocument(t);
135 }
136
137 private void ScratchPad_Load(object sender, EventArgs e)
138 {
139 int tp_index = this.tb.TabPages.Count;
140 ScratchPadDocument t = new ScratchPadDocument(tp_index);
141 AddDocument(t);
142 }
143
144 void t_DocumentClosing(ControlClosingEventArgs<int> e)
145 {
146 int index = e.Args;
147 this.docuemntList.RemoveAt(index);
148 }
149
150 private void ScratchPad_Shown(object sender, EventArgs e)
151 {
152 //tb.Font = new System.Drawing.Font(this.Font.FontFamily, this.Font.SizeInPoints);
153 }
154 }
155 }

  ViewVC Help
Powered by ViewVC 1.1.22