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