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

Diff of /trunk/RomCheater.ScratchPad/ScratchPadDocument.cs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 768 by william, Thu Jun 20 20:43:46 2013 UTC revision 769 by william, Thu Jun 20 21:34:48 2013 UTC
# Line 10  using WeifenLuo.WinFormsUI.Docking; Line 10  using WeifenLuo.WinFormsUI.Docking;
10    
11  namespace RomCheater.ScratchPad  namespace RomCheater.ScratchPad
12  {  {
13      public partial class ScratchPadDocument : DockContent      public partial class ScratchPadDocument : UserControl
14      {      {
15                  const string NewDocumentFilename = "New";
16          public ScratchPadDocument()          public ScratchPadDocument() : this(NewDocumentFilename, new TabPage(), 0) { }
17            public ScratchPadDocument(TabPage tp, int index) : this(NewDocumentFilename, tp, index) { }
18            public ScratchPadDocument(int index) : this(NewDocumentFilename, new TabPage(), index) { }
19            public ScratchPadDocument(string documentFilename, TabPage tp, int index)
20          {          {
21              InitializeComponent();              InitializeComponent();
   
             this.DocumentFilename = "New1";  
             this.DocumentIndex = 0;  
         }  
         public ScratchPadDocument(string documentFilename, int documentInex) : this()  
         {  
22              this.DocumentFilename = documentFilename;              this.DocumentFilename = documentFilename;
23              this.DocumentIndex = documentInex;              this.DocumentIndex = index;
24                this.DocumentTab = tp;
25                this.DocumentTab.Name = string.Format("tp{0}", this.DocumentIndex);
26                this.DocumentTab.Text = string.Format("{0}{1}", this.DocumentFilename, this.DocumentIndex);
27          }          }
28    
29    
30            public void OnDocumentQuit()
31            {
32                var tb = GetParentTabControl();
33            }
34    
35          private string _DocumentFilename;          private string _DocumentFilename;
36          public string DocumentFilename { get { return _DocumentFilename; } set { _DocumentFilename = value; } }          public string DocumentFilename { get { return _DocumentFilename; } set { _DocumentFilename = value; } }
37            private TabPage _DocumentTab;
38            public TabPage DocumentTab { get { return _DocumentTab; } set { _DocumentTab = value; } }
39          private int _DocumentIndex;          private int _DocumentIndex;
40          public int DocumentIndex { get { return _DocumentIndex; } set { _DocumentIndex = value; } }          public int DocumentIndex { get { return _DocumentIndex; } set { _DocumentIndex = value; } }
41    
42            private TabControl GetParentTabControl()
43            {
44                var parent = this.DocumentTab.Parent;
45                TabControl tb = (parent as TabControl);
46                if (tb == null)
47                {
48                    throw new ArgumentNullException("parent", string.Format("The parent of tabpage '{0}' cannot be null", DocumentTab.Name));
49                }
50                else
51                {
52                    return tb;
53                }
54            }
55      }      }
56  }  }

Legend:
Removed from v.768  
changed lines
  Added in v.769

  ViewVC Help
Powered by ViewVC 1.1.22