#region Logging Defines // include this any class or method that required logging, and comment-out what is not needed #define LOGGING_ENABLED // this is only valid within the logger class #region Enabled logging levels #define LOGGING_ENABLE_INFO #define LOGGING_ENABLE_WARN #define LOGGING_ENABLE_DEBUG #define LOGGING_ENABLE_VERBOSEDEBUG #define LOGGING_ENABLE_ERROR #define LOGGING_ENABLE_VERBOSEERROR #define LOGGING_ENABLE_PROFILER #endregion #endregion using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using WeifenLuo.WinFormsUI.Docking; using System.IO; using RomCheater.Logging; using RomCheater.Core; using RomCheater.PluginFramework.Core; namespace RomCheater.ScratchPad { public partial class ScratchPad : DockContent { List docuemntList = new List(); private UserControlPlugin plugin; private bool PostInitDone = false; public ScratchPad(UserControlPlugin plugin) { this.plugin = plugin; InitPluginFramework(); InitializeComponent(); } private void InitPluginFramework() { if (this.plugin == null) { return; } this.plugin.OnSelectedProcessChanged += new BaseEventHandler(plugin_OnSelectedProcessChanged); this.plugin.OnSelectedConfigChanged += new BaseEventHandler(plugin_OnSelectedConfigChanged); this.plugin.OnPEDataUpdated += new BaseEventHandler(plugin_OnPEDataUpdated); RaisePluginFrameworkEvents(); } bool EventsRaised = false; private void RaisePluginFrameworkEvents() { if (this.plugin == null) { EventsRaised = true; return; } if (!EventsRaised) { this.plugin.RaisePluginFrameworkEvents(); EventsRaised = true; } } void plugin_OnPEDataUpdated(PEViewerDataUpdatedEventArgs e) { //logger.Warn.WriteLine("plugin_OnPEDataUpdated::has not been implemented!"); } void plugin_OnSelectedConfigChanged(ConfigChangedEventArgs e) { //logger.Warn.WriteLine("plugin_OnSelectedConfigChanged::has not been implemented!"); } void plugin_OnSelectedProcessChanged(ProcessChangedEventArgs e) { //logger.Warn.WriteLine("plugin_OnSelectedProcessChanged::has not been implemented!"); } private void ScratchPad_FormClosing(object sender, FormClosingEventArgs e) { //if (txtScratchPad.Text != string.Empty && PostInitDone) //{ // DialogResult result = MessageBox.Show("Would you like to save the ScratchPad data before Closing?", "", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); // if (result == DialogResult.Cancel) // { // e.Cancel = true; // return; // } // if (result == DialogResult.Yes) // { // mnuItemSave.PerformClick(); // } //} for (int i = 0; i < docuemntList.Count; i++) { var Document = docuemntList[i]; Document.OnDocumentQuit(); } } private void ScratchPad_Deactivate(object sender, T e) where T: EventArgs { try { FormClosingEventArgs args = (e as FormClosingEventArgs); ScratchPad_FormClosing(sender, args); } catch { } } private void AddDocument(ScratchPadDocument t) { t.DocumentClosing += new BaseEventHandler>(t_DocumentClosing); docuemntList.Add(t); this.tb.TabPages.Add(t.DocumentTab); t.Dock = DockStyle.Fill; } private void mnuItemNew_Click(object sender, EventArgs e) { // create new document int tp_index = this.tb.TabPages.Count; ScratchPadDocument t = new ScratchPadDocument(tp_index); AddDocument(t); } private void ScratchPad_Load(object sender, EventArgs e) { int tp_index = this.tb.TabPages.Count; ScratchPadDocument t = new ScratchPadDocument(tp_index); AddDocument(t); } void t_DocumentClosing(ControlClosingEventArgs e) { int index = e.Args; this.docuemntList.RemoveAt(index); } //private void txtScratchPad_LinkClicked(object sender, LinkClickedEventArgs e) //{ // //System.Diagnostics.Process.Start(e.LinkText); // if (this.plugin != null) // { // var p = this.plugin.WebBrowserInterface; // if (p != null) // { // p.Navigate(e.LinkText); // } // else // { // logger.Debug.WriteLine("Could not navigate to url: '{0}'", e.LinkText); // logger.Debug.WriteLine("Could not obtain a handle to the WebBrowser Provider's Interface."); // } // } // else // { // logger.Debug.WriteLine("Could not navigate to url: '{0}'", e.LinkText); // logger.Debug.WriteLine("Loaded plugin is null"); // } //} } }