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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 892 - (hide annotations) (download)
Wed Sep 17 05:56:41 2014 UTC (5 years, 10 months ago) by william
File size: 5591 byte(s)
+ alot of dang work to force an icon to be shown on the docked panels
  ** when it was as simple as setting: DockPanel.ShowDocumentIcon to true

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 william 889 using RomCheater.Interfaces;
26 william 762 using RomCheater.PluginFramework.Core;
27 william 812 using Enterprise.Logging;
28 william 762
29     namespace RomCheater.ScratchPad
30     {
31     public partial class ScratchPad : DockContent
32 william 774 {
33 william 769 List<ScratchPadDocument> docuemntList = new List<ScratchPadDocument>();
34 william 762 private UserControlPlugin plugin;
35     public ScratchPad(UserControlPlugin plugin)
36     {
37     this.plugin = plugin;
38     InitPluginFramework();
39 william 838 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 william 783
77 william 762 private void ScratchPad_FormClosing(object sender, FormClosingEventArgs e)
78     {
79 william 769 for (int i = 0; i < docuemntList.Count; i++)
80 william 762 {
81 william 769 var Document = docuemntList[i];
82 william 774 Document.OnDocumentQuit();
83 william 762 }
84     }
85    
86     private void ScratchPad_Deactivate<T>(object sender, T e) where T: EventArgs
87     {
88     try
89     {
90     FormClosingEventArgs args = (e as FormClosingEventArgs);
91     ScratchPad_FormClosing(sender, args);
92     }
93     catch { }
94     }
95    
96 william 775
97     private void AddDocument(ScratchPadDocument t)
98     {
99     t.DocumentClosing += new BaseEventHandler<ControlClosingEventArgs<int>>(t_DocumentClosing);
100     docuemntList.Add(t);
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 785 this.tb.TabPages.Add(t.DocumentTab);
105 william 775 }
106    
107 william 783 void t_LinkClicked(object sender, LinkClickedEventArgs e)
108     {
109     //System.Diagnostics.Process.Start(e.LinkText);
110     if (this.plugin != null)
111     {
112     var p = this.plugin.WebBrowserInterface;
113     if (p != null)
114     {
115     p.Navigate(e.LinkText);
116     }
117     else
118     {
119 william 812 gLog.Debug.WriteLine("Could not navigate to url: '{0}'", e.LinkText);
120     gLog.Debug.WriteLine("Could not obtain a handle to the WebBrowser Provider's Interface.");
121 william 783 }
122     }
123     else
124     {
125 william 812 gLog.Debug.WriteLine("Could not navigate to url: '{0}'", e.LinkText);
126     gLog.Debug.WriteLine("Loaded plugin is null");
127 william 783 }
128     }
129    
130 william 769 private void mnuItemNew_Click(object sender, EventArgs e)
131 william 762 {
132 william 769 // create new document
133     int tp_index = this.tb.TabPages.Count;
134     ScratchPadDocument t = new ScratchPadDocument(tp_index);
135 william 775 AddDocument(t);
136 william 762 }
137 william 769
138 william 774 private void ScratchPad_Load(object sender, EventArgs e)
139     {
140     int tp_index = this.tb.TabPages.Count;
141     ScratchPadDocument t = new ScratchPadDocument(tp_index);
142 william 775 AddDocument(t);
143 william 774 }
144    
145     void t_DocumentClosing(ControlClosingEventArgs<int> e)
146     {
147     int index = e.Args;
148     this.docuemntList.RemoveAt(index);
149     }
150 william 785
151     private void ScratchPad_Shown(object sender, EventArgs e)
152     {
153     //tb.Font = new System.Drawing.Font(this.Font.FontFamily, this.Font.SizeInPoints);
154     }
155 william 762 }
156     }

  ViewVC Help
Powered by ViewVC 1.1.22