ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/RomCheater/trunk/RomCheater.ScratchPad/ScratchPad.cs
Revision: 775
Committed: Thu Jun 20 22:59:40 2013 UTC (9 years, 11 months ago) by william
File size: 5951 byte(s)
Log Message:

File Contents

# User Rev Content
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     private bool PostInitDone = false;
35     public ScratchPad(UserControlPlugin plugin)
36     {
37     this.plugin = plugin;
38     InitPluginFramework();
39 william 769 InitializeComponent();
40 william 762 }
41    
42    
43     private void InitPluginFramework()
44     {
45     if (this.plugin == null) { return; }
46     this.plugin.OnSelectedProcessChanged += new BaseEventHandler<ProcessChangedEventArgs>(plugin_OnSelectedProcessChanged);
47     this.plugin.OnSelectedConfigChanged += new BaseEventHandler<ConfigChangedEventArgs>(plugin_OnSelectedConfigChanged);
48     this.plugin.OnPEDataUpdated += new BaseEventHandler<PEViewerDataUpdatedEventArgs>(plugin_OnPEDataUpdated);
49     RaisePluginFrameworkEvents();
50     }
51    
52     bool EventsRaised = false;
53     private void RaisePluginFrameworkEvents()
54     {
55    
56     if (this.plugin == null) { EventsRaised = true; return; }
57     if (!EventsRaised)
58     {
59     this.plugin.RaisePluginFrameworkEvents();
60     EventsRaised = true;
61     }
62     }
63    
64     void plugin_OnPEDataUpdated(PEViewerDataUpdatedEventArgs e)
65     {
66     //logger.Warn.WriteLine("plugin_OnPEDataUpdated::has not been implemented!");
67     }
68     void plugin_OnSelectedConfigChanged(ConfigChangedEventArgs e)
69     {
70     //logger.Warn.WriteLine("plugin_OnSelectedConfigChanged::has not been implemented!");
71     }
72     void plugin_OnSelectedProcessChanged(ProcessChangedEventArgs e)
73     {
74     //logger.Warn.WriteLine("plugin_OnSelectedProcessChanged::has not been implemented!");
75     }
76    
77    
78    
79    
80    
81    
82    
83    
84    
85    
86 william 774
87 william 762 private void ScratchPad_FormClosing(object sender, FormClosingEventArgs e)
88     {
89 william 769 //if (txtScratchPad.Text != string.Empty && PostInitDone)
90     //{
91     // DialogResult result = MessageBox.Show("Would you like to save the ScratchPad data before Closing?", "", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
92     // if (result == DialogResult.Cancel)
93     // {
94     // e.Cancel = true;
95     // return;
96     // }
97     // if (result == DialogResult.Yes)
98     // {
99     // mnuItemSave.PerformClick();
100     // }
101     //}
102     for (int i = 0; i < docuemntList.Count; i++)
103 william 762 {
104 william 769 var Document = docuemntList[i];
105 william 774 Document.OnDocumentQuit();
106 william 762 }
107     }
108    
109     private void ScratchPad_Deactivate<T>(object sender, T e) where T: EventArgs
110     {
111     try
112     {
113     FormClosingEventArgs args = (e as FormClosingEventArgs);
114     ScratchPad_FormClosing(sender, args);
115     }
116     catch { }
117     }
118    
119 william 775
120     private void AddDocument(ScratchPadDocument t)
121     {
122     t.DocumentClosing += new BaseEventHandler<ControlClosingEventArgs<int>>(t_DocumentClosing);
123     docuemntList.Add(t);
124     this.tb.TabPages.Add(t.DocumentTab);
125     t.Dock = DockStyle.Fill;
126     }
127    
128 william 769 private void mnuItemNew_Click(object sender, EventArgs e)
129 william 762 {
130 william 769 // create new document
131     int tp_index = this.tb.TabPages.Count;
132     ScratchPadDocument t = new ScratchPadDocument(tp_index);
133 william 775 AddDocument(t);
134 william 762 }
135 william 769
136 william 774 private void ScratchPad_Load(object sender, EventArgs e)
137     {
138     int tp_index = this.tb.TabPages.Count;
139     ScratchPadDocument t = new ScratchPadDocument(tp_index);
140 william 775 AddDocument(t);
141 william 774 }
142    
143     void t_DocumentClosing(ControlClosingEventArgs<int> e)
144     {
145     int index = e.Args;
146     this.docuemntList.RemoveAt(index);
147     }
148    
149 william 769 //private void txtScratchPad_LinkClicked(object sender, LinkClickedEventArgs e)
150     //{
151     // //System.Diagnostics.Process.Start(e.LinkText);
152     // if (this.plugin != null)
153     // {
154     // var p = this.plugin.WebBrowserInterface;
155     // if (p != null)
156     // {
157     // p.Navigate(e.LinkText);
158     // }
159     // else
160     // {
161     // logger.Debug.WriteLine("Could not navigate to url: '{0}'", e.LinkText);
162     // logger.Debug.WriteLine("Could not obtain a handle to the WebBrowser Provider's Interface.");
163     // }
164     // }
165     // else
166     // {
167     // logger.Debug.WriteLine("Could not navigate to url: '{0}'", e.LinkText);
168     // logger.Debug.WriteLine("Loaded plugin is null");
169     // }
170     //}
171 william 762 }
172     }