Upload 2.0.2
[physicsfs] / extras / PhysFS.NET / TestApp / TestAppForm.cs
diff --git a/extras/PhysFS.NET/TestApp/TestAppForm.cs b/extras/PhysFS.NET/TestApp/TestAppForm.cs
new file mode 100755 (executable)
index 0000000..b897ae6
--- /dev/null
@@ -0,0 +1,274 @@
+using System;\r
+using System.Drawing;\r
+using System.Collections;\r
+using System.ComponentModel;\r
+using System.Windows.Forms;\r
+using System.Data;\r
+using System.IO;\r
+using PhysFS_NET;\r
+\r
+namespace TestApp\r
+{\r
+       /// <summary>\r
+       /// Summary description for Form1.\r
+       /// </summary>\r
+       public class TestAppForm : System.Windows.Forms.Form\r
+       {\r
+      private System.Windows.Forms.Label label2;\r
+      private System.Windows.Forms.Button RefreshCDsButton;\r
+      private System.Windows.Forms.ListBox CDDrivesList;\r
+      private System.Windows.Forms.ListBox SearchPathList;\r
+      private System.Windows.Forms.Label label1;\r
+      private System.Windows.Forms.TextBox EnumFilesPath;\r
+      private System.Windows.Forms.ListBox EnumList;\r
+      private System.Windows.Forms.Label label3;\r
+      private System.Windows.Forms.TextBox NewSearchPathText;\r
+      private System.Windows.Forms.Button AddSearchPathButton;\r
+      private System.Windows.Forms.Button RemovePathButton;\r
+      private System.Windows.Forms.Button RefreshEnumList;\r
+      private System.Windows.Forms.Button RefreshSearchPathButton;\r
+               /// <summary>\r
+               /// Required designer variable.\r
+               /// </summary>\r
+               private System.ComponentModel.Container components = null;\r
+\r
+               public TestAppForm()\r
+               {\r
+                       //\r
+                       // Required for Windows Form Designer support\r
+                       //\r
+                       InitializeComponent();\r
+\r
+                       //\r
+                       // TODO: Add any constructor code after InitializeComponent call\r
+                       //\r
+               }\r
+\r
+               /// <summary>\r
+               /// Clean up any resources being used.\r
+               /// </summary>\r
+               protected override void Dispose( bool disposing )\r
+               {\r
+                       if( disposing )\r
+                       {\r
+                               if (components != null) \r
+                               {\r
+                                       components.Dispose();\r
+                               }\r
+                       }\r
+                       base.Dispose( disposing );\r
+               }\r
+\r
+               #region Windows Form Designer generated code\r
+               /// <summary>\r
+               /// Required method for Designer support - do not modify\r
+               /// the contents of this method with the code editor.\r
+               /// </summary>\r
+               private void InitializeComponent()\r
+               {\r
+         this.label2 = new System.Windows.Forms.Label();\r
+         this.RefreshCDsButton = new System.Windows.Forms.Button();\r
+         this.CDDrivesList = new System.Windows.Forms.ListBox();\r
+         this.SearchPathList = new System.Windows.Forms.ListBox();\r
+         this.label1 = new System.Windows.Forms.Label();\r
+         this.EnumFilesPath = new System.Windows.Forms.TextBox();\r
+         this.EnumList = new System.Windows.Forms.ListBox();\r
+         this.label3 = new System.Windows.Forms.Label();\r
+         this.RefreshEnumList = new System.Windows.Forms.Button();\r
+         this.NewSearchPathText = new System.Windows.Forms.TextBox();\r
+         this.AddSearchPathButton = new System.Windows.Forms.Button();\r
+         this.RemovePathButton = new System.Windows.Forms.Button();\r
+         this.RefreshSearchPathButton = new System.Windows.Forms.Button();\r
+         this.SuspendLayout();\r
+         // \r
+         // label2\r
+         // \r
+         this.label2.Location = new System.Drawing.Point(8, 8);\r
+         this.label2.Name = "label2";\r
+         this.label2.Size = new System.Drawing.Size(136, 16);\r
+         this.label2.TabIndex = 2;\r
+         this.label2.Text = "Available CD-ROM Drives";\r
+         // \r
+         // RefreshCDsButton\r
+         // \r
+         this.RefreshCDsButton.Location = new System.Drawing.Point(8, 152);\r
+         this.RefreshCDsButton.Name = "RefreshCDsButton";\r
+         this.RefreshCDsButton.Size = new System.Drawing.Size(72, 24);\r
+         this.RefreshCDsButton.TabIndex = 4;\r
+         this.RefreshCDsButton.Text = "Refresh";\r
+         this.RefreshCDsButton.Click += new System.EventHandler(this.RefreshCDsButton_Click);\r
+         // \r
+         // CDDrivesList\r
+         // \r
+         this.CDDrivesList.Location = new System.Drawing.Point(8, 24);\r
+         this.CDDrivesList.Name = "CDDrivesList";\r
+         this.CDDrivesList.Size = new System.Drawing.Size(136, 121);\r
+         this.CDDrivesList.TabIndex = 7;\r
+         // \r
+         // SearchPathList\r
+         // \r
+         this.SearchPathList.Location = new System.Drawing.Point(152, 24);\r
+         this.SearchPathList.Name = "SearchPathList";\r
+         this.SearchPathList.Size = new System.Drawing.Size(248, 95);\r
+         this.SearchPathList.TabIndex = 8;\r
+         // \r
+         // label1\r
+         // \r
+         this.label1.Location = new System.Drawing.Point(152, 8);\r
+         this.label1.Name = "label1";\r
+         this.label1.Size = new System.Drawing.Size(136, 16);\r
+         this.label1.TabIndex = 10;\r
+         this.label1.Text = "Search Path";\r
+         // \r
+         // EnumFilesPath\r
+         // \r
+         this.EnumFilesPath.Location = new System.Drawing.Point(408, 128);\r
+         this.EnumFilesPath.Name = "EnumFilesPath";\r
+         this.EnumFilesPath.Size = new System.Drawing.Size(208, 20);\r
+         this.EnumFilesPath.TabIndex = 11;\r
+         this.EnumFilesPath.Text = "";\r
+         // \r
+         // EnumList\r
+         // \r
+         this.EnumList.Location = new System.Drawing.Point(408, 24);\r
+         this.EnumList.Name = "EnumList";\r
+         this.EnumList.Size = new System.Drawing.Size(208, 95);\r
+         this.EnumList.TabIndex = 12;\r
+         // \r
+         // label3\r
+         // \r
+         this.label3.Location = new System.Drawing.Point(408, 8);\r
+         this.label3.Name = "label3";\r
+         this.label3.Size = new System.Drawing.Size(136, 16);\r
+         this.label3.TabIndex = 13;\r
+         this.label3.Text = "Enumerate Files";\r
+         // \r
+         // RefreshEnumList\r
+         // \r
+         this.RefreshEnumList.Location = new System.Drawing.Point(544, 152);\r
+         this.RefreshEnumList.Name = "RefreshEnumList";\r
+         this.RefreshEnumList.Size = new System.Drawing.Size(72, 24);\r
+         this.RefreshEnumList.TabIndex = 14;\r
+         this.RefreshEnumList.Text = "Refresh";\r
+         this.RefreshEnumList.Click += new System.EventHandler(this.RefreshEnumList_Click);\r
+         // \r
+         // NewSearchPathText\r
+         // \r
+         this.NewSearchPathText.Location = new System.Drawing.Point(152, 128);\r
+         this.NewSearchPathText.Name = "NewSearchPathText";\r
+         this.NewSearchPathText.Size = new System.Drawing.Size(248, 20);\r
+         this.NewSearchPathText.TabIndex = 15;\r
+         this.NewSearchPathText.Text = "";\r
+         // \r
+         // AddSearchPathButton\r
+         // \r
+         this.AddSearchPathButton.Location = new System.Drawing.Point(152, 152);\r
+         this.AddSearchPathButton.Name = "AddSearchPathButton";\r
+         this.AddSearchPathButton.Size = new System.Drawing.Size(72, 24);\r
+         this.AddSearchPathButton.TabIndex = 9;\r
+         this.AddSearchPathButton.Text = "Add Path";\r
+         this.AddSearchPathButton.Click += new System.EventHandler(this.AddSearchPathButton_Click);\r
+         // \r
+         // RemovePathButton\r
+         // \r
+         this.RemovePathButton.Location = new System.Drawing.Point(232, 152);\r
+         this.RemovePathButton.Name = "RemovePathButton";\r
+         this.RemovePathButton.Size = new System.Drawing.Size(88, 24);\r
+         this.RemovePathButton.TabIndex = 16;\r
+         this.RemovePathButton.Text = "Remove Path";\r
+         this.RemovePathButton.Click += new System.EventHandler(this.RemovePathButton_Click);\r
+         // \r
+         // RefreshSearchPathButton\r
+         // \r
+         this.RefreshSearchPathButton.Location = new System.Drawing.Point(328, 152);\r
+         this.RefreshSearchPathButton.Name = "RefreshSearchPathButton";\r
+         this.RefreshSearchPathButton.Size = new System.Drawing.Size(72, 24);\r
+         this.RefreshSearchPathButton.TabIndex = 17;\r
+         this.RefreshSearchPathButton.Text = "Refresh";\r
+         this.RefreshSearchPathButton.Click += new System.EventHandler(this.RefreshSearchPathButton_Click);\r
+         // \r
+         // TestAppForm\r
+         // \r
+         this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);\r
+         this.ClientSize = new System.Drawing.Size(624, 309);\r
+         this.Controls.AddRange(new System.Windows.Forms.Control[] {\r
+                                                                      this.RefreshSearchPathButton,\r
+                                                                      this.RemovePathButton,\r
+                                                                      this.NewSearchPathText,\r
+                                                                      this.RefreshEnumList,\r
+                                                                      this.label3,\r
+                                                                      this.EnumList,\r
+                                                                      this.EnumFilesPath,\r
+                                                                      this.label1,\r
+                                                                      this.SearchPathList,\r
+                                                                      this.CDDrivesList,\r
+                                                                      this.RefreshCDsButton,\r
+                                                                      this.label2,\r
+                                                                      this.AddSearchPathButton});\r
+         this.Name = "TestAppForm";\r
+         this.Text = "PhysFS Test Application";\r
+         this.Load += new System.EventHandler(this.TestAppForm_Load);\r
+         this.ResumeLayout(false);\r
+\r
+      }\r
+               #endregion\r
+\r
+               /// <summary>\r
+               /// The main entry point for the application.\r
+               /// </summary>\r
+               [STAThread]\r
+               static void Main() \r
+               {\r
+         Application.Run(new TestAppForm());\r
+               }\r
+\r
+      private void TestAppForm_Load(object sender, System.EventArgs e)\r
+      {\r
+      \r
+      }\r
+\r
+      private void RefreshCDsButton_Click(object sender, System.EventArgs e)\r
+      {\r
+         // Clear ths listbox if it contains any items\r
+         CDDrivesList.Items.Clear();\r
+         // Add the items to the list\r
+         CDDrivesList.Items.AddRange(PhysFS.GetCDROMDrives());\r
+      }\r
+\r
+      private void RefreshSearchPathButton_Click(object sender, System.EventArgs e)\r
+      {\r
+         // Clear ths listbox if it contains any items\r
+         SearchPathList.Items.Clear();\r
+         // Add the items to the list\r
+         SearchPathList.Items.AddRange(PhysFS.GetSearchPath());\r
+      }\r
+\r
+      private void AddSearchPathButton_Click(object sender, System.EventArgs e)\r
+      {\r
+         // Add search path\r
+         PhysFS.AddToSearchPath(NewSearchPathText.Text, false);\r
+         // Clear ths listbox if it contains any items\r
+         SearchPathList.Items.Clear();\r
+         // Add the items to the list\r
+         SearchPathList.Items.AddRange(PhysFS.GetSearchPath());\r
+      }\r
+\r
+      private void RemovePathButton_Click(object sender, System.EventArgs e)\r
+      {\r
+         if(SearchPathList.SelectedItem != null)\r
+         {\r
+            PhysFS.RemoveFromSearchPath(SearchPathList.SelectedItem.ToString());\r
+            // Clear ths listbox if it contains any items\r
+            SearchPathList.Items.Clear();\r
+            // Add the items to the list\r
+            SearchPathList.Items.AddRange(PhysFS.GetSearchPath());\r
+         }\r
+      }\r
+\r
+      private void RefreshEnumList_Click(object sender, System.EventArgs e)\r
+      {\r
+         EnumList.Items.Clear();\r
+         EnumList.Items.AddRange(PhysFS.EnumerateFiles(EnumFilesPath.Text));\r
+      }\r
+       }\r
+}\r