/[RomCheater]/trunk/deps/WeifenLuo.WinFormsUI.Docking/DockSample/DummyDoc.cs
ViewVC logotype

Contents of /trunk/deps/WeifenLuo.WinFormsUI.Docking/DockSample/DummyDoc.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 140 - (show annotations) (download)
Fri May 11 11:29:29 2012 UTC (9 years ago) by william
File size: 2139 byte(s)


1 using System;
2 using System.Collections.Generic;
3 using System.ComponentModel;
4 using System.Data;
5 using System.Drawing;
6 using System.Text;
7 using System.Windows.Forms;
8 using WeifenLuo.WinFormsUI.Docking;
9 using System.IO;
10
11 namespace DockSample
12 {
13 public partial class DummyDoc : DockContent
14 {
15 public DummyDoc()
16 {
17 InitializeComponent();
18 }
19
20 private string m_fileName = string.Empty;
21 public string FileName
22 {
23 get { return m_fileName; }
24 set
25 {
26 if (value != string.Empty)
27 {
28 Stream s = new FileStream(value, FileMode.Open);
29
30 FileInfo efInfo = new FileInfo(value);
31
32 string fext = efInfo.Extension.ToUpper();
33
34 if (fext.Equals(".RTF"))
35 richTextBox1.LoadFile(s, RichTextBoxStreamType.RichText);
36 else
37 richTextBox1.LoadFile(s, RichTextBoxStreamType.PlainText);
38 s.Close();
39 }
40
41 m_fileName = value;
42 this.ToolTipText = value;
43 }
44 }
45
46 // workaround of RichTextbox control's bug:
47 // If load file before the control showed, all the text format will be lost
48 // re-load the file after it get showed.
49 private bool m_resetText = true;
50 protected override void OnPaint(PaintEventArgs e)
51 {
52 base.OnPaint(e);
53
54 if (m_resetText)
55 {
56 m_resetText = false;
57 FileName = FileName;
58 }
59 }
60
61 protected override string GetPersistString()
62 {
63 // Add extra information into the persist string for this document
64 // so that it is available when deserialized.
65 return GetType().ToString() + "," + FileName + "," + Text;
66 }
67
68 private void menuItem2_Click(object sender, System.EventArgs e)
69 {
70 MessageBox.Show("This is to demostrate menu item has been successfully merged into the main form. Form Text=" + Text);
71 }
72
73 private void menuItemCheckTest_Click(object sender, System.EventArgs e)
74 {
75 menuItemCheckTest.Checked = !menuItemCheckTest.Checked;
76 }
77
78 protected override void OnTextChanged(EventArgs e)
79 {
80 base.OnTextChanged (e);
81 if (FileName == string.Empty)
82 this.richTextBox1.Text = Text;
83 }
84 }
85 }

  ViewVC Help
Powered by ViewVC 1.1.22