Upload 2.0.2
[physicsfs] / extras / PhysFS.NET / TestApp / TestAppForm.cs
1 using System;\r
2 using System.Drawing;\r
3 using System.Collections;\r
4 using System.ComponentModel;\r
5 using System.Windows.Forms;\r
6 using System.Data;\r
7 using System.IO;\r
8 using PhysFS_NET;\r
9 \r
10 namespace TestApp\r
11 {\r
12         /// <summary>\r
13         /// Summary description for Form1.\r
14         /// </summary>\r
15         public class TestAppForm : System.Windows.Forms.Form\r
16         {\r
17       private System.Windows.Forms.Label label2;\r
18       private System.Windows.Forms.Button RefreshCDsButton;\r
19       private System.Windows.Forms.ListBox CDDrivesList;\r
20       private System.Windows.Forms.ListBox SearchPathList;\r
21       private System.Windows.Forms.Label label1;\r
22       private System.Windows.Forms.TextBox EnumFilesPath;\r
23       private System.Windows.Forms.ListBox EnumList;\r
24       private System.Windows.Forms.Label label3;\r
25       private System.Windows.Forms.TextBox NewSearchPathText;\r
26       private System.Windows.Forms.Button AddSearchPathButton;\r
27       private System.Windows.Forms.Button RemovePathButton;\r
28       private System.Windows.Forms.Button RefreshEnumList;\r
29       private System.Windows.Forms.Button RefreshSearchPathButton;\r
30                 /// <summary>\r
31                 /// Required designer variable.\r
32                 /// </summary>\r
33                 private System.ComponentModel.Container components = null;\r
34 \r
35                 public TestAppForm()\r
36                 {\r
37                         //\r
38                         // Required for Windows Form Designer support\r
39                         //\r
40                         InitializeComponent();\r
41 \r
42                         //\r
43                         // TODO: Add any constructor code after InitializeComponent call\r
44                         //\r
45                 }\r
46 \r
47                 /// <summary>\r
48                 /// Clean up any resources being used.\r
49                 /// </summary>\r
50                 protected override void Dispose( bool disposing )\r
51                 {\r
52                         if( disposing )\r
53                         {\r
54                                 if (components != null) \r
55                                 {\r
56                                         components.Dispose();\r
57                                 }\r
58                         }\r
59                         base.Dispose( disposing );\r
60                 }\r
61 \r
62                 #region Windows Form Designer generated code\r
63                 /// <summary>\r
64                 /// Required method for Designer support - do not modify\r
65                 /// the contents of this method with the code editor.\r
66                 /// </summary>\r
67                 private void InitializeComponent()\r
68                 {\r
69          this.label2 = new System.Windows.Forms.Label();\r
70          this.RefreshCDsButton = new System.Windows.Forms.Button();\r
71          this.CDDrivesList = new System.Windows.Forms.ListBox();\r
72          this.SearchPathList = new System.Windows.Forms.ListBox();\r
73          this.label1 = new System.Windows.Forms.Label();\r
74          this.EnumFilesPath = new System.Windows.Forms.TextBox();\r
75          this.EnumList = new System.Windows.Forms.ListBox();\r
76          this.label3 = new System.Windows.Forms.Label();\r
77          this.RefreshEnumList = new System.Windows.Forms.Button();\r
78          this.NewSearchPathText = new System.Windows.Forms.TextBox();\r
79          this.AddSearchPathButton = new System.Windows.Forms.Button();\r
80          this.RemovePathButton = new System.Windows.Forms.Button();\r
81          this.RefreshSearchPathButton = new System.Windows.Forms.Button();\r
82          this.SuspendLayout();\r
83          // \r
84          // label2\r
85          // \r
86          this.label2.Location = new System.Drawing.Point(8, 8);\r
87          this.label2.Name = "label2";\r
88          this.label2.Size = new System.Drawing.Size(136, 16);\r
89          this.label2.TabIndex = 2;\r
90          this.label2.Text = "Available CD-ROM Drives";\r
91          // \r
92          // RefreshCDsButton\r
93          // \r
94          this.RefreshCDsButton.Location = new System.Drawing.Point(8, 152);\r
95          this.RefreshCDsButton.Name = "RefreshCDsButton";\r
96          this.RefreshCDsButton.Size = new System.Drawing.Size(72, 24);\r
97          this.RefreshCDsButton.TabIndex = 4;\r
98          this.RefreshCDsButton.Text = "Refresh";\r
99          this.RefreshCDsButton.Click += new System.EventHandler(this.RefreshCDsButton_Click);\r
100          // \r
101          // CDDrivesList\r
102          // \r
103          this.CDDrivesList.Location = new System.Drawing.Point(8, 24);\r
104          this.CDDrivesList.Name = "CDDrivesList";\r
105          this.CDDrivesList.Size = new System.Drawing.Size(136, 121);\r
106          this.CDDrivesList.TabIndex = 7;\r
107          // \r
108          // SearchPathList\r
109          // \r
110          this.SearchPathList.Location = new System.Drawing.Point(152, 24);\r
111          this.SearchPathList.Name = "SearchPathList";\r
112          this.SearchPathList.Size = new System.Drawing.Size(248, 95);\r
113          this.SearchPathList.TabIndex = 8;\r
114          // \r
115          // label1\r
116          // \r
117          this.label1.Location = new System.Drawing.Point(152, 8);\r
118          this.label1.Name = "label1";\r
119          this.label1.Size = new System.Drawing.Size(136, 16);\r
120          this.label1.TabIndex = 10;\r
121          this.label1.Text = "Search Path";\r
122          // \r
123          // EnumFilesPath\r
124          // \r
125          this.EnumFilesPath.Location = new System.Drawing.Point(408, 128);\r
126          this.EnumFilesPath.Name = "EnumFilesPath";\r
127          this.EnumFilesPath.Size = new System.Drawing.Size(208, 20);\r
128          this.EnumFilesPath.TabIndex = 11;\r
129          this.EnumFilesPath.Text = "";\r
130          // \r
131          // EnumList\r
132          // \r
133          this.EnumList.Location = new System.Drawing.Point(408, 24);\r
134          this.EnumList.Name = "EnumList";\r
135          this.EnumList.Size = new System.Drawing.Size(208, 95);\r
136          this.EnumList.TabIndex = 12;\r
137          // \r
138          // label3\r
139          // \r
140          this.label3.Location = new System.Drawing.Point(408, 8);\r
141          this.label3.Name = "label3";\r
142          this.label3.Size = new System.Drawing.Size(136, 16);\r
143          this.label3.TabIndex = 13;\r
144          this.label3.Text = "Enumerate Files";\r
145          // \r
146          // RefreshEnumList\r
147          // \r
148          this.RefreshEnumList.Location = new System.Drawing.Point(544, 152);\r
149          this.RefreshEnumList.Name = "RefreshEnumList";\r
150          this.RefreshEnumList.Size = new System.Drawing.Size(72, 24);\r
151          this.RefreshEnumList.TabIndex = 14;\r
152          this.RefreshEnumList.Text = "Refresh";\r
153          this.RefreshEnumList.Click += new System.EventHandler(this.RefreshEnumList_Click);\r
154          // \r
155          // NewSearchPathText\r
156          // \r
157          this.NewSearchPathText.Location = new System.Drawing.Point(152, 128);\r
158          this.NewSearchPathText.Name = "NewSearchPathText";\r
159          this.NewSearchPathText.Size = new System.Drawing.Size(248, 20);\r
160          this.NewSearchPathText.TabIndex = 15;\r
161          this.NewSearchPathText.Text = "";\r
162          // \r
163          // AddSearchPathButton\r
164          // \r
165          this.AddSearchPathButton.Location = new System.Drawing.Point(152, 152);\r
166          this.AddSearchPathButton.Name = "AddSearchPathButton";\r
167          this.AddSearchPathButton.Size = new System.Drawing.Size(72, 24);\r
168          this.AddSearchPathButton.TabIndex = 9;\r
169          this.AddSearchPathButton.Text = "Add Path";\r
170          this.AddSearchPathButton.Click += new System.EventHandler(this.AddSearchPathButton_Click);\r
171          // \r
172          // RemovePathButton\r
173          // \r
174          this.RemovePathButton.Location = new System.Drawing.Point(232, 152);\r
175          this.RemovePathButton.Name = "RemovePathButton";\r
176          this.RemovePathButton.Size = new System.Drawing.Size(88, 24);\r
177          this.RemovePathButton.TabIndex = 16;\r
178          this.RemovePathButton.Text = "Remove Path";\r
179          this.RemovePathButton.Click += new System.EventHandler(this.RemovePathButton_Click);\r
180          // \r
181          // RefreshSearchPathButton\r
182          // \r
183          this.RefreshSearchPathButton.Location = new System.Drawing.Point(328, 152);\r
184          this.RefreshSearchPathButton.Name = "RefreshSearchPathButton";\r
185          this.RefreshSearchPathButton.Size = new System.Drawing.Size(72, 24);\r
186          this.RefreshSearchPathButton.TabIndex = 17;\r
187          this.RefreshSearchPathButton.Text = "Refresh";\r
188          this.RefreshSearchPathButton.Click += new System.EventHandler(this.RefreshSearchPathButton_Click);\r
189          // \r
190          // TestAppForm\r
191          // \r
192          this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);\r
193          this.ClientSize = new System.Drawing.Size(624, 309);\r
194          this.Controls.AddRange(new System.Windows.Forms.Control[] {\r
195                                                                       this.RefreshSearchPathButton,\r
196                                                                       this.RemovePathButton,\r
197                                                                       this.NewSearchPathText,\r
198                                                                       this.RefreshEnumList,\r
199                                                                       this.label3,\r
200                                                                       this.EnumList,\r
201                                                                       this.EnumFilesPath,\r
202                                                                       this.label1,\r
203                                                                       this.SearchPathList,\r
204                                                                       this.CDDrivesList,\r
205                                                                       this.RefreshCDsButton,\r
206                                                                       this.label2,\r
207                                                                       this.AddSearchPathButton});\r
208          this.Name = "TestAppForm";\r
209          this.Text = "PhysFS Test Application";\r
210          this.Load += new System.EventHandler(this.TestAppForm_Load);\r
211          this.ResumeLayout(false);\r
212 \r
213       }\r
214                 #endregion\r
215 \r
216                 /// <summary>\r
217                 /// The main entry point for the application.\r
218                 /// </summary>\r
219                 [STAThread]\r
220                 static void Main() \r
221                 {\r
222          Application.Run(new TestAppForm());\r
223                 }\r
224 \r
225       private void TestAppForm_Load(object sender, System.EventArgs e)\r
226       {\r
227       \r
228       }\r
229 \r
230       private void RefreshCDsButton_Click(object sender, System.EventArgs e)\r
231       {\r
232          // Clear ths listbox if it contains any items\r
233          CDDrivesList.Items.Clear();\r
234          // Add the items to the list\r
235          CDDrivesList.Items.AddRange(PhysFS.GetCDROMDrives());\r
236       }\r
237 \r
238       private void RefreshSearchPathButton_Click(object sender, System.EventArgs e)\r
239       {\r
240          // Clear ths listbox if it contains any items\r
241          SearchPathList.Items.Clear();\r
242          // Add the items to the list\r
243          SearchPathList.Items.AddRange(PhysFS.GetSearchPath());\r
244       }\r
245 \r
246       private void AddSearchPathButton_Click(object sender, System.EventArgs e)\r
247       {\r
248          // Add search path\r
249          PhysFS.AddToSearchPath(NewSearchPathText.Text, false);\r
250          // Clear ths listbox if it contains any items\r
251          SearchPathList.Items.Clear();\r
252          // Add the items to the list\r
253          SearchPathList.Items.AddRange(PhysFS.GetSearchPath());\r
254       }\r
255 \r
256       private void RemovePathButton_Click(object sender, System.EventArgs e)\r
257       {\r
258          if(SearchPathList.SelectedItem != null)\r
259          {\r
260             PhysFS.RemoveFromSearchPath(SearchPathList.SelectedItem.ToString());\r
261             // Clear ths listbox if it contains any items\r
262             SearchPathList.Items.Clear();\r
263             // Add the items to the list\r
264             SearchPathList.Items.AddRange(PhysFS.GetSearchPath());\r
265          }\r
266       }\r
267 \r
268       private void RefreshEnumList_Click(object sender, System.EventArgs e)\r
269       {\r
270          EnumList.Items.Clear();\r
271          EnumList.Items.AddRange(PhysFS.EnumerateFiles(EnumFilesPath.Text));\r
272       }\r
273         }\r
274 }\r