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

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

# Line 7 | Line 7 | using System.Linq;
7   using System.Text;
8   using System.Windows.Forms;
9   using WeifenLuo.WinFormsUI.Docking;
10 + using RomCheater.Core;
11  
12   namespace RomCheater.ScratchPad
13   {
14      public partial class ScratchPadDocument : UserControl
15      {
16 +        public event BaseEventHandler<ControlClosingEventArgs<int>> DocumentClosing;
17 +
18          const string NewDocumentFilename = "New";
19          public ScratchPadDocument() : this(NewDocumentFilename, new TabPage(), 0) { }
20          public ScratchPadDocument(TabPage tp, int index) : this(NewDocumentFilename, tp, index) { }
# Line 24 | Line 27 | namespace RomCheater.ScratchPad
27              this.DocumentTab = tp;
28              this.DocumentTab.Name = string.Format("tp{0}", this.DocumentIndex);
29              this.DocumentTab.Text = string.Format("{0}{1}", this.DocumentFilename, this.DocumentIndex);
30 +            //this.DocumentClosing += new BaseEventHandler<ControlClosingEventArgs<int>>(ScratchPadDocument_DocumentClosing);
31 +            this.DocumentTab.Controls.Add(this);
32          }
33  
34 +        //void ScratchPadDocument_DocumentClosing(ControlClosingEventArgs<int> e)
35 +        //{
36 +        //    CloseDocument(this.Disposing);
37 +        //}
38 +
39 +
40 +        
41  
42          public void OnDocumentQuit()
43          {
44 +            CloseDocument(true);
45 +        }
46 +
47 +        private void CloseDocument(bool quiting)
48 +        {
49 +            if (ShouldAskSave())
50 +            {
51 +                SaveDocument();
52 +            }
53              var tb = GetParentTabControl();
54 +            tb.TabPages.RemoveAt(this.DocumentIndex);
55 +            if (this.DocumentClosing != null && !quiting)
56 +            {
57 +                this.DocumentClosing.Invoke(new ControlClosingEventArgs<int>(this, this.DocumentIndex));
58 +            }
59 +        }
60 +
61 +        private bool ShouldAskSave()
62 +        {
63 +            bool shouldAskSave = false;
64 +            return shouldAskSave;
65 +        }
66 +
67 +        private void SaveDocument()
68 +        {
69          }
70  
71          private string _DocumentFilename;
# Line 52 | Line 88 | namespace RomCheater.ScratchPad
88                  return tb;
89              }
90          }
91 +
92 +        private void mnuItemOpen_Click(object sender, EventArgs e)
93 +        {
94 +
95 +        }
96 +
97 +        private void mnuItemSave_Click(object sender, EventArgs e)
98 +        {
99 +
100 +        }
101 +
102 +        private void mnuItemClose_Click(object sender, EventArgs e)
103 +        {
104 +            CloseDocument(false);
105 +        }
106      }
107   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines