1 |
william |
767 |
using System; |
2 |
|
|
using System.Collections.Generic; |
3 |
|
|
using System.ComponentModel; |
4 |
|
|
using System.Data; |
5 |
|
|
using System.Drawing; |
6 |
|
|
using System.Linq; |
7 |
|
|
using System.Text; |
8 |
|
|
using System.Windows.Forms; |
9 |
|
|
using WeifenLuo.WinFormsUI.Docking; |
10 |
|
|
|
11 |
|
|
namespace RomCheater.ScratchPad |
12 |
|
|
{ |
13 |
william |
769 |
public partial class ScratchPadDocument : UserControl |
14 |
william |
767 |
{ |
15 |
william |
769 |
const string NewDocumentFilename = "New"; |
16 |
|
|
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 |
william |
767 |
{ |
21 |
|
|
InitializeComponent(); |
22 |
william |
769 |
this.DocumentFilename = documentFilename; |
23 |
|
|
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 |
william |
767 |
|
29 |
william |
769 |
|
30 |
|
|
public void OnDocumentQuit() |
31 |
william |
767 |
{ |
32 |
william |
769 |
var tb = GetParentTabControl(); |
33 |
william |
767 |
} |
34 |
|
|
|
35 |
|
|
private string _DocumentFilename; |
36 |
|
|
public string DocumentFilename { get { return _DocumentFilename; } set { _DocumentFilename = value; } } |
37 |
william |
769 |
private TabPage _DocumentTab; |
38 |
|
|
public TabPage DocumentTab { get { return _DocumentTab; } set { _DocumentTab = value; } } |
39 |
william |
767 |
private int _DocumentIndex; |
40 |
|
|
public int DocumentIndex { get { return _DocumentIndex; } set { _DocumentIndex = value; } } |
41 |
william |
769 |
|
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 |
william |
767 |
} |
56 |
|
|
} |