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

Annotation of /trunk/RomCheater.ScratchPad/ScratchPad.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 784 - (hide annotations) (download)
Fri Jun 21 04:27:21 2013 UTC (7 years ago) by william
File size: 5380 byte(s)

1 william 762 #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 william 774 {
32 william 769 List<ScratchPadDocument> docuemntList = new List<ScratchPadDocument>();
33 william 762 private UserControlPlugin plugin;
34     public ScratchPad(UserControlPlugin plugin)
35     {
36     this.plugin = plugin;
37     InitPluginFramework();
38 william 769 InitializeComponent();
39 william 762 }
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 william 783
76 william 762 private void ScratchPad_FormClosing(object sender, FormClosingEventArgs e)
77     {
78 william 769 for (int i = 0; i < docuemntList.Count; i++)
79 william 762 {
80 william 769 var Document = docuemntList[i];
81 william 774 Document.OnDocumentQuit();
82 william 762 }
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 william 775
96     private void AddDocument(ScratchPadDocument t)
97     {
98     t.DocumentClosing += new BaseEventHandler<ControlClosingEventArgs<int>>(t_DocumentClosing);
99     docuemntList.Add(t);
100     this.tb.TabPages.Add(t.DocumentTab);
101     t.Dock = DockStyle.Fill;
102 william 780 t.Font = new System.Drawing.Font(this.Font.FontFamily, this.Font.SizeInPoints);
103 william 783 t.LinkClicked += new EventHandler<LinkClickedEventArgs>(t_LinkClicked);
104 william 775 }
105    
106 william 783 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 william 769 private void mnuItemNew_Click(object sender, EventArgs e)
130 william 762 {
131 william 769 // create new document
132     int tp_index = this.tb.TabPages.Count;
133     ScratchPadDocument t = new ScratchPadDocument(tp_index);
134 william 775 AddDocument(t);
135 william 762 }
136 william 769
137 william 774 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 william 775 AddDocument(t);
142 william 774 }
143    
144     void t_DocumentClosing(ControlClosingEventArgs<int> e)
145     {
146     int index = e.Args;
147     this.docuemntList.RemoveAt(index);
148     }
149 william 762 }
150     }

  ViewVC Help
Powered by ViewVC 1.1.22