ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/RomCheater/trunk/RomCheater.ScratchPad/ScratchPad.cs
(Generate patch)

Comparing trunk/RomCheater.ScratchPad/ScratchPad.cs (file contents):
Revision 773 by william, Thu Jun 20 21:34:48 2013 UTC vs.
Revision 774 by william, Thu Jun 20 22:33:04 2013 UTC

--- trunk/RomCheater.ScratchPad/ScratchPad.cs	2013/06/20 22:03:10	773
+++ trunk/RomCheater.ScratchPad/ScratchPad.cs	2013/06/20 22:33:04	774
@@ -28,7 +28,7 @@ using RomCheater.PluginFramework.Core;
 namespace RomCheater.ScratchPad
 {
     public partial class ScratchPad : DockContent
-    {
+    {        
         List<ScratchPadDocument> docuemntList = new List<ScratchPadDocument>();
         private UserControlPlugin plugin;
         private bool PostInitDone = false;
@@ -82,7 +82,7 @@ namespace RomCheater.ScratchPad
 
 
 
-     
+
 
         private void ScratchPad_FormClosing(object sender, FormClosingEventArgs e)
         {
@@ -99,13 +99,11 @@ namespace RomCheater.ScratchPad
             //        mnuItemSave.PerformClick();
             //    }
             //}
-            
             for (int i = 0; i < docuemntList.Count; i++)
             {
                 var Document = docuemntList[i];
-                Document.OnDocumentQuit();                
+                Document.OnDocumentQuit();
             }
-
         }
 
         private void ScratchPad_Deactivate<T>(object sender, T e) where T: EventArgs
@@ -123,10 +121,26 @@ namespace RomCheater.ScratchPad
             // create new document
             int tp_index = this.tb.TabPages.Count;
             ScratchPadDocument t = new ScratchPadDocument(tp_index);
+            t.DocumentClosing += new BaseEventHandler<ControlClosingEventArgs<int>>(t_DocumentClosing);
+            docuemntList.Add(t);
+            this.tb.TabPages.Add(t.DocumentTab);
+        }
+
+        private void ScratchPad_Load(object sender, EventArgs e)
+        {
+            int tp_index = this.tb.TabPages.Count;
+            ScratchPadDocument t = new ScratchPadDocument(tp_index);
+            t.DocumentClosing += new BaseEventHandler<ControlClosingEventArgs<int>>(t_DocumentClosing);
             docuemntList.Add(t);
             this.tb.TabPages.Add(t.DocumentTab);
         }
 
+        void t_DocumentClosing(ControlClosingEventArgs<int> e)
+        {
+                int index = e.Args;
+                this.docuemntList.RemoveAt(index);
+        }
+
         //private void txtScratchPad_LinkClicked(object sender, LinkClickedEventArgs e)
         //{
         //    //System.Diagnostics.Process.Start(e.LinkText);