ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/RomCheater/trunk/RomCheater.ScratchPad/ScratchPadDocument.cs
Revision: 769
Committed: Thu Jun 20 21:34:48 2013 UTC (10 years, 3 months ago) by william
File size: 2139 byte(s)
Log Message:

File Contents

# Content
1 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 public partial class ScratchPadDocument : UserControl
14 {
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();
22 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
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 }