Multiple Document Interface应用程序
View Code
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 System.IO;
10
11 namespace WindowsFormsApplication5
12 {
13 public partial class Form1 : Form
14 {
15 string address;
16 int myx;
17
18 public Form1()
19 {
20 InitializeComponent();
21 address = System.Environment.CurrentDirectory;
22 myx = 1;
23 }
24 public void ShowWindows(string filename)
25 {
26 Image Myp = Image.FromFile(filename);
27 Form Myf = new Form();
28 Myf.MdiParent = this;
29 Myf.BackgroundImage = Myp;
30 Myf.Text = "子窗口" + myx;
31 Myf.Show();
32 myx = myx + 1;
33
34 }
35 private void toolStripStatusLabel1_Click(object sender, EventArgs e)
36 {
37
38 }
39
40 private void Form1_Load(object sender, EventArgs e)
41 {
42 StreamReader Mysr = new StreamReader(address+"\\u.ini");
43 int i = this.文件ToolStripMenuItem.DropDownItems.Count - 2;
44 while (Mysr.Peek() >= 0)
45 {
46 ToolStripMenuItem menuitem = new ToolStripMenuItem(Mysr.ReadLine());
47 this.文件ToolStripMenuItem.DropDownItems.Insert(i, menuitem);
48 i++;
49 menuitem.Click += new EventHandler(MenuItem_Click);
50 }
51 Mysr.Close();
52
53 }
54
55 private void MenuItem_Click(object sender, EventArgs e)
56 {
57 ToolStripMenuItem Mymenu = (ToolStripMenuItem)sender;
58 ShowWindows(Mymenu.Text);
59 }
60
61 private void 打开ToolStripMenuItem_Click(object sender, EventArgs e)
62 {
63 openFileDialog1.FileName = "";
64 this.openFileDialog1.ShowDialog();
65 StreamWriter Mys = new StreamWriter(address+"\\u.ini",true);
66 Mys.WriteLine(openFileDialog1.FileName);
67 Mys.Flush();
68 Mys.Close();
69 ShowWindows(openFileDialog1.FileName);
70
71 }
72
73 private void 退出ToolStripMenuItem_Click(object sender, EventArgs e)
74 {
75 this.Close();
76 Application.Exit();
77 this.notifyIcon1.Visible = false;
78 }
79
80 private void 退出ToolStripMenuItem1_Click(object sender, EventArgs e)
81 {
82 this.notifyIcon1.Visible = false;
83 this.Close();
84 Application.Exit();
85 }
86
87 private void checkBox1_CheckedChanged(object sender, EventArgs e)
88 {
89 if (this.checkBox1.Checked)
90 {
91 statusStrip1.Items[1].Text = "日期:" + DateTime.Now.ToString();
92 }
93 else
94 {
95 statusStrip1.Items[1].Text = "";
96 }
97 }
98
99
100 }
101 }