10 |
|
|
11 |
|
namespace RomCheater.ScratchPad |
12 |
|
{ |
13 |
< |
public partial class ScratchPadDocument : DockContent |
13 |
> |
public partial class ScratchPadDocument : UserControl |
14 |
|
{ |
15 |
< |
|
16 |
< |
public ScratchPadDocument() |
15 |
> |
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 |
|
{ |
21 |
|
InitializeComponent(); |
19 |
– |
|
20 |
– |
this.DocumentFilename = "New1"; |
21 |
– |
this.DocumentIndex = 0; |
22 |
– |
} |
23 |
– |
public ScratchPadDocument(string documentFilename, int documentInex) : this() |
24 |
– |
{ |
22 |
|
this.DocumentFilename = documentFilename; |
23 |
< |
this.DocumentIndex = documentInex; |
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 |
|
|
29 |
|
|
30 |
+ |
public void OnDocumentQuit() |
31 |
+ |
{ |
32 |
+ |
var tb = GetParentTabControl(); |
33 |
+ |
} |
34 |
+ |
|
35 |
|
private string _DocumentFilename; |
36 |
|
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; |
40 |
|
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 |
|
} |